Jump to content

Script Help - OnEquip Weapon or Armor


edhelsereg

Recommended Posts

Hey guys,

 

I have these gloves that must be equipped last to work as intended. I want to force this by adding a script whereby equipping or changing any weapon or armor on the player un-equips and re-equips the gloves right after.

 

I have experimented with the OnObjectEquipped Event, but have had no luck

 

Scriptname KA_GloveEquipSCRIPT extends ObjectReference

 

Armor Property glove Auto

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)

if akBaseObject as Weapon
Debug.Trace("This actor just equipped a weapon!")
game.getPlayer().RemoveItem(glove)
game.getPlayer().EquipItem(glove)
endIf
endEvent

 

 

 

Could an update/refresh script also do the trick? or maybe a keyword check?

 

Thanks!

Link to comment
Share on other sites

You've attached this to the object itself, so it will only unequip and then re-equip every time you equip this particular item--which is circular, and I think not what you really want. You want to unequip and re-equip every time you equip any OTHER item. To capture those events, you could place a small script on the player using a quest alias that catches the OnObjectEquipped event.
Link to comment
Share on other sites

The script works :biggrin:
Last thing, is there a way to hide the unequip and equip messages?

 

Scriptname KA_KonahGloveQSTscript extends ReferenceAlias

{This script triggers if you are wearing Konah Gloves and switch any equippable item}
Keyword Property VendorItemWeapon Auto
Keyword Property VendorItemJewelry Auto
Keyword Property VendorItemClothing Auto
Keyword Property ArmorHelmet Auto
Keyword Property ArmorCuirass Auto
Keyword Property ArmorBoots Auto
Armor Property Gloves Auto
{Konah Gloves}
Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
if Game.GetPlayer().IsEquipped(Gloves)
Debug.Trace("The player has the gloves equipped")
if akBaseObject.HasKeyword(VendorItemWeapon)
Debug.Trace("This actor just equipped a weapon!")
game.getPlayer().UnequipItem(Gloves)
game.getPlayer().EquipItem(Gloves)
elseIf akBaseObject.HasKeyword(ArmorHelmet)
Debug.Trace("This actor just equipped armor!")
game.getPlayer().UnequipItem(Gloves)
game.getPlayer().EquipItem(Gloves)
elseIf akBaseObject.HasKeyword(ArmorCuirass)
Debug.Trace("This actor just equipped armor!")
game.getPlayer().UnequipItem(Gloves)
game.getPlayer().EquipItem(Gloves)
elseIf akBaseObject.HasKeyword(ArmorBoots)
Debug.Trace("This actor just equipped armor!")
game.getPlayer().UnequipItem(Gloves)
game.getPlayer().EquipItem(Gloves)
elseIf akBaseObject.HasKeyword(VendorItemJewelry)
Debug.Trace("This actor just equipped jewelry!")
game.getPlayer().UnequipItem(Gloves)
game.getPlayer().EquipItem(Gloves)
elseIf akBaseObject.HasKeyword(VendorItemClothing)
Debug.Trace("This actor just equipped a clothing!")
game.getPlayer().UnequipItem(Gloves)
game.getPlayer().EquipItem(Gloves)
endIf
endIf
endEvent

 

Edited by edhelsereg
Link to comment
Share on other sites

1. Save yourself some processing time... One time is not a big deal, but multiple calls add up.

 

Use

Actor Property PlayerRef Auto

 

Then replace all the

game.getPlayer()

with

PlayerRef

 

2. As for your question...

 

UnEquipItem(Gloves, false, true)

EquipItem(Gloves, false, true)

 

http://www.creationkit.com/EquipItem_-_Actor

http://www.creationkit.com/UnequipItem_-_Actor

Link to comment
Share on other sites

  • Recently Browsing   0 members

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