2021-10-05 22:15:58 +00:00
|
|
|
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
|
2024-01-05 20:06:45 +00:00
|
|
|
;this event won't be sent by SKSE / SkyUI when using the Equip Mode of SkyUI to directly equip an item from another container.
|
2021-10-05 22:59:59 +00:00
|
|
|
;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
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
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()
|
2021-10-05 22:15:58 +00:00
|
|
|
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
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
EndEvent
|
|
|
|
|
|
|
|
;=====================================================================================
|
|
|
|
; FUNCTIONS
|
|
|
|
;=====================================================================================
|
|
|
|
|
2021-10-05 22:22:24 +00:00
|
|
|
Function UpdateSpells()
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2024-01-05 20:06:45 +00:00
|
|
|
Int iIndex = 0
|
2021-10-05 22:59:59 +00:00
|
|
|
Int nEquippedPieces = 0
|
|
|
|
Form[] setPieces = __Config_SetList.ToArray()
|
|
|
|
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
|
2024-01-05 20:06:45 +00:00
|
|
|
ArmorSetListener.OnArmorSetBonusAdded(nEquippedPieces >= setPieces.Length)
|
2021-10-05 22:59:59 +00:00
|
|
|
ElseIf bSpellRemoved
|
2024-01-05 20:06:45 +00:00
|
|
|
ArmorSetListener.OnArmorSetBonusRemoved()
|
2021-10-05 22:59:59 +00:00
|
|
|
EndIf
|
2021-10-05 22:22:24 +00:00
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
EndFunction
|
|
|
|
|
2021-10-05 22:22:24 +00:00
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; PROPERTIES
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Bool Property __Config_5Pieces Auto
|
|
|
|
{Does this set have five pieces? Default: False}
|
|
|
|
|
2024-01-05 20:06:45 +00:00
|
|
|
_00E_ArmorSetListener Property ArmorSetListener Auto
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
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
|