script_enemy_main{

let speed1=1.05;
let randomangle1=0;
let speed2=1.05;
let randomangle2=0;

let angle3a=rand(0,360);
let angle3b=0;
let speed3=1.5;
let angle4a=rand(0,360);
let angle4b=0;
let speed4=1.5;

let character="TomomiTakeo";
let cutin=character;
let dispelled=0;
let spellcards=1;
let spellcardnumber=33;
let damagerate=10;
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 SEwater1=("script\SoundEffects\water1.wav");

let BG1=("\script\Images\BackgroundLayers\Tomomi3.png");
let BG2=("\script\Images\BackgroundLayers\Takeo1b.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\ShotsTomomiTakeo1.txt");

	LoadSE("script\SoundEffects\water1.wav");
	
	LoadGraphic("\script\Images\BackgroundLayers\Tomomi3.png");
	LoadGraphic("\script\Images\BackgroundLayers\Takeo1b.png");

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

	SetScore(600000);
	SetLife(300);
	SetTimer(50);
	SetInvincibility(120);
	SetDamageRate(10,10);

	SetCommonData("UseSpell1",0);
	SetCommonData("UseSpell2",0);

	SetX(cx);
	SetY(miny-500);
		
	SetCommonData("Difficulty",4);
}
	
@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(16,16,16,16);

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("Cold Deck [Royal Flush] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(time==45){ CreateEnemyFromFile(("script\Functions\spellcardwarning.txt"),0,0,0,0,0); }

if(time==0){
CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Tomomi.txt"),GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,0);
CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Takeo.txt"),GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,0);
}

let TomomiX=GetCommonData("Boss1X");
let TomomiY=GetCommonData("Boss1Y");
let TakeoX=GetCommonData("Boss2X");
let TakeoY=GetCommonData("Boss2Y");


if(frame==230){
SetCommonData("WarningX",cx);
SetCommonData("WarningSide",1);
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",1);
SetCommonData("WarningType",2);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
}

if(frame>=300 && frame<450){
let xpos=cx-170;
let angle=90+2*cos(time*3);
	loop(5){
		loop(3){
		CreateShot01(xpos+rand(-20,20),miny,rand(4.5,5),angle,rand_int(31,32),20);
		}
	xpos+=85;
	}
if(time%5==0){ PlaySE(SEwater1); }
}
if(frame==450){ frame=0; }


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }

#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(2,2);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(200,200,200);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,-time/4);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0-80*cos(time),0,528-80*cos(time),592);
	SetGraphicScale(1,1);
	SetTexture(BG2);
	SetAlpha(bgfade/2);
	SetColor(0,0,0);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
}

@DrawLoop{
}

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

}