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

	SpellID=8;

	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);
	MagicCircle(false);
	SetEnemyMarker(true);

	EnderInit;
	shotinit;

	MainTask;
    }

	let cshot=[WHITE32,ORANGE32,RED32,PURPLE32];
function Wait(frames){loop(frames){yield;}}

task MainTask{
	SetMovePosition03(GetCenterX,GetClipMinY+120,30,10);
	WaitEvent(10);
	while(EventActive){
		yield;
	}
	DelayBombTask;
	let i=0;
	let angle=0;
	SoundTask;
	loop{
		angle=i*5;
		CreateShot01(GetX+cos(angle+90)*40,GetY+sin(angle+90)*40,(i%4)/3+1,angle+prand(-2,2)+180,cshot[i%4],0);
		CreateShot01(GetX+cos(angle-90)*40,GetY+sin(angle-90)*40,(i%4)/3+1,angle+prand(-2,2),cshot[i%4],0);
		CreateShot01(GetX+cos(angle+90)*40,GetY+sin(angle+90)*40,(i%4)/3+1,angle+prand(-2,2),cshot[i%4],0);
		CreateShot01(GetX+cos(angle-90)*40,GetY+sin(angle-90)*40,(i%4)/3+1,angle+prand(-2,2)+180,cshot[i%4],0);
		i++;
		yield;
		if(i%2==0){
			yield;
		}
	}
}
task SoundTask{
	loop{
		if(i%5==0){SE("shot1");}
		Wait(5);
	}
}
    @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);
    }

}