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

script_enemy_main {
    let ImgBosss = GetCurrentScriptDirectory~"fairies.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let explode = GetCurrentScriptDirectory~"explode.wav";
	let t = 0;
	let a = 0;
	let b = 0;
	let v = 1;
	let angle = 50;
	let radius = 50;
	let z = 0;
    let frame = -120;
	let frame = 0;
	let frame2 = 1;
	let n = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
        SetLife(100);
        SetTimer(9999);
        LoadSE(shot);
	LoadSE(bounce);
	LoadSE(shot2);
	SetShotAutoDeleteClip(200, 200, 200, 40);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(10);
	SetDamageRate(100, 100);
        
        LoadGraphic(ImgBosss);
        SetTexture(ImgBosss);
        SetGraphicRect(0, 290, 30, 318);
	
    }

    @MainLoop {
	if(frame == 30){
	PlaySE(shot2);
	}

	if(frame == 20){
	

let a   = rand(0, 100);
        let num = 1; //Change this number here to specify the number of bullets in the ring.
	PlaySE(bounce);
	loop(num)
            {	
		CreateShotA(1, GetX, GetY, 10);
		SetShotDataA(1, 0, 0, angle, -1, -0.1, 0, YELLOW58);
		SetShotDataA(1, 0, 0, NULL, 1, 0.1, 0, YELLOW58);
		SetShotDataA(1, 60, 0, NULL, -1, -0.1, 0, YELLOW58);
		SetShotDataA(1, 120, 0, NULL, 1, 0.2, 0, YELLOW58);
		SetShotKillTime(1, 158);
		ascent(i in 1..10){
		
	PlaySE(shot);
	
		CreateShotA(2, 0, 0, 30);
		SetShotDataA(2, 0, 0, atan2(GetCenterY-GetY,GetCenterX-GetX), 0.01, 0.02, 1.5, RED58);
		AddShot(120, 1, 2, NULL);
		}
		angle +=360/num;
FireShot(1);

}
        }
if(GetX>GetClipMaxX+20 || GetX<GetClipMinX-20||GetY>GetClipMaxY+20 || GetY<GetClipMinY-20){
	SetSpeed(1);
	SetAngle(atan2(GetCenterY-GetY+v, GetCenterX-GetX+v));
	
	}
	if(frame == 50){
	frame=0;
	}


        frame++;
	v+=0.02;
	b+=1;
	
    }

function Wait(w){loop(w){yield;}}




    @DrawLoop {
		SetGraphicAngle(0,0,b);
                DrawGraphic(GetX,GetY);
    }
let v = 0;
    @Finalize {
        DeleteGraphic(ImgBosss);
    }
}
