script_enemy_main{

let speed=2;

let character="Midori";
let cutin=character;
let dispelled=0;
let spellcards=7;
let spellcardnumber=51;
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 SEshots3=("script\SoundEffects\shots3.wav");

let BG1=("\script\Images\BackgroundLayers\Midori1.png");
let GRboss=("\script\Images\CharacterSprites\Midori.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\ShotsMidori1.txt");
	
	LoadSE("script\SoundEffects\shots3.wav");

	LoadGraphic("\script\Images\CharacterSprites\Midori.png");
	LoadGraphic("\script\Images\BackgroundLayers\Midori1.png");

	SetScore(750000);
	SetLife(550);
	SetTimer(60);
	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(32,32,32,32);

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("Kymophobia [Fear of Waves]",spellcardnumber); 
HealthBar();
Portrait(cutin,2);


if(time%4==0 && time>=60){
let angle=30*cos(time*0.28);
	loop(12){
	CreateShot01(GetX,GetY,speed,angle+30*cos(time*2),100,0);
	if(time%8==0){ CreateShot01(GetX,GetY,speed-1,angle+10*cos(-time*3),89,0); }
	angle+=360/12;
	}
}
if(speed<5){ speed+=0.002; }
if(time%5==0 && time>=60){ PlaySE(SEshots3); }


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<125){ bgfade+=5; }

	SetGraphicRect(0,0,600,600);
	SetGraphicScale(2,2);
	SetTexture(BG1);
	SetRenderState(ALPHA);
	
	SetAlpha(bgfade*2);
	SetColor(127+127*cos(time),127+127*cos(time+120),127+127*cos(time+240));
	SetGraphicAngle(0,0,-time);
	DrawGraphic(cx-150,cy);
	
	SetColor(127-127*cos(time),127-127*cos(time+120),127-127*cos(time+240));
	SetAlpha(bgfade);
	SetGraphicAngle(0,0,time);
	DrawGraphic(cx+150,cy);
}

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

}