I'm trying to make an item equip when added to an actor's inventory. When equipped, the item should turn the actor into a hagraven. I have the spell effect and spell set up. Effect: Scriptname PolymorphHostileEffectScript extends ActiveMagicEffect
{Turns target into a hostile polymorph}
Race Property PolymorphRace auto
Faction Property PlayerWerewolfFaction auto
Event OnEffectStart(Actor Target, Actor Caster)
if (Target.GetActorBase().GetRace() != PolymorphRace)
Target.SetRace(PolymorphRace)
Target.UnequipAll()
Target.SetAttackActorOnSight(true)
Target.AddToFaction(PlayerWerewolfFaction)
endif
EndEvent
Event OnEffectFinish(Actor Target, Actor Caster)
; change back
Target.SetRace(None)
Target.SetAttackActorOnSight(false)
Target.RemoveFromFaction(PlayerWerewolfFaction)
endEvent
EquipOnAddNotPlayer: Scriptname EquipOnAddNotPlayer extends ObjectReference
{Equips item when added to inventory,
unless actor is player.}
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
if akNewContainer != Game.GetPlayer()
if akNewContainer
Debug.Trace("Item contained by " + akNewContainer)
; (akNewContainer as Actor).Equip(this) ; <- I'm not sure what to do here
endIf
endIf
endEvent
CastOnEquip:
Scriptname CastOnEquip extends ObjectReference
{Object casts spell when equipped }
Spell Property SpellToCast auto
Event OnEquipped(Actor AkActor)
AkActor.AddSpell(SpellToCast)
SpellToCast.Cast(Self, Self)
EndEvent
Event OnUnequipped(Actor AkActor)
AkActor.RemoveSpell(SpellToCast)
EndEvent
In the CastOnEquip script, I'm not sure if AddSpell() and RemoveSpell() are needed. Please enlighten me! In the EquipOnAddNotPlayer script, see the commented line. I'm wondering how to cast akNewContainer to an Actor object so I can call EquipItem on it (or how to achieve this by other means). I also wouldn't know what to pass as akItem to EquipItem() in this case.