2021-10-05 22:15:58 +00:00
|
|
|
Scriptname _00E_Game_TalentControlSC extends Actor
|
|
|
|
{Controls animation behaviour for all talents}
|
|
|
|
|
|
|
|
|
|
|
|
;=====================================================================================
|
|
|
|
; FUNCTIONS
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Function RegisterForActions()
|
|
|
|
RegisterForActorAction(3)
|
|
|
|
RegisterForActorAction(4)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
; Called by the magic effect (_00E_Game_TalentCooldownSC)
|
|
|
|
Function RegisterCooldownMagicEffect(_00E_Game_TalentCooldownSC newCooldownMagicEffect)
|
|
|
|
CooldownMagicEffect = newCooldownMagicEffect
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function RefreshCooldownSpell()
|
|
|
|
; The order of operation below is probably the most race-condition-safe one (see the comment in OnUpdate)
|
|
|
|
RegisterForSingleUpdate(2)
|
|
|
|
RemoveSpell(_00E_Game_AbTalentCooldown)
|
|
|
|
_00E_Game_TalentControl_CooldownResetDesired.SetValue(1)
|
|
|
|
CooldownMagicEffect = None
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function SetTalentRecoveryTime(Shout talent, Float newRecoveryTime)
|
|
|
|
If CooldownMagicEffect
|
|
|
|
CooldownMagicEffect.SetShoutRecoveryTime(talent, newRecoveryTime)
|
|
|
|
Else
|
|
|
|
SetVoiceRecoveryTime(newRecoveryTime)
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
|
|
|
|
;=====================================================================================
|
|
|
|
; EVENTS
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Event OnInit()
|
2024-02-07 15:20:32 +00:00
|
|
|
OnPlayerLoadGame()
|
2021-10-05 22:15:58 +00:00
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnPlayerLoadGame()
|
2024-02-19 21:04:15 +00:00
|
|
|
If SKSE.GetVersion()
|
|
|
|
if self == PlayerREF
|
|
|
|
if GetState() != "RealPlayer"
|
|
|
|
GoToState("RealPlayer")
|
|
|
|
endif
|
|
|
|
RegisterForActions()
|
2024-02-26 16:39:08 +00:00
|
|
|
if CooldownMagicEffect == None || CooldownMagicEffect as String == "[_00E_Game_TalentCooldownSC <None>]"
|
|
|
|
RefreshCooldownSpell()
|
|
|
|
endif
|
2024-02-07 15:20:32 +00:00
|
|
|
endif
|
|
|
|
else
|
|
|
|
Debug.Trace("NO SKSE: individual shout cooldowns are disabled")
|
|
|
|
if GetState() != "Disabled"
|
|
|
|
GoToState("Disabled")
|
|
|
|
endif
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
State RealPlayer
|
|
|
|
|
|
|
|
Event OnUpdate()
|
|
|
|
; This OnUpdate is triggered by RegisterForUpdates in other scripts attached to the player, e.g. in _00E_EPUpdateFunctions.
|
|
|
|
; So we must be cautious here.
|
|
|
|
|
2024-02-26 16:39:08 +00:00
|
|
|
If (CooldownMagicEffect == None && _00E_Game_TalentControl_CooldownResetDesired.GetValueInt() != 0)
|
2021-10-05 22:15:58 +00:00
|
|
|
_00E_Game_TalentControl_CooldownResetDesired.SetValue(0)
|
|
|
|
AddSpell(_00E_Game_AbTalentCooldown, False)
|
|
|
|
EndIf
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnActorAction(int actionType, Actor akActor, Form source, int slot)
|
|
|
|
Shout shoutUsed = source as Shout
|
|
|
|
if(!shoutUsed)
|
|
|
|
return
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
If actionType == 3
|
|
|
|
LastShoutUsed = shoutUsed
|
|
|
|
EndIf
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnSpellCast(Form maybeSpell)
|
|
|
|
If(!LastShoutUsed)
|
|
|
|
return
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
Spell castSpell = maybeSpell as Spell
|
|
|
|
If castSpell
|
|
|
|
If (castSpell == LastShoutUsed.GetNthSpell(0) || castSpell == LastShoutUsed.GetNthSpell(1) || castSpell == LastShoutUsed.GetNthSpell(2))
|
|
|
|
LastShoutUsed = None
|
|
|
|
CooldownMagicEffect.OnShoutCast()
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
EndState
|
|
|
|
|
2024-02-07 15:20:32 +00:00
|
|
|
state Disabled
|
|
|
|
; Do nothing
|
|
|
|
endstate
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; PROPERTIES
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Actor Property PlayerREF Auto
|
|
|
|
|
|
|
|
Spell Property _00E_Game_AbTalentCooldown Auto
|
|
|
|
|
|
|
|
GlobalVariable Property _00E_Game_TalentControl_CooldownResetDesired Auto
|
|
|
|
|
|
|
|
_00E_Game_TalentCooldownSC CooldownMagicEffect = None
|
|
|
|
Shout LastShoutUsed = None
|