2021-10-05 22:15:58 +00:00
Scriptname _00E_Class_PerkScript extends ObjectReference
Import Game
;=====================================================================================
; EVENTS
;=====================================================================================
2021-10-12 02:10:35 +00:00
Event OnActivate(ObjectReference akActionRef)
If akActionRef != PlayerREF
Return
EndIf
2021-10-05 22:15:58 +00:00
2021-10-12 02:10:35 +00:00
GoToState("DoNothing")
2021-10-05 22:15:58 +00:00
2021-10-12 02:10:35 +00:00
Int iButton = __Config_DisplayMessage.Show()
2021-10-05 22:59:59 +00:00
If __Config_MultipleLevelsConfirm
2021-10-12 02:10:35 +00:00
__Config_MultipleLevels = True
2021-10-05 22:59:59 +00:00
EndIf
2021-10-12 02:10:35 +00:00
If __Config_MultipleLevels
If __Config_MultipleLevelsTwoLevels
If iButton < 2
2021-10-05 22:15:58 +00:00
TeachPerk()
2021-10-12 02:10:35 +00:00
FinalizeUnlock()
Return
EndIf
Else ; __Config_MultipleLevelsTwoLevels == False
If iButton < 3
If __Config_TeachesTalent
TeachTalent()
Else
TeachPerk()
EndIf
FinalizeUnlock()
Return
2021-10-05 22:15:58 +00:00
EndIf
2021-10-05 22:59:59 +00:00
EndIf
2021-10-12 02:10:35 +00:00
Else ; __Config_MultipleLevels == False
2021-10-05 22:59:59 +00:00
If iButton == 0
2021-10-12 02:10:35 +00:00
TeachFirstPerk()
FinalizeUnlock()
Return
2021-10-05 22:59:59 +00:00
EndIf
2021-10-05 22:15:58 +00:00
EndIf
2021-10-12 02:10:35 +00:00
GoToState("")
2021-10-05 22:15:58 +00:00
EndEvent
2021-10-12 02:10:35 +00:00
State DoNothing
Event OnActivate(ObjectReference akActionRef)
; Do nothing
EndEvent
EndState
2021-10-05 22:15:58 +00:00
;=====================================================================================
; FUNCTIONS
;=====================================================================================
Function TeachPerk()
2021-10-12 02:10:35 +00:00
If PlayerREF.HasPerk(__Config_PerkToTeach1) == False
TeachFirstPerk()
ElseIf PlayerREF.HasPerk(__Config_PerkToTeach2) == False
2021-10-05 22:15:58 +00:00
PlayerREF.AddPerk(__Config_PerkToTeach2)
2021-10-12 02:10:35 +00:00
Else
2021-10-05 22:15:58 +00:00
PlayerREF.AddPerk(__Config_PerkToTeach3)
2021-10-12 02:10:35 +00:00
EndIf
2021-10-05 22:15:58 +00:00
EndFunction
Function TeachTalent()
2021-10-12 02:10:35 +00:00
If Game.IsWordUnlocked(__Config_WordToTeach1) == False
2021-10-05 22:15:58 +00:00
PlayerREF.AddShout(__Config_TalentToTeach)
WordToTeach = __Config_WordToTeach1
2021-10-12 02:10:35 +00:00
TeachFirstPerk(False)
ElseIf Game.IsWordUnlocked(__Config_WordToTeach2) == False
2021-10-05 22:15:58 +00:00
WordToTeach = __Config_WordToTeach2
PlayerREF.AddPerk(__Config_PerkToTeach2)
2021-10-12 02:10:35 +00:00
Else
2021-10-05 22:15:58 +00:00
WordToTeach = __Config_WordToTeach3
PlayerREF.AddPerk(__Config_PerkToTeach3)
2021-10-12 02:10:35 +00:00
EndIf
2021-10-05 22:15:58 +00:00
Game.UnlockWord(WordToTeach)
Game.TeachWord(WordToTeach)
SetRecoveryTime(WordToTeach)
2021-10-12 02:10:35 +00:00
EndFunction
2021-10-05 22:15:58 +00:00
2021-10-12 02:10:35 +00:00
Function TeachFirstPerk(Bool bTeachAdditionalPerk = True)
PlayerREF.AddPerk(__Config_PerkToTeach1)
If __Config_QuestToStart
__Config_QuestToStart.Start()
EndIf
If AdditionalPerk && bTeachAdditionalPerk
PlayerREF.AddPerk(AdditionalPerk)
EndIf
If sendModEventOnUnlock
SendModEvent(modEventName)
EndIf
2021-10-05 22:15:58 +00:00
EndFunction
Function SetRecoveryTime(WordOfPower WordToTeach)
{This function handles the issue of cooldowns not depending on the value in the CK but on the duration the player presses the [Shout] key on his keyboard.}
If WordToTeach == __Config_WordToTeach2
__Config_TalentToTeach.SetNthRecoveryTime(0, fRecoveryTime02)
__Config_TalentToTeach.SetNthRecoveryTime(1, fRecoveryTime02)
ElseIf WordToTeach == __Config_WordToTeach3
__Config_TalentToTeach.SetNthRecoveryTime(0, fRecoveryTime03)
__Config_TalentToTeach.SetNthRecoveryTime(1, fRecoveryTime03)
__Config_TalentToTeach.SetNthRecoveryTime(2, fRecoveryTime03)
EndIf
EndFunction
Function PlayVisuals()
;Fix for ERB-1355, somehow _00E_TalentpointsRemaining was not filled in that save game on all perk activators
If _00E_TalentpointsRemaining == None
_00E_TalentpointsRemaining = Game.GetFormFromFile(0x000431FB, "Skyrim.esm") as Message
EndIf
2021-10-12 02:10:35 +00:00
_00E_TalentpointsRemaining.Show(TalentPoints.GetValueInt())
2021-10-05 22:15:58 +00:00
ObjectReference MemoryPoint = Self.GetLinkedRef()
2021-10-12 02:10:35 +00:00
2021-10-05 22:15:58 +00:00
MAGConjureImpact.Play(PlayerREF)
2021-10-12 02:10:35 +00:00
2021-10-05 22:15:58 +00:00
MemoryPoint.PlayAnimation("PlayAnim02")
2021-10-12 02:10:35 +00:00
PlayUnlockAnimationOnLinkedRef(MemoryPoint, TestLine)
PlayUnlockAnimationOnLinkedRef(MemoryPoint, __PerkLine01)
PlayUnlockAnimationOnLinkedRef(MemoryPoint, __PerkLine02)
PlayUnlockAnimationOnLinkedRef(MemoryPoint, __PerkLine03)
PlayUnlockAnimationOnLinkedRef(MemoryPoint, __PerkLine04)
PlayUnlockAnimationOnLinkedRef(MemoryPoint, __PerkLine05)
PlayUnlockAnimationOnLinkedRef(MemoryPoint, __PerkLine06)
GoToState("") ; Time to unlock OnActivate
2021-10-05 22:15:58 +00:00
2021-10-12 02:10:35 +00:00
Sound unlockSound = Game.GetFormFromFile(0x0003A1E7, "Skyrim.esm") as Sound
2021-10-05 22:15:58 +00:00
unlockSound.Play(PlayerREF)
2021-10-12 02:10:35 +00:00
MAGDragonPowerAbsorbManEffect.Play(PlayerREF, 8, MemoryPoint)
2021-10-05 22:15:58 +00:00
_00E_UnlockClassIMOD.Apply()
Utility.Wait(0.1)
2021-10-12 02:10:35 +00:00
_00E_Class_MemoryAbsorbFXS.Play(PlayerREF)
2021-10-05 22:15:58 +00:00
Utility.Wait(3)
2021-10-12 02:10:35 +00:00
_00E_Class_MemoryAbsorbFXS.Stop(PlayerREF)
2021-10-05 22:15:58 +00:00
Utility.Wait(2)
MAGDragonPowerAbsorbManEffect.Stop(PlayerREF)
2021-10-12 02:10:35 +00:00
EndFunction
Function PlayUnlockAnimationOnLinkedRef(ObjectReference MemoryPoint, Keyword linkedKwd)
ObjectReference ref = MemoryPoint.GetLinkedRef(linkedKwd)
If ref
ref.PlayAnimation("Unlock")
EndIf
EndFunction
2021-10-05 22:15:58 +00:00
2021-10-12 02:10:35 +00:00
Function FinalizeUnlock()
TalentPoints.Mod(-1)
PlayerREF.SetAV("dragonsouls", TalentPoints.GetValueInt())
PlayVisuals()
2021-10-05 22:15:58 +00:00
EndFunction
;=====================================================================================
; PROPERTIES
;=====================================================================================
bool Property __Config_bValue01 = False Auto
{Whether the talent this perk teaches needs one value (for example, magnitude). Usually true.}
bool Property __Config_bValue02 = False Auto
{Whether the talent this perk teaches needs a second value (for example, duration).}
bool Property __Config_bValue03 = False Auto
{Whether the talent this perk teaches needs third value (for example, distance).}
bool Property sendModEventOnUnlock = False Auto
String Property modEventName = "" Auto
bool Property __Config_MultipleLevels Auto
{Does this perk have multiple levels to teach? ALWAYS true for Talents! Max: 3}
bool Property __Config_MultipleLevelsTwoLevels Auto
{Does this multiple level perk only have two two ranks?}
bool Property __Config_TeachesTalent Auto
{Does this perk/memory teach a talent?}
float Property fRecoveryTime02 Auto
{Set this to the cooldown of the second talent.}
float Property fRecoveryTime03 Auto
{Set this to the cooldown of the third talent.}
Message Property __Config_DisplayMessage Auto
{The corresponding MessageBox to display when this perk is selected}
Perk Property __Config_PerkToTeach1 Auto
{Perk/First rank perk this memory teaches. Always fill!}
Perk Property __Config_PerkToTeach2 Auto
{Second rank of the perk this memory star teaches}
Perk Property __Config_PerkToTeach3 Auto
{Third rank of the perk this memory star teaches}
Perk Property AdditionalPerk Auto
Shout Property __Config_TalentToTeach Auto
{Talent this perk teaches. Leave empty if this perk doesn't teach a talent.}
Quest Property __Config_QuestToStart = None Auto
{When the first perk is added to the player, this quest is started, too}
WordOfPower Property __Config_WordToTeach1 Auto
{1st level of Talent this perk/memory teaches. Leave empty if this perk doesn't teach a talent.}
WordOfPower Property __Config_WordToTeach2 Auto
{2nd level of Talent this perk/memory teaches. Leave empty if this perk doesn't teach a talent.}
WordOfPower Property __Config_WordToTeach3 Auto
{3rd of Talent this perk/memory teaches. Leave empty if this perk doesn't teach a talent.}
WordOfPower Property WordToTeach Auto Hidden
Keyword Property TestLine Auto
Keyword Property __PerkLine01 Auto
Keyword Property __PerkLine02 Auto
Keyword Property __PerkLine03 Auto
Keyword Property __PerkLine04 Auto
Keyword Property __PerkLine05 Auto
Keyword Property __PerkLine06 Auto
Message Property _00E_TalentpointsRemaining Auto
GlobalVariable Property TalentPoints Auto
VisualEffect Property MAGDragonPowerAbsorbManEffect Auto
EffectShader Property _00E_Class_MemoryAbsorbFXS Auto
ImagespaceModifier Property _00E_UnlockClassIMOD Auto
Sound Property MAGConjureImpact Auto
Actor Property PlayerREF Auto
bool Property __Config_MultipleLevelsConfirm Auto