Trouble with trading equipment between actors

Post » Thu Jun 21, 2012 7:25 am

Occasionally I get amusing ideas for spells, and I'm thinking of making a mod where I include several of these humorous distractions. Anyhow, I had the idea for a spell that makes a zombie version of the actor, which then goes out and kills everyone around and all of them become zombies and so on.
I've tried resurrecting the original actors, applying a shader and sending them on their way, but a lot of commands don't work on resurrected actors I think, so I'm not bothering with it anymore. Now I'm spawning a zombie actor on top of anyone that dies who has the zombie ability. The zombie ability is first given through a typical on target script spell, but it has to subsequently spread to everyone that this actor kills.

All of that works fine and dandy (after a day or so of frustration) except that the zombies just have some typical draugr rags on. I want them instead to have all of the equipment that the original actor had, to make it a bit more convincing. So, I wrote this, and it doesn't work.
Scriptname AAAZombieTurnEffScript extends activemagiceffectRace Property AAAZombieRace autoKeyword Property ActorTypeUndead autoKeyword Property ActorTypeNPC autoKeyword Property VendorItemArmor autoKeyword Property VendorItemClothing autoFaction Property PatientZeroFaction autoFaction Property AAAZombieFaction autoActor CasterActor TargetSpell Property AAAZombietoZombieAb autoSpell Property AAAZombieTurnAb autoActor ZombieEffectShader Property AAAZombieShader auto	 ActorBase Property AAAZombieActor  Auto ActorBase Property AAAZombieActorF  Auto event OnEffectSTart(Actor akTarget, Actor akCaster)   Target = akTarget   Caster = akCasterendEventevent OnDeath(Actor akKiller)   ;if akKiller.GetRace()==AAAZombieRace|| Target.IsInFaction(PatientZeroFaction) ==true && Target.HasKeyWord(ActorTypeNPC)==true && Target.GetRace()!=AAAZombieRace	  Utility.Wait(2)	 Target.Disable(1)	 if (Target.GetBaseObject() as ActorBase).Getsix()==0		 Zombie = Target.PlaceActorAtMe(AAAZombieActor)		else    Zombie = Target.PlaceActorAtMe(AAAZombieActorF)	  endIf	  Zombie.Disable()	  Target.RemoveAllItems()	  Zombie.Enable();endIfendEventevent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)   if akBaseItem.HasKeyword(VendorItemArmor) || akBaseItem.HasKeyword(VendorItemClothing)	  Zombie.AddItem(akBaseItem)	  Zombie.EquipItem(akBaseItem)  endIfendEvent

Basically, the items get removed, but they don't go to the zombie. I'm wondering if this has something to do with the fact that RemoveAllItems removes and deletes everything simultaneously, not giving the OnItemRemoved event time to do its thing.
Suggestions?
User avatar
Mistress trades Melissa
 
Posts: 3464
Joined: Mon Jun 19, 2006 9:28 pm

Post » Thu Jun 21, 2012 8:11 am

you may want to try calling remove items before the disable.

when working on a custom mannequin script that uses disable and enable to reset their position and pose, i noticed it will sometimes delete their inventory and reset it to default.

also im not sure if OnItemRemoved will do anything on a magic effect script (because you cant remove items from a magic effect, this would have to be called on a reference script)



additionally you may want to create a persistent invisible container as a safer way to transfer items between actors

Zombie.RemoveAllItems(invisChest)
;do something
InvisChest.RemoveAllItems(Zombie)
;do something
User avatar
Chloe Yarnall
 
Posts: 3461
Joined: Sun Oct 08, 2006 3:26 am

Post » Thu Jun 21, 2012 3:48 pm

I had no idea you could specifiy the container to transfer to. I need to read the documentation more carefully next time.
User avatar
kennedy
 
Posts: 3299
Joined: Mon Oct 16, 2006 1:53 am

Post » Thu Jun 21, 2012 3:32 am

also, actors will only wear and equip items while the actor is loaded in Ram. once it is unloaded it will default back to its designated Outfit.

if you want permanent clothing changes to take effect, you need to use SetOutfit()



but another caveat to be aware of. there is no GetOutfit(), so you will not ever be able to revert the actors outfit to their vanilla in a persisting save game (without out using a really ugly and lengthy script). but then again, your NPC is already dead so it may not even matter in this case
User avatar
GPMG
 
Posts: 3507
Joined: Sat Sep 15, 2007 10:55 am

Post » Thu Jun 21, 2012 8:56 am

I got this working completely the way I want it to. One of the problems was that I was attempting to call functions on akItemReference rather than akBaseObject in my OnItemAdded event on the zombies.

One final issue: I have a race of zombies based off of a draugr with the Morph and Armor race set as DefaultRace. They are capable of putting stuff on, but their body parts become invisible as soon as they do. I hypothesize that this is because the draugr body part data is different, causing compatibility issues. Can anyone confirm this?
User avatar
StunnaLiike FiiFii
 
Posts: 3373
Joined: Tue Oct 31, 2006 2:30 am


Return to V - Skyrim