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

	SpellID=35;

	let i=0;
	let frame=0;

    @Initialize {
	StartFunctions(1,1,0);
	Randomize;
        SetLife(2000);
        SetTimer2(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=[AQUA50,WHITE50,GREEN50,WHITE50];
//let colors=[YELLOW50,YELLOW50,BLUE50,BLUE50];

	let armangle=0;

task MainTask{
	if(GetY>GetClipMinY){
		NoEnemyMarker;
		WaitEvent(280);
		Wait(280);
		FadeEnemyMarkerEX(GetEnemyX,60,0,1);
		while(EventActive){yield;}
	}
	SetMovePosition03(GetCenterX,GetCenterY-80,10,5);
	DelayBombTask;
	Wait(40);
	MainTask2;
	let color=0;
	let i=3;
	let i2=0;
	let len=0;
	lightninglaseralpha=200;
	loop{
		SE("shot4");
		len=prand(80,100);
		LightningLaser(GetX+50,GetY,-80+i*12,60*(i2%2-0.5), len,15,5, RED52,11,-len/3);
		LightningLaser(GetX-50,GetY,80-i*12,-60*(i2%2-0.5), len,15,5, RED52,11,-len/3);
		Wait(10);
		i+=prand(0.9,1);
		i2++;
		LightningLaser(GetX+50,GetY,-80+i*12,80*(i2%2-0.5), len*0.8,15,4, PURPLE52,11,-len/4);
		LightningLaser(GetX-50,GetY,80-i*12,-80*(i2%2-0.5), len*0.8,15,4, PURPLE52,11,-len/4);
		Wait(10);
		i+=prand(0.9,1);
		i2++;
	}
}
task MainTask2{
	Wait(120);
	let angle=0;
	let i=0;
	let color=0;
	angle=rand(0,360);
	let dir=1;
	loop{
		SE("shot2");
		angle=rand(0,360);
		loop(20){
			CreateShot01(GetX+50*dir,GetY,2.5,angle,AQUA11+color,0);
			CreateShot01(GetX+50*dir,GetY,1.5,angle,AQUA11+color,0);
			color=1-color;
			angle+=360/20;
		}
		dir=-dir;
		Wait(32);
	}
}

    let speed=1.8;
    let framef=0;

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

	OverloadDrawLogic;
	yield;
}
    @DrawLoop {
	OverloadDrawLoop;
}

    @Finalize {
	OverFinalize;
	EndingFunc(2);
	PointItems(GetX,GetY,2,0);
    }
}