Enderal SE https://mod.pub/enderal-se/38-enderal-se
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.1 KiB
116 lines
3.1 KiB
3 years ago
|
Scriptname _00E_ArmorSetScript extends ObjectReference
|
||
|
|
||
|
;=====================================================================================
|
||
|
; EVENTS
|
||
|
;=====================================================================================
|
||
|
|
||
|
Event OnEquipped(Actor akActor)
|
||
3 years ago
|
|
||
3 years ago
|
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()
|
||
3 years ago
|
EndIf
|
||
|
|
||
3 years ago
|
EndEvent
|
||
|
|
||
|
Event OnUnequipped(Actor akActor)
|
||
3 years ago
|
|
||
3 years ago
|
If akActor == PlayerREF
|
||
|
UpdateSpells()
|
||
3 years ago
|
EndIf
|
||
|
|
||
|
EndEvent
|
||
|
|
||
|
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
|
||
3 years ago
|
|
||
3 years ago
|
If akNewContainer == PlayerREF
|
||
|
; Take All, no need to check for equipped items
|
||
|
If UI.IsMenuOpen("ContainerMenu") == False
|
||
|
return
|
||
|
EndIf
|
||
3 years ago
|
|
||
3 years ago
|
If PlayerREF.IsEquipped(__Config_SetList)
|
||
|
UpdateSpells()
|
||
|
EndIf
|
||
|
EndIf
|
||
3 years ago
|
|
||
3 years ago
|
EndEvent
|
||
|
|
||
|
;=====================================================================================
|
||
|
; FUNCTIONS
|
||
|
;=====================================================================================
|
||
|
|
||
3 years ago
|
Function UpdateSpells()
|
||
3 years ago
|
|
||
3 years ago
|
Int iIndex
|
||
|
|
||
3 years ago
|
If Levelsystem == None
|
||
|
Levelsystem = Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") As _00E_Questfunctions
|
||
|
EndIf
|
||
3 years ago
|
|
||
3 years ago
|
Int nEquippedPieces = 0
|
||
|
Form[] setPieces = __Config_SetList.ToArray()
|
||
|
iIndex = 0
|
||
|
While iIndex < setPieces.Length
|
||
|
If PlayerREF.IsEquipped(setPieces[iIndex] as Armor)
|
||
|
nEquippedPieces += 1
|
||
3 years ago
|
EndIf
|
||
|
|
||
3 years ago
|
iIndex += 1
|
||
3 years ago
|
EndWhile
|
||
|
|
||
3 years ago
|
__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
|
||
3 years ago
|
EndIf
|
||
3 years ago
|
|
||
|
iIndex += 1
|
||
|
EndWhile
|
||
|
|
||
|
If bSpellAdded
|
||
|
Levelsystem.OnArmorSetBonusAdded(nEquippedPieces >= setPieces.Length)
|
||
|
ElseIf bSpellRemoved
|
||
|
Levelsystem.OnArmorSetBonusRemoved()
|
||
|
EndIf
|
||
3 years ago
|
|
||
3 years ago
|
EndFunction
|
||
|
|
||
3 years ago
|
|
||
3 years ago
|
;=====================================================================================
|
||
|
; 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.}
|
||
|
|
||
3 years ago
|
Actor Property PlayerREF Auto
|