#TouhouDanmakufu
#Title["Boundary of Consciousness and Unconsciousness"]
#Text[A Rainbow of DEATH!]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\patchybackground.png, 0, -2)]
script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
    let shot = GetCurrentScriptDirectory~"shot.wav";
    let frame = -120;
	let bgm = GetCurrentScriptDirectory~"bgm.wav";
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	let background = GetCurrentScriptDirectory~"patchybackground.png";
	let cms = GetCurrentScriptDirectory~"Couplemoreshots.mp3";
    @Initialize {
        SetLife(12000);
        SetTimer(99);
	LoadSE(shot);
        SetScore(1000000);
	SetEffectForZeroLife(120,150,1.5);
	SetDamageRate(90,0);
	shotinit;
	SetInvincibility(180);
	LoadGraphic(background);
        SetMovePosition02(GetCenterX, 20+GetClipMinY + 120, 120);
         CutIn(KOUMA, "Boundary of Consciousness and Unconsciousness"\", GetCurrentScriptDirectory~"rumia.png", 0, 0, 128, 256);
	LoadSE(cms);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(0, 0, 64, 64);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	
	if(GetPlayerType == REIMU_A){
	SetDamageRate(200, 0);
	}

	if(GetEnemyLife<13000 || GetTimer<=20){

        if(frame == 10){

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

if(GetEnemyLife<=11000 || GetTimer<=20){


if(frame == 10){

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

if(GetEnemyLife<=10000 || GetTimer<=20){
if(frame == 15){

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

if(frame == 15){

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

if(GetEnemyLife<=9000 || GetTimer<=20){
if(frame == 10){

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

if(GetEnemyLife<=8000 || GetTimer<=20){
if(frame == 20){

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

if(GetEnemyLife<=7000 || GetTimer<=20){
if(frame == 30){

	let a   = -2;
        let num = 22; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 2.25, a+GetAngleToPlayer, AQUA32, 0);
            a += 360/num;
	PlaySE(shot);
}
}
}
if(GetEnemyLife<=5000 || GetTimer<=20){
if(frame == 40){

	let a   = 0;
        let num = 24; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 3.25, a+GetAngleToPlayer, WHITE22, 0);
            a += 360/num;
PlaySE(shot);
}
}
}
if(GetEnemyLife<=5500 || GetTimer<20){
SetDamageRate(200, 0);
if(GetPlayerType == REIMU_A){
	SetDamageRate(300, 0);
	}
if(frame == 50){

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


}
}
}

if(GetTimer<=20){
if(frame == 50){

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

if(frame == 51){
frame=0 
}

if(GetEnemyLife<=5000){
PlaySE(cms);

}
if(GetEnemyLife<=5100){
FadeOutMusic(bgm, 1000);
}

if(GetEnemyLife<=4900){
FadeOutMusic(bgm, -1000);
}
        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+= 2;
}

    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
