script_enemy_main{

let color=rand_int(0,10);
let angle=0;
let size=2;

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

let character="Kurumi";
let cutin=character;
let dispelled=0;
let spellcards=2;
let spellcardnumber=23;
let damagerate=10;
let outfit=6;
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 SEcharge2=("\script\SoundEffects\charge2.wav");
let SElaserb1=("\script\SoundEffects\laserb1.wav");
let SEshots5=("\script\SoundEffects\shots5.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\charge2.wav");
	LoadSE("\script\SoundEffects\laserb1.wav");
	LoadSE("\script\SoundEffects\shots5.wav");

	LoadGraphic("\script\Images\CharacterSprites\Kurumi.png");
	LoadGraphic("\script\Images\BackgroundLayers\Kurumi1.png");

	SetScore(250000);
	SetLife(250);
	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"));
	SetCommonData("Boss1Vanish",1);
	SetMovePosition02(cx,miny+100,50);

	SetCommonData("Boss2Move",4);
}
	
@MainLoop{

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

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=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("Tyrannization [Oppression] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);

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


if(usespell<-50){
let shotx=0;
	CreateShotA(shotx,GetX,GetY,0);
	SetShotDataA(shotx,0,rand(1,7),rand(0,360),0,-0.07,0,119);
	SetShotKillTime(shotx,40);
	FireShot(shotx);
	CreateShotA(shotx,GetX,GetY,0);
	SetShotDataA(shotx,0,rand(1,7),rand(0,360),0,-0.07,0,131);
	SetShotKillTime(shotx,40);
	FireShot(shotx);
}


if((time+270)%400==0 && time>=60){
SetSpeed(0);
let shotx=0;
angle=GetAngleToPlayer;
	CreateLaserA(shotx,GetX,GetY,500,30,87,301);
	SetLaserDataA(shotx,0,GetAngleToPlayer,0,0,0,0);
	SetShotKillTime(shotx,310);
	FireShot(shotx);
SetColor(190,255,60);
Concentration01(90);
SetColor(255,255,255);
PlaySE(SEcharge2);
}
if((time+180)%400==0 && time>=60){
let shotx=0;
let angleshift=0;
let shift=0;
let speed=3;
	loop(6){
	CreateLaserA(shotx,GetX+shift,GetY,10,30,87,0);
	SetLaserDataA(shotx,0,angle+angleshift,0,speed,0,0);
	SetShotKillTime(shotx,240);
	FireShot(shotx);
	CreateLaserA(shotx,GetX-shift,GetY,10,30,87,0);
	SetLaserDataA(shotx,0,angle-angleshift,0,speed,0,0);
	SetShotKillTime(shotx,240);
	FireShot(shotx);
	angleshift+=1.5;
	shift+=1.5;
	speed-=0.1;
	}
PlaySE(SElaserb1);
usespell=-270;
}


if(time%30==0 && time>=90){
let angle=0;
if(time%60==0){ angle=360/40; }
if(time%60!=0){ angle=360/80; }
	loop(40){
	CreateShot02(GetX,GetY,7,angle,-0.15,1.2,20,0);
	angle+=360/40;
	}
PlaySE(SEshots5);
}

if(time%5==0 && OnPlayerMissed==false && GetTimeOfPlayerInvincibility<60 && time>=120){
let angle=rand(0,360);
let radius=rand(50*size,70*size);
	loop(6){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetPlayerX+radius*cos(angle),GetPlayerY+radius*sin(angle));
	Obj_SetAngle(shot1,angle+135);
	Obj_SetSpeed(shot1,1);
	ObjShot_SetDelay(shot1,15);
	ObjShot_SetGraphic(shot1,96+color);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	angle+=360/6;
	}
if(time%60==0){ color-=1; }
if(color<1){ color+=10; }
}
if(size>1 && time>=60){ size-=0.001; }



let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i);
	i--;
	}
	else{
	if(timer1[i]==120){ ObjShot_FadeDelete(bullet1[i]); }
	timer1[i]=timer1[i]+1;
	}
i++;
}


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";
}

@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,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}