Scriptname ARMDEG_CastingSpellScript extends activemagiceffectFormList Property ArmDegList0 autoFormList Property ArmDegList1 autoFormList Property ArmDegList2 autoFormList Property ArmDegList3 autoFormList Property ArmDegList4 autoFormList Property ArmDegList5 autoFormList Property ArmDegList6 autoFormList Property ArmDegList7 autoFormList Property ArmDegList8 autoFormList Property ArmDegList9 autoevent OnEffectStart(Actor C, Actor T)Degrade(C)endEventfunction Degrade(Actor T)ObjectReference ArmorInQuestion = PickSlot(T)if (ArmorInQuestion) Debug.Notification("ArmorInQuestion Exists") if ArmDegList1.HasForm(ArmorInQuestion) ArmDegList0.addForm(ArmorInQuestion) ArmDegList1.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList2.HasForm(ArmorInQuestion) ArmDegList1.addForm(ArmorInQuestion) ArmDegList2.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList3.HasForm(ArmorInQuestion) ArmDegList2.addForm(ArmorInQuestion) ArmDegList3.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList4.HasForm(ArmorInQuestion) ArmDegList3.addForm(ArmorInQuestion) ArmDegList4.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList5.HasForm(ArmorInQuestion) ArmDegList4.addForm(ArmorInQuestion) ArmDegList5.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList6.HasForm(ArmorInQuestion) ArmDegList5.addForm(ArmorInQuestion) ArmDegList6.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList7.HasForm(ArmorInQuestion) ArmDegList6.addForm(ArmorInQuestion) ArmDegList7.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList8.HasForm(ArmorInQuestion) ArmDegList7.addForm(ArmorInQuestion) ArmDegList8.RemoveAddedForm(ArmorInQuestion) elseIf ArmDegList9.HasForm(ArmorInQuestion) ArmDegList8.addForm(ArmorInQuestion) ArmDegList9.RemoveAddedForm(ArmorInQuestion) else ArmDegList9.addForm(ArmorInQuestion) endIfDebug.Notification("A piece of armor has degraded.")endIf endFunctionObjectReference Function PickSlot(Actor T)int SlotNum = Utility.RandomInt(1,5)Debug.Notification("SlotNum = " +SlotNum)if SlotNum==1;Cuirassif ((T.GetWornForm(0x00000004) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000004) as Armor).IsLightArmor()) return T.GetWornForm(0x00000004) as ObjectReferenceelse return NONEendIfelseIf SlotNum==2;GauntletsIf T.GetWornForm(0x00000010) as ObjectReference && ((T.GetWornForm(0x00000010) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000010) as Armor).IsLightArmor()) return T.GetWornForm(0x00000010) as ObjectReferenceelseIf T.GetWornForm(0x00000018) as ObjectReference && ((T.GetWornForm(0x00000018) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000018) as Armor).IsLightArmor()) return T.GetWornForm(0x00000018) as ObjectReferenceelseIf T.GetWornForm(0x00000008) as ObjectReference && ((T.GetWornForm(0x00000008) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000008) as Armor).IsLightArmor()) return T.GetWornForm(0x00000008) as ObjectReferenceelse return NONEendIfelseIf SlotNum==3;shieldreturn T.GetWornForm(0x00000200) as ObjectReferenceelseIf SlotNum==4;helmetIf T.GetWornForm(0x00000001) as ObjectReference && ((T.GetWornForm(0x00000001) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000001) as Armor).IsLightArmor()) return T.GetWornForm(0x00000001) as ObjectReferenceelseIf T.GetWornForm(0x00000002) as ObjectReference && ((T.GetWornForm(0x00000002) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000002) as Armor).IsLightArmor()) return T.GetWornForm(0x00000002) as ObjectReferenceelseIf T.GetWornForm(0x00000003) as ObjectReference && ((T.GetWornForm(0x00000003) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000003) as Armor).IsLightArmor()) return T.GetWornForm(0x00000003) as ObjectReferenceelse return NONEendIfelseIf SlotNum==5; bootsIf T.GetWornForm(0x00000080) as ObjectReference && ((T.GetWornForm(0x00000080) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000080) as Armor).IsLightArmor()) return T.GetWornForm(0x00000080) as ObjectReferenceelseIf T.GetWornForm(0x00000100) as ObjectReference && ((T.GetWornForm(0x00000100) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000100) as Armor).IsLightArmor()) return T.GetWornForm(0x00000100) as ObjectReferenceelseIf T.GetWornForm(0x00000180) as ObjectReference && ((T.GetWornForm(0x00000180) as Armor).IsHeavyArmor()||(T.GetWornForm(0x00000180) as Armor).IsLightArmor()) return T.GetWornForm(0x00000180) as ObjectReferenceelse return NONEendIfendIfendFunction
This spell is autocast every time you are hit by the way (I will eventually make it 3-5% of the time) and the debug notifications are going off, until the one that says "ArmorInQuestion Exists". So, I guess I'm getting NONE returned from PickSlot().
Is this because I can't cast GetWornForm()s as ObjectReferences or something? Because I don't get any errors like that...
Supplementary question:
If I get this working, will it effect (for example) EVERY IronCuirass if my IronCuirass I have equipped gets damaged? Because that would be unfortunate.
EDIT: Yep, doing a find replace of the word ObjectReference with Form makes it work perfectly, but apply to every instance of the armor. Time for an alias workaround.
EDIT2: DARNIT! I can't do an alias workaround, as doing so would demand putting the equipped object into an alias, and I can't ForceRefTo, as if it isn't persistent there is nothing to force it to.