DEATHS_THRESHOLD		= 5;

-----------------------------------------------------------------------------
-- CHECK DEATH
-----------------------------------------------------------------------------
function CheckDeath()
	System.OutputDebugString("Checking Death\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_DEATH) == false) then
		deaths = Profile.GetDeaths(profile);
		if(deaths >= DEATHS_THRESHOLD) then
			EntGame.AwardAchievement(ACH_DEATH);
			return(true);
			end;
		end;
	end;	

-----------------------------------------------------------------------------
-- DO ACH IN-GAME
-- Processes all in-game acheivements.  Returns true if a new ach was found.
-----------------------------------------------------------------------------

function DoAchInGame()
    System.OutputDebugString("Checking in-game achievements\n");
    
    profile = EntGame.GetProfile();
    
 	-- ACH_DEATH
	if(CheckDeath()) then
		return(true);
		end;


    return(false);
    	
	end; -- end function
------------------------------------------------------------------------------------


if(DoAchInGame()) then
	EntGame.PushMenu("MenuAchieveNotice");
	EntGame.ClearFlag(GF_READYTOSTART);		
	
	-- wait until the we accepted the award
	while (EntGame.GetFlag(GF_READYTOSTART) == false) do
		Script.WaitFrame(1);
		end;
	end;