script_enemy_main{

let survivalcirclesize=1;
let survivalcirclespin=1;

let bgspin=0;
let bgspeed=0.1;

let character="Witches";
let cutin=character;
let dispelled=0;
let spellcards=1;
let spellcardnumber=85;
let damagerate=10;
let outfit=1;
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 BG1=("\script\Images\BackgroundLayers\Witches1.png");
let BG2=("\script\Images\BackgroundLayers\Witches3a.png");
let BG3=("\script\Images\OtherEffects\SpellCircle1a.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\ShotsWitches1.txt");

	LoadGraphic("\script\Images\BackgroundLayers\Witches1.png");
	LoadGraphic("\script\Images\BackgroundLayers\Witches3a.png");
	LoadGraphic("\script\Images\OtherEffects\SpellCircle1a.png");
	
	SetScore(2500000);
	SetLife(1000);
	SetTimer(60);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	MagicCircle(false);

	SetDurableSpellCard;
	
	SetX(cx);
	SetY(miny-1000);
	SetCommonData("UseSpell1",0);
	SetCommonData("UseSpell2",0);
}
	
@MainLoop{

SetShotAutoDeleteClip(64,64,64,64);

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


if(time==0){
CreateEnemyFromFile((GetCurrentScriptDirectory~"Witches - Eternal Recurrence - Youko.txt"),cx-100,miny+180,0,0,0);
CreateEnemyFromFile((GetCurrentScriptDirectory~"Witches - Eternal Recurrence - Amaya.txt"),cx+100,miny+180,0,0,0);
}


bgspin+=bgspeed;
bgspeed+=0.0006;

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,500,500);
	SetGraphicScale(1+(bgspeed/2),1+(bgspeed/2));
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(200,200,200);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,bgspin);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0,0,300,300);
	SetGraphicScale(1.5+(bgspeed/2),1.5+(bgspeed/2));
	SetTexture(BG2);
	SetGraphicAngle(0,0,bgspin);
	DrawGraphic(cx,cy);

if(survivalcirclesize>0){
	SetGraphicRect(0,0,200,200);
	SetGraphicScale(survivalcirclesize*1.4,survivalcirclesize*1.4);
	SetTexture(BG3);
	SetAlpha(bgfade/2);
	SetColor(70+60*cos((time+0)/2),70+60*cos((time+120)/2),70+60*cos((time+240)/2));
	SetGraphicAngle(0,0,survivalcirclespin*1.2);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0,0,200,200);
	SetGraphicScale(survivalcirclesize*2,survivalcirclesize*2);
	SetTexture(BG3);
	SetAlpha(bgfade/2);
	SetColor(170+60*cos((time+0)/2),170+60*cos((time+120)/2),170+60*cos((time+240)/2));
	SetGraphicAngle(0,0,-survivalcirclespin*0.7);
	DrawGraphic(cx,cy);
}
survivalcirclespin++;
if(GetLife<=0 && survivalcirclesize>0){ survivalcirclesize-=0.03; }

if(GetLife<=0){ bgspin+=bgspeed; bgspeed+=0.01; }
}

@DrawLoop{
}

@Finalize{
	if(GotSpellCardBonus){ SetCommonData("LastTrumpCard",18); }
	NewPointData(spellcardnumber,7);
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}