enderalse/source/scripts/_00e_bonespiritcontrolscript.psc

104 lines
2.7 KiB
Plaintext
Raw Permalink Normal View History

Scriptname _00E_BoneSpiritControlScript extends Quest
Event OnInit()
RegisterForSingleUpdate(3.0)
EndEvent
Event OnUpdate()
If ! bSetupDone
Setup()
EndIf
EndEvent
Function Setup()
; Can be called on demand from GetOriginalSpellDamage()
if ! SKSE.GetVersion()
return
endif
boneSpiritSpells = New Spell[12]
boneSpiritMagnitudes = New Float[12]
Actor PlayerRef = Game.GetPlayer()
Form[] spells = _00E_FS_Entropy_BoneSpiritSpells.ToArray()
Int Index = 0
Bool bPlayerHasBoneSpirits = False
While Index < spells.Length
boneSpiritSpells[Index] = spells[Index] as Spell
boneSpiritMagnitudes[Index] = boneSpiritSpells[Index].GetNthEffectMagnitude(0)
If bPlayerHasBoneSpirits == False && PlayerRef.HasSpell(boneSpiritSpells[Index])
bPlayerHasBoneSpirits = True
EndIf
Index += 1
EndWhile
; Mid-game version update
If bPlayerHasBoneSpirits
Index = 0
While Index < boneSpiritSpells.Length && boneSpiritSpells[Index]
Spell spellBoneSpirit = boneSpiritSpells[Index]
If spellBoneSpirit == _07E_FS_BoneSpirit
boneSpiritMagnitudes[Index] = 11.0
ElseIf spellBoneSpirit == _17E_FS_BoneSpirit
boneSpiritMagnitudes[Index] = 17.0
ElseIf spellBoneSpirit == _25E_FS_BoneSpirit
boneSpiritMagnitudes[Index] = 22.0
ElseIf spellBoneSpirit == _40E_FS_BoneSpirit
boneSpiritMagnitudes[Index] = 30.0
ElseIf spellBoneSpirit == _50E_FS_BoneSpirit
boneSpiritMagnitudes[Index] = 38.0
EndIf
Index += 1
EndWhile
RestoreSpellMagnitudes()
EndIf
bSetupDone = True
EndFunction
Float Function GetOriginalSpellDamage(Spell spellBoneSpirit)
If bSetupDone == False
Setup()
EndIf
Int Index = 0
While Index < boneSpiritSpells.Length && boneSpiritSpells[Index] && boneSpiritSpells[Index] != spellBoneSpirit
Index += 1
EndWhile
If Index >= boneSpiritSpells.Length
Debug.Trace(self + ", RegisterSpell: ERROR - out of free slots for spells")
Return spellBoneSpirit.GetNthEffectMagnitude(0)
EndIf
If boneSpiritSpells[Index] == None
boneSpiritSpells[Index] = spellBoneSpirit
boneSpiritMagnitudes[Index] = spellBoneSpirit.GetNthEffectMagnitude(0)
EndIf
Return boneSpiritMagnitudes[Index]
EndFunction
Function RestoreSpellMagnitudes()
Int Index = 0
While Index < boneSpiritSpells.Length && boneSpiritSpells[Index]
boneSpiritSpells[Index].SetNthEffectMagnitude(0, boneSpiritMagnitudes[Index])
Index += 1
EndWhile
EndFunction
Spell[] boneSpiritSpells
Float[] boneSpiritMagnitudes
Bool bSetupDone
Formlist Property _00E_FS_Entropy_BoneSpiritSpells Auto
Spell Property _07E_FS_BoneSpirit Auto
Spell Property _17E_FS_BoneSpirit Auto
Spell Property _25E_FS_BoneSpirit Auto
Spell Property _40E_FS_BoneSpirit Auto
Spell Property _50E_FS_BoneSpirit Auto