enderalse/source/scripts/_00e_armorsetscript.psc

116 lines
3.1 KiB
Plaintext
Raw Normal View History

Scriptname _00E_ArmorSetScript extends ObjectReference
;=====================================================================================
; EVENTS
;=====================================================================================
Event OnEquipped(Actor akActor)
2021-10-05 22:22:24 +00:00
2021-10-05 22:59:59 +00:00
If akActor == PlayerREF
;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()
2021-10-05 22:22:24 +00:00
EndIf
EndEvent
Event OnUnequipped(Actor akActor)
2021-10-05 22:22:24 +00:00
2021-10-05 22:59:59 +00:00
If akActor == PlayerREF
UpdateSpells()
EndIf
EndEvent
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
2021-10-05 22:22:24 +00:00
2021-10-05 22:59:59 +00:00
If akNewContainer == PlayerREF
; Take All, no need to check for equipped items
If UI.IsMenuOpen("ContainerMenu") == False
return
EndIf
2021-10-05 22:22:24 +00:00
2021-10-05 22:59:59 +00:00
If PlayerREF.IsEquipped(__Config_SetList)
UpdateSpells()
EndIf
EndIf
2021-10-05 22:22:24 +00:00
EndEvent
;=====================================================================================
; FUNCTIONS
;=====================================================================================
2021-10-05 22:22:24 +00:00
Function UpdateSpells()
2021-10-05 22:59:59 +00:00
Int iIndex
If Levelsystem == None
Levelsystem = Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") As _00E_Questfunctions
EndIf
2021-10-05 22:22:24 +00:00
2021-10-05 22:59:59 +00:00
Int nEquippedPieces = 0
Form[] setPieces = __Config_SetList.ToArray()
iIndex = 0
While iIndex < setPieces.Length
If PlayerREF.IsEquipped(setPieces[iIndex] as Armor)
nEquippedPieces += 1
2021-10-05 22:22:24 +00:00
EndIf
2021-10-05 22:59:59 +00:00
iIndex += 1
2021-10-05 22:22:24 +00:00
EndWhile
2021-10-05 22:59:59 +00:00
__Config_SetGlobal.SetValueInt(nEquippedPieces)
Int nBonusSpells = nEquippedPieces - 1
Bool bSpellRemoved = False
Bool bSpellAdded = False
Form[] bonusSpells = __Config_SetBonusesList.ToArray()
iIndex = 0
While iIndex < bonusSpells.Length
Spell bonusSpell = bonusSpells[iIndex] as Spell
If iIndex < nBonusSpells
If PlayerREF.HasSpell(bonusSpell) == False
PlayerREF.AddSpell(bonusSpell)
bSpellAdded = True
EndIf
Else ; iIndex >= nBonusSpells
If PlayerREF.HasSpell(bonusSpell)
PlayerREF.RemoveSpell(bonusSpell)
bSpellRemoved = True
EndIf
2021-10-05 22:22:24 +00:00
EndIf
2021-10-05 22:59:59 +00:00
iIndex += 1
EndWhile
If bSpellAdded
Levelsystem.OnArmorSetBonusAdded(nEquippedPieces >= setPieces.Length)
ElseIf bSpellRemoved
Levelsystem.OnArmorSetBonusRemoved()
EndIf
2021-10-05 22:22:24 +00:00
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