script_enemy_main
{
	let frame=-100;
	let obj;
	let objb;
	#include_function ".\spellcard.txt";
    #include_function ".\..\lib\enemyfunctions.txt"
	#include_function ".\boss1anim.txt";
	
task attack{
	Concentration01(100);
	PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
	loop(100){yield;}
	trapper; PlaySE(GetCurrentScriptDirectory~"sound\Laser1.wav");
	loop(130){yield;}
	lasers;
	loop(200){yield;}
	explo;
}

task explo{
	let ang=rand(0, 359);
	loop{
		PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
		ang=rand(0, 359);
		if(GetCommonData("DIFFICULTY")=="EASY"){
			ascent(i in 0..10){
				CreateShotA(1, GetX+40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*36, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, 1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, 0.125, 0, 0, 17);
				FireShot(1);
				CreateShotA(1, GetX-40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*36, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, -1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, -0.125, 0, 0, 17);
				FireShot(1);
			}
		}
		if(GetCommonData("DIFFICULTY")=="NORMAL"){
			ascent(i in 0..15){
				CreateShotA(1, GetX+40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*24, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, 1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, 0.125, 0, 0, 17);
				FireShot(1);
				CreateShotA(1, GetX-40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*24, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, -1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, -0.125, 0, 0, 17);
				FireShot(1);
			}
		}
		if(GetCommonData("DIFFICULTY")=="HARD"){
			ascent(i in 0..24){
				CreateShotA(1, GetX+40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*15, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, 1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, 0.125, 0, 0, 17);
				FireShot(1);
				CreateShotA(1, GetX-40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*15, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, -1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, -0.125, 0, 0, 17);
				FireShot(1);
			}
		}
		if(GetCommonData("DIFFICULTY")=="LUNATIC"){
			ascent(i in 0..30){
				CreateShotA(1, GetX+40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*12, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, 1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, 0.125, 0, 0, 17);
				FireShot(1);
				CreateShotA(1, GetX-40, GetY+50, 5);
				SetShotDataA(1, 0, 2, ang+i*12, 0, 0, 0, 17);
				SetShotDataA(1, 20, 0, NULL, -1, 0, 0, 17);
				SetShotDataA(1, 30, 2, NULL, -0.125, 0, 0, 17);
				FireShot(1);
			}
		}
		loop(60){yield;}
	}
}

task lasers{
	loop{
		PlaySE(GetCurrentScriptDirectory~"sound\Laser4.wav");
		CreateLaserC(1, GetX, GetY, 5, 10, 231, 10);
		SetLaserDataC(1, 0, 4, GetAngleToPlayer+rand(-15, 15), 0, 0, 0);
		FireShot(1);
		if(GetCommonData("DIFFICULTY")=="EASY"){
			loop(20){yield;}
		}
		if(GetCommonData("DIFFICULTY")=="NORMAL"){
			loop(15){yield;}
		}
		if(GetCommonData("DIFFICULTY")=="HARD"){
			loop(10){yield;}
		}
		if(GetCommonData("DIFFICULTY")=="LUNATIC"){
			loop(5){yield;}
		}
	}
}

task trapper{
	let ang=135;
	let dist=0;
	let distb=0;
	let counter=30;
	obj=Obj_Create(OBJ_LASER);
	objb=Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj, GetX+40, GetY+50);
	Obj_SetPosition(objb, GetX-40, GetY+50);
	Obj_SetAngle(obj, -45);
	Obj_SetAngle(objb, 225);
	ObjShot_SetGraphic(obj, 229);
	ObjShot_SetGraphic(objb, 229);
	ObjShot_SetDelay(obj, 30);
	ObjShot_SetDelay(objb, 30);
	ObjLaser_SetLength(obj, 600);
	ObjLaser_SetLength(objb, 600);
	ObjLaser_SetWidth(obj, 25);
	ObjLaser_SetWidth(objb, 25);
	while(Obj_BeDeleted(obj)==false){
		counter--;
		if(counter<=0){
			if(ang>5){ang-=2;}
			dist=Obj_GetAngle(obj)-GetAngleToPlayer+ang;
			distb=Obj_GetAngle(objb)-GetAngleToPlayer-ang;
			if(dist>2){Obj_SetAngle(obj, Obj_GetAngle(obj)-2);}
			if(dist<-2){Obj_SetAngle(obj, Obj_GetAngle(obj)+2);}
			if(distb>2){Obj_SetAngle(objb, Obj_GetAngle(objb)-2);}
			if(distb<-2){Obj_SetAngle(objb, Obj_GetAngle(objb)+2);}
			if(dist<=2 && dist>=-2){Obj_SetAngle(obj, GetAngleToPlayer-ang);}
			if(distb<=2 && distb>=-2){Obj_SetAngle(objb, GetAngleToPlayer+ang);}
		}
		yield;
	}
}
	
	@Initialize
	{
		SetInvincibility(200);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");

		EnemyInit(70, 10);
		ClearScreen;
		Atktimer(3600);
	}
	
	@MainLoop
	{
		SetCollisionA(GetX(),GetY(),60);
		SetCollisionB(GetX(),GetY(),40);
		frame++;
		if(frame==0){attack;}
		yield;
}
	
	@Finalize
	{
		Obj_Delete(obj);
		Obj_Delete(objb);
		CreateEnemyFromFile(GetCurrentScriptDirectory~"boss1_talk03.txt", GetX, GetY, 0, 0, 0);
	}
	
	@DrawLoop
	{
		anim_idle;
	}
}