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

	SpellID=0;

	let i=0;
	let frame=0;

    @Initialize {
	StartFunctions(1,1,0);
	Randomize;
        SetLife(2500);
        SetTimer(30);
	SetDamageRate(100,100);
//	SetScore(50000);
	MagicCircle(false);
	SetEnemyMarker(true);
	OverInit;
	SetInvincibility(100);

	shotinit;

	MainTask;
	HandleShots(30);
    }


function Wait(frames){loop(frames){yield;}}
let colors=[WHITE50,ORANGE50,PURPLE50];

	let armangle=0;

task MainTask{
	SetMovePosition03(GetCenterX,GetCenterY-80,10,5);
	DelayBombTask;
	Wait(100);
	let color=0;
	let i=3;
	let i2=0;
	let length=0;
	MainTask2;
	loop{
		AwesomeLaser(GetX,GetY,2,90,colors,5);
		AwesomeLaser(GetX,GetY,2,-90,colors,5);
		Wait(90);
		AwesomeLaser(GetX,GetY,2,45,colors,5);
		AwesomeLaser(GetX,GetY,2,-135,colors,5);
		Wait(110);
		AwesomeLaser(GetX,GetY,2,90,colors,5);
		AwesomeLaser(GetX,GetY,2,-90,colors,5);
		Wait(90);
		AwesomeLaser(GetX,GetY,2,135,colors,5);
		AwesomeLaser(GetX,GetY,2,-45,colors,5);
		Wait(110);
	}
}
task MainTask2{
	let k=0;
	let k2=1;
	loop{
		Wait(120);
		k=0;
		loop(6){
			CreateLaser01(GetX,GetY,3,GetAngleToPlayer+k,100,15,colors[k2%3],0);
			k+=360/6;
			k2++;
		}
		k2-=5;
	}
}

    let speed=1.8;
    let framef=0;

    @MainLoop {
        SetCollisionA(GetX, GetY, 40);
	SetCollisionB(GetX, GetY, 20);

	OverloadDrawLogic;
	yield;
}
    @DrawLoop {
	OverloadDrawLoop;
}

    @Finalize {
	OverFinalize;
	EndingFunc(2);
    }

task AwesomeLaser(x,y,v,a,g,d){
	let offset=0;
	let k=0;
	while(OffScreen(x,y,90)==0){
		x+=cos(a)*v*d;
		y+=sin(a)*v*d;
		CreateShotA(0,x,y,d*2);
		k=0;
		loop(5){
			SetShotDataA(0,60+k*120,0,a+90+offset*180,0,0,0,g[trunc(offset/2)%(length(g))]);
			SetShotDataA(0,0+k*120,v,a+90+offset*180,0,0,0,g[trunc(offset/2)%(length(g))]);
			k++;
		}
		FireShot(0);
		offset++;
		Wait(d);
	}
}
}