#TouhouDanmakufu
#Title[EnemyD]
#Text[Moo]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\moon.png, 0, 0)]
#BGM[.\bgm2.mp3]

script_enemy_main{
	let Enemy = GetCurrentScriptDirectory~"fairies.png";
	let frame = -30;
	let frame2= 0;
	let frame3= 0;
	let v = 60;
	let ani = 0;
	let shot = GetCurrentScriptDirectory~"shot.wav";
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh";
	let death = GetCurrentScriptDirectory~"explode.wav";

	@Initialize{
	shotinit;
	SetMovePosition02(GetX, GetClipMinY+100, 120);
	LoadSE(shot);
	SetLife(1500);
	LoadSE(death);
	LoadGraphic(Enemy);
        SetInvincibility(120);

	}

	@MainLoop {
	SetCollisionA(GetX, GetY, 18);
	SetCollisionB(GetX, GetY, 14);
	

	if(frame2>900){
	SetMovePosition02(GetX, GetY-2, 2);
	}
	
	if(frame == 60){
	PlaySE(shot);
	let a   = 0;
        let num = 2; //Change this number here to specify the number of bullets in the ring.

	loop(num)
            {	
		

		CreateShotA(2, GetX, GetY, 2);
		CreateShotA(3, GetX, GetY, 2);
		SetShotDataA(2, 0, 0.1, 80+a+frame3, 0.11, 0.05, -2, PURPLE56);
		SetShotDataA(2, v, -4, NULL, -0.1, -0.5, -2, PURPLE56);
		SetShotDataA(3, 0, 0.1, 80+a+frame3, 0.11, 0.05, -2, PURPLE56);
		SetShotDataA(3, v, -4, NULL, 0.1, -0.5, -2, PURPLE56);
		
		
		
		a +=360/num;
		
FireShot(2);
FireShot(3);
frame=59;
}
}        
	

	if (GetY<GetClipMinY-20){VanishEnemy;}
	
	frame++;
	frame2++;
	frame3+=10.1;
	yield;
	}


	@DrawLoop {
	 SetTexture(Enemy);
	ani+=0.5;
	if(ani>0 && ani<2){
	SetGraphicRect(65, 449, 130, 510);
	}
	if(ani>9){
	SetGraphicRect(131, 449, 193, 510);
}
	if(ani>2 && ani<4){
	SetGraphicRect(0, 449, 63, 510);
	}

	if(ani>4 && ani<6){
	SetGraphicRect(198, 449, 255, 510); 
	}

	if(ani>6 && ani<9){
	SetGraphicRect(257, 449, 320, 510);
	}
	if(ani==10){
	ani=0;
	}

	 DrawGraphic(GetX, GetY);
    }
	 @Finalize {
	
	if(GetY>GetClipMinY+20){ PlaySE(death); loop(rand_int(1, 3)){
	CreateItem(ITEM_SCORE,GetX + rand(-20,20),GetY + rand(-20,20));
	}
    }
	}
	}