I have attached a copy of the worst offender as a "spoiler" below. This particular script unequips armor if it's broken, replaces that armor with the highest value clothing (of the right type) in inventory, and also scales the enchantments on any magic armor according to the condition (health) of that armor. All armor types are supported, and it does this for the player and all NPCs. Much of the "bulk" of the script deals with multi-slot issues (for example, if slot 2 = Upper Body is open, and slot 3 = Lower Body is broken, then slot 18 = Upper + Lower Body should be available to reequip). Thanks in advance!
Spoiler
;Script written by BFG July, 2010;You may modify this script without notifying me if this heading is not removed, and I am credited in your work!scriptName BFGEnchantedArmor00short fQuestDelayTimeshort ArmorCountershort numbereffectsshort ReEquipshort ObjCurHPfloat ObjTtlHPfloat Percentagefloat tempafloat tempbfloat tempcref Actref Objref probearray_var ArmorSlotarray_var clothingarray_var itemarray_var probevaluearray_var finalarray_var origmagnarray_var origeffectnumarray_var origeffectnumusedarray_var originitializedbegin GameModeset fQuestDelayTime to 1if GetGameLoaded if GetOBSEVersion < 18 MessageBox "BFG's Enhanced Armory requires Oblivion Script Extender (OBSE) v.18 or higher to run!", "OK" StopQuest BFGEA00 endif let ArmorSlot := ar_Construct Array let tempa := -1 While tempa < 5 let tempa := tempa + 1 let ArmorSlot[tempa] := tempa loop let ArmorSlot[6] := 13 let ArmorSlot[7] := 15 let ArmorSlot[8] := 18 let ArmorSlot[9] := 19 let ArmorSlot[10] := 20 let probevalue := ar_construct Map let final := ar_construct Map let origmagn := ar_construct StringMap let origeffectnum := ar_construct StringMap let originitialized := ar_construct StringMap endifset Act to PlayerWhile Act let ReEquip := 0 let ArmorCounter := -1 While ArmorCounter < 10 let ArmorCounter := ArmorCounter + 1 let tempa := ArmorSlot[ArmorCounter] let final[tempa] := 0 let ObjCurHP := Act.GetEquippedCurrentHealth tempa if ObjCurHP > 0 let probevalue[tempa] := 999999 ;prohibit slot change by default Continue else let Obj := (Act.GetEquippedObject tempa) if (IsArmor Obj == 0) let probevalue[tempa] := 500000 ;can only override with multislotted clothing Continue else if (CompareName "Arena" Obj) || (IsQuestItem Obj) || (GetObjectHealth Obj <= 0) || ArmorCounter == 6 || ((ArmorCounter == 0) && (GetBipedSlotMask Obj > 0)) let probevalue[tempa] := 999999 ;prohibit slot change by default Continue else let ReEquip := 1 let probevalue[tempa] := 0 ;open slot since armor was broken Act.UnequipItemNS Obj endif endif endif loop if ReEquip == 1 let ArmorCounter := 11 While ArmorCounter > 0 ;this loop sets flags on additional slots let ArmorCounter := ArmorCounter - 1 let tempa := probevalue[ArmorSlot[ArmorCounter]] if tempa >= 500000 && ArmorCounter <= 1 let probevalue[1 - ArmorCounter] := tempa ;if helm or hood is prohibited then both should be elseif tempa == 0 ;open slot if ArmorCounter == 3 && eval (probevalue[2] < 999999) let probevalue[18] := 0 ;cuirass and greaves open, 18 should be too if eval (probevalue[5] < 999999) let probevalue[19] := 0 ;feet open, 19 should be too if eval (probevalue[4] < 999999) let probevalue[20] := 0 ;hands open, 20 should be too endif endif endif if ArmorCounter >= 8 let probevalue[2] := 0 let probevalue[3] := 0 if ArmorCounter >= 9 let probevalue[5] := 0 let probevalue[18] := 0 if ArmorCounter >= 10 let probevalue[4] := 0 let probevalue[19] := 0 endif endif endif endif loop let clothing := Act.GetItems 22 ForEach item <- clothing let Obj := item["Value"] let ArmorCounter := GetEquipmentSlot Obj if ArmorCounter > 0 || GetBipedSlotMask Obj == 0 ;if ArmorCounter = 0 & GetBiped > 0, unrecognized type let tempa := probevalue[ArmorCounter] if tempa <= (GetFullGoldValue Obj) && (IsPlayable Obj) let probevalue[ArmorCounter] := GetFullGoldValue Obj let final[ArmorCounter] := Obj endif endif loop let ArmorCounter := -1 While ArmorCounter < 10 let ArmorCounter := ArmorCounter + 1 let Obj := final[ArmorSlot[ArmorCounter]] if Obj > 0 Act.EquipItem2NS Obj endif loop endif let origeffectnumused := ar_construct StringMap let numbereffects := Act.GetActiveEffectCount let tempa := -1 While tempa < numbereffects - 1 let tempa := tempa + 1 set Obj to Act.GetNthActiveEffectEnchantObject tempa if (IsArmor Obj) == 0 Continue else let ArmorCounter := Act.GetEquipmentSlot Obj let ObjCurHP := Act.GetEquippedCurrentHealth ArmorCounter let ObjTtlHP := (GetObjectHealth Obj) + 0.00001 let Percentage := ObjCurHP / ObjTtlHP let tempb := 0 let tempb := originitialized[$Act+$Obj] if tempb != 1 let originitialized[$Act+$Obj] := 1 let origeffectnum[$Act+$Obj] := 1 let origmagn[$Act+$Obj+$1] := Act.GetNthActiveEffectMagnitude tempa let tempc := tempa While tempc < numbereffects - 1 let tempc := tempc + 1 set probe to Act.GetNthActiveEffectEnchantObject tempc if Obj != probe Continue else let origeffectnum[$Act+$Obj] := origeffectnum[$Act+$Obj] + 1 let origmagn[$Act+$Obj+$origeffectnum[$Act+$Obj]] := Act.GetNthActiveEffectMagnitude tempc endif loop endif let tempc := 1 let tempc := origeffectnumused[$Act+$Obj] + 1 let origeffectnumused[$Act+$Obj] := tempc let tempb := (Percentage * 0.8 * origmagn[$Act+$Obj+$tempc]) + (0.2 * origmagn[$Act+$Obj+$tempc]) + 0.5 Act.SetNthActiveEffectMagnitude tempb tempa endif loop if Act == Player set Act to GetFirstRef 35 2 else set Act to GetNextRef endif loopend