Disable an NPC's Combat

Post » Fri Sep 05, 2014 2:11 am

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:

Spoiler
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.

User avatar
Pawel Platek
 
Posts: 3489
Joined: Sat May 26, 2007 2:08 pm

Post » Thu Sep 04, 2014 6:56 pm

Npc, hostile or not, won't fight if you add a package to them flagged "no combat" The player can hit them as often as he wants, they'll never enter combat. You can avoid modifying vanilla forms by adding packages to npc in aliases in a quest.

User avatar
RObert loVes MOmmy
 
Posts: 3432
Joined: Fri Dec 08, 2006 10:12 am

Post » Thu Sep 04, 2014 8:33 pm

Ohh I must reiterate the above statement. The best way to avoid editing vanilla forms is through quests. Quests are very versatile and relatively safe.

User avatar
Strawberry
 
Posts: 3446
Joined: Thu Jul 05, 2007 11:08 am


Return to V - Skyrim