Scriptname BskAbilityBerserkStylishScript extends activemagiceffect  

import Utility

Int index

Spell Property BskSpellSlashHit  auto

Spell Property BskSpellDimensionBlade01  auto
Spell Property BskSpellDimensionBlade02  auto
Spell Property BskSpellDimensionBlade03  auto
Spell Property BskSpellDimensionBlade04  auto
Spell Property BskSpellDimensionBlade05  auto

VisualEffect Property BskVisualSlashFWD  Auto
VisualEffect Property BskVisualSlashLeft  Auto
VisualEffect Property BskVisualSlashRight  Auto
VisualEffect Property BskVisualSlashBWD  Auto
VisualEffect Property BskVisualSlashStand  Auto

Sound Property BskFXSlash01  Auto
Sound Property BskFXSlash02  Auto
Sound Property BskFXSlash03  Auto

Event OnEffectStart(Actor Target, Actor Caster)

	registerForAnimationEvent(Caster, "AttackPowerStanding_FXstart")
	registerForAnimationEvent(Caster, "AttackPowerRight_FXstart")
	registerForAnimationEvent(Caster, "AttackPowerLeft_FXstart")
	registerForAnimationEvent(Caster, "AttackPowerBackward_FXstart")
	registerForAnimationEvent(Caster, "AttackPowerForward_FXstart")

EndEvent

Event OnEffectFinish(Actor Target, Actor Caster)

	UnregisterForAnimationEvent(Caster, "AttackPowerStanding_FXstart")
	UnregisterForAnimationEvent(Caster, "AttackPowerRight_FXstart")
	UnregisterForAnimationEvent(Caster, "AttackPowerLeft_FXstart")
	UnregisterForAnimationEvent(Caster, "AttackPowerBackward_FXstart")
	UnregisterForAnimationEvent(Caster, "AttackPowerForward_FXstart")

EndEvent

Event OnAnimationEvent(ObjectReference akSource, String asEventName)

	if asEventName == "AttackPowerForward_FXstart"

		BskVisualSlashFWD.play(akSource,0.4)
		BskSpellDimensionBlade01.cast(akSource)
		BskFX(akSource)
		BskSpellSlashHit.cast(akSource)
		
;		wait(0.1)

;		BskFX(akSource)
;		BskSpellSlashHit.cast(akSource)
	
	elseif asEventName == "AttackPowerLeft_FXstart"

		BskVisualSlashLeft.play(akSource,0.4)
		BskSpellDimensionBlade02.cast(akSource)
		BskFX(akSource)
		BskSpellSlashHit.cast(akSource)
		
;		wait(0.1)

;		BskFX(akSource)
;		BskSpellSlashHit.cast(akSource)
		
	elseif asEventName == "AttackPowerRight_FXstart"

		BskVisualSlashRight.play(akSource,0.4)
		BskSpellDimensionBlade03.cast(akSource)
		BskFX(akSource)
		BskSpellSlashHit.cast(akSource)
		
;		wait(0.1)

;		BskFX(akSource)
;		BskSpellSlashHit.cast(akSource)

	elseif asEventName == "AttackPowerBackward_FXstart"

		BskVisualSlashBWD.play(akSource,0.4)
		BskSpellDimensionBlade04.cast(akSource)
		BskFX(akSource)
		BskSpellSlashHit.cast(akSource)
		
;		wait(0.1)

;		BskFX(akSource)
;		BskSpellSlashHit.cast(akSource)

	elseif asEventName == "AttackPowerStanding_FXstart" 

		BskVisualSlashStand.play(akSource,0.4)
		BskSpellDimensionBlade05.cast(akSource)
		BskFX(akSource)
		BskSpellSlashHit.cast(akSource)
		
;		wait(0.1)

;		BskFX(akSource)
;		BskSpellSlashHit.cast(akSource)
		
	endif
		
endEVENT

Function BskFX(ObjectReference akActor)

		index = RandomInt(1,3)

		if index == 1
			BskFXSlash01.play(akActor)  
		elseif index == 2
			BskFXSlash02.play(akActor)
		else
			BskFXSlash03.play(akActor)
		endif

endFunction
