script_enemy_main {
	#include_function ".\..\ShotSheet\shot_replace.dnh"
	#include_function ".\..\functions.txt"
	#include_function ".\e_functions.txt"

	SpellID=5;

	let frame = 0;
	let shottimer=1;
	let x=0;
	let y=0;
	let i=0;
	let i2=0;
	let i3=0;
	let angle=0;
	let attacks=1;
	let xshift=0;
	let yshift=0;
	let side=130;
	let vside=90;

	let BGscrollx=0;
	let BGscrolly=0;
	let BGscrollx2=0;
	let BGscrolly2=0;
	let BGscrollx3=0;
	let BGscrolly3=0;
	let bgrot=0;

    @Initialize {
	StartFunctions(1,1,0);
	Randomize;
        SetLife(3500);
        SetTimer2(25);
//        SetScore(50000);
	SetDamageRate(150,100);
	SetInvincibility(60);
	MagicCircle(false);
	SetEnemyMarker(true);

	EnderInit;
	shotinit;

	MainTask;
    }

	let cshot1=[RED56,ORANGE56,YELLOW56,ORANGE56];
	let cshot2=[BLUE56,AQUA56,GREEN56,AQUA56];
	let cshot3=[PURPLE56,PURPLE56,PURPLE56,PURPLE56];
function Wait(frames){loop(frames){yield;}}

function CenterShot(speed,angle,radius,graphic,dir){
			CreateShotA(1,GetX,GetY,0);
			SetShotDataA(1,0,speed,angle,360/time,0,0,graphic);
			SetShotDataA(1,time/2,2.5,angle+90+(90*dir),0,0,0,graphic);
			FireShot(1);
}

let wait=5;
let time=60;

task MainTask{
	SetMovePosition03(GetCenterX,GetClipMinY+160,30,10);
	DelayBombTask;
	Wait(60);
	let i=0;
	let graphic=0;
	let x=0;
	let radius=100;
	loop{
		loop(time){
			CenterShot(5,x,radius,cshot1[graphic%4],1);
			CenterShot(5,x+180,radius,cshot1[graphic%4],1);
			CenterShot(5,x,radius,cshot1[graphic%4],0.5);
			CenterShot(5,x+180,radius,cshot1[graphic%4],0.5);

			CenterShot(5,x+120,radius,cshot2[graphic%4],-1);
			CenterShot(5,x-60,radius,cshot2[graphic%4],-1);
			CenterShot(5,x+120,radius,cshot2[graphic%4],-0.5);
			CenterShot(5,x-60,radius,cshot2[graphic%4],-0.5);

			CenterShot(5,x+240,radius,cshot3[graphic%4],0.25);
			CenterShot(5,x+60,radius,cshot3[graphic%4],0.25);
			CenterShot(5,x+240,radius,cshot3[graphic%4],-0.25);
			CenterShot(5,x+60,radius,cshot3[graphic%4],-0.25);

			Wait(wait);
			SE("shot1");
			x+=(prand(3,5))*wait;
			graphic++;
		}
	}
}

    @MainLoop {
	EnderDrawLogic;
        SetCollisionA(GetX, GetY, 35);
	SetCollisionB(GetX, GetY, 25);

	yield;
}


	let EnderFrame=0;

	let aurarot=0;
	let aurascale=0;
	let scaler=prand(1.7,1.9);

    @DrawLoop {
	EnderDrawLoop;
}


    @Finalize {
	EndingFunc(1);
	EnderFinalize;
	PointItems(GetX,GetY,1,0);
    }

}