script_enemy_main
{

	#include_function".\..\function\glo_enemydrop.txt";
	#include_function".\stage2_Boss_Info.txt";


	sfx01 = "t";

	sfx11 = "t";

	sfx21 = "t";

	sfx50 = "t";
	sfx51 = "t";

	#include_function".\..\function\soundfx.txt";

	ng_timeset = 75;
	ng_spellcard = 1;

	let frame1 = 0;
	let frame2 = 0;


//-------------------------------------------------------------------------------------------------
// Any Task


	function rood_drone(drone_angle, maxshot, density, speed, Xpos, Ypos)
	{
	PlaySE(sfx01);
	CreateShotA(1, Xpos, Ypos, 0);
	SetShotDataA(1, 0, 0, drone_angle, 0, 0.2, 8, GREEN21);
		ascent(i in 0..maxshot)
		{
		CreateShotA(2, 0, 0, 30);
		SetShotDataA(2, 0, 0, 0, 0, 0, 5, GREEN01);
		SetShotDataA(2, 30, 0, SetShotDirectionType(PLAYER), 0, 0.1, speed, GREEN01);
		AddShot(i*density, 1, 2, 0);
		}
	SetShotDirectionType(ABSOLUTE);
	FireShot(1);
	}


//---------------------------------------------------------------

	@Initialize
	{
	SetInvincibility(60);
	SetLife(350);
	SetDamageRate(0,0);
	SetTimer(ng_timeset);
	SetScore(700000);

	SetMovePosition02(GetCenterX, GetClipMinY + 100, 30);
	CutIn(YOUMU, "Engineering Type "\""Guarding Bot"\", BossCutin, BCR_x1, BCR_y1, BCR_x2, BCR_y2);


	LoadGraphic(BossSprite);

	// Fever score decrease if this is not survival card.
	SetCommonData("ng_feverdecrease", 1);

//	Concentration01(90);
//	PlaySE(GetCurrentScriptDirectory~"..\sfx\Charge.wav");

	}

//---------------------------------------------------------------

	@MainLoop 
	{
	SFU_GloBossCounter;

	SetCollisionA(GetX, GetY, 32);
	SetCollisionB(GetX, GetY, 16);

//----------------------
// Attack script below
//----------------------

	if (ng_sframe == 1)
	{
	CreateEnemyFromFile(GetCurrentScriptDirectory~"stage2_DropItemBossSpell2.txt", GetCenterX, GetClipMinY+100, 0, 0, 0);
	}

	if (ng_sframe == 60)
	{
	ng_start = 1;
	frame1 = 0;
	frame2 = 0;
	}

	if ((ng_start == 1) && (frame1 == 1))
	{
	Concentration01(60);
	}



//Lunatic
if (GetCommonData("CD_gamemode") == 2)
{
	if ((ng_start == 1) && (frame1 == 60))
	{
	PlaySE(sfx21);
	ascent (i in 0..6)
		{
		CreateEnemyFromFile(GetCurrentScriptDirectory~"stage2_familiar02.txt", GetX, GetY, 0, 0, i*60);
		}
	}

	if ((ng_start == 1) && (frame1 == 420))
	{
	frame1 = 0;
	}


	if ((ng_start == 1) && (frame2 >= 90) && (frame2%10 == 0))
	{
	PlaySE(sfx01);
		ascent(i in 0..24)
		{
		CreateShot02(GetX, GetY, 0, GetAngleToPlayer+(i*15), 0.05, 3, YELLOW02, 10);
		}
	}

	if ((ng_start == 1) && (frame2 == 135))
	{
	frame2 = 0;
	}
}
else
{
	if ((ng_start == 1) && (frame1 == 60))
	{
	PlaySE(sfx21);
	ascent (i in 0..6)
		{
		CreateEnemyFromFile(GetCurrentScriptDirectory~"stage2_familiar02.txt", GetX, GetY, 0, 0, i*60);
		}
	}

	if ((ng_start == 1) && (frame1 == 420))
	{
	frame1 = 0;
	}


	if ((ng_start == 1) && (frame2 >= 90) && (frame2%10 == 0))
	{
	PlaySE(sfx01);
		ascent(i in 0..18)
		{
		CreateShot02(GetX, GetY, 0, GetAngleToPlayer+(i*20), 0.05, 3, YELLOW02, 10);
		}
	}

	if ((ng_start == 1) && (frame2 == 135))
	{
	frame2 = 0;
	}
}







	if (ng_bossmframe == 120)
	{
	SetMovePositionRandom01(rand_int(25,75), rand_int(5,15), 50, GetClipMinX+100, 30, GetClipMaxX-100, 150);
	ng_bossmframe = 0;
	}



	frame1++;
	frame2++;

//----------------------
// Attack script above
//----------------------

	#include_function".\..\function\glo_timernotice.txt";
	yield;
	}

//---------------------------------------------------------------

	@DrawLoop
	{
	SetTexture(BossSprite);
	SetGraphicAngle(0, 0, 0);
	SetGraphicScale(1, 1);
	#include_function".\..\function\boss_draw.txt";
	}

//---------------------------------------------------------------

	@BackGround
	{
	LoadGraphic(BossBG1);
	SetTexture(BossBG1);
	SetGraphicRect( 0, 0, 256, 256);
	SetGraphicScale(2, 2);
	SetGraphicAngle(0, 0, 0);
	SetAlpha(255);
	DrawGraphic(GetCenterX, GetCenterY);
	}

//---------------------------------------------------------------

	@Finalize
	{
	EnemyDropItem(1, 25);
	if(GotSpellCardBonus)
		{	
		PlaySE(GetCurrentScriptDirectory~"..\sfx\SpellBonus.wav");
		AddScore(ng_spellbonus * (GetCommonDataDefault("CD_FeverMultiplyUse",1)-1))
		}
	DeleteGraphic(BossSprite);
	DeleteGraphic(BossBG1);
	SFX_Delete;
    	}
}
