Jump to content

Making New Unequip Event


Recommended Posts

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 by paulatreides0
Link to comment
Share on other sites

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

 

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 by paulatreides0
Link to comment
Share on other sites

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 by Reneer
Link to comment
Share on other sites

 

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 by paulatreides0
Link to comment
Share on other sites

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

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...