script_enemy_main secant {
    let ImgBoss = GetCurrentScriptDirectory~"secant.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let charge = GetCurrentScriptDirectory~"charge.wav";
	let base = GetCurrentScriptDirectory~"ufo.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let laser = GetCurrentScriptDirectory~"laser.wav";
	let bn = 0;
	let explode = GetCurrentScriptDirectory~"explode.wav";
	let b = 0;
	let tilt = 0;
	let radius = 100;
	let angle = GetAngleToPlayer;
	let alive = 1;
	let waffle = 1;
	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(85000);
	LoadSE(base);
	LoadSE(laser);
	SetCommonData("alive", true);
        SetTimer(99999999);
        LoadSE(shot);
	SetCommonData("secy", GetY);
	SetCommonData("secx", GetX);
	LoadSE(bounce);
	LoadSE(charge);
	LoadSE(shot2);
	SetShotAutoDeleteClip(100, 200, 100, 100);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(120);
	SetDamageRate(0, 0);        
	SetMovePosition02(GetCenterX-100, GetClipMinY + 120, 120);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(1, 1, 128, 128);
    }

    @MainLoop {
	b+=0.01;
	SetCollisionA(GetX, GetY, 16);
	SetCollisionB(GetX, GetY, 16);


	SetCommonData("secy", GetY);
	SetCommonData("secx", GetX);

	if(frame ==0){
	Concentration01(60);
	PlaySE(GetCurrentScriptDirectory~"charge.wav");
	}

	if(frame == 60){
	PlaySE(base);
	let a = GetAngleToPlayer;
	let num = 4;
	loop(num){
	
	CreateLaserB(1, 75, 15, ORANGE21, 20);
	SetLaserDataB(1, 0, 0, 0, 0, 0, 0, 90+a, 3);
	SetShotKillTime(1, 300);
	a+=360/num;
	FireShot(1);
	
	}
}

	if(frame == 40){
	
	SetMovePosition02(GetClipMinX+10, GetClipMinY+50, 80);

	}

	if(frame==-30){
		PlaySE(bounce);

	

	let a = GetAngleToPlayer;
	let num = 25;
	loop(num){
	CreateLaser01(GetCenterX, GetClipMinY, 3, GetAngleToPlayer+a, 950, 10, RED21, 0);
	CreateLaser01(GetCenterX, GetClipMinY, 3, GetAngleToPlayer+a, 0.000001, 0.0000001, RED21, 270);
	a+=360/num;
	}

	}

	if(frame==120){
	SetMovePosition02(GetClipMinX+10, GetClipMaxY-50, 80);
	}

	if(frame==200){
	
	
	
	SetMovePosition02(GetClipMaxX-10, GetClipMaxY-50, 80);

	}

	if(frame==280){
	
	SetMovePosition02(GetClipMaxX-10, GetClipMinY+50, 80);
	}

	if(frame == 300){
	PlaySE(GetCurrentScriptDirectory~"charge.wav");
	}

	if(frame==360){

	SetMovePosition02(GetPlayerX, GetPlayerY, 80);
	}
	if(frame==350){
	PlaySE(base);
	let a = 0;
	let num = 4;
	loop(num){
	CreateLaserB(1, 75+b, 15, ORANGE21, 0);
	SetLaserDataB(1, 0, 0, 0, 0, 0, 0, 90+a, 10);
	SetShotKillTime(1, 160);
	a+=360/num;
	FireShot(1);
	}
	}

	if(frame == 420){
	PlaySE(charge);
	Concentration01(60);
	}

	if(frame == 480){
	frame=-40;
	}

	yield;
	frame3++;

	
        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-70 - ud, height + ud), 5, 11);
		} else {
			SetMovePosition03(GetX - length, rand(height-70 - ud, height + ud), 5, 11);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length, rand(height-70 - ud, height + ud), 5, 11);
		} else {
			SetMovePosition03(GetX + length, rand(height-70 - 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(360);
		alive=1;
		SetDamageRate(25, 40);
		AddLife(GetLife);
		
		Explosion01(GetX, GetY, 50, 1, 60);
		xy=0;
		tilt=0;
		frame3=-10;
		SetCommonData("alive", true);
		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);
    }
}
