script_enemy_main{

let angle=180;

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

let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0;
let time=0;
let move=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 SEshot1=("script\SoundEffects\shotb5.wav");
let SEshot2=("script\SoundEffects\shots3.wav");
let SEshot3=("script\SoundEffects\shots4.wav");

let GRfan=("\script\Images\OtherEffects\Fan1.png");
let GRboss=("\script\Images\CharacterSprites\Setsuko.png");

@Initialize{
	LoadGraphic("\script\Images\CharacterSprites\Setsuko.png");
	LoadGraphic("\script\Images\OtherEffects\Fan1.png");

	LoadSE("script\SoundEffects\fan1.wav");
	LoadSE("script\SoundEffects\shotb5.wav");
	LoadSE("script\SoundEffects\shots3.wav");
	LoadSE("script\SoundEffects\shots4.wav");

	SetColor(255,160,200);
	Concentration01(90);
	SetColor(255,255,255);
	SetLife(10000);
	MagicCircle(false);
	SetInvincibility(120);
	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));
	SetMovePosition02(cx,cy-40,60);
}
	
@MainLoop{

SetCollisionB(GetX,GetY,16);


if(frame==70 && time>=150){
let angle=rand(0,360);
let shot1=0;
	loop(70){
	CreateShotA(shot1,GetX,GetY,0);
	SetShotDataA(shot1,0,5,angle,0,-0.2,0,2);
	SetShotDataA(shot1,40,1,angle+45,0,0,0,2);
	FireShot(shot1);
	angle+=360/70;
	}

	loop(70){
	CreateShotA(shot1,GetX,GetY,0);
	SetShotDataA(shot1,0,5,angle,0,-0.2,0,2);
	SetShotDataA(shot1,40,1,angle-45,0,0,0,2);
	FireShot(shot1);
	angle+=360/70;
	}
usespell=-30;
PlaySE(SEshot1);
}
if(frame==220){
let angle=rand(0,360);
let shot1=0;
	loop(90){
	CreateShotA(shot1,GetX,GetY,0);
	SetShotDataA(shot1,0,5,angle,0,-0.2,0,3);
	SetShotDataA(shot1,40,1,angle,0,0,0,3);
	FireShot(shot1);
	angle+=360/90;
	}
PlaySE(SEshot1);
}


if(frame>=220 && frame%5==0){
let shot1=0;
	CreateShotA(shot1,GetX,GetY-25,0);
	SetShotDataA(shot1,0,4,angle,0,-0.05,0,15);
	SetShotDirectionType(PLAYER);
	SetShotDataA(shot1,120,6,0,0,0,0,24);
	SetShotDirectionType(ABSOLUTE);
	FireShot(shot1);

	CreateShotA(shot1,GetX,GetY-25,0);
	SetShotDataA(shot1,0,4,180-angle,0,-0.05,0,15);
	SetShotDirectionType(PLAYER);
	SetShotDataA(shot1,120,6,0,0,0,0,24);
	SetShotDirectionType(ABSOLUTE);
	FireShot(shot1);
angle+=90/16;
usespell=20;
PlaySE(SEshot2);
}
if(frame>=40 && frame<120 && time%5==0 && time>=160){ PlaySE(SEshot3); }


if(frame==300){ frame=0; angle=180; }



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(GetCommonData("UseSpell1")!=0){ usespell=GetCommonData("UseSpell1"); SetCommonData("UseSpell1",0); }
if(usespell>0){ usespell-=1; }
if(usespell<0){ usespell+=1; }

SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);
}

@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{
	CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,"Setsuko");
}

}