enderalse/scripts/source/_00e_armorsetscript.psc

120 lines
3.2 KiB
Plaintext
Raw Normal View History

Scriptname _00E_ArmorSetScript extends ObjectReference
;=====================================================================================
; EVENTS
;=====================================================================================
Event OnEquipped(Actor akActor)
2021-10-05 22:22:24 +00:00
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
2021-10-05 22:22:24 +00:00
UpdateSpells()
EndEvent
Event OnUnequipped(Actor akActor)
2021-10-05 22:22:24 +00:00
if akActor != PlayerREF
return
EndIf
2021-10-05 22:22:24 +00:00
UpdateSpells()
EndEvent
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
2021-10-05 22:22:24 +00:00
if akNewContainer != PlayerREF
return
EndIf
2021-10-05 22:22:24 +00:00
; 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
;=====================================================================================
2021-10-05 22:22:24 +00:00
Function UpdateSpells()
If Levelsystem == None
Levelsystem = Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") As _00E_Questfunctions
EndIf
2021-10-05 22:22:24 +00:00
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
2021-10-05 22:22:24 +00:00
;=====================================================================================
; 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.}
2021-10-05 22:22:24 +00:00
Actor Property PlayerREF Auto