// EndMut.
class EndMut expands Mutator;

Var string CurrentMap;
Var float MinimumPlayTime;

// Original function from WFlexMap
// all credits to }TCP{Wolf
function string getCurrentMap()
{
	local string sb;

	sb = string(Level.Game);
	while (Right(sb, 1) != ".")
	{
		sb = Left(sb, len(sb)-1);
		if (sb == "")
			break;
	}
	sb = Left(sb, Len(sb)-1);

	return sb;
}

auto state InitEndMut
{
        simulated function Timer()
        {
   	ConsoleCommand("_blockend false");
	ConsoleCommand("say **End is ENABLED again.**");
	ConsoleCommand("say > However, ALWAYS ASK before you end. Players might want to stay here. Thank you.");
	ConsoleCommand("say > Ending without asking can get you killed, kicked, or banned by the admin or moderator");
        log("  End should be enabled",'EndMut');
        }
Begin:
        log("----------------------------------------------------------------------------------",'EndMut');
        log("  EndMut loaded",'EndMut');
	log("  Note: EndMut requires MCoop2 mod to work",'EndMut');
        log("----------------------------------------------------------------------------------",'EndMut');
   	ConsoleCommand("_blockend true");
	ConsoleCommand("say **End is automatically DISABLED**");
        log("  End should be blocked",'EndMut');
	CurrentMap = getCurrentMap();
	log("  Current map is " $CurrentMap,'EndMut');
	MinimumPlayTime = 5.0; //default

	if (CurrentMap=="vortex2" || CurrentMap=="Vortex2")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="nyleve" || CurrentMap=="NyLeve")
	{
	MinimumPlayTime = 6.0;
	}
	if (CurrentMap=="dig" || CurrentMap=="Dig")
	{
	MinimumPlayTime = 10.0;
	}
	if (CurrentMap=="dug" || CurrentMap=="Dug")
	{
	MinimumPlayTime = 5.0;
	}
	if (CurrentMap=="passage" || CurrentMap=="Passage")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="chizra" || CurrentMap=="Chizra")
	{
	MinimumPlayTime = 10.0;
	}
	if (CurrentMap=="ceremony" || CurrentMap=="Ceremony")
	{
	MinimumPlayTime = 7.0;
	}
	if (CurrentMap=="dark" || CurrentMap=="Dark")
	{
	MinimumPlayTime = 7.0;
	}
	if (CurrentMap=="harobed" || CurrentMap=="Harobed")
	{
	MinimumPlayTime = 10.0;
	}
	if (CurrentMap=="terralift" || CurrentMap=="TerraLift")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="terraniux" || CurrentMap=="Terraniux")
	{
	MinimumPlayTime = 10.0;
	}
	if (CurrentMap=="noork" || CurrentMap=="Noork")
	{
	MinimumPlayTime = 8.0;
	}
	if (CurrentMap=="ruins" || CurrentMap=="Ruins")
	{
	MinimumPlayTime = 10.0;
	}
	if (CurrentMap=="trench" || CurrentMap=="Trench")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="isvkran4" || CurrentMap=="IsvKran4")
	{
	MinimumPlayTime = 6.0;
	}
	if (CurrentMap=="isvkran32" || CurrentMap=="IsvKran32")
	{
	MinimumPlayTime = 8.0;
	}
	if (CurrentMap=="isvdeck1" || CurrentMap=="IsvDeck1")
	{
	MinimumPlayTime = 5.0;
	}
	if (CurrentMap=="spirevillage" || CurrentMap=="SpireVillage")
	{
	MinimumPlayTime = 30.0;
	}
	if (CurrentMap=="thesunspire" || CurrentMap=="TheSunspire")
	{
	MinimumPlayTime = 30.0;
	}
	if (CurrentMap=="skycaves" || CurrentMap=="SkyCaves")
	{
	MinimumPlayTime = 5.0;
	}
	if (CurrentMap=="skytown" || CurrentMap=="SkyTown")
	{
	MinimumPlayTime = 15.0;
	}
	if (CurrentMap=="skybase" || CurrentMap=="SkyBase")
	{
	MinimumPlayTime = 6.0;
	}
	if (CurrentMap=="veloraend" || CurrentMap=="VeloraEnd")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="bluff" || CurrentMap=="Bluff")
	{
	MinimumPlayTime = 20.0;
	}
	if (CurrentMap=="dasapass" || CurrentMap=="DasaPass")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="dasacellars" || CurrentMap=="DasaCellars")
	{
	MinimumPlayTime = 10.0;
	}
	if (CurrentMap=="naliboat" || CurrentMap=="NaliBoat")
	{
	MinimumPlayTime = 5.0;
	}
	if (CurrentMap=="nalic" || CurrentMap=="NaliC")
	{
	MinimumPlayTime = 20.0;
	}
	if (CurrentMap=="nalilord" || CurrentMap=="NaliLord")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="dcrater" || CurrentMap=="DCrater")
	{
	MinimumPlayTime = 5.0;
	}
	if (CurrentMap=="extremebeg" || CurrentMap=="ExtremeBeg")
	{
	MinimumPlayTime = 2.0;
	}
	if (CurrentMap=="extremelab" || CurrentMap=="ExtremeLab")
	{
	MinimumPlayTime = 6.0;
	}
	if (CurrentMap=="extremecore" || CurrentMap=="ExtremeCore")
	{
	MinimumPlayTime = 6.0;
	}
	if (CurrentMap=="extremegen" || CurrentMap=="ExtremeGen")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="extremedgen" || CurrentMap=="ExtremeDGen")
	{
	MinimumPlayTime = 0.5;
	}
	if (CurrentMap=="extremedark" || CurrentMap=="ExtremeDark")
	{
	MinimumPlayTime = 4.0;
	}
	if (CurrentMap=="extremeend" || CurrentMap=="ExtremeEnd")
	{
	MinimumPlayTime = 2.0;
	}
	if (CurrentMap=="queenend" || CurrentMap=="QueenEnd")
	{
	MinimumPlayTime = 10.0;
	}	


	log("  The minimum play time in minutes for this map is " $MinimumPlayTime,'EndMut');
        SetTimer(MinimumPlayTime*60, False);

End:
}

defaultproperties
{
}