script_enemy_main{

let charge=0;
let boost=0;

let character="SayuriMai";
let cutin=character;
let dispelled=0;
let spellcards=2;
let spellcardnumber=16;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let move=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 SEsurreal=("\script\SoundEffects\surreal1.wav");
let BG1=("\script\Images\BackgroundLayers\Sayuri2a.png");
let BG2=("\script\Images\BackgroundLayers\Sayuri2b.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\ShotsSayuriMai1.txt");

	LoadSE("\script\SoundEffects\surreal1.wav");
	LoadGraphic("\script\Images\BackgroundLayers\Sayuri2a.png");
	LoadGraphic("\script\Images\BackgroundLayers\Sayuri2b.png");

	SetScore(200000);
	SetLife(500);
	SetTimer(40);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(false);
	MagicCircle(false);
	SetX(cx);
	SetY(miny-1000);
	SetEffectForZeroLife(60,100,1);

	SetCommonData("UseSpell1",0);
	SetCommonData("UseSpell2",0);
}
	
@MainLoop{

SetCollisionA(GetCommonData("Boss1X"),GetCommonData("Boss1Y"),16);
SetCollisionA(GetCommonData("Boss2X"),GetCommonData("Boss2Y"),16);
SetCollisionB(GetCommonData("Boss1X"),GetCommonData("Boss1Y"),16);
SetCollisionB(GetCommonData("Boss2X"),GetCommonData("Boss2Y"),16);
SetShotAutoDeleteClip(80,80,80,80);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=8+(4*GetCommonData("Speed")); }
if(GetCommonData("BombOn")==1){ damagerate=6; }
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("Misdirection [Terminal Velocity] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(time==0){
SetCommonData("Speed",0);
SetCommonData("Angle",rand(35,55));
CreateEnemyFromFile(GetCurrentScriptDirectory~"Sayuri-Mai - Terminal Velocity - Sayuri.txt",GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Sayuri-Mai - Terminal Velocity - Mai.txt",GetCommonData("Boss2X"),GetCommonData("Boss2Y"),0,0,0);
}

if(GetCommonData("Speed")<6){ SetCommonData("Speed",GetCommonData("Speed")+0.004); }

if(GetCommonData("Speed")>=4 && boost==0){
	PlaySE(SEsurreal);
	MotionBlurEx(ALL,60,255,ALPHA);
	Slow(1);
	SetCommonData("Speed",GetCommonData("Speed")+1);
	boost=1;
}
if(boost>0){ if(boost==20){ Slow(0); } boost++; }


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,300,300);
	SetGraphicScale(1.5,1.5);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(255,255,255);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0,0,100,100);
	SetGraphicScale(2.5,2.5);
	SetAlpha(bgfade);
	SetRenderState(ADD);
	SetGraphicAngle(0,0,0);
	SetTexture(BG2);
	
	SetColor(255,0,0);
	DrawGraphic(cx+140*cos(time)*1.7,cy+140*sin(time*1.4));
	SetColor(0,255,0);
	DrawGraphic(cx-120*cos((time+120)*1.2),cy-170*sin((time+120)*1.8));
	SetColor(0,0,255);
	DrawGraphic(cx-90*cos((time+240)*2),cy+110*sin((time+240)*1.3));
}

@DrawLoop{
}

@Finalize{
//	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}