#TouhouDanmakufu
#Title["Tiger Patterned Vaisravana"]
#Text[To reach the spellcard standards, Rumia's hitbox size has been upgraded to "Letty Type".]
#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 ufo = GetCurrentScriptDirectory~"ufo.wav";
	let shot3 = GetCurrentScriptDirectory~"shot3.wav";
	let laser = GetCurrentScriptDirectory~"laser.wav";
	let background = GetCurrentScriptDirectory~"patchybackground.png";
    @Initialize {
        SetLife(3500);
        SetTimer(60);
        SetScore(1000000);
	SetInvincibility(180);
	shotinit;
	LoadGraphic(background);
        SetMovePosition02(GetCenterX, GetCenterY, 120);
       CutIn(KOUMA, "Tiger Patterned Vaisravana", GetCurrentScriptDirectory~"rumia.png", 0, 0, 128, 256);
	LoadSE(ufo);
	LoadSE(shot3);
	LoadSE(laser);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(0, 0, 64, 64);
	SetDamageRate(50, 0);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 200);
        SetCollisionB(GetX, GetY, 16);
	if(GetPlayerType == REIMU_A){
	SetDamageRate(70, 0);
	}
        if(frame == 60) {
            CreateLaserB(1, 500, 50, GREEN60, 180);
	    CreateLaserB(2, 500, 50, GREEN60, 180);
	    CreateLaserB(3, 500, 50, GREEN60, 180);
	     CreateLaserB(4, 500, 50, GREEN60, 180);	
	        SetLaserDataB(1, 0, 0, 0, 0, 0, 0, 90, 0.5);
	        SetLaserDataB(2, 0, 0, 0, 0, 0, 0, 180, 0.5);
                SetLaserDataB(3, 0, 0, 0, 0, 0, 0, 270, 0.5);
		SetLaserDataB(4, 0, 0, 0, 0, 0, 0, 360, 0.5);
		SetShotKillTime(1,850);
		SetShotKillTime(2,850);
		SetShotKillTime(3,850);
		SetShotKillTime(4,850);
	    	FireShot(1);
		FireShot(2);
		FireShot(3);
		FireShot(4);
		
		PlaySE(ufo);
         
        }
	if(frame == 20 || frame == 60 || frame == 100 || frame == 140 || frame == 180 || frame == 220 || frame == 260 || 
	 frame == 300 || frame == 340 || frame == 380 || frame == 420 || frame == 460 || frame == 500 || frame == 540 ||
	 frame == 580 || frame == 620 || frame == 660 || frame == 700 || frame == 740 || frame == 780 || frame == 820 || 
         frame == 860 || frame == 900 || frame == 940 || frame == 980 || frame == 1020 || frame == 1060 || frame == 1100 || 
	 frame == 1140 || frame == 1180 || frame == 1220 || frame == 1260 || frame == 1300 || frame == 1340 || frame == 1380 || 
	 frame == 1420 || frame == 1440){

	let a   = rand(0, 90);
        let num = 14; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 3, a+90, RED54, 0);
            a += 360/num;
	PlaySE(shot3);
}

}



	if(frame == 240){

	PlaySE(laser);

}
	if(frame == 720) {
            CreateLaserB(5, 500, 50, GREEN60, 180);
	    CreateLaserB(6, 500, 50, GREEN60, 180);
	    CreateLaserB(7, 500, 50, GREEN60, 180);
	     CreateLaserB(8, 500, 50, GREEN60, 180);	
	    SetLaserDataB(5, 0, 0, 0, 0, 0, 0, 90, -0.5);
	    SetLaserDataB(6, 0, 0, 0, 0, 0, 0, 180, -0.5);
            SetLaserDataB(7, 0, 0, 0, 0, 0, 0, 270, -0.5);
		SetLaserDataB(8, 0, 0, 0, 0, 0, 0, 360, -0.5);
		SetShotKillTime(5,1080);
		SetShotKillTime(6,1080);
		SetShotKillTime(7,1080);
		SetShotKillTime(8,1080);
	    	FireShot(5);
		FireShot(6);
		FireShot(7);
		FireShot(8);
		
		PlaySE(ufo);
         
        }
	
	if(frame == 900){

	PlaySE(laser);

}
	if(frame == 1441) {
	frame=-59;

	}
        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++;
}

    @Finalize {
        DeleteGraphic(ImgBoss);
    }




}
