First off I'm using OBSE v1800. I've been trying to add a dynamic stack gain to my Stackable Oblivion mod, but out of the blue the GetArmorAR function started giving me really weird values.
I posted this question on the CS forums over at beth but got no response so I guess I'll ask here, and in more detail so that the helpful people that browse these forums can help.
Here is entire first half of my script so that someone may spot something wrong:
ref Helmet
ref Cuirass
ref Boots
ref Greaves
ref Gauntlets
ref Shield
ref Weapon
ref NHelmet
ref NCuirass
ref NBoots
ref NGreaves
ref NGauntlets
ref NShield
ref NWeapon
ref NewObj
short Choosing
short Choice
float ItemNum
long ArmorAR
long OldAR
long WeapDMG
long OldDMG
float temp
float temp2
float fQuestDelayTime
short GamemodeCheck
short MenumodeRun
Begin Gamemode
Set fQuestDelayTime to 0.01
if GamemodeCheck == 1
Set MenumodeRun to 1
endif
End
Begin Menumode 1002
if OnControlDown 7 == 1
Set Choosing to -1
Set Helmet to Player.GetEquippedObject 1
Set Cuirass to Player.GetEquippedObject 2
Set Greaves to Player.GetEquippedObject 3
Set Gauntlets to Player.GetEquippedObject 4
Set Boots to Player.GetEquippedObject 5
Set Shield to Player.GetEquippedObject 13
Set Weapon to Player.GetEquippedObject 16
if Database.Full == 1
Message "WARNING: You have used up the 30 slots in the stack database! Do not stack anymore items!"
endif
endif
if Choosing == -1
MessageBoxEx "Select which object to stack. (<no name> means you have no item equipped in that slot) |Helmet: %n|Cuirass: %n|Greaves: %n|Gauntlets: %n|Boots: %n|Shield: %n|Weapon: %n|Close" Helmet Cuirass Greaves Gauntlets Boots Shield Weapon
Set Choosing to 1
Set Choice to -1
elseif Choosing == 1
if Choice == -1
Set Choice to GetButtonPressed
elseif Choice == 0
Set ItemNum to Player.GetItemCount Helmet
if ItemNum > 1
Let OldAR := GetArmorAR Helmet
PrintC "CM: OldAR == %.2f" OldAR
let temp := OldAR / 100
PrintC "CM: 1. temp = %.2f" temp
let temp := 1 - temp
PrintC "CM: 2. temp = %.2f" temp
let temp2 := 1.28
PrintC "CM: 3. temp2 = %.2f" temp2
let temp2 ^= temp
PrintC "CM: 4. temp2 = %.2f" temp2
let ArmorAR := 1 - temp2
PrintC "CM: 5. ArmorAR = %.2f" ArmorAR
let ArmorAR := 100 * ArmorAR
PrintC "CM: 6. ArmorAR = %.2f" ArmorAR
Player.UnequipItemNS Helmet
Set NHelmet to CloneForm Helmet
SetArmorAR ArmorAR NHelmet
Player.AddItemNS NHelmet 1
Player.RemoveItemNS Helmet 2
Player.EquipItemNS NHelmet
Call AddToDatabase NHelmet 1
PrintC "CM: Save01 = %n" Database.Save01
Set Choosing to 0
return
Now, you'll see I added a bunch of debug text to the math part, I did this to begin with when my armor was getting set to odd values. But what I found was that the original GetArmorAR call was not working right. Here is the print out exactly though:
"CM: OldAR == 300.00"
"CM: 1. temp = 3.00"
"CM: 2. temp = -2.00"
"CM: 3. temp2 = 1.28"
"CM: 4. temp2 = 0.61"
"CM: 5. ArmorAR = 0.00"
"CM: 6. ArmorAR = 0.00"
I'm totally confused, why would it give me 300 instead of the 1 I should get (was testing with a Guard Helmet). I should also mention that when I later call GetArmorAR on the new cloned and set AR object it gives me a 0.
AND, what confuses me even more is that even the SetArmorAR line isn't working. I got 0 as my final ArmorAR right? So why didn't I have an Armor rating of 0 at the end (maybe not possible)? BUT, when I do this whole code again on my newly cloned object it sets the AR to 145 . (the final ArmorAR value after all of the math there is -100).
Ok complete chaos, am I right? And then something happened that really got me stumped. Once of my cloned object got a " (2)" appended on it's name. Ok I looked through the ENTIRE script and nowhere to I have an AppendName call. But I did put it in before, I had set a string_var to " (2)" and in the script I had put AppendName [string_var]. BUT I had deleted that! I'm certain I don't have another script running in the background that I may have forgot, because I checked the details menu in the CS and only saw the scripts that I had.
So now I have some phantom code running on my mod . Do I make a new script, and copy the code over or something? This has really got me , usually its some stupidness on my part that causes these problems, but now I'm convinced its some OBSE madness (I really hope it's some stupid mistake I made).
Any suggestions? I'm pretty sure I explained everything out, I can post the entire script if you want to look at it too.