Scriptname _00E_A2_BladedanceMonitorAbility extends activemagiceffect  

 import debug
import _00E_TalentLibrary
 
;=====================================================================================
;              							EVENTS                  					 
;=====================================================================================


Event OnEffectStart(Actor akTarget, Actor akCaster)
Victim = akTarget
EndEvent


Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \
  bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

if (akAggressor == PlayerREF) && Counter < __Config_RequiredHits
	Counter = _00E_A2_BladeDanceCounter.GetValueInt()
	Counter = Counter + 1
	_00E_A2_BladeDanceCounter.SetValueInt(Counter)
	Notification(Counter)
elseif Counter == __Config_RequiredHits
	_00E_A2_BladeDanceCounter.SetValue(0)
	Counter = 0
	DealALotOfDamage()
	Game.GetPlayer().DispelSpell(_00E_A2_BladedanceCloakSpell)
	Victim.RemoveSpell(_00E_A2_BladedanceHitAbility)
endif


EndEvent

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

Function DealALotOfDamage()

	PowerLevel = GetTalentLevel(_00E_A2_BladedanceWord01, _00E_A2_BladedanceWord02, _00E_A2_BladedanceWord03)
	
	if PowerLevel == 1
		DamageSpell = _00E_A2_BladeDanceDamage_L01
	ElseIf PowerLevel == 2
		DamageSpell = _00E_A2_BladeDanceDamage_L02
	ElseIf PowerLevel == 3
		DamageSpell = _00E_A2_BladeDanceDamage_L03
	EndIf
	
	DamageSpell.RemoteCast(Victim, PlayerREF, Victim)
	_00E_A2_BladeDance_FinalBoom.Play(PlayerREF)
	Game.ShakeCamera(afStrength = 0.4)

EndFunction


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

int Counter 
int Property __Config_RequiredHits = 5 Auto
{How many hits have to be landed before the damage effect kicks in? Default: 5}
int PowerLevel 

Actor Victim
Spell DamageSpell

GlobalVariable Property _00E_A2_BladeDanceCounter Auto

Explosion Property _00E_BladeDanceExplosion Auto

WordOfPower Property _00E_A2_BladedanceWord01 Auto
WordOfPower Property _00E_A2_BladedanceWord02 Auto
WordOfPower Property _00E_A2_BladedanceWord03 Auto
 


Sound Property _00E_A2_BladeDance_FinalBoom Auto

Actor Caster
Actor Property PlayerREF Auto

Spell Property _00E_A2_BladedanceHitAbility Auto
Spell Property _00E_A2_BladeDanceDamage_L01 Auto
Spell Property _00E_A2_BladeDanceDamage_L02 Auto
Spell Property _00E_A2_BladeDanceDamage_L03 Auto
Spell Property _00E_A2_BladedanceCloakSpell Auto