
#include "./default_system/AllStarShot_Const.txt"
#include"./functions.txt"
#include "./cutin.txt"
@Initialize {
	// define a boss in bossObj and register it
	bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(bossObj);
	// move boss to desired x y location at desired speed
	ObjMove_SetDestAtSpeed(bossObj, 192,100,6);
	mainTask;	// run mainTask
	
} 

@Event { 
	// setting the boss timer and life
	alternative(GetEventType()) 
	case(EV_REQUEST_LIFE) { 
		SetScriptResult(2500);
	}
	case(EV_REQUEST_TIMER) { 
		SetScriptResult(46);
	}
} 

@MainLoop {
	bossX = ObjMove_GetX(bossObj);
	bossY = ObjMove_GetY(bossObj);
	
	// collision for the shots and player
	ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
	ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,10);
	yield;
} 

@Finalize {


} 

task mainTask { 
	RenderBoss;
	movement;
	TEnd;
	yield;
} 

//ObjMove_SetDestAtSpeed(bossObj,x,y,speed);		

task movement {
	wait(120);
	loop{
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0) {return;}
		fire;
		wait(20);
	}

}

task fire{	
        let angleT = angleToPlayer;
			SE_Play(shoot2,40);
            loop(30){
				if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0 ){return;}
                let obj = CreateShotA1(bossX, bossY, 4, angleT, rand(209,223), 12);
                angleT += 360/30;
			}
 }
 
