Setting the aggression of an NPC by script?

Post » Tue Jan 06, 2015 8:55 pm

Hi there! This is my first post in this forum, so I'll try to avoid being overly noob here, lol.

I've been working on a little mod that for now adds an ability that revives a dead NPC into a follower. I would love to have the mod be as compatible as possible without needing to patch things, so the approach I've attemped is a script like this attached to the magic effect:

Scriptname BT_RescueSpellScript extends activemagiceffect  {Clone a dead NPC as a follower}	Faction property bt_petFac auto	Faction	property bt_currentFollowerFac auto	Faction property bt_FollowerFac auto	Event OnEffectStart(Actor akTarget, Actor akCaster)		ActorBase akTargetBase	= akTarget.GetActorBase()		Actor akPet		= akTarget.PlaceActorAtMe(akTargetBase)		akPet.SetFactionRank(bt_petFac, 0)		akPet.SetFactionRank(bt_currentFollowerFac, -1)		akPet.SetFactionRank(bt_FollowerFac, 0)		akPet.modAv("Aggression", 0)	endEvent

As you can see, it's rather simplistic. It gets the base actor of the target NPC (dead check is in the effect itself) and uses it to spawn a new one, then adds some parameters including the follower factions. That way, it should work even on custom NPCs added by other mods, which is my aim. I still need to add a lot of code, for example to get rid of the targetted corpse, but for now I'm trying to get things working one by one.

Everything seems to work properly except for the modAv function. Even though the aggression is set (and in game shows as 0 with a getav console command), if the NPC's aggression was originally "very aggressive" it will attack everything that is not an "ally" no matter what I try.

I assume I'm simply forgetting something since it's my first script, probably something very simple, but I've been checking this for a while already and I can't figure out how to make the new aggression levels stick. Any ideas?

User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am

Return to V - Skyrim