script_enemy_main{

let type=1;

let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let frame=-210;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshots5=("script\SoundEffects\shots5.wav");

let GRboss=("\script\Images\CharacterSprites\Takeo.png");

@Initialize{
	LoadSE("script\SoundEffects\shots5.wav");
	
	LoadGraphic(GRboss);

if(GetArgument==0){
	SetColor(0,100,255);
	Concentration01(90);
	SetColor(255,255,255);
}
	SetLife(10000);
	MagicCircle(false);
	SetInvincibility(120);
	SetX(GetCommonData("Boss2X"));
	SetY(GetCommonData("Boss2Y"));
	SetMovePosition02(cx-100,miny+100,60);
}
	
@MainLoop{

SetCollisionB(GetX,GetY,16);

if(time%20==0 && time>=90){ SetMovePosition02(cx-100*cos(time+270),miny+100+40*sin(time+270),50); }

//=============================================================

if(GetCommonData("Difficulty")==2){
	if(frame==300){ type++; frame=0; }

	if(type%2==0 && frame<270 && frame>=0){
		if(time%5==0 && time>=90){
		let shot1=0;
		let angle=-time*3.1;
			loop(1){
			shot1=(Obj_Create(OBJ_SHOT));
			Obj_SetPosition(shot1,GetX-6,GetY-27);
			Obj_SetAngle(shot1,angle);
			Obj_SetSpeed(shot1,2.5);
			ObjShot_SetBombResist(shot1,true);
			ObjShot_SetGraphic(shot1,67);
			angle+=360/2;
			}
		let angle=time*1.9;
			loop(1){
			shot1=(Obj_Create(OBJ_SHOT));
			Obj_SetPosition(shot1,GetX-6,GetY-27);
			Obj_SetAngle(shot1,angle);
			Obj_SetSpeed(shot1,2.5);
			ObjShot_SetBombResist(shot1,true);
			ObjShot_SetGraphic(shot1,67);
			angle+=360/2;
			}
		}
		if(time%8==0 && frame<270 && frame>=0){ PlaySE(SEshots5); }
	usespell=10;
	}
	
	if(type%2!=0){
		if(time%60==0 && frame<270 && frame>=0){
		let angle=rand(0,360);
			loop(30){
			CreateShot01(GetX,GetY,2.5,angle,67,0);
			angle+=360/30;
			}
		usespell=-20;
		PlaySE(SEshots5);
		}

	}
} //Normal

//=============================================================

if(GetCommonData("Difficulty")==3){
	if(frame==300){ type++; frame=0; }

	if(type%2==0 && frame<270 && frame>=0){
		if(time%5==0 && time>=90){
		let shot1=0;
		let angle=-time*2.1;
			loop(2){
			shot1=(Obj_Create(OBJ_SHOT));
			Obj_SetPosition(shot1,GetX-6,GetY-27);
			Obj_SetAngle(shot1,angle);
			Obj_SetSpeed(shot1,2.5);
			ObjShot_SetBombResist(shot1,true);
			ObjShot_SetGraphic(shot1,67);
			angle+=360/2;
			}
		let angle=time*1.9;
			loop(2){
			shot1=(Obj_Create(OBJ_SHOT));
			Obj_SetPosition(shot1,GetX-6,GetY-27);
			Obj_SetAngle(shot1,angle);
			Obj_SetSpeed(shot1,2.5);
			ObjShot_SetBombResist(shot1,true);
			ObjShot_SetGraphic(shot1,67);
			angle+=360/2;
			}
		}
		if(time%8==0 && frame<270 && frame>=0){ PlaySE(SEshots5); }
	usespell=10;
	}
	
	if(type%2!=0){
		if(time%60==0 && frame<270 && frame>=0){
		let angle=rand(0,360);
			loop(40){
			CreateShot01(GetX,GetY,2.5,angle,67,0);
			angle+=360/40;
			}
		usespell=-20;
		PlaySE(SEshots5);
		}
	}
} //Hard

//=============================================================

if(GetCommonData("Difficulty")==4){
	if(frame==300){ type++; frame=0; }

	if(type%2==0 && frame<270 && frame>=0){
		if(time%4==0 && time>=90){
		let shot1=0;
		let angle=-time*2.1;
			loop(2){
			shot1=(Obj_Create(OBJ_SHOT));
			Obj_SetPosition(shot1,GetX-6,GetY-27);
			Obj_SetAngle(shot1,angle);
			Obj_SetSpeed(shot1,2.5);
			ObjShot_SetBombResist(shot1,true);
			ObjShot_SetGraphic(shot1,67);
			angle+=360/2;
			}
		let angle=time*1.9;
			loop(2){
			shot1=(Obj_Create(OBJ_SHOT));
			Obj_SetPosition(shot1,GetX-6,GetY-27);
			Obj_SetAngle(shot1,angle);
			Obj_SetSpeed(shot1,2.5);
			ObjShot_SetBombResist(shot1,true);
			ObjShot_SetGraphic(shot1,67);
			angle+=360/2;
			}
		}
		if(time%8==0 && frame<270 && frame>=0){ PlaySE(SEshots5); }
	usespell=10;
	}
	
	if(type%2!=0){
		if(time%60==0 && frame<270 && frame>=0){
		let angle=rand(0,360);
			loop(50){
			CreateShot01(GetX,GetY,2.5,angle,67,0);
			angle+=360/50;
			}
		PlaySE(SEshots5);
		usespell=-20;
		}
	}
} //Lunatic

//=============================================================



time++;
frame++;

if(GetCommonData("UseSpell2")!=0){ usespell=GetCommonData("UseSpell2"); SetCommonData("UseSpell2",0); }
if(usespell>0){ usespell--; }
if(usespell<0){ usespell++; }

SetCommonData("Boss2X",GetX); SetCommonData("Boss2Y",GetY);

}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
	CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,"Takeo");
	if(GetLife>0 && GetTimer>0){ CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Splashing The Pot - Takeo.txt"),GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,1); }
}

}