#TouhouDanmakufu
#Title[Nonspell 4]
#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(3500);
        SetTimer(50);
	LoadSE(shot);
	SetDamageRate(90, 25);
	SetInvincibility(250);
	shotinit;
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CreateItem(ITEM_SCORE, rand(50, -50)+GetX, rand(10, -10)+GetY);
	CreateItem(ITEM_1UP, rand(50, -50)+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 == 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 == 45) {
            CreateShot01(GetX, GetY, 7, GetAngleToPlayer, RED01, 0);
 	    CreateShot01(GetX, GetY, 6, -7+GetAngleToPlayer, RED02, 0); 
	    CreateShot01(GetX, GetY, 0.75, GetAngleToPlayer, RED03, 0);
            CreateShot01(GetX, GetY, 5.5, -1+GetAngleToPlayer, RED04, 0); 
	CreateShot01(GetX, GetY, 5, 1+GetAngleToPlayer, RED05, 0); 
	CreateShot01(GetX, GetY, 2, -2.5+GetAngleToPlayer, RED11, 0); 
	CreateShot01(GetX, GetY, 1, 4+GetAngleToPlayer, RED12, 0); 
	CreateShot01(GetX, GetY, 4, -3.5+GetAngleToPlayer, RED21, 0); 
	CreateShot01(GetX, GetY, 5.98, -6+GetAngleToPlayer, RED22, 0); 
	CreateShot01(GetX, GetY, 6, 7+GetAngleToPlayer, RED23, 0); 
	CreateShot01(GetX, GetY, 5, -2.5+GetAngleToPlayer, RED31, 0); 
	CreateShot01(GetX, GetY, 3, 8+GetAngleToPlayer, RED32, 0); 
	PlaySE(shot);
        }

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

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

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



	if(frame == 225){
	frame=0 }
        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);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
    }




}
