
#ScriptVersion[3]
#Title["S3L"]
#Text["S3L"]
#Background["./BG.txt"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/ZUNShot_Const.txt"
#include"./system/Default_Effect.Txt"


let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let bSpell=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let idle = true;
let atk = false;
let fog = 0;
let objScene=GetEnemyBossSceneObjectID();
let arr = [1,6,4,2,3,5,0];
@Initialize
{
SetBoss(false);
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),25);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),26);
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(3000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

//----------------------------------------------------
task mainTask{
	DamageRateAtFrame(100,50,120);
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,140,10,7);
	wait(90);
	TShot1;
	}
//----------------------------------------------------

task TShot1{
	let maxx = 0;
	let maxy = 0;
	while(!Obj_IsDeleted(objBoss)){
	maple(2);
	wait(60);
		let ang = rand(-4,4);
		ascent(i in -6..7){
		PlaySound("Laser2",95,0);
		Curvy(i*2.5+45,7,0);
		}
		wait(45);
		ascent(i in -6..7){
		PlaySound("Laser2",95,0);
		Curvy(i*2.5+135,7,1);
		}
		wait(45);
		ascent(i in -6..7){
		PlaySound("Laser2",95,0);
		Curvy(i*3.5+225,5,2);
		Curvy(i*3.5+315,5,3);
		}		
		wait(60);
			ascent(i in 0..30){
			PlaySound("BulletWave",100,0);
			ShotA2(GetEnemyX,GetEnemyY,0.5,i*12+angleToPlayer,0.02,4,306,0,12);
			}
		TAccel(35,5,0.1,60);
		wait(75);
	}
}

task Curvy(dir,v,type){
		let shot = CurvyLaser(GetEnemyX,GetEnemyY,v,dir,5,30,513,0);
		ObjShot_SetAutoDelete(shot,false);
		if(type==0){
		ObjMove_AddPatternB2(shot,0,NO_CHANGE,NO_CHANGE,-0.05,-0.05,-5,-5);
		}
		else if(type==1){
		ObjMove_AddPatternB2(shot,0,NO_CHANGE,NO_CHANGE,0.05,-0.05,5,-5);
		}
		else if(type==2){
		ObjMove_AddPatternB2(shot,0,NO_CHANGE,NO_CHANGE,0.05,0.05,5,5);
		}
		else if(type==3){
		ObjMove_AddPatternB2(shot,0,NO_CHANGE,NO_CHANGE,-0.05,0.05,-5,5);
		}
		wait(180);
		ObjShot_SetAutoDelete(shot,true);
}

//----------------------------------------------------

task TRender
{
	DrawBoss;
}

//----------------------------------------------------

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		EndBoss(0);
		yield;
		CloseScript(GetOwnScriptID());
	}