Scriptname _00E_ArmorSetScript extends ObjectReference ;===================================================================================== ; EVENTS ;===================================================================================== Event OnEquipped(Actor akActor) if akActor != PlayerREF return EndIf ;this event won't be sent by SKSE / SkyUI when using he Equip Mode of SkyUI to directly equip an item from another container. ;the same goes for the OnObjectEquipped event, hence we need the work around in OnContainerChanged UpdateSpells() EndEvent Event OnUnequipped(Actor akActor) if akActor != PlayerREF return EndIf UpdateSpells() EndEvent Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akNewContainer != PlayerREF return EndIf ; Take All, no need to check for equipped items if UI.IsMenuOpen("ContainerMenu") == False return endif If PlayerREF.IsEquipped(__Config_SetList) UpdateSpells() endif EndEvent ;===================================================================================== ; FUNCTIONS ;===================================================================================== Function UpdateSpells() If Levelsystem == None Levelsystem = Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") As _00E_Questfunctions EndIf Int iIndex = __Config_SetList.GetSize() Int iAmountEquippedPieces = 0 While iIndex > 0 iIndex -= 1 Armor aArmorPiece = __Config_SetList.GetAt(iIndex) as Armor If PlayerREF.IsEquipped(aArmorPiece) iAmountEquippedPieces += 1 EndIf EndWhile __Config_SetGlobal.SetValueInt(iAmountEquippedPieces) Int iSpellIndex = iAmountEquippedPieces - 2 Bool bSpellRemoved = false Bool bSpellAdded = false iIndex = __Config_SetBonusesList.GetSize() While iIndex > 0 iIndex -= 1 Spell BonusSpell = __Config_SetBonusesList.GetAt(iIndex) as Spell if iIndex > iSpellIndex if PlayerREF.HasSpell(BonusSpell) PlayerREF.RemoveSpell(BonusSpell) bSpellRemoved = true endif elseif PlayerREF.HasSpell(BonusSpell) == false PlayerREF.AddSpell(BonusSpell) bSpellAdded = true endif EndWhile if bSpellAdded (Levelsystem.MAGIllusionCharm as Sound).Play(PlayerREF) If iAmountEquippedPieces == __Config_SetBonusesList.GetSize() + 1 Levelsystem.ArmorSetUnlockAchievement() EndIf elseif bSpellRemoved (Levelsystem._00E_ArmorSetScript_sSetBonusRemoved as Message).Show() endif EndFunction ;===================================================================================== ; PROPERTIES ;===================================================================================== Bool Property __Config_5Pieces Auto {Does this set have five pieces? Default: False} _00E_Questfunctions Property Levelsystem Auto GlobalVariable Property __Config_SetGlobal Auto {The global associated with this set. Example _25E_HSet_FallenOneGlobal.} Formlist Property __Config_SetBonusesList Auto {The formlist containing the spell bonuses of the set.} Formlist Property __Config_SetList Auto {The formlist containing the set pieces.} Actor Property PlayerREF Auto