#library "SKULFORT.acs"
#include "zcommon.acs"

/// OdaFlag ACS

int flagcount;
int totalflag;

str redflag = "OdaRedFlag";
str blueflag = "OdaBlueFlag";
str greenflag = "OdaGreenFlag";
str goldflag = "OdaGoldFlag";

script 840 OPEN
{
	delay(1);

	totalflag = ThingCountName(redflag, 0) + ThingCountName(blueflag, 0) + ThingCountName(greenflag, 0) + ThingCountName(goldflag, 0);
}

script 841 (void)
{
	SetResultValue(FALSE);
	flagcount++;
		
	if (flagcount > totalflag)
	{
		SetResultValue(TRUE);
	}
}

/// SkullFort ACS

/// Global variables

Script "SFort_Open" OPEN
{
	Delay(1);
	ResetCustomDataToDefault("Ratio",-1);
}

// Player TID change & team check

Script "SFort_Enter" ENTER
{
	AmbientSound("misc/join",127);
	ACS_NamedExecuteAlways("SFort_Respawn",0);
}

Script "SFort_Ratio_Enter" ENTER
{
	Delay(1);
	ResetCustomDataToDefault("Ratio",-1);
}

Script "SFort_Respawn" RESPAWN
{
	// Clear Random Tip message
	HudMessage(s:"";HUDMSG_PLAIN,4708,CR_UNTRANSLATED,1.5,0.725,0.1);
	// Do the TID change & team check on respawn too:
	//LocalSetMusic("*");
	Thing_ChangeTID(0, 1000 + PlayerNumber());
	// Give the player a team identification item for Decorate:
	if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 0)
	{
		GiveInventory("BlueTeamToken",1);
	}
	if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 1)
	{
		GiveInventory("RedTeamToken",1);
	}
	if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 2)
	{
		GiveInventory("GreenTeamToken",1);
	}
	if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 3)
	{
		GiveInventory("GoldTeamToken",1);
	}
	// 1-second spawn invulnerability time:
	Delay(35);
	TakeInventory("PowerRespawnInvulnerable",1);
}

// Playerclass info

Script "ClassInfo_Enter" ENTER CLIENTSIDE
{
	if(GetCVAR("sfort_classinfo") == true)
	{
		SetFont("BIGFONT");
		if(GetCVar("Teamplay") == 1 || GetCVar("TeamLMS") == 1 || ("CTF") == 1 || GetCVar("Skulltag") == 1 || GetCVar("Domination") == 1 || GetCVar("TeamGame") == 1)
		{
			// Blue team info
			if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 0)
			{
				if(PlayerClass(PlayerNumber()) == 0)
				{
					Hudmessage(s:StrParam(l:"INTRO_INFANTRY_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 1)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCOUT_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 2)
				{
					Hudmessage(s:StrParam(l:"INTRO_ROCKETEER_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 3)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCORCHER_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 4)
				{
					Hudmessage(s:StrParam(l:"INTRO_GUNNER_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 5)
				{
					Hudmessage(s:StrParam(l:"INTRO_DEMOLITIONER_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 6)
				{
					Hudmessage(s:StrParam(l:"INTRO_PIONEER_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 7)
				{
					Hudmessage(s:StrParam(l:"INTRO_MARKSMAN_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 8)
				{
					Hudmessage(s:StrParam(l:"INTRO_MEDIC_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 9)
				{
					Hudmessage(s:StrParam(l:"INTRO_GHOST_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 10)
				{
					Hudmessage(s:StrParam(l:"INTRO_CYBORG_BLUE"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
			}
			// Red team info
			if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 1)
			{
				if(PlayerClass(PlayerNumber()) == 0)
				{
					Hudmessage(s:StrParam(l:"INTRO_INFANTRY_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 1)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCOUT_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 2)
				{
					Hudmessage(s:StrParam(l:"INTRO_ROCKETEER_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 3)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCORCHER_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 4)
				{
					Hudmessage(s:StrParam(l:"INTRO_GUNNER_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 5)
				{
					Hudmessage(s:StrParam(l:"INTRO_DEMOLITIONER_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 6)
				{
					Hudmessage(s:StrParam(l:"INTRO_PIONEER_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 7)
				{
					Hudmessage(s:StrParam(l:"INTRO_MARKSMAN_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 8)
				{
					Hudmessage(s:StrParam(l:"INTRO_MEDIC_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 9)
				{
					Hudmessage(s:StrParam(l:"INTRO_GHOST_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 10)
				{
					Hudmessage(s:StrParam(l:"INTRO_CYBORG_RED"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
			}
			// Green team info
			if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 2)
			{
				if(PlayerClass(PlayerNumber()) == 0)
				{
					Hudmessage(s:StrParam(l:"INTRO_INFANTRY_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 1)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCOUT_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 2)
				{
					Hudmessage(s:StrParam(l:"INTRO_ROCKETEER_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 3)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCORCHER_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 4)
				{
					Hudmessage(s:StrParam(l:"INTRO_GUNNER_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 5)
				{
					Hudmessage(s:StrParam(l:"INTRO_DEMOLITIONER_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 6)
				{
					Hudmessage(s:StrParam(l:"INTRO_PIONEER_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 7)
				{
					Hudmessage(s:StrParam(l:"INTRO_MARKSMAN_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 8)
				{
					Hudmessage(s:StrParam(l:"INTRO_MEDIC_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 9)
				{
					Hudmessage(s:StrParam(l:"INTRO_GHOST_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 10)
				{
					Hudmessage(s:StrParam(l:"INTRO_CYBORG_GREEN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
			}
			// Gold team info
			if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 3)
			{
				if(PlayerClass(PlayerNumber()) == 0)
				{
					Hudmessage(s:StrParam(l:"INTRO_INFANTRY_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 1)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCOUT_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 2)
				{
					Hudmessage(s:StrParam(l:"INTRO_ROCKETEER_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 3)
				{
					Hudmessage(s:StrParam(l:"INTRO_SCORCHER_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 4)
				{
					Hudmessage(s:StrParam(l:"INTRO_GUNNER_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 5)
				{
					Hudmessage(s:StrParam(l:"INTRO_DEMOLITIONER_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 6)
				{
					Hudmessage(s:StrParam(l:"INTRO_PIONEER_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 7)
				{
					Hudmessage(s:StrParam(l:"INTRO_MARKSMAN_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 8)
				{
					Hudmessage(s:StrParam(l:"INTRO_MEDIC_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 9)
				{
					Hudmessage(s:StrParam(l:"INTRO_GHOST_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
				if(PlayerClass(PlayerNumber()) == 10)
				{
					Hudmessage(s:StrParam(l:"INTRO_CYBORG_GOLD"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
				}
			}
		}
		else
		{
			if(PlayerClass(PlayerNumber()) == 0)
			{
				Hudmessage(s:StrParam(l:"INTRO_INFANTRY"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 1)
			{
				Hudmessage(s:StrParam(l:"INTRO_SCOUT"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 2)
			{
				Hudmessage(s:StrParam(l:"INTRO_ROCKETEER"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 3)
			{
				Hudmessage(s:StrParam(l:"INTRO_SCORCHER"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 4)
			{
				Hudmessage(s:StrParam(l:"INTRO_GUNNER"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 5)
			{
				Hudmessage(s:StrParam(l:"INTRO_DEMOLITIONER"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 6)
			{
				Hudmessage(s:StrParam(l:"INTRO_PIONEER"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 7)
			{
				Hudmessage(s:StrParam(l:"INTRO_MARKSMAN"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 8)
			{
				Hudmessage(s:StrParam(l:"INTRO_MEDIC"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 9)
			{
				Hudmessage(s:StrParam(l:"INTRO_GHOST"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
			if(PlayerClass(PlayerNumber()) == 10)
			{
				Hudmessage(s:StrParam(l:"INTRO_CYBORG"); HUDMSG_TYPEON|HUDMSG_LOG, 4703, CR_UNTRANSLATED, 1.5, 0.85, 5.0, 0.01, 1.0);
			}
		}
	}
}

Script "ClassInfo_Respawn" RESPAWN CLIENTSIDE
{
	ACS_NamedExecuteAlways("ClassInfo_Enter",0);
}

Script "ClassScoreboard_Enter" ENTER
{
	int player = PlayerNumber();
	for(int i = 0; i < 8; i++)
	{
		Switch(PlayerClass(PlayerNumber()))
		{
			Case 0:
			{
				str infantry = "Infantry";
				SetCustomPlayerValue("ClassName",player,infantry);
				break;
			}
			Case 1:
			{
				str scout = "Scout";
				SetCustomPlayerValue("ClassName",player,scout);
				break;
			}
			Case 2:
			{
				str rocketeer = "Rocketeer";
				SetCustomPlayerValue("ClassName",player,rocketeer);
				break;
			}
			Case 3:
			{
				str scorcher = "Scorcher";
				SetCustomPlayerValue("ClassName",player,scorcher);
				break;
			}
			Case 4:
			{
				str gunner = "Gunner";
				SetCustomPlayerValue("ClassName",player,gunner);
				break;
			}
			Case 5:
			{
				str demolitioner = "Demolitioner";
				SetCustomPlayerValue("ClassName",player,demolitioner);
				break;
			}
			Case 6:
			{
				str pioneer = "Pioneer";
				SetCustomPlayerValue("ClassName",player,pioneer);
				break;
			}
			Case 7:
			{
				str marksman = "Marksman";
				SetCustomPlayerValue("ClassName",player,marksman);
				break;
			}
			Case 8:
			{
				str medic = "Medic";
				SetCustomPlayerValue("ClassName",player,medic);
				break;
			}
			Case 9:
			{
				str ghost = "Ghost";
				SetCustomPlayerValue("ClassName",player,ghost);
				break;
			}
			Case 10:
			{
				str cyborg = "Cyborg";
				SetCustomPlayerValue("ClassName",player,cyborg);
				break;
			}
			Delay(5);
		}
	}
}

Script "ClassScoreboard_Respawn" RESPAWN
{
	ACS_NamedExecuteAlways("ClassScoreboard_Enter",0);
}

Script "RandomTip" (void) CLIENTSIDE
{
	//if(ConsolePlayerNumber() != PlayerNumber()) { Terminate; }
	if(GetCVar("sfort_tips") == true)
	{
		//Delay(1);
		str TipName = StrParam(s:"TIP", i:Random(0,29));
		SetFont("Smallfont");
		HudMessage(s:StrParam(l:TipName); HUDMSG_FADEOUT|HUDMSG_LOG, 4708, CR_UNTRANSLATED, 1.5, 0.675, 5.0, 1.5);
	}
}

// Marksman bot railgun selector
/*
Script "MarksmanBotRailgun_Enter" ENTER
{
	if(PlayerClass(PlayerNumber()) == 7 && ConsolePlayerNumber() != PlayerNumber())
	{
		SetWeapon("SFortRailgun");
	}
}

Script "MarksmanBotRailgun_Respawn" RESPAWN
{
	ACS_NamedExecuteAlways("MarksmanBotRailgun_Enter",0);
}*/

// Spectate sound

Script "SFort_Spectate" (int player) DISCONNECT
{
	AmbientSound("misc/spectate",127);
}

// Mod's own health degeneration, because Skulltag's own sucks!

Script "SFort_HealthDegen_Enter" ENTER
{
	while(true)
	{
		// If the class played is Cyborg or the actor is dead, terminate the script.
		if(PlayerClass(PlayerNumber()) == 10 || GetActorProperty(0,APROP_HEALTH) <= 0)
		{
			terminate;
		}
		if(PlayerClass(PlayerNumber()) == 4 && GetActorProperty(0,APROP_HEALTH) > 300)
		// If the class played is Gunner and health is above 300, decrease health until it's back to 300 or lower.
		{
			Delay(35);
			if(GetActorProperty(0,APROP_HEALTH) <= 200)
			{
				continue;
			}
			SetActorProperty(0,APROP_HEALTH,GetActorProperty(0,APROP_HEALTH) - 1);
		}
		else if((PlayerClass(PlayerNumber()) != 4 && PlayerClass(PlayerNumber()) != 10) && GetActorProperty(0,APROP_HEALTH) > 100)
		// Otherwise, if health is above 100, decrease health until it's back to 100 or lower.
		{
			Delay(35);
			if(GetActorProperty(0,APROP_HEALTH) <= 100)
			{
				continue;
			}
			SetActorProperty(0,APROP_HEALTH,GetActorProperty(0,APROP_HEALTH) - 1);
		}
		else
		{
			Delay(1);
		}
	}
}

Script "SFort_HealthDegen_Respawn" RESPAWN
{
	ACS_NamedExecuteAlways("SFort_HealthDegen_Enter",0);
}

Script "Gunner_ArmorRegen_Enter" ENTER
{
	while(true)
	{
		if(PlayerClass(PlayerNumber()) != 4 || GetActorProperty(0,APROP_HEALTH) <= 0)
		// If the class played isn't Gunner or the player is dead, stop the script.
		{
			terminate;
		}
		else if(PlayerClass(PlayerNumber()) == 4 && CheckActorInventory(0,"BasicArmor") < 200)
		// If the class played is Gunner, regenerate 5 armor every 30 tics until at 200 armor or dead.
		{
			Delay(30);
			if(CheckActorInventory(0,"BasicArmor") >= 200 || GetActorProperty(0,APROP_HEALTH) <= 0)
			// If during the 30 tics the player has got 200 or more armor or they die, skip giving the 5 armor.
			{
				continue;
			}
			GiveInventory("GunnerArmorRegenBonus",1);
		}
		else
		{
			Delay(1);
		}
	}
}

Script "Gunner_ArmorRegen_Respawn" RESPAWN
{
	ACS_NamedExecuteAlways("Gunner_ArmorRegen_Enter",0);
}

// Powerup wearoff sounds

Script "DoomSphereCounter" (void) CLIENTSIDE
{
	Delay(700);
	if(GetActorProperty(0,APROP_HEALTH) > 0 && CheckInventory("PowerQuadDamage"))
	{
		Playsound(0,"misc/quad_wearoff",CHAN_6);
	}
}

Script "GuardSphereCounter" (void) CLIENTSIDE
{
	Delay(805);
	if(GetActorProperty(0,APROP_HEALTH) > 0 && CheckInventory("PowerQuarterDamage"))
	{
		Playsound(0,"misc/guard_wearoff",CHAN_6);
	}
}

Script "InvisibilitySphereCounter" (void) CLIENTSIDE
{
	Delay(1470);
	if(GetActorProperty(0,APROP_HEALTH) > 0 && (CheckInventory("PowerTranslucency") || CheckInventory("PowerInvisibility")))
	{
		Playsound(0,"misc/invis_wearoff",CHAN_6);
	}
}

// Spam medal checker remover
Script "SpamRemover" (void)
{
	Delay(1);
	TakeInventory("SFortSpam",63);
}

// Frags/Death ratio DEATH script for scoreboard
// Special Thanks to Kaminsky for the assistance on this
/*
Script "FragDeathRatio_Death" DEATH
{
	int player = PlayerNumber();
	int frags = GetPlayerScore(player, SCORE_FRAGS);
	int deaths = GetPlayerScore(player, SCORE_DEATHS);
	int ratio = FixedDiv(frags << 16, deaths << 16);
	if(frags < 1)
	{
		SetCustomPlayerValue("Ratio", player, 0);
	}
	if(frags > 0)
	{
		SetCustomPlayerValue("Ratio", player, ratio);
	}
}*/

// EVENT scripts

Script "SFort_Events_Server" (int type, int arg1, int arg2) EVENT
{

	/// Game/server specific events:

	// Disconnect sound
	if(type == GAMEEVENT_PLAYERLEAVESSERVER)
	{
		ACS_NamedTerminate("SFort_Spectate",0);
		AmbientSound("zandronum/disconnect",127);
		//Playsound(0,"misc/disconnect",CHAN_AUTO,1,0,0);
	}
	// Hit sound
	if(type == GAMEEVENT_ACTOR_DAMAGED)
	{
		SetActivator(0,AAPTR_DAMAGE_SOURCE);
		// If the damage type is Suicide, SelfDestruct, or the damage dealer is the same as the receiver, terminate the script:
		if(StrICmp(arg2,"Suicide") == 0 || StrICmp(arg2,"SelfDestruct") == 0 || IsPointerEqual(AAPTR_DAMAGE_SOURCE,AAPTR_DAMAGE_TARGET,0,0))
		{
			terminate;
		}
		else if(GetUserCVar(PlayerNumber(),"sfort_hitfeedback") == true)
		{
			str hitsounds = StrParam(s:"misc/hitsound_",i:GetUserCVar(PlayerNumber(),"sfort_hitsound"));
			PlaySound(0,hitsounds,CHAN_7,GetUserCVar(PlayerNumber(),"sfort_hitvolume"),0,100.0);
		}
	}
	// Frag/Death ratio
/*	if(type == GAMEEVENT_PLAYERFRAGS)
	{
		// Calculate Frags/Death ratio after a frag
		int player = PlayerNumber();
		int frags = GetPlayerScore(player, SCORE_FRAGS);
		int deaths = GetPlayerScore(player, SCORE_DEATHS);
		if(deaths == 0) // Treat 0 deaths as 1 death to avoid division by 0:
		{
			int ratio1 = FixedDiv(frags << 16, 1 << 16);
			SetCustomPlayerValue("Ratio", player, ratio1);
		}
		if(deaths > 0)
		{
			int ratio2 = FixedDiv(frags << 16, deaths << 16);
			SetCustomPlayerValue("Ratio", player, ratio2);
		}
	}*/
	// Medal disabler
	if(type == GAMEEVENT_MEDALS)
	{
		if(StrICmp(arg1,"Accuracy") == 0 || StrICmp(arg1,"Precision") == 0 || StrICmp(arg1,"YouFailIt") == 0 || StrICmp(arg1,"YourSkillIsNotEnough") == 0)
		{
			SetResultValue(0);
		}
		if((StrICmp(arg1,"Impressive") == 0 || StrICmp(arg1,"MostImpressive") == 0) && (CheckWeapon("SFortBFG10K") || CheckWeapon("SFortPoisonBlaster") || CheckWeapon("MedicNailPistol") || CheckWeapon("MedicScatterPistol") || CheckWeapon("MedicPistol") || CheckWeapon("MedicFist") || CheckWeapon("SFortThunderBolt")))
		{
			SetResultValue(0);
		}
	}
	// Domination
	if(type == GAMEEVENT_DOMINATION_CONTEST)
	{
		if(CheckInventory("GhostStealthItem") || CheckInventory("PowerGhostStealth9"))
		{
			SetResultValue(false);
			TakeInventory("GhostStealthItem",1);
			TakeInventory("PowerGhostStealth1",1);
			TakeInventory("PowerGhostStealth2",1);
			TakeInventory("PowerGhostStealth3",1);
			TakeInventory("PowerGhostStealth4",1);
			TakeInventory("PowerGhostStealth5",1);
			TakeInventory("PowerGhostStealth6",1);
			TakeInventory("PowerGhostStealth7",1);
			TakeInventory("PowerGhostStealth8",1);
			TakeInventory("PowerGhostStealth9",1);
			PlaySound(0,"misc/ghoststealth",CHAN_5);
		}
	}
	
	/// Client specific events:
	
	// Frag quotes
	if(type == GAMEEVENT_PLAYERFRAGS && GetActorProperty(0,APROP_HEALTH) > 0)
	{
		int quotechance = random(1,20);
		if(quotechance == 1)
		{
			Playsound(0,"player/fragquote",CHAN_VOICE);
		}
	}
	// Round end
	if(type == GAMEEVENT_ROUND_ENDS)
	{
		AmbientSound("misc/roundend",127);
	}
	// Capture sounds
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 0)
	{
		AmbientSound("misc/bluecapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 1)
	{
		AmbientSound("misc/redcapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 2)
	{
		AmbientSound("misc/greencapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 3)
	{
		AmbientSound("misc/goldcapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	// Flag taken sounds
	if(type == GAMEEVENT_TOUCHES && arg1 == 0)
	{
		AmbientSound("misc/bluetaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	if(type == GAMEEVENT_TOUCHES && arg1 == 1)
	{
		AmbientSound("misc/redtaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	if(type == GAMEEVENT_TOUCHES && arg1 == 2)
	{
		AmbientSound("misc/greentaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	if(type == GAMEEVENT_TOUCHES && arg1 == 3)
	{
		AmbientSound("misc/goldtaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	// Flag return sounds
	if(type == GAMEEVENT_RETURNS && arg1 == 0)
	{
		AmbientSound("misc/bluereturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_RETURNS && arg1 == 1)
	{
		AmbientSound("misc/redreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_RETURNS && arg1 == 2)
	{
		AmbientSound("misc/greenreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_RETURNS && arg1 == 3)
	{
		AmbientSound("misc/goldreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	// Domination control point capture sounds
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 0) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 0 ))
	{
		AmbientSound("misc/bluereturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 1) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 1)
	{
		AmbientSound("misc/redreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 2) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 2)
	{
		AmbientSound("misc/greenreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 3) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 3)
	{
		AmbientSound("misc/goldreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
}

// Client specific EVENT scripts
/*
Script "SFort_Events_Client" (int type, int arg1, int arg2) EVENT CLIENTSIDE
{
	/// Client specific events
	
	// Frag quotes
	if(type == GAMEEVENT_PLAYERFRAGS && GetActorProperty(0,APROP_HEALTH) > 0)
	{
		int quotechance = random(1,20);
		if(quotechance == 1)
		{
			Playsound(0,"player/fragquote",CHAN_VOICE);
		}
	}
	// Round end
	if(type == GAMEEVENT_ROUND_ENDS)
	{
		AmbientSound("misc/roundend",127);
	}
	// Capture sounds
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 0)
	{
		AmbientSound("misc/bluecapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 1)
	{
		AmbientSound("misc/redcapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 2)
	{
		AmbientSound("misc/greencapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	if(type == GAMEEVENT_CAPTURES && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 3)
	{
		AmbientSound("misc/goldcapture",127);//GetUserCVar(PlayerNumber(),"sfort_capturevolume"));
	}
	// Flag taken sounds
	if(type == GAMEEVENT_TOUCHES && arg1 == 0)
	{
		AmbientSound("misc/bluetaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	if(type == GAMEEVENT_TOUCHES && arg1 == 1)
	{
		AmbientSound("misc/redtaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	if(type == GAMEEVENT_TOUCHES && arg1 == 2)
	{
		AmbientSound("misc/greentaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	if(type == GAMEEVENT_TOUCHES && arg1 == 3)
	{
		AmbientSound("misc/goldtaken",127);//GetUserCVar(PlayerNumber(),"sfort_takenvolume"));
	}
	// Flag return sounds
	if(type == GAMEEVENT_RETURNS && arg1 == 0)
	{
		AmbientSound("misc/bluereturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_RETURNS && arg1 == 1)
	{
		AmbientSound("misc/redreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_RETURNS && arg1 == 2)
	{
		AmbientSound("misc/greenreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_RETURNS && arg1 == 3)
	{
		AmbientSound("misc/goldreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	// Domination control point capture sounds
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 0) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 0 ))
	{
		AmbientSound("misc/bluereturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 1) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 1)
	{
		AmbientSound("misc/redreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 2) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 2)
	{
		AmbientSound("misc/greenreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
	if(type == GAMEEVENT_DOMINATION_PRECONTROL && arg1 == 3) //type == GAMEEVENT_DOMINATION_CONTROL && GetPlayerInfo(PlayerNumber(),PLAYERINFO_TEAM) == 3)
	{
		AmbientSound("misc/goldreturn",127);//GetUserCVar(PlayerNumber(),"sfort_returnvolume"));
	}
		
}*/

// Footstep sound
Script "SFortFootStepSound" (void) CLIENTSIDE
{
	if((GetActorZ(0) - GetActorFloorZ(0) == 0))
	{
		Playsound(0,"player/land",CHAN_AUTO);
	}
}

// BFG Alt-fire text

Script "BFGAltCell" (void)
{
	HudMessage(s:"600 cells needed for BFG alt-fire!";HUDMSG_PLAIN,4710,CR_GOLD,1.5,0.425,2.0);
}

// Scout grenade text

Script "NoGrenades" (void) CLIENTSIDE
{
	HudMessage(s:"No rockets to throw a grenade!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}

// Scorcher texts

Script "ScorcherFireText" (void) CLIENTSIDE
{
	if(GetUserCVar(PlayerNumber(),"sfort_dottext") == true)
	{
		HudMessage(s:"You are on fire!";HUDMSG_PLAIN,4708,CR_GOLD,1.5,0.725,1.0);
	}
	if(GetUserCVar(PlayerNumber(),"sfort_dottext") == false)
	{
		terminate;
	}
}

Script "ScorcherAirblastNoAmmo" (void) CLIENTSIDE
{
	HudMessage(s:"No cells for airblast!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}

// Pioneer texts

Script "PioneerGamemodeCheck" (void)
{
	if(GetCVar("CTF") == 1 || GetCVar("Skulltag") == 1 || GetCVar("Invasion") == 1)
	{
		SetResultValue(0);
	}
	else
	{
		SetResultValue(1);
	}
}
/*
Script "SentryHealth" (void)
{
	int SentryHP = GetActorProperty(0,APROP_HEALTH);
	SetActivator(0,AAPTR_MASTER);
	until(SentryHP <= 0)
	{
		HudMessage(s:"Sentry HP: "+StrParam(i:SentryHP);HUDMSG_PLAIN,4708,CR_BRICK,1.5,0.425,1.0);
		Delay(1);
	}
}*/

Script "SentryPlacing" (void) CLIENTSIDE
{
	HudMessage(s:"Placing Sentry Gun...";HUDMSG_PLAIN,4707,CR_GOLD,1.5,0.5,0.06);
}

Script "SentryBuildingStart" (void) CLIENTSIDE
{
	Delay(1);
	ACS_NamedExecute("SentryBuilding",0);
}

Script "SentryBuilding" (void) CLIENTSIDE
{
	HudMessage(s:"Building Sentry Gun... 8";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 7";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 6";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 5";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 4";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 3";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 2";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 1";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,0.875);
}

Script "FastSentryBuildingStart" (void) CLIENTSIDE
{
	Delay(1);
	ACS_NamedExecute("FastSentryBuilding",0);
}

Script "FastSentryBuilding" (void) CLIENTSIDE
{
	HudMessage(s:"Building Sentry Gun... 4";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 3";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 2";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,1.125);
	Delay(35);
	HudMessage(s:"Building Sentry Gun... 1";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,0.875);
}

Script "SentryComplete" (void) CLIENTSIDE
{
	HudMessage(s:"Sentry Gun ready!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}

Script "SentryDestroyed" (void) CLIENTSIDE
{
	Delay(2);
	ACS_NamedTerminate("SentryBuilding",0);
	HudMessage(s:"Sentry Gun destroyed!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,3.0);
}

Script "SentryDestroyedGlobal" (void)
{
	Log(s:StrParam(n:PlayerNumber()),s:"'s Sentry Gun was destroyed!");
}

Script "SentryAmmoDepleted" (void) CLIENTSIDE
{
	HudMessage(s:"Sentry ammo depleted! Rebuild Sentry Gun!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,3.0);
}

Script "SentryRemoverChecker" (void)
{
	if(CheckActorProperty(0,APROP_SPECIES,"Sentry"))
	{
		SetResultValue(1);
	}
	else
	{
		SetResultValue(0);
	}
}

Script "DispenserPlacing" (void) CLIENTSIDE
{
	HudMessage(s:"Placing Dispenser...";HUDMSG_PLAIN,4707,CR_GOLD,1.5,0.5,0.06);
}

Script "DispenserBuildingStart" (void) CLIENTSIDE
{
	Delay(1);
	ACS_NamedExecute("DispenserBuilding",0);
}

Script "DispenserBuilding" (void) CLIENTSIDE
{
	HudMessage(s:"Building Dispenser... 8";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 7";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 6";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 5";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 4";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 3";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 2";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 1";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,0.875);
}

Script "FastDispenserBuildingStart" (void) CLIENTSIDE
{
	Delay(1);
	ACS_NamedExecute("FastDispenserBuilding",0);
}

Script "FastDispenserBuilding" (void) CLIENTSIDE
{
	HudMessage(s:"Building Dispenser... 4";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 3";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 2";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,1.125);
	Delay(35);
	HudMessage(s:"Building Dispenser... 1";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,0.875);
}

Script "DispenserComplete" (void) CLIENTSIDE
{
	HudMessage(s:"Dispenser ready!";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,2.0);
}

Script "DispenserDestroyed" (void) CLIENTSIDE
{
	Delay(2);
	ACS_NamedTerminate("DispenserBuilding",0);
	HudMessage(s:"Dispenser destroyed!";HUDMSG_PLAIN,4709,CR_GOLD,1.5,0.3875,3.0);
}

Script "DispenserRemoverChecker" (void)
{
	if(CheckActorProperty(0,APROP_SPECIES,"Dispenser"))
	{
		SetResultValue(1);
	}
	else
	{
		SetResultValue(0);
	}
}

// Marksman Railgun texts

Script "RailgunInfo" (void) CLIENTSIDE
{
	HudMessage(s:StrParam(l:"RAILGUN_INFO");HUDMSG_FADEOUT,4704,CR_UNTRANSLATED,1.5,0.75,3.0,1.0);
}

Script "SuperRailgunInfo" (void) CLIENTSIDE
{
	HudMessage(s:StrParam(l:"SUPERRAILGUN_INFO");HUDMSG_FADEOUT,4704,CR_UNTRANSLATED,1.5,0.75,3.0,1.0);
}

Script "RailgunDMG1" (void) CLIENTSIDE {HudMessage(s:"150 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG2" (void) CLIENTSIDE {HudMessage(s:"160 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG3" (void) CLIENTSIDE {HudMessage(s:"170 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG4" (void) CLIENTSIDE {HudMessage(s:"180 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG5" (void) CLIENTSIDE {HudMessage(s:"190 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG6" (void) CLIENTSIDE {HudMessage(s:"200 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG7" (void) CLIENTSIDE {HudMessage(s:"210 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG8" (void) CLIENTSIDE {HudMessage(s:"220 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG9" (void) CLIENTSIDE {HudMessage(s:"230 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG10" (void) CLIENTSIDE {HudMessage(s:"240 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}
Script "RailgunDMG11" (void) CLIENTSIDE {HudMessage(s:"250 DMG";HUDMSG_PLAIN,4705,CR_GOLD,1.5,0.65,1.0);}

Script "RailgunBar1" (void) CLIENTSIDE {HudMessage(s:"\c[M3]IIIIIIIIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar2" (void) CLIENTSIDE {HudMessage(s:"\c[M4]I\c[M3]IIIIIIIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar3" (void) CLIENTSIDE {HudMessage(s:"\c[M1]II\c[M3]IIIIIIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar4" (void) CLIENTSIDE {HudMessage(s:"\c[M1]III\c[M3]IIIIIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar5" (void) CLIENTSIDE {HudMessage(s:"\c[M1]IIII\c[M3]IIIIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar6" (void) CLIENTSIDE {HudMessage(s:"\c[E2]IIIII\c[M3]IIIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar7" (void) CLIENTSIDE {HudMessage(s:"\c[E2]IIIIII\c[M3]IIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar8" (void) CLIENTSIDE {HudMessage(s:"\c[E2]IIIIIII\c[M3]III";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar9" (void) CLIENTSIDE {HudMessage(s:"\c[E2]IIIIIIII\c[M3]II";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar10" (void) CLIENTSIDE {HudMessage(s:"\c[E2]IIIIIIIII\c[M3]I";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}
Script "RailgunBar11" (void) CLIENTSIDE {HudMessage(s:"\c[M6]IIIIIIIIII";HUDMSG_PLAIN,4706,CR_GOLD,0.5,0.68,1.0);}

// Medic texts

Script "PoisonText" (void) CLIENTSIDE
{
	if(GetUserCVar(PlayerNumber(),"sfort_dottext") == true)
	{
		HudMessage(s:"You are poisoned!";HUDMSG_PLAIN,4708,CR_GOLD,1.5,0.725,2.0);
	}
	if(GetUserCVar(PlayerNumber(),"sfort_dottext") == false)
	{
		terminate;
	}
}

Script "MedicHealNoAmmo" (void) CLIENTSIDE
{
	HudMessage(s:"No cells for medi-shots!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}

// Ghost invisibility

Script "GhostInvisLoop_Enter" ENTER
{
	while(PlayerClass(PlayerNumber()) == 9)
	{
		if(GetActorProperty(0,APROP_HEALTH) <= 0)
		{
			terminate;
		}
		else if(CheckInventory("PowerGhostStealth9") == 1)
		{
			TakeInventory("Cell",1);
			Delay(1);
			if(CheckInventory("Cell") == 0)
			{
				TakeInventory("GhostStealthItem",1);
				TakeInventory("PowerGhostStealth1",1);
				TakeInventory("PowerGhostStealth2",1);
				TakeInventory("PowerGhostStealth3",1);
				TakeInventory("PowerGhostStealth4",1);
				TakeInventory("PowerGhostStealth5",1);
				TakeInventory("PowerGhostStealth6",1);
				TakeInventory("PowerGhostStealth7",1);
				TakeInventory("PowerGhostStealth8",1);
				TakeInventory("PowerGhostStealth9",1);
				PlaySound(0,"misc/ghoststealth",CHAN_5);
				HudMessage(s:"Out of cells to stay cloaked!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
			}
		}
		else if(CheckInventory("GhostStealthItem") == 1)
		{
			Delay(1);
		}
		else
		{
			GiveInventory("RegenCell",1);
			Delay(3);
		}
	}
}

Script "GhostInvisLoop_Respawn" RESPAWN
{
	ACS_NamedExecuteAlways("GhostInvisLoop_Enter",0);
}

Script "GhostInvisInfo" (void) CLIENTSIDE
{
	HudMessage(s:"You are already cloaked!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}

Script "GhostInvisTeamItem" (void) CLIENTSIDE
{
	HudMessage(s:"You can't cloak while carrying a team item!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}

// Cyborg cell regeneration

Script "CyborgCellRegen_Enter" ENTER
{
	while(PlayerClass(PlayerNumber()) == 10)
	{
		if(GetActorProperty(0,APROP_HEALTH) <= 0)
		{
			terminate;
		}
		else if(CheckInventory("CyborgFiringItem") == 1)
		{
			Delay(1);
		}
		else
		{
			Delay(7);
			GiveInventory("RegenCell",1);
		}
	}
}

Script "CyborgCellRegen_Respawn" RESPAWN
{
	ACS_NamedExecuteAlways("CyborgCellRegen_Enter",0);
}

// Cyborg Plasma Grenade texts

Script "PlasmaGrenadeText" (void)
{
	HudMessage(s:"Your armor is destroyed!";HUDMSG_PLAIN,4708,CR_GOLD,1.5,0.725,3.0);
}

Script "NoPlasmaGrenades" (void) CLIENTSIDE
{
	HudMessage(s:"200 cells needed for a Plasma Grenade!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}

// Cyborg Thunderbolt text

Script "ThunderboltNoBattery" (void) CLIENTSIDE
{
	HudMessage(s:"Thunderbolt battery low!";HUDMSG_PLAIN,4706,CR_GOLD,1.5,0.425,2.0);
}