script_enemy_main
{



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


	sfx01 = "t";
	sfx03 = "t";
	sfx04 = "t";

	sfx11 = "t";

	sfx44 = "t";

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

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

	ng_timeset = 71;
	ng_spellcard = 1;






	let ng_degree = 0;
	let ng_playerx = 0;

	let frame1 = 0;
	let frame2 = 0;
	let frame3 = 0;
	let frame4 = 0;


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


	function Firefall(posX, posY)
	{
	CreateShotA(0, posX, posY, 0);
	SetShotDataA(0, 0, 0, SetShotDirectionType(PLAYER), 0, 0.1, 5, RED02);
	SetShotDirectionType(ABSOLUTE);
		ascent(i in 1..200)
		{
		CreateShotA(i, 0, 0, 60);
		SetShotDataA(i, 0, 0, 0, 0, 0, 0, RED05);
		SetShotKillTime(i, 2);
		AddShot(i*3, 0, i, 0);
		}
	FireShot(0);
	}

	function FireWave(posX, posY, num)
	{
	ascent (i in 0 .. num)
		{
		CreateShot12(posX+rand(-25, 25), posY, rand(-3, 3), rand(-2, -5), 0, 0.05, 0, 5, RED11, 10);
		}
	}

	function FireWaveUp(posX, posY, num)
	{
	ascent (i in 0 .. num)
		{
		CreateShot12(posX+rand(-25, 25), posY, rand(-3, 3), rand(3, 6), 0, -0.05, 0, -5, RED11, 10);
		}
	}

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

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

	SetMovePosition02(GetCenterX, GetClipMinY + 100, 30);
	CutIn(YOUMU, "Fire Esper "\""Inferno Fall"\", 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~"stage3_DropItemBossSpell1.txt", GetCenterX, GetClipMinY+100, 0, 0, 0);
	}


	if (ng_sframe == 30)
	{
	ng_start = 1;
	frame1 = 0;
	frame2 = 0;
	frame3 = 0;
	frame4 = 0;
	PlaySE(sfx04);
	CreateLaserA(0, GetX, GetY, 500, 6, RED01, 0);
	SetLaserDataA(0, 0, 200, 0, 0, 0, 0);
	SetLaserDataA(0, 10, 190, 8, 0, 0, 0);
	SetShotKillTime(0, 30);
	FireShot(0);
	}

	if (ng_sframe == 60)
	{
	ng_start = 2;
	frame1 = 0;
	frame2 = 0;
	frame3 = 0;
	frame4 = 0;
	}

	if ((ng_start == 2) && (frame3 == 5))
	{
	ascent(i in 0..5)
		{
		CreateShotA(0, rand(GetClipMinX, GetClipMaxX), rand(GetClipMinY, GetClipMinY+50), 60);
		SetShotDataA(0, 0, 0, 0, 0, 0, 0, RED01);
		SetShotKillTime(0, 0);
		FireShot(0);
		}
	CreateShotA(0, rand(GetClipMinX, GetClipMaxX), rand(GetClipMinY, GetClipMinY+20), 60);
	SetShotDataA(0, 0, 1.5, rand(80,100), 0, -0.05, 0.5, RED11);
	SetShotKillTime(0, 120);
	FireShot(0);
	frame3 = 0;
	}








	if ((ng_start == 2) && (frame1 >= 5) && (ng_sframe >= 300))
	{
	ascent(i in 0..5)
		{
		CreateShotA(0, rand(GetClipMinX, GetClipMaxX), rand(GetClipMaxY-35, GetClipMaxY), 60);
		SetShotDataA(0, 0, 0, 0, 0, 0, 0, RED01);
		SetShotKillTime(0, 0);
		FireShot(0);
		}
	CreateShotA(0, rand(GetClipMinX, GetClipMaxX), rand(GetClipMaxY-10, GetClipMaxY), 60);
	SetShotDataA(0, 0, 1.5, rand(260,280), 0, -0.05, 0.25, RED11);
	SetShotKillTime(0, 90);
	FireShot(0);
	frame1 = 0;
	}









	if ((ng_start == 2) && (frame2 == 1))
	{
	PlaySE(GetCurrentScriptDirectory~"..\sfx\Charge.wav");
	}

	if ((ng_start == 2) && (frame2 == 30))
	{
	Concentration01(60);
	}



	if ((ng_start == 2) && (frame2 == 90))
	{
	PlaySE(sfx01);
	ascent(i in 0..30)
		{
		Firefall(GetClipMinX + (i*20), GetClipMinY);
		}
	ng_playerx = GetPlayerX;
	MotionBlur(SHOT, 150, 200);
	}

//Lunatic
if (GetCommonData("CD_gamemode") == 2)
{
	if ((ng_start == 2) && (frame2 >= 90) && (frame2 <= 130))
	{
	FireWaveUp(ng_playerx, GetClipMinY, 3);
	}

	if ((ng_start == 2) && (frame2 >= 200) && (frame2 <= 240))
	{
	FireWave(ng_playerx, GetClipMaxY, 2);
	}
}
else
{
	if ((ng_start == 2) && (frame2 >= 90) && (frame2 <= 130))
	{
	FireWaveUp(ng_playerx, GetClipMinY, 2);
	}

	if ((ng_start == 2) && (frame2 >= 200) && (frame2 <= 240))
	{
	FireWave(ng_playerx, GetClipMaxY, 1);
	}
}




	if ((ng_start == 2) && (frame2 == 205))
	{
	PlaySE(sfx44);
	}

	if ((ng_start == 2) && (frame2 == 240))
	{
	frame2 = 0;
	}






	if (ng_bossmframe == 120)
	{
	SetMovePositionRandom01(rand_int(25,75), rand_int(5,10), 100, GetClipMinX+100, 120, GetClipMaxX-100, 90);
	ng_bossmframe = 0;
	}



	frame1++;
	frame2++;
	frame3++;
	frame4++;

//----------------------
// 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(BossBG2);
	SetTexture(BossBG2);
	SetGraphicRect( 0, 0, 256, 256);
	SetGraphicScale(1.8, 1.8);
	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(BossBG2);
	SFX_Delete;
    	}
}
