

script_enemy_main{
	let Enemy = GetCurrentScriptDirectory~"fairies.png";
	let frame = 50;
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh";
	let death = GetCurrentScriptDirectory~"explode.wav";
	let ani =0;
	let v = 0;
	let frame2 = 0;
	let c = 6;
	let w = 0;
	@Initialize{
	shotinit;
	SetMovePosition02(GetX, GetClipMinY+80, 60);
	LoadSE(death);
	LoadSE(shot);
	SetLife(100);
	 LoadGraphic(Enemy);
       
        

	}

	@MainLoop {
	SetCollisionA(GetX, GetY, 10);
	SetCollisionB(GetX, GetY, 10);
	if(frame == 100){
	w = rand_int(1, 0);
	}

	if(w == 1){
	c = 6;
	}

	if(w == 0){
	c = -6;
	}

	if(frame == 170){
	frame=100;
	}
     

	if(frame2>360){
	SetMovePosition02(GetX, GetY-3, 2);
	frame = 9001;
	}

if(frame==110){
		PlaySE(shot);
	let a   = 0;
        let num = 40; //Change this number here to specify the number of bullets in the ring.

	loop(num)
            {	
		

		CreateShotA(2, GetX, GetY, 2);
		SetShotDataA(2, 0, 0.1, 90+a, 0.11, 0.05, 1, GREEN21);
		SetShotDataA(2, 30, 1, NULL, c, -2, -2, YELLOW21);
		SetShotDataA(2, 60, 0, NULL, 0, 2, 2.4, RED21);
		
		v+=2;
		
		a +=360/num;
		frame2++;
FireShot(2);


}
}        
if(frame == 140){
	PlaySE(shot2);
	}


	if (GetY>500 || GetY<GetClipMinY-20){VanishEnemy;}

	frame++;
	
	}

	 @DrawLoop {
	 SetTexture(Enemy);
	ani++;
	if(ani>0 && ani<4){
	SetGraphicRect(33, 349, 66, 385);
	}
	if(ani>16){
	SetGraphicRect(66, 349, 97, 385);
}
	if(ani>4 && ani<8){
	SetGraphicRect(0, 349, 33, 385);
	}

	if(ani>8 && ani<12){
	SetGraphicRect(99, 349, 129, 385); 
	}

	if(ani>12 && ani<16){
	SetGraphicRect(129, 349, 162, 385);
	}
	if(ani==17){
	ani=0;
	}

	 DrawGraphic(GetX, GetY);
    }
	 @Finalize {
	
	if(GetY<500 && GetY>GetClipMinY-20){
PlaySE(death);

loop(rand_int(1, 3)){
	
	CreateItem(ITEM_SCORE,GetX + rand(-20,20),GetY + rand(-20,20));
	}
    }
	}
	}