BUFFALO_THRESHOLD		= 150;
ELAND_THRESHOLD			= 150;
GEMSBOK_THRESHOLD   	= 150;
HARE_THRESHOLD			= 500;
HIPPO_THRESHOLD			= 150;
IMPALA_THRESHOLD		= 300;
KUDU_THRESHOLD			= 150;
LEOPARD_THRESHOLD   	= 300;
LION_THRESHOLD			= 50;
NILECROC_THRESHOLD  	= 150;
GOOSE_THRESHOLD			= 1000;
SABLE_THRESHOLD			= 150;
ELEPHANT_THRESHOLD  	= 50;
RHINO_THRESHOLD			= 150;
WILDEBEEST_THRESHOLD	= 150;
MEERKAT_THRESHOLD   	= 500;
VULTURE_THRESHOLD   	= 150;

HEADSHOT_THRESHOLD		= 150;
VITALSHOT_THRESHOLD     = 150;
RICH_THRESHOLD			= 5000000;
RIFLE_KILL_THRESHOLD    = 1000;
PISTOL_KILL_THRESHOLD	= 1000;
GOLD_TROPHY_THRESHOLD   = 35;
TREASURE_THRESHOLD		= 35;
ACCURATE_THRESHOLD		= 3;
NO_DAMAGE_THRESHOLD		= 1;
NO_FEM_KILL_THRESHOLD   = 1;
-- JJK: 2010-09-27 Added thresholds from instore.lua
EQUIPMENT_THRESHOLD     = 20;  
GUNS_THRESHOLD			= 12;  


-- JJK: 2010-09-27 Added functions from instore.lua

-----------------------------------------------------------------------------
-- CHECK ALL GUNS PURCHASED
-----------------------------------------------------------------------------
function CheckAllGuns()
	System.OutputDebugString("Checking All Guns\n");
	
	if(Profile.IsAchievementUnlocked(profile, ACH_ALL_GUNS) == false) then
		if(Profile.GetGunsPurchased(profile) >= GUNS_THRESHOLD) then
			EntGame.AwardAchievement(ACH_ALL_GUNS);
			return(true);
			end;
		end;
	end;


------------------------------------------------------------------------------
-- CHECK ALL EQUIPMENT PURCHASED
------------------------------------------------------------------------------	
function CheckAllEquip()
	System.OutputDebugString("Checking All Equipment\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_EQUIPMENT) == false) then
		if(Profile.GetEquipPurchased(profile) >= EQUIPMENT_THRESHOLD) then
			EntGame.AwardAchievement(ACH_EQUIPMENT);
			return(true);
			end;
		end;			
	end;

-----------------------------------------------------------------------------
-- CHECK ANIMAL KILLS
-- Helper function to quickly check the kill count of an animal against
-- it's threshold
-----------------------------------------------------------------------------

function CheckAnimalKills(achieveId, animalId, count)
    System.OutputDebugString("Checking Animal Kills\n");
	
	if (Profile.IsAchievementUnlocked(profile, achieveId) == false) then
		totalKills = Profile.GetAnimalKills(profile, animalId);
		if (totalKills >= count) then
			EntGame.AwardAchievement(achieveId);
			return(true);
			end;
		end;
		
	return(false);
	end;
	
	
-----------------------------------------------------------------------------
-- CHECK NEW TREASURE HIT
-----------------------------------------------------------------------------

function CheckTreasureHit(achieveId)
	System.OutputDebugString("Checking Treasure Hit\n");
	
	if(PlayerState.GetTreasureHit(stats) < 0) then
		return(false);
	else
		achieveId = 100 + EntGame.GetTreasureHit();
		end;
		
	if(Profile.IsAchievementUnlocked(profile, achieveId) == false) then
		EntGame.AwardTreasure(PlayerState.GetTreasureHit(stats));
		return(true);
		end;
		
	return(false);
	
	end;

	
-----------------------------------------------------------------------------
-- CHECK ALL TREASURES/FINALl TREASURE HIT
-----------------------------------------------------------------------------
function CheckAllTreasures()
	System.OutputDebugString("Checking All Treasure\n");
	
	if(Profile.IsAchievementUnlocked(profile, ACH_ALL_TREASURES) == false) then
		if(Profile.GetTreasures(profile) == TREASURE_THRESHOLD) then
			EntGame.AwardAchievement(ACH_ALL_TREASURES);
			return(true);
			end;
		end;
	end;

	
-----------------------------------------------------------------------------
-- CHECK NEW TOTAL $$$$
-----------------------------------------------------------------------------	
function CheckRich()
	System.OutputDebugString("Checking Rich\n");
	
	if(Profile.IsAchievementUnlocked(profile, ACH_RICH) == false) then
		totalCash = Profile.GetCredits(profile) + PlayerState.GetMoney(stats);
		if(totalCash >= RICH_THRESHOLD) then
			EntGame.AwardAchievement(ACH_RICH);
			return(true);
			end;
		end;
	end;
	
	
-----------------------------------------------------------------------------
-- CHECK HEADSHOTS
-----------------------------------------------------------------------------	
function CheckHeadShots()
	System.OutputDebugString("Checking Head Shots\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_HEADSHOT) == false) then
		headShots = Profile.GetHeadShots(profile);
		if(headShots >= HEADSHOT_THRESHOLD) then
			EntGame.AwardAchievement(ACH_HEADSHOT);
			return(true);
			end;
		end;
	end;

-----------------------------------------------------------------------------
-- CHECK VITALSHOTS
-----------------------------------------------------------------------------	
function CheckVitalShots()
	System.OutputDebugString("Checking Vital Shots\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_VITALSHOT) == false) then
		vitalShots = Profile.GetVitalShots(profile);
		if(vitalShots >= VITALSHOT_THRESHOLD) then
			EntGame.AwardAchievement(ACH_VITALSHOT);
			return(true);
			end;
		end;
	end;
-----------------------------------------------------------------------------
-- CHECK ACCURACY
-----------------------------------------------------------------------------
function CheckAccuracy()
	System.OutputDebugString("Checking Accuracy\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_ACCURACY) == false) then
		if((Profile.GetRoundsAccurate(profile)) >= ACCURATE_THRESHOLD) then
			EntGame.AwardAchievement(ACH_ACCURACY);
			return(true);
			end;
		end;
	end;
	
-----------------------------------------------------------------------------
-- CHECK RIFLE KILLS
-----------------------------------------------------------------------------
function CheckRifleKills()
	System.OutputDebugString("Checking Rifle Kills\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_RIFLE) == false) then
		rifleKills = Profile.GetRifleKills(profile); 
		if(rifleKills >= RIFLE_KILL_THRESHOLD) then
			EntGame.AwardAchievement(ACH_RIFLE);
			return(true);
			end;
		end;
	end;
	
-----------------------------------------------------------------------------
-- CHECK PISTOL KILLS
-----------------------------------------------------------------------------
function CheckPistolKills()
	System.OutputDebugString("Checking Pistol Kills\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_PISTOL) == false) then
		pistolKills = Profile.GetPistolKills(profile);
		if(pistolKills >= PISTOL_KILL_THRESHOLD) then
			EntGame.AwardAchievement(ACH_PISTOL);
			return(true);
			end;
		end;
	end;


-----------------------------------------------------------------------------
-- CHECK GOLD TROPHY
-----------------------------------------------------------------------------
function CheckGoldTrophy()
	System.OutputDebugString("Checking Gold Trophy\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_GOLD_TROPHY) == false) then
		if(Profile.GetGoldTrophies(profile) == GOLD_TROPHY_THRESHOLD) then
			EntGame.AwardAchievement(ACH_GOLD_TROPHY);
			return(true);
			end;
		end;
	end;

-----------------------------------------------------------------------------
-- CHECK FEMALE STAGE
-----------------------------------------------------------------------------	
function CheckFemaleStage()
	System.OutputDebugString("Checking Female Stage\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_FEMALE_STAGE) == false) then
		if(PlayerState.GetFemaleKills(stats) <= 0) then
			EntGame.AwardAchievement(ACH_FEMALE_STAGE);
			return(true);
			end;
		end;
	end;

-----------------------------------------------------------------------------
-- CHECK ALL COINS
-----------------------------------------------------------------------------
function CheckAllCoins()
	System.OutputDebugString("Checking All Coins\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_ALL_COINS) == false) then
		if(PlayerState.GetCoins(stats) > 0) then
			if(PlayerState.GetCoinsShot(stats) >= PlayerState.GetCoins(stats)) then
				EntGame.AwardAchievement(ACH_ALL_COINS);
				return(true);
				end;
			end;
		end;
	end;
	
-----------------------------------------------------------------------------
-- CHECK TRIGGER HAPPY
-----------------------------------------------------------------------------
function CheckTriggerHappy()
	System.OutputDebugString("Checking Trigger Happy\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_TRIGGER_HAPPY) == false) then
		if(PlayerState.GetShotsFired(stats) >= 50) then
			if(PlayerState.GetShotsHit(stats) / PlayerState.GetShotsFired(stats) <= 0.10) then
				EntGame.AwardAchievement(ACH_TRIGGER_HAPPY);
				return(true);
				end;
			end;
		end;
	end;
		
-----------------------------------------------------------------------------
-- CHECK JAWS OF DEATH
-----------------------------------------------------------------------------
function CheckJawsOfDeath()
	System.OutputDebugString("Checking Jaws of Death\n");

	if(Profile.IsAchievementUnlocked(profile, ACH_JAWS_OF_DEATH) == false) then
		if(PlayerState.JawsOfDeath(stats)) then
			EntGame.AwardAchievement(ACH_JAWS_OF_DEATH);
			return(true);
			end;
		end;
	end;
		
------------------------------------------------------------------------------
function DoAchEndRound()
	System.OutputDebugString("Checking End-of-Round achievements\n");
	
	profile = EntGame.GetProfile();
    stats	= EntGame.GetPlayerState(0);
	
    -- ACH_BUFFALO
    if (CheckAnimalKills(ACH_BUFFALO, AID_BUFFALO_M, BUFFALO_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_ELAND
    if (CheckAnimalKills(ACH_ELAND, AID_ELAND_M, ELAND_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_GEMSBOK
    if (CheckAnimalKills(ACH_GEMSBOK, AID_GEMSBOK_M, GEMSBOK_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_HARE
    if (CheckAnimalKills(ACH_HARE, AID_HARE_M, HARE_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_HIPPO
    if (CheckAnimalKills(ACH_HIPPO, AID_HIPPO_M, HIPPO_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_IMPALA
    if (CheckAnimalKills(ACH_IMPALA, AID_IMPALA_M, IMPALA_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_KUDU
    if (CheckAnimalKills(ACH_KUDU, AID_KUDU_M, KUDU_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_LEOPARD
    if (CheckAnimalKills(ACH_LEOPARD, AID_LEOPARD_M, LEOPARD_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_LION
    if (CheckAnimalKills(ACH_LION, AID_LION_M, LION_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_NILECROC
    if (CheckAnimalKills(ACH_NILECROC, AID_NILECROC_M, NILECROC_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_GOOSE
    if (CheckAnimalKills(ACH_GOOSE, AID_SPURWINGGOOSE_M, GOOSE_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_SABLE
    if (CheckAnimalKills(ACH_SABLE, AID_SABLE_M, SABLE_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_ELEPHANT
    if (CheckAnimalKills(ACH_ELEPHANT, AID_ELEPHANT_M, ELEPHANT_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_RHINO
    if (CheckAnimalKills(ACH_RHINO, AID_RHINO_M, RHINO_THRESHOLD)) then 
		return(true); 
		end;

    -- ACH_WILDEBEEST
    if (CheckAnimalKills(ACH_WILDEBEEST, AID_WILDEBEEST_M, WILDEBEEST_THRESHOLD)) then 
		return(true); 
		end;
		
	-- ACH_MEERKAT
	if (CheckAnimalKills(ACH_MEERKAT, AID_MEERKAT_M, MEERKAT_THRESHOLD)) then
		return(true);
		end;

	-- ACH_VULTURE
	if (CheckAnimalKills(ACH_VULTURE, AID_VULTURE_M, VULTURE_THRESHOLD)) then
		return(true);
		end;

	-- ACH_MASKX_Y
	if(CheckTreasureHit()) then
		return(true);
		end;
	
	-- ACH_ALL_TREASURES
	if(CheckAllTreasures()) then
		return(true);
		end;
	
	-- ACH_RICH
	if(CheckRich()) then
		return(true);
		end;
		
	-- ACH_HEADSHOT
	if(CheckHeadShots()) then
		return(true);
		end;
	
	-- ACH_VITALSHOT
	if(CheckVitalShots()) then
		return(true);
		end;
	
	-- ACH_ACCURACY
	if(CheckAccuracy()) then
		return(true);
		end;
	
	-- ACH_RIFLE
	if(CheckRifleKills()) then
		return(true);
		end;
	
	-- ACH_PISTOL
	if(CheckPistolKills()) then
		return(true);
		end;
		
	-- ACH_GOLD_TROPHY
	if(CheckGoldTrophy()) then
		return(true);
		end;
		
	-- ACH_FEMALE_STAGE
	if(CheckFemaleStage()) then
		return(true);
		end;
		
	-- ACH_ALL_COINS
	if(CheckAllCoins()) then
		return(true);
		end;
	
	-- ACH_TRIGGER_HAPPY
	if(CheckTriggerHappy()) then
		return(true);
		end;
		
	-- ACH_JAWS_OF_DEATH
	if(CheckJawsOfDeath()) then
		return(true);
		end;
		
	-- JJK: 2010-09-27 Added 2 more achievements that were in instore.lua
	-- ACH_ALL_GUNS
	if(CheckAllGuns()) then
		return(true);
		end;
		
	-- ACH_EQUIPMENT
	if(CheckAllEquip()) then
		return(true);
		end;
	
	end;