GetItemHealthPercentage Returns 0

Post » Mon Jun 18, 2012 12:04 pm

I'm trying to access data about armor in a script, and according to the wiki using GetItemHealthPercentage should return 1 for regular armor, weapons, etc and higher numbers depending on how well its been upgraded via smithing. This works as expected for some of the items in my inventory, specifically a legendary elven sword and 'the forgemasters fingers' gauntlets, however for almost all other armor or weapons I try it merely returns 0 as if the item doesn't exist (examples: iron dagger, flawless iron dagger, elven greatsword, legendary elven greatsword)

I'm calling GetItemHealthPercentage from within a script on the player whenever an item is equiped like this:
float totalGauntletArmorRating = 0.0

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)

totalGauntletArmorRating = akReference.GetItemHealthPercent()
Debug.MessageBox(totalGauntletArmorRating)

endEvent

Any ideas on what's going on?

Edit: Apparently it's an issue with items being equipped, if I tell it to also print the formID for baseobject it'll give me that value, but if I ask for the formID for the reference I get 0 for most items.

Example:
Iron Dagger: baseObject formID = 80254, reference formID = 0
Elven Sword Legendary: baseObject formId = 80289, reference formID = -16772189
User avatar
Baby K(:
 
Posts: 3395
Joined: Thu Nov 09, 2006 9:07 pm

Post » Mon Jun 18, 2012 7:20 am

Anyone?
User avatar
abi
 
Posts: 3405
Joined: Sat Nov 11, 2006 7:17 am

Post » Mon Jun 18, 2012 6:55 am

There's got to be a way to make this work right
User avatar
Amanda Leis
 
Posts: 3518
Joined: Sun Dec 24, 2006 1:57 am

Post » Mon Jun 18, 2012 3:17 am

I have been working on my own solution to this very problem. GetItemHealthPercent only returns a value if the item is persistent. As a lot of stuff isn't, and for good reason, this is a no go. The best I have come up with is system whereby I hold the current "health" of each Weapon type I Equip in an array. This means that if I have 5 Iron Daggers but no way to tell them apart because they are not persistent, I have 1 "Health" value for all of them as a collection. I cannot unequip a worn dagger and equip a healthy one.

I am finding this acceptable except when one of the those daggers has been improved with smithing. I have 4 daggers and 1 Fine Dagger but I cannot tell them apart in script.

Persistence would seem to be the key, then you could put a script on each object and then, where you have 5 daggers, you have 5 versions of the script running; each with their own health being tracked. I have spent a lot of time trying to get that to work but the only way to get the weapons persistent is to drop them on the floor and pick them up again. And that only works if there is a script on them in the first place.

On the subject of the GetItemHealthPercent, the game must know which dagger has been improved and which hasn't as it shows them separately in the inventory. It would be most helpful if this information was usable in the scripting.
User avatar
Captian Caveman
 
Posts: 3410
Joined: Thu Sep 20, 2007 5:36 am


Return to V - Skyrim