
script_enemy_main secant {
    let ImgBoss = GetCurrentScriptDirectory~"secant.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let revive = GetCurrentScriptDirectory~"revive.wav";
	let explode = GetCurrentScriptDirectory~"explode.wav";
	let charge = GetCurrentScriptDirectory~"charge.wav";
	let tilt = 0;
	let alive = 1;
	SetCommonData("secy", GetY);
	SetCommonData("secx", GetX);
	let moo = 867;
	let xy = 0;
	let frame3=60;
	let nyan = 1;
	let v = 1;
    let frame = -90;
	let frame2 = 1;
	let n = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
        SetLife(750);
	SetCommonData("alive", true);
	LoadSE(charge);
        SetTimer(99999999);
	LoadSE(revive);
        LoadSE(shot);
	SetCommonData("secy", GetEnemyY);
	SetCommonData("secx", GetEnemyX);
	LoadSE(bounce);
	LoadSE(shot2);
	SetShotAutoDeleteClip(100, 200, 100, 100);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(120);
	SetDamageRate(25, 40);        
	SetMovePosition02(GetCenterX-100, GetClipMinY + 120, 120);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(1, 1, 128, 128);
    }

    @MainLoop {
	SetCommonData("secy", GetY);
	SetCommonData("secx", GetX);


	yield;
	frame3++;

	if(nyan ==2){

	AddLife(20);
	nyan=1;
	}
	if(tilt == 0){
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	}

	if(tilt == 1){
	SetCollisionA(GetX, GetY, 0);
        SetCollisionB(GetX, GetY, 0);
	}
	if(GetLife<500){
	SetDamageRate(0, 0);
	alive=2;
	nyan=2;
	}
	

if(alive==2){
alive=30;
dead;
SetCommonData("alive", false);
SetCommonData("lol", true);


}


if(frame3==0){
let a = 0;
let num = 50;
loop(num){
PlaySE(revive);
CreateShot01(GetX, GetY, 2.25, a+GetAngleToPlayer, YELLOW57, 2.5);
CreateShot01(GetX, GetY, 1.25, a+GetAngleToPlayer, YELLOW57, 0);
	    CreateShot01(GetX, GetY, 3.25, a+GetAngleToPlayer, YELLOW57, 5);
		a+=360/num;
}
}




if(tilt==1){
frame=-60;
}

if(frame == 109){
frame2=rand_int(1, 2);
}
if(frame == 110){
	
	ExMove;
	let a   = 0;
        let num = 30; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
		
            CreateShot01(GetX, GetY, 2, a+GetAngleToPlayer, RED57, 2.5);
		CreateShot01(GetX, GetY, 1.5, a+GetAngleToPlayer, RED57, 0);
	    CreateShot01(GetX, GetY, 2.5, a+GetAngleToPlayer, RED57, 5);
	    
            a += 360/num;
	PlaySE(bounce);
	frame=0;
	
		

}

}


if(frame == 110){
frame=0;
}



yield;
        frame++;
	
	
    }


sub ExMove { ExMove_(GetCenterY-75, 30, rand(15, 30)); }
function ExMove_(height, ud, length) {
	
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length, rand(height+20 - 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.

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

task LifeGet{ AddLife(1); }

task dead{	

loop(1){
		PlaySE(explode);
		Explosion01(GetX, GetY, 50, 1, 60);
		SetDamageRate(0, 0);
		tilt=1;
		xy = 1;
		wait(280);
		Concentration01(60);
		PlaySE(charge);
		wait(80);
			SetCommonData("alive", true);
		alive=1;
		SetDamageRate(25, 40);
		AddLife(GetLife);
		
		Explosion01(GetX, GetY, 50, 1, 60);
		xy=0;
		tilt=0;
		frame3=-10;
	
		yield;
		
}
}



    @DrawLoop {
		if(tilt == 0){
		SetGraphicAngle(0, 0, 0);
                DrawGraphic(GetX,GetY);
		}

		if(tilt == 1){
		SetTexture(ImgBoss);
		SetGraphicAngle(0, 0, 90);
		DrawGraphic(GetX, GetY);
}
    }
let v = 0;
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
