h3Xh3X Posted July 10, 2012 Share Posted July 10, 2012 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. Link to comment Share on other sites More sharing options...
steve40 Posted July 11, 2012 Share Posted July 11, 2012 (edited) EquipOnAddNotPlayer: - you also need to test that the container is an actor, (EquipItem will give an error on non-actors).- it's EquipItem, not Equip- use "self" Scriptname EquipOnAddNotPlayer extends ObjectReference {Equips item when added to inventory, unless actor is player.} Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if (akNewContainer as Actor) != none && akNewContainer != Game.GetPlayer() Debug.Trace("[EquipOnAddNotPlayer] Item contained by " + akNewContainer) (akNewContainer as Actor).EquipItem(self) else Debug.Trace("[EquipOnAddNotPlayer] Container is not a non-player actor " + akNewContainer) endIf endEvent CastOnEquip: - AddSpell and RemoveSpell are not necessary. Scriptname CastOnEquip extends ObjectReference {Object casts spell when equipped } Spell Property SpellToCast auto Event OnEquipped(Actor AkActor) SpellToCast.Cast(Self, Self) EndEvent PS. I don't have the CK handy, so I couldn't test if the scripts work or not. Edited July 11, 2012 by steve40 Link to comment Share on other sites More sharing options...
steve40 Posted July 11, 2012 Share Posted July 11, 2012 (edited) Btw, I'm not sure if setting race to "none" will work (or it might default to Nord race!). You need to store the initial race in a property, then set it back afterwards: Scriptname PolymorphHostileEffectScript extends ActiveMagicEffect {Turns target into a hostile polymorph} Race Property PolymorphRace auto Faction Property PlayerWerewolfFaction auto Race Property InitialRace auto hidden Event OnEffectStart(Actor Target, Actor Caster) InitialRace = Target.GetActorBase().GetRace() if (InitialRace != PolymorphRace) Target.SetRace(PolymorphRace) Target.UnequipAll() Target.SetAttackActorOnSight(true) Target.AddToFaction(PlayerWerewolfFaction) endif EndEvent Event OnEffectFinish(Actor Target, Actor Caster) ; change back Target.SetRace(InitialRace) Target.SetAttackActorOnSight(false) Target.RemoveFromFaction(PlayerWerewolfFaction) endEvent Edited July 13, 2012 by steve40 Link to comment Share on other sites More sharing options...
h3Xh3X Posted July 11, 2012 Author Share Posted July 11, 2012 (edited) Btw, I'm not sure if setting race to "none" will work (or it might default to Nord race!). You need to store the initial race in a property, the set it back afterwards: This was what the "polymorph skeever" test script in the ck did, so I just blindly copied that (adding hostile effects). Thanks for the pointer, I'll keep it in mind when I test. :)Now I'm gonna go around reverse pickpocketing polymorph rings to guards! :D Edited July 11, 2012 by h3Xh3X Link to comment Share on other sites More sharing options...
h3Xh3X Posted July 11, 2012 Author Share Posted July 11, 2012 Well, tested it now, and I don't see any of the debug messages when the ring changes container. Too late at night to figure this out now, but I'll look more into it tomorrow. Link to comment Share on other sites More sharing options...
gasti89 Posted July 11, 2012 Share Posted July 11, 2012 If you want to pop a a message use MessageBox instead of Trace. Or Notification, if you want the message to display in the top left corner (like when you equip something). Link to comment Share on other sites More sharing options...
steve40 Posted July 11, 2012 Share Posted July 11, 2012 The Debug.Trace messages will print into the papyrus log, but will only work if you have enabled trace logging in your Skyrim.ini file. As gast89 says, you can change "Debug.Trace" to "Debug.Notification" and the messages will show on your monitor. Link to comment Share on other sites More sharing options...
h3Xh3X Posted July 12, 2012 Author Share Posted July 12, 2012 (edited) Okay, getting the messages now. Still no transformation. One question; how can I invoke a script from within another script instead of triggering it on an event? The message says it is contained by TGAssaultScript <reference> instead of Actor or ObjectReference <reference>. This may be because I'm testing it on people in thieves guild (TG) and they are supposed to react as if assaulted?Maybe I can put it in their inventory without pickpocketing for now. Not sure if Actor.OpenInventory() is implemented in console. Edited July 12, 2012 by h3Xh3X Link to comment Share on other sites More sharing options...
steve40 Posted July 13, 2012 Share Posted July 13, 2012 (edited) Hmmm. Maybe that means that you got busted pickpocketing? Could you try it on some ordinary guards please. Also try this putting this script on the ring, I've added a debug message. Scriptname CastOnEquip extends ObjectReference {Object casts spell when equipped } Spell Property SpellToCast auto Event OnEquipped(Actor AkActor) Debug.Notification("[CastOnEquip]Item was equipped by: " + AkActor) SpellToCast.Cast(Self, Self) EndEvent Edit: also try this modified script: Scriptname EquipOnAddNotPlayer extends ObjectReference {Equips item when added to inventory, unless actor is player.} Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if (akNewContainer as Actor) != none && akNewContainer != Game.GetPlayer() Debug.Trace("[EquipOnAddNotPlayer] Item contained by " + akNewContainer) (akNewContainer as Actor).EquipItem((self as Armor).GetBaseObject(), True, True) else Debug.Trace("[EquipOnAddNotPlayer] Container is not a non-player actor " + akNewContainer) endIf endEvent Edited July 13, 2012 by steve40 Link to comment Share on other sites More sharing options...
Recommended Posts