Scriptname _00E_A2_SkyfallPlayerSC extends activemagiceffect  

; Script that controls the selection mode

Import _00E_TalentLibrary
Import Utility

;=====================================================================================
;              							EVENTS & STATES                 					 
;=====================================================================================

Event OnEffectStart(Actor akTarget, Actor akCaster)

	AdjustDamage()
	
	Utility.Wait(0.11)
	MAGRestorationBaneOfTheDeadExplosion2DM.Play(akCaster)
	MAGShockExpMassImod.Apply()
	Game.ShakeCamera(afStrength = 0.5)
	akCaster.PlaceAtMe(_00E_A2_SkyfallNovaExplosion)
	akCaster.PlaceAtMe(ExplosionShockMassNoEffects)
	akCaster.KnockAreaEffect(1, 512)

	if akCaster.HasSpell(_00E_A2_EyeOfTheStormSP) || akCaster.HasSpell(_00E_A2_EyeOfTheStormAb)
	
		akCaster.PlaceAtMe(_00E_A2_SynergyRiftImplosion)
		
		if _00E_Synergy_EyeOfTheStormSkyfall.GetValueInt() == 0
			_00E_Synergy_EyeOfTheStormSkyfall.SetValueInt(1)
			_00E_PlayerFunctions.GetSkillControl().ShowSynergyMessage()
		EndIf
		
	EndIf
	
	_00E_A2_ChaosruneImplosionSoundM.Play(akCaster)
	
EndEvent

;=====================================================================================
;              							FUNCTIONS                  					 
;=====================================================================================

Function AdjustDamage()

	int iIndex = GetPlayerTalentLevel(_00E_Class_Elementalist_P09b_Talent_Skyfall, _00E_Class_Elementalist_P09b_Talent_Skyfall2, _00E_Class_Elementalist_P09b_Talent_Skyfall3)

	float fNovaDamage = _00E_A2_SkyfallSP.GetNthEffectMagnitude(iIndex + 3)
	float fLightningDamage = _00E_A2_SkyfallSP.GetNthEffectMagnitude(iIndex)
	
	_00E_A2_SkyfallNovaEnch.SetNthEffectMagnitude(0, fNovaDamage)
	_00E_A2_SkyfallBoltSP.SetNthEffectMagnitude(0, fLightningDamage)

EndFunction

;=====================================================================================
;              							PROPERTIES                  					 
;=====================================================================================

GlobalVariable Property _00E_Synergy_EyeOfTheStormSkyfall Auto

ImageSpaceModifier Property MAGShockExpMassImod Auto

Explosion Property _00E_A2_SkyfallNovaExplosion Auto
Explosion Property _00E_A2_SynergyRiftImplosion Auto
Explosion Property ExplosionShockMassNoEffects Auto

Enchantment Property _00E_A2_SkyfallNovaEnch Auto

Sound Property MAGRestorationBaneOfTheDeadExplosion2DM Auto
Sound Property _00E_A2_ChaosruneImplosionSoundM Auto

Perk Property _00E_Class_Elementalist_P09b_Talent_Skyfall3 Auto
Perk Property _00E_Class_Elementalist_P09b_Talent_Skyfall2 Auto
Perk Property _00E_Class_Elementalist_P09b_Talent_Skyfall Auto

Spell Property _00E_A2_EyeOfTheStormSP Auto
Spell Property _00E_A2_EyeOfTheStormAb Auto
Spell Property _00E_A2_SkyfallBoltSP Auto
Spell Property _00E_A2_SkyfallSP Auto