script_enemy_main
{


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

	sfx01 = "t";

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

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

	ng_timeset = 60;
	ng_spellcard = 1;

	let frame1 = 0;
	let frame2 = 0;




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

	function rood_drone(drone_angle, maxshot, density, maxspeed, killtime)
	{
	PlaySE(sfx01);
	CreateShotA(1, GetX, GetY, 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.005, maxspeed, GREEN01);	
		SetShotKillTime(2, killtime);
		AddShot(i*density, 1, 2, 0);
		}
	SetShotDirectionType(ABSOLUTE);
	FireShot(1);
	}



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

	@Initialize
	{
	SetInvincibility(60);
	SetLife(300);
	SetDamageRate(0,0);
	SetTimer(ng_timeset);
	SetScore(600000);

	SetMovePosition02(GetCenterX, GetClipMinY + 45, 30);
	CutIn(YOUMU, "Engineering Type "\""Scratter Swarm"\", 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);

	SetShotDirectionType(ABSOLUTE);

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

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




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



	// Lunatic
	if (GetCommonData("CD_gamemode") == 2)
{
	if ((ng_start == 1) && (frame1 == 120))
	{
	ascent (i in 0 .. 8)
		{
		rood_drone(i*45, 15, 6, 1, 300);
		}
	frame1 = 0;
	}

	if ((ng_start == 1) && (frame2 == 60))
	{
	PlaySE(sfx01);
		ascent(i in 0..72)
		{
		CreateShot02(GetX, GetY, 0, i*5, 0.05, 2, YELLOW02, 10);
		}
	frame2 = 0;
	}
}
// Normal
else
{
	if ((ng_start == 1) && (frame1 == 120))
	{
	ascent (i in 0 .. 8)
		{
		rood_drone(i*45, 10, 8, 0.5, 450);
		}
	frame1 = 0;
	}

	if ((ng_start == 1) && (frame2 == 60))
	{
	PlaySE(sfx01);
		ascent(i in 0..36)
		{
		CreateShot02(GetX, GetY, 0, i*10, 0.05, 3, YELLOW02, 10);
		}
	frame2 = 0;
	}
}









	if (ng_bossmframe == 120)
	{
	SetMovePositionRandom01(rand_int(25,75), 5, 15, GetClipMinX+100, 30, GetClipMaxX-100, 90);
	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
	{
	loop (30)	{	EnemyDropItem(1, 25);	}
	if(GotSpellCardBonus)
		{	
		PlaySE(GetCurrentScriptDirectory~"..\sfx\SpellBonus.wav");
		AddScore(ng_spellbonus * (GetCommonDataDefault("CD_FeverMultiplyUse",1)-1))
		}
	DeleteGraphic(BossSprite);
	DeleteGraphic(BossBG1);
	SFX_Delete;
    	}
}
