#TouhouDanmakufu
#Title[Tenko "Charming Seige From All Sides"]
#Text[Go through gaps aggressively.]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    let frame = -120;
	let v = 0;
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let background = GetCurrentScriptDirectory~"patchybackground.png";
    @Initialize {
        SetLife(3300);
        SetTimer(70);
        SetScore(1000000);
	LoadGraphic(background);
	LoadSE(shot);
	SetInvincibility(180);
	shotinit;
	SetDamageRate(100, -100);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CutIn(KOUMA, "Tenko "\""Charming Seige From All Sides"\", GetCurrentScriptDirectory~"rumia.png", 0, 0, 128, 256);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(0, 0, 64, 64);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);

        if(frame == 0) {
	let a   = 8;
        let num = 18; //Change this number here to specify the number of bullets in the ring.
	loop(num)
            {	PlaySE(shot);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 5, a+GetAngleToPlayer+v, 0.55, -0.08, 2, BLUE03);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 40) {
	let a   = 8;
        let num = 18; //Change this number here to specify the number of bullets in the ring.
	loop(num)
            {	PlaySE(shot);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 5, a+GetAngleToPlayer+v, -0.55, -0.08, 2, RED03);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 80) {
	let a   = 8;
        let num = 18; //Change this number here to specify the number of bullets in the ring.
	loop(num)
            {	PlaySE(shot);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 5, a+GetAngleToPlayer+v, 0.55, -0.08, 2, BLUE03);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 120) {
	let a   = 8;
        let num = 18; //Change this number here to specify the number of bullets in the ring.
	loop(num)
            {	PlaySE(shot);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 5, a+GetAngleToPlayer+v, -0.55, -0.08, 2, RED03);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 160) {
	let a   = 8;
        let num = 18; //Change this number here to specify the number of bullets in the ring.
	loop(num)
            {	
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 5, a+GetAngleToPlayer, -0.55, -0.08, 2, RED03);
		a +=360/num;
FireShot(1);
}
        }

	if (frame == 161) {
		frame=-1 }
        frame++;
	

    }

    @DrawLoop {
	SetTexture(ImgBoss);
                SetRenderState(ALPHA);
                SetAlpha(255);  
                SetGraphicScale(1,1);
                SetGraphicAngle(0,0,0);

                if(GetSpeedX==0){
                         SetGraphicRect(0,0,64,64); }
                        
 
                if(GetSpeedX>0){
                        SetGraphicRect(190, 126, 256, 64);
			}
 
                if(GetSpeedX<0){
                        
                        SetGraphicRect(128,128,186,64); }
                      
 
                DrawGraphic(GetX,GetY);
    }

let y = 0;

@BackGround{
   SetTexture(background);
   SetGraphicRect(0, 0 - y, 512, 512 - y);
   DrawGraphic(GetCenterX, GetCenterY);
   y++;
   v++;
}



    @Finalize {
        DeleteGraphic(ImgBoss);
    }




}
