#TouhouDanmakufu
#Title[Rumia's Desperate Arcanum "DIE BIYATCH"]
#Text[Title says it all?]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\lol.mp3]
script_enemy_main{


	let ImgBoss="script\ExRumia\img\ExRumia.png"; 
	let frame = -120; 
	let timestop = GetCurrentScriptDirectory~ "timestop.wav";
	let frame2 = 0;
	let angle = 0;
	let angleAcc = 0;
	let radius = 0;
	let b = 1;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let background = GetCurrentScriptDirectory~"patchybackground.png";
	let laser = GetCurrentScriptDirectory~"laser.wav";
	let die = GetCurrentScriptDirectory~"die.wav";
	@Initialize{
		SetLife(10000);
		SetTimer(140);
		shotinit;
		LoadSE(shot);
		LoadMusic(die);
		PlayMusic(die);
		LastSpell;
		SetInvincibility(180);
		LoadGraphic(ImgBoss);
		LoadSE(timestop);
		CutIn(KOUMA, "Rumia's Desperate Arcanum "\""DIE BIYATCH!"\", GetCurrentScriptDirectory~"rumia.png", 0, 0, 128, 256);
		SetMovePosition02(GetCenterX, GetCenterY -120, 120); 
		SetDamageRate(125, 2);
		SetScore(100000);
	LoadGraphic(background);
	SetShotAutoDeleteClip(30, 30, 30, 30);
	}
	
	@MainLoop{
	SetCollisionA(GetX, GetY, 32);
	SetCollisionB(GetX, GetY, 16);
	frame++; 
	frame2++;
if(GetEnemyLife>5000){

if(frame == 0){

	let a   = rand(0, 0.9);
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, RED32, 0);
            a += 360/num;
PlaySE(shot);

}

}

if(frame == 20){

	let a   = rand(10, 100);
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, ORANGE32, 0);
            a += 360/num;
PlaySE(shot);
}

}

if(frame == 40){

	let a   = 0;
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+GetAngleToPlayer, YELLOW32, 0);
            a += 360/num;
PlaySE(shot);
}

}

if(frame == 60){

	let a   = 1;
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, GREEN32, 0);
            a += 360/num;
PlaySE(shot);
}

}


if(frame == 160){

	let a   = 1;
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, BLUE32, 0);
            a += 360/num;
PlaySE(shot);
}

}

if(frame == 180){

	let a   = rand(2, 20);
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, AQUA32, 0);
            a += 360/num;
PlaySE(shot);
}

}

if(frame == 200){

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

}

if(frame == 220){

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

}

if(frame == 240){

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

}

if(frame == 260){

	let a   = rand(3, 30);
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+GetAngleToPlayer, ORANGE32, 0);
            a += 360/num;
PlaySE(shot);
}

}

if(frame == 280){

	let a   = rand(3, 30);
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+GetAngleToPlayer, YELLOW32, 0);
            a += 360/num;
		
PlaySE(shot);
}

}

if(frame == 300){

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

}

if(frame == 320){

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

}

if(frame == 340){

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

}

if(frame == 360){

	let a   = rand(3, 30);
        let num = 70; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, PURPLE32, 0);
            a += 360/num;
	frame=0;
PlaySE(shot);
}

}
	
	let a   = 0;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
if(frame == 100) {
            CreateShot01(GetX, GetY, 5, a+GetAngleToPlayer, BLUE32, 0);
		PlaySE(shot);
		 a += 360/num;
		
}

            
        if(frame == 60) {

        let a   = 0;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        	loop(num){
                 CreateShot01(GetX, GetY, 4.75, a+GetAngleToPlayer, RED32, 0);
		 a += 360/num;
}
}

if(frame == 65) {
let a   = -1;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 4.75, a+GetAngleToPlayer, BLUE32, 0);
		 a += 360/num;
PlaySE(shot);
}
}

if(frame == 70) {
let a   = 2;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){

            CreateShot01(GetX, GetY, 4.5, a+GetAngleToPlayer, RED32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 75) {
let a   = -2;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 4.5, a+GetAngleToPlayer, BLUE32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 80) {
let a   = 3;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 4.25, a+GetAngleToPlayer, RED32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 85) {
let a   = -3;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 4.25, a+GetAngleToPlayer, BLUE32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 90) {
let a   = -4;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 4, a+GetAngleToPlayer, RED32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 95) 
{	let a   = 4;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 4, a+GetAngleToPlayer, BLUE32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 100) {
	let a   = 5;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 3.75, a+GetAngleToPlayer, RED32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 105) {
	let a   = -5;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 3.75, a+GetAngleToPlayer, BLUE32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 110) {
	let a   = 6;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 3.5, a+GetAngleToPlayer, RED32, 0);
		 a += 360/num;
PlaySE(shot);
}
}
if(frame == 115) {
	let a = -6;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num){
            CreateShot01(GetX, GetY, 3.5, a+GetAngleToPlayer, BLUE32, 0);
		 a += 360/num;
		PlaySE(shot);
}
}


	if(frame == 60) {
		TimeStop(100, 1, 1, 1);
                PlaySE(timestop);
}

	if(frame == 361){
	frame=-1
}
}





	
	if(GetEnemyLife<5000 && GetEnemyLife>4000) {
	if(GetEnemyLife<5000 && GetEnemyLife>4950){
DeleteEnemyShotToItem(ALL);
}
	SetDamageRate(40, 0);
	if(GetPlayerType == REIMU_A){
	SetDamageRate(30, 0);
	}


	if(frame == 30 || frame == 60 || frame == 90 || frame == 120 || frame == 150 || frame == 180 || frame == 210 || frame == 240 || frame == 270 || frame == 300){

	let a   = rand(0, 100);
        let num = 65; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2.5, a+90, WHITE05, 0);
            a += 360/num;
		PlaySE(shot);
	
		
	
}

}


	if(frame == 30){
		CreateLaserB(1, 400, 60, BLUE60, 55);
	         SetLaserDataB(1, 0, 2, 0, 0, 0, 0, 110, -0.6);
	        SetShotKillTime(1, 91.5);
	        FireShot(1);
                PlaySE(laser);
	
		CreateLaserB(2, 400, 60, BLUE60, 55);
	        SetLaserDataB(2, 0, 2, 0, 0, 0, 0, 70, 0.6);
	        SetShotKillTime(2, 91.5);
	        FireShot(2);
                PlaySE(laser);
        }

	if(frame == 120){
		CreateLaserB(3, 400, 60, BLUE60, 50);
	         SetLaserDataB(3, 0, 2, 0, 0, 0, 0, 110, 2.8);
	        SetShotKillTime(3, 120);
	        FireShot(3);
                PlaySE(laser);
	
		CreateLaserB(4, 400, 60, BLUE60, 50);
	        SetLaserDataB(4, 0, 2, 0, 0, 0, 0, 70, -2.8);
	        SetShotKillTime(4, 120);
	        FireShot(4);
                PlaySE(laser);
        }
	


	if(frame == 105){
	SetMovePosition02(GetCenterX +120, GetCenterY-120, 120);
	}

	if(frame == 210){
	SetMovePosition02(GetCenterX -120, GetCenterY-120, 120);
	}
	if(frame>301){
	frame=0;
		}	











}

if(GetEnemyLife<4000 && GetEnemyLife>2000){
if(GetEnemyLife<4000 && GetEnemyLife>3950){
DeleteEnemyShotToItem(ALL);
SetMovePosition02(GetCenterX, GetCenterY-120, 120);
}
SetDamageRate(75,0);
if(frame == 60){
	let a = rand(-10, 10);
	let num = 40;

	loop(num)
	{
		CreateLaserA(1, GetX, GetY, 20, 50, BLUE60, 120);
		SetLaserDataA(1, 0, a+GetAngleToPlayer, 0, 10, 0, 0);
		SetShotKillTime(1, 180);
		FireShot(1);
       	a+=360/num;
	
	frame=-20;
    }
	}

	if(frame == 59){PlaySE(laser);}

	
	
	if(frame>120){
	frame=0;
		}	

	if(frame == 70){
	frame=0;
}
}


if(GetEnemyLife<2000 && GetEnemyLife>1000){
if(GetEnemyLife<2000 && GetEnemyLife>1950){
DeleteEnemyShotToItem(ALL);
}
SetDamageRate(25, 0);
if(GetPlayerType == REIMU_A){
	SetDamageRate(35, 0);
	}
if(frame == 60){
	let a   = rand(-10, 35);
        let num = 50; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, GREEN01, 0);
            a += 360/num;
	    
	PlaySE(shot);
}

}

if(frame == 100){
	let a   = rand(-10, 35);
        let num = 50; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, GREEN01, 0);
            a += 360/num;
	    
	
}

}

if(frame == 60){
	let a   = rand(0,56);
        let num = 50; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.5, a+GetAngleToPlayer, BLUE01, 0);
            a += 360/num;
	    
	PlaySE(shot);
}

}

if(frame == 100){
	let a   = rand(0,56);
        let num = 50; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.5, a+GetAngleToPlayer, BLUE01, 0);
            a += 360/num;
	    
	
}

}

if(frame == 90){
	let a   = 2;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, YELLOW03, 0);
            a += 60/num;
	    
	PlaySE(shot);
}

}

if(frame == 90){
	let a   = 4;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.8, a+90, YELLOW03, 0);
            a += 60/num;
	    
	PlaySE(shot);
}

}

if(frame == 90){
	let a   = 2;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+90, YELLOW03, 0);
            a += -60/num;
	    
	PlaySE(shot);
}

}

if(frame == 90){
	let a   = 4;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.8, a+90, YELLOW03, 0);
            a += -60/num;
	    
	PlaySE(shot);
}

}

if(frame == 150){
	let a   = 0;
        let num = 50; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, GREEN01, 0);
            a += 360/num;
	    
	PlaySE(shot);
}

}

if(frame == 150){
	let a   = 2;
        let num = 50; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.5, a+GetAngleToPlayer, BLUE01, 0);
            a += 360/num;
	    
	PlaySE(shot);
}

}

if(frame == 180){
	let a   = 2;
        let num = 4; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+GetAngleToPlayer, YELLOW03, 0);
            a += 60/num;
	    
	PlaySE(shot);
}

}

if(frame == 180){
	let a   = 4;
        let num = 4; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.8, a+GetAngleToPlayer, YELLOW03, 0);
            a += 60/num;
	    
	PlaySE(shot);
}

}

if(frame == 180){
	let a   = 2;
        let num = 4; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2, a+GetAngleToPlayer, YELLOW03, 0);
            a += -60/num;
	    
	PlaySE(shot);
}

}

if(frame == 180){
	let a   = 4;
        let num = 4; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.8, a+GetAngleToPlayer, YELLOW03, 0);
            a += -60/num;
	    
	PlaySE(shot);
}

}

if(frame == 90) {

SetMovePosition03(rand(-50, -15)+GetX, rand(10, 20)+GetY, 3, 1); 

}

if(frame == 180) {

SetMovePosition03(rand(50, 15)+GetX, rand(-10, -20)+GetY, 3, 1); 

}	
	
	if(frame>180){
	frame=-1;
		}	


}

if(GetEnemyLife<1000){
SetDamageRate(30, 0);
SetMovePosition02(GetCenterX, GetCenterY -120, 120);
if(GetEnemyLife<1000 && GetEnemyLife>900){
DeleteEnemyShotToItem(ALL);
}
if(frame == 50){
	let a   = rand(0, 100);
        let num = 110; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, rand_int(-5, 5), a+GetAngleToPlayer, BLUE01, 0);
            a += 360/num;
	    
	PlaySE(shot);
}

}

	
	
	if(frame>50){
	frame=20;
		}	


}
}
	@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);
	}
}
