I'd like to prevent certain NPCs from being able to enter combat. This would be easy to do if I edited the NPC's base form, but I don't want to do that because I want to be compatible with every NPC in the game, including any base forms that might be added by other mods.
It's easy enough to make a hostile NPC friendly. The bigger problem is preventing that friendly NPC from starting combat when it's attacked by the player. This is as far as I've gotten:
Faction property PlayerFaction autoFunction MakeFriendly() self.MakePlayerFriend() self.RemoveFromAllFactions() self.AddToFaction(PlayerFaction)EndFunctionEvent OnInit() self.MakeFriendly()EndEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) self.StopCombat() self.MakeFriendly()EndEventEvent OnCombatStateChanged(Actor akTarget, int aeCombatState) self.StopCombat() self.MakeFriendly()EndEvent
This will make any unfriendly NPC become friendly. SOMETIMES it even works to stop the NPC from going into combat when the player hits it. Other times the NPC will enter combat and go after the player and then stop shortly after.
Does anyone have any ideas on how to disable combat for an NPC in Papyrus or SKSE? If I could simply prevent any damage to the NPC from player attacks and therefore prevent them from even wanting to go into combat, that would work too.