script_enemy_main{

let effect1=0;
let object1=[];
let count1=[];
let angle1=[];
let fanangle=0;

let direction=0;
let angle=0;
let size=0;
let phase=0;

let character="Setsuko";
let cutin=character;
let spellcards=5;
let spellcardnumber=54;
let dispelled=0;
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 SEfan=("script\SoundEffects\fan1.wav");
let SElaserm1=("script\SoundEffects\laserm1.wav");
let SEshots4=("script\SoundEffects\shots4.wav");
let SEshotb6=("script\SoundEffects\shotb6.wav");

let GRfan=("\script\Images\OtherEffects\Fan1.png");
let BG1=("\script\Images\BackgroundLayers\Setsuko1.png");
let BG2=("\script\Images\BackgroundLayers\Setsuko3.png");
let GRboss=("\script\Images\CharacterSprites\Setsuko.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\ShotsSetsuko1.txt");

	LoadSE("script\SoundEffects\fan1.wav");
	LoadSE("script\SoundEffects\laserm1.wav");
	LoadSE("script\SoundEffects\shots4.wav");
	LoadSE("script\SoundEffects\shotb6.wav");

	LoadGraphic("\script\Images\OtherEffects\Fan1.png");
		
	LoadGraphic("\script\Images\BackgroundLayers\Setsuko1.png");
	LoadGraphic("\script\Images\BackgroundLayers\Setsuko3.png");
	LoadGraphic("\script\Images\CharacterSprites\Setsuko.png");

	SetScore(750000);
	SetLife(500);
	SetTimer(80);
	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+150,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("Justice [Egalitarianism]",spellcardnumber); 
HealthBar();
Portrait(cutin,2);


if(time%120==0 && time>=60){
direction=GetAngleToPlayer;
angle=0;
let shot1=0;
	CreateLaserA(shot1,GetX,GetY,500,10,27,201);
	SetLaserDataA(shot1,0,direction,0,0,0,0);
	SetShotKillTime(shot1,200);
	FireShot(shot1);
let angle2=direction-4;
	loop(5){
	CreateShot01(GetX,GetY,0.75,angle2,13,0);
	angle2+=2;
	}
size+=10;
usespell=-30;
PlaySE(SEshotb6);
}

if(time>=120){
	if(time%2==0){
	CreateShot01(GetX,GetY,2,time*12.3,11,0);
	CreateShot01(GetX,GetY,2,180+time*12.3,12,0);
	}
CreateLaser01(GetX,GetY,5,direction+178+angle,70+size,15,27,10);
CreateLaser01(GetX,GetY,5,direction+182-angle,70+size,15,27,10);
angle+=1.5;
if(time%10==0){ PlaySE(SElaserm1); }
if((time+3)%5==0){ PlaySE(SEshots4); }
}



if(time==60){
let picture=0;
let i=0;
	loop(16){
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,GetX,GetY);
	ObjEffect_SetScale(effect1,1,1); ObjEffect_SetAngle(effect1,0,0,-90);
	ObjEffect_SetLayer(effect1,1); ObjEffect_SetTexture(effect1,GRfan); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-25,-175); ObjEffect_SetVertexUV(effect1,0,0+picture,0);
	ObjEffect_SetVertexXY(effect1,1,25,-175); ObjEffect_SetVertexUV(effect1,2,0+picture,350);
	ObjEffect_SetVertexXY(effect1,2,-25,175); ObjEffect_SetVertexUV(effect1,1,50+picture,0);
	ObjEffect_SetVertexXY(effect1,3,25,175); ObjEffect_SetVertexUV(effect1,3,50+picture,350);
	ObjEffect_SetVertexColor(effect1,0,255,255,255,255); ObjEffect_SetVertexColor(effect1,1,255,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,125,255,255,255); ObjEffect_SetVertexColor(effect1,3,125,255,255,255);
	object1=object1~[effect1];
	count1=count1~[effect1];
	count1[length(object1)-1]=i*12;
	angle1=angle1~[effect1];
	angle1[length(object1)-1]=0;
	if((i+1)%2==0){ picture=0; }
	if((i+0)%2==0){ picture=50; }
	i++;
	}
}

if(time>=60){
let i=0;
	loop(16){
	Obj_SetPosition(object1[i],GetX,GetY);
	ObjEffect_SetAngle(object1[i],0,0,-90+angle1[i]+fanangle);
	if(angle1[i]<count1[i]){ angle1[i]=angle1[i]+4; fanangle+=1; }
	if(angle1[i]==count1[i] && time>=80 && time%3==0){ PlaySE(SEfan); angle1[i]=count1[i]+0.01; }
	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";

if(GetLife==0 && dispelled==0){ CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,character); dispelled=1; }
}

@BackGround{
	if(bgfade<255){bgfade+=5;}

	SetGraphicRect(0,0,300,400);
	SetGraphicScale(1.3,1.3);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(180,180,180);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0,0,300,300);
	SetAlpha(bgfade);
	SetColor(180,180,180);
	SetGraphicScale(1.5,1.5);
	SetTexture(BG2);
	SetGraphicAngle(0,0,time);
	DrawGraphic(cx,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);
	NewPointData(spellcardnumber,5);
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}