Jump to content

Small Problem with OnEquipped/OnUneqipped events


tamrielhillbilly

Recommended Posts

Hello all. Beginner here trying to add a perk via script whenever someone equips my Shield, and remove the perk when they unequip it.

 

Works fine if you manually equip/unequip it. But if you say, switch to your bow (this will fire OnUnequip event as expected and take away the perk) but then switch back to a weapon/spell, it will NOT fire the OnEquipped event like it should. So you have the Shield equipped, but no perk for it do its magic until you manually uneqip and re-equip it again.

 

Anyone know a way around this behavior? Or a better way? Thanks.

 

Scriptname SomeModShieldScript extends ObjectReference  

Perk Property SomeModShieldPerk auto

Event OnEquipped(Actor akActor)
akActor.AddPerk(SomeModShieldPerk)
Debug.Notification("Shield was equipped")
EndEvent

Event OnUnEquipped(Actor akActor)
akActor.RemovePerk(SomeModShieldPerk)
Debug.Notification("Shield was unequipped")
EndEvent

Link to comment
Share on other sites

You can put a script on the player to use OnObjectEquipped and OnObjectUnequipped - those always fire.

 

A better way might be to just leave your perk on the player and (depending on what your perk does) add a condition for

 

GetEquipped YourShield == 1

to the perk entry point or ability.

Link to comment
Share on other sites

Thanks for the guidance. I guess I'll just leave the perk on the player.

 

Its just a special bash it does with this Shield. I already have the GetEquipped check in the perk entry point.

 

I was hoping to add the perk to NPCs who may also equip the Shield, but it looks like you can't add perks to NPCs on the fly. At least I can't.

Adding it to my follower in the CK works well enough though.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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