Scriptname swordWeaponBlastLauncherScript extends ObjectReference Const

import Math
import Utility

ActorValue property AP  Auto Const

Weapon Property swordWeaponFullBurster  Auto Const
Weapon Property swordWeaponBlastLauncher  Auto Const

Ammo Property swordAmmoFullBurster  Auto Const

Sound Property swordSEPlasma01  Auto Const
Sound Property swordSEPlasma02  Auto Const

ObjectReference Property Cast Auto Const

GlobalVariable Property swordBlastFullBursterAP  Auto Const

Event OnEquipped(Actor akActor)

	akActor.UnequipItem(swordWeaponBlastLauncher,0, true)
	float ActionPoint = swordBlastFullBursterAP.getValue() as float 

	if akActor.GetValue(AP) as float >= ActionPoint 
		akActor.DamageValue(AP,ActionPoint)

		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 = akActor.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(akActor, xPos , yPos , zPos , true)
			if RandomInt(0, 1) == 0
				swordSEPlasma01.Play(akActor)  
			else
				swordSEPlasma02.Play(akActor) 
			endIf

			swordWeaponFullBurster.Fire(Cast, swordAmmoFullBurster)

			index += 1

		endWhile 

	endif

EndEvent