How do you properly get the reference to an equipped item?

Post » Mon Jun 18, 2012 9:13 am

I'm trying to get values from an item when the player equips it (specifically armor), right now I've set up a script on the player that runs whenever an item is equipped and puts a messagebox on the screen that's supposed to display the formID of the base object, formID of the reference equipped, and the healthpercent of the reference equipped. Here's the script:

Scriptname UnarmedDamage extends Actor{Adds Unarmed Damage when item is equiped}ObjectReference equippedItem;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)   equippedItem = akReference   Debug.MessageBox(akBaseObject.GetFormID()+"   "+equippedItem.GetFormID()+"	"+equippedItem.GetItemHealthPercent())EndEvent

Unfortunately, it only behaves as expected maybe 1/100th of the time. akReference seems to not be getting passed correctly to the event, so when I call getFormID on it it returns 0 while akBaseObject returns the proper formID. Very few items will return an ID when getFormID is called on the reference

Is there a proper way to get the reference to the item when it's equipped, or reference the armor weared by the player?
User avatar
Elle H
 
Posts: 3407
Joined: Sun Aug 06, 2006 3:15 am

Post » Mon Jun 18, 2012 6:24 pm

bump
User avatar
Noely Ulloa
 
Posts: 3596
Joined: Tue Jul 04, 2006 1:33 am


Return to V - Skyrim