script_enemy_main{

let shot1=0;

let character="Takeo";
let cutin=character;
let dispelled=0;
let spellcards=5;
if(GetCommonData("Difficulty")>=2){ spellcards=6; }
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0; let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

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

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

#include_function "script/Functions/HealthBarLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsTakeo1.txt");

	LoadSE("script\SoundEffects\shots6.wav");
	LoadSE("script\SoundEffects\shots5.wav");

	LoadGraphic("\script\Images\CharacterSprites\Takeo.png");

	SetLife(100);
	SetTimer(25);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(true);
	MagicCircle(true);
	SetMovePosition02(cx,miny+100,50);

	SetX(GetCommonData("Boss2X"));
	SetY(GetCommonData("Boss2Y"));
	SetCommonData("Boss2Vanish",1);
	SetMovePosition02(cx,miny+100,50);
	
	SetCommonData("Boss1Move",3);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(64,64,64,64);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=3; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

HealthBar();


if(time%60==0 && time>=60){ SetMovePosition01(cx+rand(-50,50),rand(miny+80,miny+120),1.5); }


if(GetCommonData("Difficulty")==1){

let direction=4*cos(time);
if(time>=60){
let color=rand_int(255,150);
	loop(7){
	SetShotColor(color,color,color);
	CreateShot01(cx+rand(-300,300),miny,rand(4,4.5),90+direction,104,0);
	}
SetShotColor(255,255,255);
}
if(time>=60 && time%5==0){ PlaySE(SEshots6); }

if(time%90==0 && time>=90){
let angle=rand(0,360);
	loop(30){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,2.5);
	ObjShot_SetBombResist(shot1,true);
	ObjShot_SetGraphic(shot1,67);
	angle+=360/30;
	}
PlaySE(SEshots5);
}

if(time==50){ CreateEnemyFromFile(GetCurrentScriptDirectory~"Takeo - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,0); }

} //Easy

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

if(GetCommonData("Difficulty")==2){

let direction=6*cos(time);
if(time>=60){
let color=rand_int(255,150);
	loop(8){
	SetShotColor(color,color,color);
	CreateShot01(cx+rand(-300,300),miny,rand(4,4.5),90+direction,104,0);
	}
SetShotColor(255,255,255);
}
if(time>=60 && time%5==0){ PlaySE(SEshots6); }

if(time%80==0 && time>=90){
let angle=rand(0,360);
	loop(40){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,2.8);
	ObjShot_SetBombResist(shot1,true);
	ObjShot_SetGraphic(shot1,67);
	angle+=360/40;
	}
PlaySE(SEshots5);
}

if(time==50){ CreateEnemyFromFile(GetCurrentScriptDirectory~"Takeo - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,0); }

} //Normal

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

if(GetCommonData("Difficulty")==3){

let direction=8*cos(time);
if(time>=60){
let color=rand_int(255,150);
	loop(9){
	SetShotColor(color,color,color);
	CreateShot01(cx+rand(-300,300),miny,rand(4,4.5),90+direction,104,0);
	}
SetShotColor(255,255,255);
}
if(time>=60 && time%5==0){ PlaySE(SEshots6); }

if(time%70==0 && time>=90){
let angle=rand(0,360);
	loop(50){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,3.2);
	ObjShot_SetBombResist(shot1,true);
	ObjShot_SetGraphic(shot1,67);
	angle+=360/50;
	}
PlaySE(SEshots5);
}

if(time==50){ CreateEnemyFromFile(GetCurrentScriptDirectory~"Takeo - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,0); }

} //Hard

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

if(GetCommonData("Difficulty")==4){

let direction=10*cos(time);
if(time>=60){
let color=rand_int(255,150);
	loop(10){
	SetShotColor(color,color,color);
	CreateShot01(cx+rand(-300,300),miny,rand(4,4.5),90+direction,104,0);
	}
SetShotColor(255,255,255);
}
if(time>=60 && time%5==0){ PlaySE(SEshots6); }

if(time%60==0 && time>=90){
let angle=rand(0,360);
	loop(60){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,3.5);
	ObjShot_SetBombResist(shot1,true);
	ObjShot_SetGraphic(shot1,67);
	angle+=360/60;
	}
PlaySE(SEshots5);
}

if(time==50){ CreateEnemyFromFile(GetCurrentScriptDirectory~"Takeo - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,0); }

} //Lunatic


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss2X",GetX); SetCommonData("Boss2Y",GetY);

#include_function "script/Functions/HealthBar.txt";
}

@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); }
	}
	if(GetLife>0){ DrawGraphic(GetX,GetY); }
}
 
@Finalize{
}

}