script_enemy_main{

let shot1=0;
let bullet1=[];
let timer1=[];

let phase=1;

let character="Kurumi";
let cutin=character;
let spellcards=5;
let spellcardnumber=53;
let dispelled=0;
let damagerate=10;
let outfit=5;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=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 SEshots4=("\script\SoundEffects\shots4.wav");
let SEshots7=("\script\SoundEffects\shots7.wav");

let BG1=("\script\Images\BackgroundLayers\Kurumi1.png");
let GRboss=("\script\Images\CharacterSprites\Kurumi.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsKurumi1.txt");
	
	LoadSE("\script\SoundEffects\shots4.wav");
	LoadSE("\script\SoundEffects\shots7.wav");
	
	LoadGraphic("\script\Images\CharacterSprites\Kurumi.png");
	LoadGraphic("\script\Images\BackgroundLayers\Kurumi1.png");

	SetScore(750000);
	SetLife(700);
	SetTimer(50);
	SetInvincibility(120);
	SetDamageRate(10,10);
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	
	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));
	SetMovePosition02(cx,miny+100,50);

	SetCommonData("Boss1Vanish",1);
}
	
@MainLoop{

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

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=2.5; }
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"; }

SpellcardName("Pressure [Mind Crusher]",spellcardnumber); 
HealthBar();
Portrait(cutin,2);

if(time%200==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+60,miny+120),1.5);
	}
}


if(time%120==0 && time>=120){
let angle=rand(0,360);
let radius=120;
let color=53;
	loop(phase){
		loop(15){
		CreateShot02(GetPlayerX+radius*cos(angle),GetPlayerY+radius*sin(angle),0,angle+180,0.02,3,color,10);
		angle+=360/15;
		}
	radius-=15;
	color-=1;
	}
PlaySE(SEshots7);
}

if(time%360==0 && time>=60){ if(phase<5){ phase+=1; } }


if(time==60){
let angle=0;
let bullet=1;
	loop(4){
	shot1=(Obj_Create(OBJ_LASER));
	if(bullet==1){ Obj_SetPosition(shot1,cx-230,cy-230); }
	if(bullet==2){ Obj_SetPosition(shot1,cx+230,cy-230); } 
	if(bullet==3){ Obj_SetPosition(shot1,cx+230,cy+230); }
	if(bullet==4){ Obj_SetPosition(shot1,cx-230,cy+230); }
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,0);
	ObjLaser_SetLength(shot1,500);
	ObjLaser_SetWidth(shot1,20);
	ObjLaser_SetSource(shot1,false);
	ObjShot_SetGraphic(shot1,37);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	angle+=90;
	bullet+=1;
	}
}
if(time>=60){
let i=0;
	while(i<length(bullet1)){
		if(timer1[i]<1550){
		Obj_SetPosition(bullet1[i],Obj_GetX(bullet1[i])+0.12*cos(Obj_GetAngle(bullet1[i])+90),Obj_GetY(bullet1[i])+0.12*sin(Obj_GetAngle(bullet1[i])+90));
		}

		if(time%5==0){
		let move=10;
		let angle=Obj_GetAngle(bullet1[i]);
			loop(9){
			CreateShot01(Obj_GetX(bullet1[i])+move*cos(angle-90),Obj_GetY(bullet1[i])+move*sin(angle-90),4,angle+rand(-1,1),24,0);
			move+=20;
			}
		}
	timer1[i]=timer1[i]+1;
	i++;
	}
}
if(time%5==0 && time>=60){ PlaySE(SEshots4); }


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

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";

if(GetLife==0 && dispelled==0){ CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,character); dispelled=1; }
}

@BackGround{
	if(bgfade<255){ bgfade+=5; }
	SetGraphicRect(0,0,50,1200);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(255,255,255);
	SetRenderState(ALPHA);
	SetGraphicScale(0.6,0.6); SetGraphicAngle(0,0,-10); DrawGraphic(cx-100,cy);
	SetGraphicScale(0.7,0.7); SetGraphicAngle(0,0,30); DrawGraphic(cx-100,cy);
	SetGraphicScale(0.8,0.8); SetGraphicAngle(0,0,70); DrawGraphic(cx+100,cy);
	SetGraphicScale(0.9,0.9); SetGraphicAngle(0,0,120); DrawGraphic(cx-40,cy);
	SetGraphicScale(1,1); SetGraphicAngle(0,0,160); DrawGraphic(cx+120,cy);
	SetGraphicScale(1.1,1.1); SetGraphicAngle(0,0,10); DrawGraphic(cx+70,cy);
	SetGraphicScale(1.2,1.2); SetGraphicAngle(0,0,100); DrawGraphic(cx,cy+150);
	SetGraphicScale(1.3,1.3); SetGraphicAngle(0,0,80); DrawGraphic(cx,cy-150);
}

@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{
//	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,5);
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}