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

	SpellID=2;

	let frame = 0;

    @Initialize {
	StartFunctions(1,1,0);
	Randomize;
        SetLife(4500);
        SetTimer2(40);
//        SetScore(50000);
	SetDamageRate(180,100);
	MagicCircle(false);
	SetEnemyMarker(true);
	SetShotAutoDeleteClip(120,120,120,0);

	EnderInit;
	shotinit;

	MainTask;
    }

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

	let hitbox=0;
task MainTask{
	SetMovePosition03(GetCenterX,GetClipMinY+120,30,10);
	DelayBombTask;
	Wait(5);
	hitbox=1;
	let i=0;
	let side=-1;
	let angle=0;
	let turnspeed;
	let v=3.5;
	let shotangleadd;
	let xo;
	let yo;
	let dir=1;
	let randangle;
	loop{
		NewChargeShrink(100,6,0.5,255,150,150);
		NewChargeShrink(100,6,0.5,255,150,255);
		Wait(100);
		i=0;
		loop(4){
			CreateExplosionEX(3,GetX,GetY,0.1,[150,50,50],0.1+i/30,60);
			i++;
			CreateExplosionEX(3,GetX,GetY,0.1,[90,90,90],0.1+i/30,60);
			i++;
		}
		SetMovePositionNew(GetCenterX+prand(30,50)*side,prand(150,190),150);
		angle=rand(0,360);
		shotangleadd=rand(0,360);
		turnspeed=20;
		loop(50){
			angle+=4*dir;
			shotangleadd-=360/50*dir;
			xo=cos(shotangleadd)*90;
			yo=sin(shotangleadd)*50;
			loop(6){
				randangle=rand(0,-3);
				i=2;
				loop(2){
					CreateShotA(0,GetX+xo,GetY+yo,i*3);
					SetShotDataA(0,0,v,angle,360/turnspeed*dir,0,0,WHITE11);
					SetShotDataA(0,(|turnspeed|)+randangle,NULL,NULL,0,0,0,NULL);

					FireShot(0);

					i--;
				}

				CreateShotA(0,GetX+xo,GetY+yo,0);
				SetShotDataA(0,0,v,angle,360/turnspeed*dir,0,0,RED21+(-dir*3)+3);
				SetShotDataA(0,(|turnspeed|)+randangle,NULL,NULL,0,0,0,NULL);

				FireShot(0);
				angle+=360/6;
			}
			turnspeed+=3;
			SE("shot1");
			SE("shot3");
			Wait(2);
		}
		side=-side;
		dir=-dir;
		Wait(0);
	}
}
    @MainLoop {
	EnderDrawLogic;
	if(hitbox==1){
	        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);
	SetShotAutoDeleteClip(64,64,64,64);
    }

}