AtomsChosen Posted September 17, 2023 Share Posted September 17, 2023 I decided to make a custom weapon for robots. Specifically I was using a cryo explosion. The weapon itself works, but I was noticing that even with inspirational maxed out Robots using this weapon are hurting friendlies and this sometimes causes friendly folks to turn hostile. I tried looking at the Fatman launcher robots use, but I found nothing that immediately stood out to me that would disable friendly fire other then the non hostile flag. But that doesn't seem to work for explosions. So I wanted to know how I could disable friendly fire from explosions. Preferably without scripting if possible since I am not that knowledgeable about that. Link to comment Share on other sites More sharing options...
RaidersClamoring Posted September 18, 2023 Share Posted September 18, 2023 You could try attaching a script to whichever projectile or explosion this weapon uses to deal damage and track the OnHit events it triggers. In the event handler, or in the registration directly, you can filter out allies by checking against PlayerFaction keyword (or some other similar keyword) and skip dealing damage in that case.Chances are there is a magic effect associated with the damage-dealing of the weapon already, and if so you could also filter out allies directly in the CK using condition functions. There is probably an "IsAlly" condition, else you can use the keywords as mentioned.There might also be a simple checkbox on the weapon/projectile/explosion form itself that will toggle friendly fire. Link to comment Share on other sites More sharing options...
LarannKiar Posted September 18, 2023 Share Posted September 18, 2023 The most reliable way to make certain NPCs "ignore" an Explosion is adding a perk to them with the entry type "Mod Incoming Explosion Damage" with "SetValue 0". You'll need to use a script to do add/remove perks dynamically though. Link to comment Share on other sites More sharing options...
AtomsChosen Posted October 2, 2023 Author Share Posted October 2, 2023 (edited) Hello. I finally gave this a try and only seem to be having partial success. Under the sell list of the npc I placed a perk that has mod incoming damage, stagger, limb damage and explosive damage to zero. However despite this and my checking this with a damage check mod, npcs are still turning hostile when I attack them about 4 times. I am not sure why this is happpening. https://imgur.com/a/24WQXGN This is how the setup looks. However it does seem to work when I tick the non hostile option. The problem with ticking the non hostile in weapons is I wonder what if I decide I want to attack one of the npcs myself. "The most reliable way to make certain NPCs "ignore" an Explosion is adding a perk to them with the entry type "Mod Incoming Explosion Damage" with "SetValue 0". You'll need to use a script to do add/remove perks dynamically though." Can you also elaborate on what you mean by dynamically? Edited October 2, 2023 by RayoftheSun Link to comment Share on other sites More sharing options...
PJMail Posted October 2, 2023 Share Posted October 2, 2023 I had to solve this problem a while ago (as explosive bullets were agro-ing my companions).What you describe suggests your Perk is not working as the base game mechanics allows 3 'friendly fire' hits on associates before they get aggro'd (there is an ini setting that controls this number). You need to make sure the conditions are correct on 'set value 0' as there are a number of tabs on that perk and you need to put the condition on the correct tab. I assume your perk sets the "Mod incoming explosion damage" to zero under a condition?This is a very hard thing to get right as that perk needs to be on the recipients as I don't think there is a "mod outgoing explosion damage" option. Explosive damage is a real pain... It bypasses most of the normal damage mitigation options... You could try "Mod Weapon Attack Damage" and set that to 0 if the target is non-hostile. May work when attached to weapon... Link to comment Share on other sites More sharing options...
LarannKiar Posted October 2, 2023 Share Posted October 2, 2023 (edited) "The most reliable way to make certain NPCs "ignore" an Explosion is adding a perk to them with the entry type "Mod Incoming Explosion Damage" with "SetValue 0". You'll need to use a script to do add/remove perks dynamically though." Can you also elaborate on what you mean by dynamically? If needed, you can add and remove perks ingame without editing the Actor records in the Creation Kit with Papyrus scripts. Unfortunately Mod Incoming Explosion Damage doesn't have an "Attacker" tab to conditionalize it based on the explosion source, but you can try these Perk Entries too: Mod Incoming Weapon Damage: Attacker: GetIsID = CryoGrenade Function: SetValue = 0 Mod Incoming Spell Magnitude: Spell: GetIsID = enchMod_LaserReceiver_Fire2 ( AND ) EPMagic_SpellHasKeyword = DamageTypeCryo ( AND ) Enchantment: EnchWeaponMod_JunkJetFire Function: SetValue = 0 Mod Incoming Limb Damage: Attacker: GetIsID = CryoGrenade Function: SetValue = 0 Mod Weapon Attack Damage: Target: IsHostileToActor : PlayerRef = 0 Function: SetValue = 0 The attacker forms I wrote after GetIsID are just examples, replace them in accordance with your robot weapon mod. Note: Mod Incoming Spell Magnitude can accept "Magic Keywords" and Enchantments too. They might be useful depending on your robot weapon mod. Perks with the "Incoming" damage modifiers should be added to the friendly NPCs, and Mod Weapon Attack Damage to your robot. The perk entry functions like SetValue, Multiply Value and Add Value are all added to the hardcoded damage formula calculated against the Perk Owner. If you need to eliminate a certain damage input/output, make sure to use SetValue = 0. Edited October 2, 2023 by LarannKiar Link to comment Share on other sites More sharing options...
AtomsChosen Posted October 2, 2023 Author Share Posted October 2, 2023 "If needed, you can add and remove perks ingame without editing the Actor records in the Creation Kit with Papyrus scripts." At the moment currently don't have any knowledge on how scripting is done although it is on my to do list to learn. Can you tell me a bit more about this? "The attacker forms I wrote after GetIsID are just examples, replace them in accordance with your robot weapon mod." Is there a way to specify if the damage is coming from the player directly? Something like getisplayer. I am going to give these a try. Link to comment Share on other sites More sharing options...
LarannKiar Posted October 2, 2023 Share Posted October 2, 2023 (edited) "If needed, you can add and remove perks ingame without editing the Actor records in the Creation Kit with Papyrus scripts." At the moment currently don't have any knowledge on how scripting is done although it is on my to do list to learn. Can you tell me a bit more about this? For example, this script would add a perk (I named it "MyPerk") to the Actor the script is attached to when the actor's 3D gets loaded, then remove it when they get unloaded. Scriptname YOURSCRIPTNAME extends Auto Const Perk Property MyPerk Auto Const Event OnInit() Utility.Wait(1.0) If Self.Is3DLoaded() Self.AddPerk(MyPerk) EndIf EndEvent Event OnLoad() Self.AddPerk(MyPerk) EndEvent Event OnUnload() Self.RemovePerk(MyPerk) EndEvent You need to fill the script property MyPerk in the editor with the perk that you'd like to add/remove from this actor OnLoad() and OnUnload(). OnInit(), the script adds the perk to the actor if their 3D is already loaded by the time the script initializes (happens only once). "The attacker forms I wrote after GetIsID are just examples, replace them in accordance with your robot weapon mod." Is there a way to specify if the damage is coming from the player directly? Something like getisplayer. I am going to give these a try. It depends on the Perk Entry because they come with somewhat different Condition tabs. For Mod Incoming Weapon Damage, you can add: Conditions >> Attacker >> GetIsID : PlayerRef == 1. Edited October 2, 2023 by LarannKiar Link to comment Share on other sites More sharing options...
AtomsChosen Posted October 2, 2023 Author Share Posted October 2, 2023 Hey! One of your suggestions worked. https://imgur.com/a/EFzkeLw Mod Weapon Attack Damage: Target: IsHostileToActor : PlayerRef = 0 Function: SetValue = 0 I put this on the robot and the plaayer with a custom weapon and specified a faction. Because I only want this to effect those in the workshop npc faction and workshop robot faction I specified those. After testing this out robots are doing normal damage to everything else including other neutral actors outside of that faction, but they no longer aggro. However this was onnly part of the solution. The second thing is I needed to see the "non hostile" flag on their weapons. This prevented the friendly fire trigger from happening. However in order to do this I had to place a spell on the robot workshop npc and player actor. And I am mainly worried this could cause conflicts. And that is where I need to learn scripting. So this script you posted. Adding perks that way should prevent conflicts right? Link to comment Share on other sites More sharing options...
LarannKiar Posted October 3, 2023 Share Posted October 3, 2023 Hey! One of your suggestions worked. https://imgur.com/a/EFzkeLw Mod Weapon Attack Damage: Target: IsHostileToActor : PlayerRef = 0 Function: SetValue = 0 I put this on the robot and the plaayer with a custom weapon and specified a faction. Because I only want this to effect those in the workshop npc faction and workshop robot faction I specified those. After testing this out robots are doing normal damage to everything else including other neutral actors outside of that faction, but they no longer aggro. However this was onnly part of the solution. The second thing is I needed to see the "non hostile" flag on their weapons. This prevented the friendly fire trigger from happening. However in order to do this I had to place a spell on the robot workshop npc and player actor. And I am mainly worried this could cause conflicts. And that is where I need to learn scripting. So this script you posted. Adding perks that way should prevent conflicts right? Unfortunately no, that script is just an example. It works if it's attached to an Actor (which results in overwriting their actor record). You can edit the script to make it periodically search for suitable "remote actors" (actors the script is not attached to) but a reliable code requires advanced level of scripting knowledge. There are other ways to add/remove perks or spells from actors without complex scripting and without editing the actor records.. I'd recommend the helper/handler quest method. A helper quest that finds matching actor references and fills them into a quest alias ( whose Alias Spells field should contain your spell ) and a handler quest that controls the helper quest ( starts and stops it, basically ). You'll need to get acquainted with quests and quest aliases first if you haven't implemented such method in a mod. Alternativaly, you can add perks and spells to actors with an F4SE plugin too, see Spell Perk Item Distributor. Link to comment Share on other sites More sharing options...
Recommended Posts