Make an NPC equip clothes on death?

Post » Sun May 18, 2014 12:27 am

Can anyone help me out making NPCs equip clothes on death?

I'm using an Ability with a custom script, which is added to the target when a certain spell is cast on them.
When they die, I use :
Target.AddItem([Clothing], 1)
Target.EquipItem([Clothing])

But the issue I have is it doesn't work...

If I run this inside an OnUpdate() event, nothing happens at all; if I run it on an OnEffectFinish() they equip and unequip the item of clothing indefinitely...

It seems like the code is working fine, but it seems like it's tied to effect, like it is deactivating and re-applying constantly?

Does anyone have any idea how to get this working?

Two Versions of my code :
Event OnUpdate()
If ( DeathDone == 0 )
DeathDone = 1
Target.AddItem(ZSCorpseClothing01, 1)
Target.EquipItem(ZSCorpseClothing01)
EndIf
EndEvent

Event OnEffectFinish()
Target.AddItem(ZSCorpseClothing01, 1)
Target.EquipItem(ZSCorpseClothing01)
EndEvent

Target is defined elsewhere in the Script, and DeathDone is a float.
User avatar
Gen Daley
 
Posts: 3315
Joined: Sat Jul 08, 2006 3:36 pm

Post » Sun May 18, 2014 7:53 am

Have you tried the OnDying event? Not quite sure when it triggers in relationship to OnDeath, but your problem could just be an issue with using equip function on a dead actor. Also try to use SetOutfit http://www.creationkit.com/SetOutfit_-_Actor.

Also, for event oneffectfinish, you don't need to define the target elsewhere as they are already assigned in the parameters OnEffectFinish(Actor akTarget, Actor akCaster)
User avatar
kirsty joanne hines
 
Posts: 3361
Joined: Fri Aug 18, 2006 10:06 am

Post » Sun May 18, 2014 5:36 am

Thank-you for your help! /smile.png' class='bbc_emoticon' alt=':)' />
User avatar
Harry-James Payne
 
Posts: 3464
Joined: Wed May 09, 2007 6:58 am


Return to V - Skyrim