#include "commondefines.h"

int g_bosscount;

//== STATE PROTOTYPES =========================================================

state	Spawn;
state	Main;
state	Restore;

event_instant( "player revived" )
{
	if ( WasLevelSpawned( ) == false )
	{
		// Destroy gibs, puddles, etc.
		DestroyChildren( );

		DestroySelf( );
	}
		changestate( Restore );
}

//-----------------------------------------------------------------------------
event_instant( "player continued" )
{
	if ( WasLevelSpawned( ) == false )
	{
		// Destroy gibs, puddles, etc.
		DestroyChildren( );

		DestroySelf( );
	}

	changestate( Restore );
}

event_instant( "Boss" )
{
g_bosscount++;
if (g_bosscount == 1)
ExecuteMapScript( "Supply1", 0, 0, 0, 0 );
if (g_bosscount == 2)
ExecuteMapScript( "Supply2", 0, 0, 0, 0 );
if (g_bosscount == 3)
ExecuteMapScript( "Wave1", 0, 0, 0, 0 );
if (g_bosscount == 4)
ExecuteMapScript( "Supply3", 0, 0, 0, 0 );
if (g_bosscount == 5)
ExecuteMapScript( "Wave2", 0, 0, 0, 0 );
if (g_bosscount == 6)
ExecuteMapScript( "Supply4", 0, 0, 0, 0 );
if (g_bosscount == 7)
ExecuteMapScript( "Wave3", 0, 0, 0, 0 );
if (g_bosscount == 8)
ExecuteMapScript( "Supply5", 0, 0, 0, 0 );
if (g_bosscount == 9)
ExecuteMapScript( "Supply6", 0, 0, 0, 0 );
if (g_bosscount == 10)
ExecuteMapScript( "Supply7", 0, 0, 0, 0 );
if (g_bosscount == 11)
ExecuteMapScript( "Supply8", 0, 0, 0, 0 );
if (g_bosscount == 12)
ExecuteMapScript( "Wave4", 0, 0, 0, 0 );
ChangeState (Main);
}

event_instant ("Exit")
{
		//MeLazy
		ChangeState (Main);
}
//== STATES ===================================================================

state Spawn
{
	OnEnter
	{
		g_bosscount = 0;
		ChangeState (Main);
	}
	MainLoop
	{
	}
}

state Main
{
	MainLoop
	{
	}
}

//-----------------------------------------------------------------------------
state Restore
{
	MainLoop
	{
		// Destroy gibs, puddles, etc.
		DestroyChildren( );

		// Put us back in the original state we were in when the map
		// started.
		RestoreSelf( 0 );
		changestate( Spawn );
	}
}
