#TouhouDanmakufu
#Title[Nonspell 4 Hard]
#Text[Moo]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\moon.png, 0, 0)]
script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
    let frame = -200;
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
        SetLife(2000);
        SetTimer(50);
	LoadSE(shot);
	shotinit;
	SetInvincibility(250);
	SetDamageRate(100, 100);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
	CreateItem(ITEM_1UP, rand(100, -100)+GetX, rand(10, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -40)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);
	CreateItem(ITEM_SCORE, rand(70, -70)+GetX, rand(40, -10)+GetY);

        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(0, 0, 64, 64);
    }

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

       
if(frame == 180 || frame == 45 || frame == 135 || frame == 90) {
            CreateShot01(GetX, GetY, 7, GetAngleToPlayer, RED01, 0);
 	    CreateShot01(GetX, GetY, 6, -7+GetAngleToPlayer, RED02, 0); 
	    
            CreateShot01(GetX, GetY, 5.5, rand(1, -1)+GetAngleToPlayer, RED04, 0); 
	CreateShot01(GetX, GetY, 5, rand(1, 10)+GetAngleToPlayer, RED05, 0); 
	CreateShot01(GetX, GetY, 2, rand(-2.5, 2.5)+GetAngleToPlayer, RED11, 0); 
	CreateShot01(GetX, GetY, 1, rand(4, -4)+GetAngleToPlayer, RED12, 0); 
	CreateShot01(GetX, GetY, 4, rand(3.5,-3.5)+GetAngleToPlayer, RED21, 0); 
	CreateShot01(GetX, GetY, 5.98, rand(-6, 6)+GetAngleToPlayer, RED22, 0); 
	CreateShot01(GetX, GetY, 6, rand(7, -7)+GetAngleToPlayer, RED23, 0); 
	CreateShot01(GetX, GetY, 5, rand(-2.5, 2.5)+GetAngleToPlayer, RED31, 0); 
	CreateShot01(GetX, GetY, 3, rand(8, -8)+GetAngleToPlayer, RED32, 0); 
	PlaySE(shot);
        }

if(frame == 45) {
let a   = 0;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.5, a+GetAngleToPlayer, PURPLE02, 0);
            a += 360/num;

}

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

}

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

}

}

if(frame == 180) {
let a   = 0;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1.5, a+GetAngleToPlayer, PURPLE02, 0);
            a += 360/num;

}

}

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

}
if(frame == 120) {

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

}

if(frame == 60) {

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

}

	if(frame == 226){
	frame=0 }
        frame++;
	

    }

    @DrawLoop {
        SetTexture(ImgBoss);
                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);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
    }




}
