Spoiler
scriptName BFGEnchantedArmorScale
ref HeadObj
ref UpperObj
ref LowerObj
ref HandObj
ref FootObj
ref ShieldObj
ref TailObj
float fQuestDelayTime
float HeadObjCurHP
float UpperObjCurHP
float LowerObjCurHP
float HandObjCurHP
float FootObjCurHP
float ShieldObjCurHP
float TailObjCurHP
float Percentage
long HeadObjHP
long UpperObjHP
long LowerObjHP
long HandObjHP
long FootObjHP
long ShieldObjHP
long TailObjHP
begin GameMode
set fQuestDelayTime to 2
let HeadObj := (Player.GetEquippedObject 0) ;0 = head
If HeadObj == 0
let HeadObj := (Player.GetEquippedObject 1) ;1 = hair
Endif
let UpperObj := (Player.GetEquippedObject 2) ;2 = cuirass
let LowerObj := (Player.GetEquippedObject 3) ;3 = greaves
let HandObj := (Player.GetEquippedObject 4) ;4 = gauntlets/bracers
let FootObj := (Player.GetEquippedObject 5) ;5 = boots
let ShieldObj := (Player.GetEquippedObject 13) ;13 = shield
let TailObj := (Player.GetEquippedObject 15) ;15 = tail
if LowerObj == 0
if UpperObj == 0
if FootObj == 0
if HandObj == 0
let UpperObj := (Player.GetEquippedObject 20) ;20 = cuirass + greaves + gauntlets + boots
else
let UpperObj := (Player.GetEquippedObject 19) ;19 = cuirass + greaves + boots
endif
else
let UpperObj := (Player.GetEquippedObject 18) ;18 = cuirass + greaves
endif
endif
endif
if HeadObj.IsArmor
let HeadObjCurHP := Player.GetEquippedCurrentHealth 0
if HeadObjCurHP == 0
let HeadObjCurHP := Player.GetEquippedCurrentHealth 1
endif
if HeadObjCurHP == 0
player.UnequipitemNS HeadObj
endif
let HeadObjHP := HeadObj.GetObjectHealth
let Percentage := HeadObjCurHP / HeadObjHP
Message "Helmet Health is %.0f%%.", Percentage
endif
if UpperObj.IsArmor
let UpperObjCurHP := Player.GetEquippedCurrentHealth 2
if UpperObjCurHP == 0
player.UnequipitemNS UpperObj
endif
let UpperObjHP := UpperObj.GetObjectHealth
let Percentage := UpperObjCurHP / UpperObjHP
Message "Cuirass Health is %.0f%%.", Percentage
endif
end
scriptName BFGEnchantedArmorScale
ref HeadObj
ref UpperObj
ref LowerObj
ref HandObj
ref FootObj
ref ShieldObj
ref TailObj
float fQuestDelayTime
float HeadObjCurHP
float UpperObjCurHP
float LowerObjCurHP
float HandObjCurHP
float FootObjCurHP
float ShieldObjCurHP
float TailObjCurHP
float Percentage
long HeadObjHP
long UpperObjHP
long LowerObjHP
long HandObjHP
long FootObjHP
long ShieldObjHP
long TailObjHP
begin GameMode
set fQuestDelayTime to 2
let HeadObj := (Player.GetEquippedObject 0) ;0 = head
If HeadObj == 0
let HeadObj := (Player.GetEquippedObject 1) ;1 = hair
Endif
let UpperObj := (Player.GetEquippedObject 2) ;2 = cuirass
let LowerObj := (Player.GetEquippedObject 3) ;3 = greaves
let HandObj := (Player.GetEquippedObject 4) ;4 = gauntlets/bracers
let FootObj := (Player.GetEquippedObject 5) ;5 = boots
let ShieldObj := (Player.GetEquippedObject 13) ;13 = shield
let TailObj := (Player.GetEquippedObject 15) ;15 = tail
if LowerObj == 0
if UpperObj == 0
if FootObj == 0
if HandObj == 0
let UpperObj := (Player.GetEquippedObject 20) ;20 = cuirass + greaves + gauntlets + boots
else
let UpperObj := (Player.GetEquippedObject 19) ;19 = cuirass + greaves + boots
endif
else
let UpperObj := (Player.GetEquippedObject 18) ;18 = cuirass + greaves
endif
endif
endif
if HeadObj.IsArmor
let HeadObjCurHP := Player.GetEquippedCurrentHealth 0
if HeadObjCurHP == 0
let HeadObjCurHP := Player.GetEquippedCurrentHealth 1
endif
if HeadObjCurHP == 0
player.UnequipitemNS HeadObj
endif
let HeadObjHP := HeadObj.GetObjectHealth
let Percentage := HeadObjCurHP / HeadObjHP
Message "Helmet Health is %.0f%%.", Percentage
endif
if UpperObj.IsArmor
let UpperObjCurHP := Player.GetEquippedCurrentHealth 2
if UpperObjCurHP == 0
player.UnequipitemNS UpperObj
endif
let UpperObjHP := UpperObj.GetObjectHealth
let Percentage := UpperObjCurHP / UpperObjHP
Message "Cuirass Health is %.0f%%.", Percentage
endif
end
"HeadObj.IsArmor" and "UpperObj.IsArmor" are never true, at least in my test case - a custom enchanted hood and custom enchanted Perfect Madness cuirass. For that matter, HeadObj.IsClothing and UpperObj.IsClothing are never true either. But the Object IDs are being properly recognized.
Is there a limitation to these commands that prevents them from recognizing custom enchanted armor/clothing, or am I missing something? Thanks in advance!
(By the way, any other general suggestions are also appreciated. The ultimate goal of this mod is to scale the enchantments of armor so that the more damage the armor takes, the less potent the enchantment. For example a cuirass at 20% health may only have 60% of its enchantment in effect.)