Is there any way to disable Oblivion's automatic unequipping of broken weapons so that this script will kick in? Or maybe the problem is something completely different, in which case I'm open to general advice!
Related to that - I don't like the fact that, in the script, I have to equip every weapon in inventory before I can determine that weapon's current (as opposed to base) health. The GetCurrentHealth function doesn't work on ObjectIDs. But I can't find a way around it - any advice on how to change that, or general advice on how to optimize this script, is appreciated.
Spoiler
begin GameMode
set fQuestDelayTime to 1
let WeaponSlot := 16
let Obj := (Player.GetEquippedObject WeaponSlot)
if IsWeapon Obj == 0
Return
else
let ObjCurHP := Player.GetEquippedCurrentHealth WeaponSlot
if ObjCurHP > 0
Return
else
if player.IsWeaponOut == 1
set rdyWpn to GetControl 8
Tapkey rdyWpn ;this sheathes the weapon temporarily
let alert := 1
else
let alert := 0
Endif
player.UnequipitemNS Obj
let allowedweapon := ar_Construct Map
let tempa := -1
While tempa < 5
let tempa := tempa + 1
let allowedweapon[tempa] := 1
loop
let Obj := (Player.GetEquippedObject 13) ;check if a shield is currently equipped, disable 2H weapons if so
if IsArmor Obj
let allowedweapon[1] := -1
let allowedweapon[3] := -1
let allowedweapon[4] := -1
let allowedweapon[5] := -1
endif
let Obj := (Player.GetEquippedObject 17) ;check if ammo is equipped, disable bows if not
if IsAmmo Obj == 0
let allowedweapon[5] := -1
endif
let clothing := player.GetItems 33 ;20 = armor, 22 = clothes, 33 = weapon
let final := 0
let probevalue := -1
ForEach item <- clothing
let probe := item["Value"]
let tempa := GetWeaponType probe
if eval (allowedweapon[tempa]) > 0 && Obj != probe ;don't try to requip same weapon.
let ObjCurHP := -1
Player.Equipitem2NS probe
let ObjCurHP := Player.GetEquippedCurrentHealth WeaponSlot
Player.UnequipitemNS probe
If (probevalue <= GetFullGoldValue probe) && ObjCurHP > 0 ;find highest value weapon of right type
let probevalue := GetFullGoldValue probe
let final := probe
endif
endif
loop
if final > 0
player.EquipItem2NS final
if alert == 1
Tapkey rdyWpn ;this draws the new weapon if the previous one was drawn
endif
Return
endif
endif
endif
end
begin GameMode
set fQuestDelayTime to 1
let WeaponSlot := 16
let Obj := (Player.GetEquippedObject WeaponSlot)
if IsWeapon Obj == 0
Return
else
let ObjCurHP := Player.GetEquippedCurrentHealth WeaponSlot
if ObjCurHP > 0
Return
else
if player.IsWeaponOut == 1
set rdyWpn to GetControl 8
Tapkey rdyWpn ;this sheathes the weapon temporarily
let alert := 1
else
let alert := 0
Endif
player.UnequipitemNS Obj
let allowedweapon := ar_Construct Map
let tempa := -1
While tempa < 5
let tempa := tempa + 1
let allowedweapon[tempa] := 1
loop
let Obj := (Player.GetEquippedObject 13) ;check if a shield is currently equipped, disable 2H weapons if so
if IsArmor Obj
let allowedweapon[1] := -1
let allowedweapon[3] := -1
let allowedweapon[4] := -1
let allowedweapon[5] := -1
endif
let Obj := (Player.GetEquippedObject 17) ;check if ammo is equipped, disable bows if not
if IsAmmo Obj == 0
let allowedweapon[5] := -1
endif
let clothing := player.GetItems 33 ;20 = armor, 22 = clothes, 33 = weapon
let final := 0
let probevalue := -1
ForEach item <- clothing
let probe := item["Value"]
let tempa := GetWeaponType probe
if eval (allowedweapon[tempa]) > 0 && Obj != probe ;don't try to requip same weapon.
let ObjCurHP := -1
Player.Equipitem2NS probe
let ObjCurHP := Player.GetEquippedCurrentHealth WeaponSlot
Player.UnequipitemNS probe
If (probevalue <= GetFullGoldValue probe) && ObjCurHP > 0 ;find highest value weapon of right type
let probevalue := GetFullGoldValue probe
let final := probe
endif
endif
loop
if final > 0
player.EquipItem2NS final
if alert == 1
Tapkey rdyWpn ;this draws the new weapon if the previous one was drawn
endif
Return
endif
endif
endif
end