#TouhouDanmakufu
#Title[Secant nonspell]
#Text[SECANTCOSINE!]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\moon.png, 0, 0)]
script_enemy_main {
    let ImgBoss = GetCurrentScriptDirectory~"sprite.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
    let frame = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
        SetLife(1500);
        SetTimer(35);
        LoadSE(shot);
	LoadSE(shot2);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(60);
	SetDamageRate(100, 100);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(1, 1, 128, 128);
    }

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

if(frame == 50 || frame==53 || frame==56 || frame==59 || frame==62 || frame == 65 || frame == 68 || frame == 71 || frame == 74 || frame == 77 || frame == 80 || frame == 83 || frame == 86 || frame == 89 || frame == 92 || frame == 95 || frame == 98 || frame == 101 || frame == 104 || frame == 107 || frame == 110){
	let a   = 0;
        let num = 15; //Change this number here to specify the number of bullets in the ring.
	PlaySE(shot2);
	loop(num)
            {	
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 6, a+90+v, -0.07, -0.2, 2.25, GREEN56);
		a +=360/num;
FireShot(1);
}
        }

if(frame == -1 || frame==2 || frame==5 || frame==8 || frame==11 || frame == 14 || frame == 17 || frame == 20 || frame == 23 || frame == 26 || frame == 29 || frame == 32 || frame == 35 || frame == 38 || frame == 41 || frame == 44 || frame == 47 || frame == 50){
	let a   = 8;
	PlaySE(shot2);
        let num = 15; //Change this number here to specify the number of bullets in the ring.
	loop(num)
            {	
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 6, a+90+v, -0.07, -0.2, 2.25, GREEN56);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 120){
	ExMove;
	let a   = 8;
        let num = 25; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
		PlaySE(shot);
            CreateShot01(GetX, GetY, 2, a+GetAngleToPlayer, GREEN03, 0);
            a += 360/num;
	PlaySE(shot);
		frame=-10;

}

}








if(frame>50){
       v+=3;
	}
if(frame<50){
	v+=-2.95;
	}
        frame++;
    }


sub ExMove { ExMove_(GetCenterY-100, 30, rand(15, 30)); }
function ExMove_(height, ud, length) {
	
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length, rand(height - ud, height + ud), 5, 11);
		} else {
			SetMovePosition03(GetX - length, rand(height - ud, height + ud), 5, 11);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length, rand(height - ud, height + ud), 5, 11);
		} else {
			SetMovePosition03(GetX + length, rand(height - ud, height + ud), 5, 11);
		}
	}
}
	// Movement functions for the boss to move towards the player.
    @DrawLoop {

                DrawGraphic(GetX,GetY);
    }
let v = 0;
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
