script_enemy_main
{
	let frame=-100;
	#include_function ".\spellcard.txt";
	#include_function ".\boss2anim.txt";
	
task attack{
	let angle=0;
	loop{
		PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
		ascent(i in 0..4){
			ShotA(GetX+70*cos(-angle+i*90)+30*sin(angle), GetY+70*sin(-angle+i*90)+30*cos(angle), 3*angle+i*90);
			ShotA(GetX+35*cos(2*angle+i*90)-15*sin(angle/2), GetY+35*sin(2*angle+i*90)-15*cos(angle/2), angle+i*90);
		}
		angle+=7.3;
		loop(5){yield;}
	}
	
	task ShotA(x, y, ang){
		let angle=rand(0, 359);
		let angleb=0;
		while(angleb>-2 && angleb<2){angleb=rand(-3, 3);}
		let obj=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, 0);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 53);
		ObjShot_SetDelay(obj, 15);
		ObjShot_ToItem(obj, false);
		while(Obj_BeDeleted(obj)==false){
			Obj_SetAngle(obj, Obj_GetAngle(obj)+angleb);
			Obj_SetPosition(obj, Obj_GetX(obj)+2*cos(ang), Obj_GetY(obj)+2*sin(ang));
			yield;
		}
	}
}

sub move{
	let x=GetPlayerX+rand(-100, 100);
	let y=rand(70, 130);
	while(x>GetClipMaxX-20 || x<GetClipMinX+20){
		x=GetPlayerX+rand(-100, 100);
	}
	SetMovePosition03(x, y, 10, 4);
}

	@Initialize
	{
		SetInvincibility(200);
		SetLife(700);
		SetDamageRate(100,100);
		SetMovePosition02(GetCenterX,120,20);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");

		timer;
		SetCommonData("timercount", 4500);
	}
	
	@MainLoop
	{
		SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
		frame++;
		if(frame==0){attack;}
		if(GetSpeed==0){move;}
		yield;
}
	
	@Finalize
	{
	}
	
	@DrawLoop
	{
		anim_idle;
	}
}