Scriptname swordMagicCoreScript extends activemagiceffect

import Math
import Utility

Weapon Property swordWeaponFullBurster  Auto Const

Ammo Property swordAmmoFullBurster  Auto Const

;Idle Property swordIdleBlast01 Auto Const
;Idle Property swordIdleBlast02 Auto Const

Sound Property swordSEPlasma01  Auto Const
Sound Property swordSEPlasma02  Auto Const

ObjectReference Property Cast Auto Const

Event OnEffectStart(Actor akTarget, Actor akCaster)

	float ftimeStart = GetCurrentRealTime()
	float ftimeEnd = 0.0

	float xMove
	float yMove
	float rXMove
	float rYMove

	; initial position vector
	float xPos
	float yPos
	float zPos

	float zAng  
;	ObjectReference Cast

;	if !IsInMenuMode() 
;		akCaster.PlayIdle(swordIdleBlast01)
;	endif

;	While ftimeEnd - ftimeStart < 1.0
;		ftimeEnd = GetCurrentRealTime()
;	endWhile 
	
	int index = 1

	While index <=4

		if index == 1
			xMove = 100
			zPos = 45
		elseif index == 2
			xMove = -100
			zPos = 45
		elseif index == 3
			xMove = 100
			zPos = 160
		else
			xMove = -100
			zPos = 160
		endif
		yMove = 0

		zAng = akCaster.getAngleZ()

		rXMove = (math.Sin(zAng) * yMove)+(math.Cos(zAng) * xMove)
		rYMove = (math.Cos(zAng) * yMove)-(math.Sin(zAng) * xMove)

		xPos = rXMove
		yPos = rYMove

		Cast .moveTo(akCaster, xPos , yPos , zPos , true)
		if RandomInt(0, 1) == 0
			swordSEPlasma01.Play(akCaster)  
		else
			swordSEPlasma02.Play(akCaster) 
		endIf
		swordWeaponFullBurster.Fire(Cast, swordAmmoFullBurster)

		index += 1

	endWhile 

EndEvent
