paulatreides0 Posted August 11, 2016 Share Posted August 11, 2016 (edited) I want to make a new unequip event, but am not sure how exactly to define the event and execute it. Because I want this to apply to every actor of the human race, I am thinking of applying it via an ability-type spell effect that runs a script-archetype magic effect. The problem is that I need to be able to freely reference both the actor and the item the actor equips in the same event, I tried playing around with using Onequip and OnItemEquipped simultaneously, but that didn't work because it seemed to only fire one off at a time. So instead I'm trying to go about it by defining a new type of "OnEquip" event that has both objects and actors as parameter inputs. The big problem is that I'm not exactly sure how to do that. I tried reading what Scrivener07 had said in another thread, but I didn't really understand how to apply that in my case. EDIT: Oops, name should be making new EQUIP event. Not unequip. Edited August 11, 2016 by paulatreides0 Link to comment Share on other sites More sharing options...
khazerruss Posted August 13, 2016 Share Posted August 13, 2016 Why not just make a normal actor script and add it to every actor in the game? Link to comment Share on other sites More sharing options...
paulatreides0 Posted August 13, 2016 Author Share Posted August 13, 2016 (edited) Because being able to add it as an ability effect on humanrace means that it would be automatically added to every humanrace actor, including custom companions and new NPCs. Which means more extendability and support. Edited August 13, 2016 by paulatreides0 Link to comment Share on other sites More sharing options...
khazerruss Posted August 13, 2016 Share Posted August 13, 2016 You have the point.My point is that's probably undoable without the engine. Link to comment Share on other sites More sharing options...
Reneer Posted August 14, 2016 Share Posted August 14, 2016 What you want is something like this on a MagicEffect: Scriptname RenEquipAbilityEffectScript extends ActiveMagicEffect Actor NPCRef Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) if (NPCRef != none) ; do your stuff here. endif endEvent Event OnEffectStart(Actor akTarget, Actor akCaster) NPCRef = akTarget EndEvent Link to comment Share on other sites More sharing options...
paulatreides0 Posted August 14, 2016 Author Share Posted August 14, 2016 (edited) What you want is something like this on a MagicEffect: Scriptname RenEquipAbilityEffectScript extends ActiveMagicEffect Actor NPCRef Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) if (NPCRef != none) ; do your stuff here. endif endEvent Event OnEffectStart(Actor akTarget, Actor akCaster) NPCRef = akTarget EndEvent If I use "Actor NPCRef", wouldn't I have to explicitly name the actor beforehand? Or is it like defining a generic actor such that any actor that triggers the "OnItemEquipped" trigger will get saved as a reference and carry over into the event? Edited August 14, 2016 by paulatreides0 Link to comment Share on other sites More sharing options...
Reneer Posted August 14, 2016 Share Posted August 14, 2016 (edited) If I use "Actor NPCRef", wouldn't I have to explicitly name the actor beforehand? Or is it like defining a generic actor such that any actor that triggers the "OnItemEquipped" trigger will get saved as a reference and carry over into the event?No, you would not. Look at the OnEffectStart event - it provides the akTarget for you. akTarget is the NPC that the Magic Effect is running on. NPCRef is a global variable that is available everywhere in the script. Edited August 14, 2016 by Reneer Link to comment Share on other sites More sharing options...
paulatreides0 Posted August 14, 2016 Author Share Posted August 14, 2016 (edited) If I use "Actor NPCRef", wouldn't I have to explicitly name the actor beforehand? Or is it like defining a generic actor such that any actor that triggers the "OnItemEquipped" trigger will get saved as a reference and carry over into the event?No, you would not. Look at the OnEffectStart event - it provides the akTarget for you. akTarget is the NPC that the Magic Effect is running on. NPCRef is a global variable that is available everywhere in the script. Ohhh, I think I see. Since NPCRef is a global variable, when I define it in "OnEffectStart", then the value is saved, globally, correct? By which I mean, if I were to use a third event trigger, "OnEventX(ObjectReference akReference)", then I could use still use NPCRef with it's stored value of akTarget, correct? Such that an instance of the magic effect, if "akTarget = Game.GetPlayer()", when I call "NPCRef.GetHealth()" it'll call "Game.GetPlayer().GetHealth", right?? Edited August 14, 2016 by paulatreides0 Link to comment Share on other sites More sharing options...
Reneer Posted August 15, 2016 Share Posted August 15, 2016 Ohhh, I think I see. Since NPCRef is a global variable, when I define it in "OnEffectStart", then the value is saved, globally, correct? By which I mean, if I were to use a third event trigger, "OnEventX(ObjectReference akReference)", then I could use still use NPCRef with it's stored value of akTarget, correct? Such that an instance of the magic effect, if "akTarget = Game.GetPlayer()", when I call "NPCRef.GetHealth()" it'll call "Game.GetPlayer().GetHealth", right??You got it. Link to comment Share on other sites More sharing options...
paulatreides0 Posted August 16, 2016 Author Share Posted August 16, 2016 Ohhh, I think I see. Since NPCRef is a global variable, when I define it in "OnEffectStart", then the value is saved, globally, correct? By which I mean, if I were to use a third event trigger, "OnEventX(ObjectReference akReference)", then I could use still use NPCRef with it's stored value of akTarget, correct? Such that an instance of the magic effect, if "akTarget = Game.GetPlayer()", when I call "NPCRef.GetHealth()" it'll call "Game.GetPlayer().GetHealth", right??You got it. Words cannot describe my excitement right now. I've been trying to figure out how to define flags and global variables in Papyrus for a while now, and had no idea it was so simple! Thank you so very, very much! You've been a greater help than mere language can express, Reneer! Link to comment Share on other sites More sharing options...
Recommended Posts