#TouhouDanmakufu
#Title[Marisa Boss nonspell 2]
#Text[Moo]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\moon.png, 0, 0)]
script_enemy_main {
    let ImgBoss = GetCurrentScriptDirectory~"MarisaSprites.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let t = 0;
	let pie = 0;
	let a = 0;
	let v = 27;
	let x = 0;
	let z = 0;
    let frame = -120;
	let frame2 = 1;
	let n = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
        SetLife(8000);
        SetTimer(60);
        LoadSE(shot);
	LoadSE(bounce);
	LoadSE(shot2);
	SetShotAutoDeleteClip(150, 200, 150, 150);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(200);
	SetDamageRate(300, 120);
	
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(1, 1, 64, 70);
    }

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

	if(frame == 2 || frame==9 || frame==16 || frame==23 || frame==30 || frame==37 || frame==44 || frame == 51 || frame == 58 || frame == 65){
	let a   = 0;
        let num = 14; //Change this number here to specify the number of bullets in the ring.

	loop(num)
            {	
		PlaySE(shot);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, -3.1, v+90+a, 0.01, 0.01, 1, BLUE59);
		SetShotDataA(1, 70, 1, v+90+a, 0.01, 0.05, 2.5, RED59);
		SetShotDataA(1, 190, -2, v+90+a, 0.2, 0.00, 3, GREEN59);
		SetShotDataA(1, 210, 3, v+90+a, 0.2, 0.00, 3, BLUE59);
		SetShotDataA(1, 225, 3, v+90+a, 0.2, 0.00, 3, AQUA59);
		SetShotDataA(1, 240, 3, v+90+a, 0.2, 0.00, 3, PURPLE59);
		SetShotDataA(1, 255, 3, v+90+a, 0.2, 0.00, 3, RED59);
		SetShotDataA(1, 270, 3, v+90+a, 0.2, 0.00, 3, ORANGE59);
		SetShotDataA(1, 285, 3, v+90+a, 0.2, 0.00, 3, YELLOW59);
		SetShotDataA(1, 300, 3, v+90+a, 0.2, 0.00, 3.1, GREEN59);
		v+=0.16;
		
		a +=360/num;
FireShot(1);


}
}        
if(frame==60){
}
if(frame==65){
z=rand_int(-1, 1);
frame=-4;
}
        frame++;
	v++;
	frame2++;
	
    }

if(frame2 == 360){
ExMove;
frame2=0;
}

function Wait(w){loop(w){yield;}}


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;
let frame2 = 0;
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
