#include "zcommon.acs"
#library "global"

int timestop=0;

// Fade Script (?)
//
Script 999 (int fade)
{
	// Clear all fades
	if(fade==0){
	FadeTo(0,0,0,0.0,0.0);
	}
	
	// Fade to Green (?)
	if(fade==1){
	FadeTo(0,255,0,0.3,0.0);
	}
}

// Various per player scritps
// On level enter/spawn
//
script 997 ENTER
{
	// Team specific player colors
	if(PlayerTeam()==1){
	Thing_SetTranslation(0, 48);
	}
	if(PlayerTeam()==2){
	Thing_SetTranslation(0, 43);
	}
	if(PlayerTeam()==3){
	Thing_SetTranslation(0, 47);
	}
	
	// If a timestop is active, freeze the player
	if(timestop>0){
	SetPlayerProperty(0,1,4);
	}

	// If instagib is enabled, give Instagib Blades
	if(GetCvar("instagib")==1){
	TakeInventory("MegaBuster",1);
	GiveInventory("IGMetalBladeWep",1);
	}

	// If player is a bot, enable ledge blocking (Monster Cross Lines)
	if(PlayerIsBot(PlayerNumber())){
	GiveInventory("MonsterBlock",1);
	}

// Give Player a unique TID (tag)
Thing_ChangeTID(0,PlayerNumber()+1000);

// Clear the HUD of any effects/messages etc
HudMessage(s:""; HUDMSG_PLAIN,50,CR_UNTRANSLATED,0.0,0.0,0.1);
}

// Various per player scritps
// On respawn
//
script 996 RESPAWN
{
// Execute the ENTER script above
ACS_ExecuteAlways(997,0);
}

// Foce compat_clientssendfullbuttoninfo true (to enable jump cancel)
//
script 995 OPEN
{
	// Check if multiplayer
	if(PlayerCount()>0){
		// Check if the server has compat_clientssendfullbuttoninfo set to false
		if(GetCVar("compat_clientssendfullbuttoninfo")==0){
		ConsoleCommand("compat_clientssendfullbuttoninfo 1");
		}
		
		// Prevent suicides in LMS and Team LMS
		if(GetCvar("lastmanstanding")==1){
			if(GetCvar("sv_disallowsuicide")==0){
			ConsoleCommand("sv_disallowsuicide 1");
			}
		}
		if(GetCvar("teamlms")==1){
			if(GetCvar("sv_disallowsuicide")==0){
			ConsoleCommand("sv_disallowsuicide 1");
			}
		}
	}
}

// Force certain weapons to not function in CTF/LMS/Possession etc such as Time stop
//
script 994 (void)
{
if(PlayerIsBot(PlayerNumber())){
if(CheckInventory("TimeStopperWep")>0){
TakeInventory("TimeStopperWep",1);
GiveInventory("MegaBuster",1);
SetWeapon("MegaBuster");
}

if(CheckInventory("SkullBarrierWep")>0){
TakeInventory("SkullBarrierWep",1);
GiveInventory("MegaBuster",1);
SetWeapon("MegaBuster");
}

if(CheckInventory("JunkShieldWep")>0){
TakeInventory("JunkShieldWep",1);
GiveInventory("MegaBuster",1);
SetWeapon("MegaBuster");
}

if(CheckInventory("PlantBarrierWep")>0){
TakeInventory("PlantBarrierWep",1);
GiveInventory("MegaBuster",1);
SetWeapon("MegaBuster");
}
SetPlayerProperty(0,1,4);
Delay(1);
SetPlayerProperty(0,0,4);
}}


// Player Color
//
script 991 (int weap)
{
	// Terminate if any teamplay game mode
	if(GetCvar("teamgame")==1){terminate;}
	if(GetCvar("teamplay")==1){terminate;}
	if(GetCvar("teamlms")==1){terminate;}
	if(GetCvar("ctf")==1){terminate;}
	if(GetCvar("oneflagctf")==1){terminate;}

// See WCOLORS for color information
Thing_SetTranslation(0, weap);
}

// Rotation scripts
//
script 990 (int whichrotate)
{
	// Top Spin
	if(whichrotate==1){
	SetActorAngle (ActivatorTID(), GetActorAngle (ActivatorTID()) - 0.06);
	}
	// Power Stone
	if(whichrotate==2){
	SetActorAngle (ActivatorTID(), GetActorAngle (ActivatorTID()) - 0.05);
	}
}

script 989 (void) // Empty script woo!
{

}

// Integer to keep track of the unique TIDs of Power Stone (5000 - 5100)
int powerstonecount=5000;

// Delicously horrible way to keep each unique Power Stone rotating
//
script 988 (void)
{
// New Power Stone TID
powerstonecount++;
Thing_ChangeTID(0,powerstonecount);
	
	// Do not allow any more than 100 Power Stone TIDs
	// FUN FACT: If you can summon more than 100 Power Stones in a match, this will most likely go nuts
	if(powerstonecount>=5100){
	powerstonecount = 5000;
	}
}

// Remove Time Stop on Death (user only)
// (could probably merge a few scripts with this)
script 987 DEATH
{
	// Check if the guy who died stopped time
	if(timestop==PlayerNumber()){
	ACS_Terminate(986,0); // Stop the flashy effects on the HUD for all players
	HudMessageBold(s:""; HUDMSG_PLAIN,50,CR_UNTRANSLATED,0.0,0.0,0.1);
	SetWeapon("MegaBuster");
	Delay(1);
	SetPlayerProperty(1,0,4);
	TakeInventory("PowerTimeFreezer",1);
	TakeInventory("TimeFreezer",1);
	TakeInventory("TimeStopperWep",1);
	timestop=0;
	ACS_Terminate(193,0); //
	}
	
	// Stop the HUD effects
	HudMessageBold(s:""; HUDMSG_PLAIN,50,CR_UNTRANSLATED,0.0,0.0,0.1);
	//ACS_Terminate(986,0);
}

// Time Stopper HUD FX
//
script 986 (void)
{
SetHudSize(256,224,0);
SetFont("FLASHS1");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS2");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS3");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS4");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS5");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS6");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS7");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS8");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
SetFont("FLASHS9");
HudMessageBold(s:"A"; HUDMSG_PLAIN,50,CR_UNTRANSLATED,128.0,112.0,0.0);
Delay(4);
Restart;
}


script 985 (void) // Empty script woo!
{

}

// Very basic Mega Buster check (used for certain items?)
//
script 984 (void)
{
	if(CheckWeapon("MegaBuster")==0){
	SetResultValue( TRUE );
	}
	if(CheckWeapon("MegaBuster")==1){
	SetResultValue( FALSE );
	}
}

// Some extra stuff to help bots
//
script 983 ENTER
{
	if(PlayerIsBot(PlayerNumber())){
		if(timestop==0){
		// Give the bot the special "stair checker" actor
		GiveInventory("CreateBotBuddy",1);
		// And infinite ammo
		GiveInventory("WeaponEnergy",50);
		Delay(1);
		
		// If CutterFlag is 999, the player is dead, so terminate this script
		if(CheckInventory("CutterFlag")==999){terminate;}
		
		Restart;
		}
	}
}

// Duplicate of the above for RESPAWN
//
script 982 RESPAWN
{
ACS_ExecuteAlways(983,0);
}

// Set up weapon randomization for LMS/TLMS
//
str RangedWep[13]={
"BlizzardAttackWep",
"SparkShockWep",
"FireStormWep",
"DustCrusherWep",
"ThunderBeamWep",
"GyroAttackWep",
"DiveMissileWep",
"SilverTomahawkWep",
"MagnetMissileWep",
"NoiseCrushWep",
"GeminiLaserWep",
"ThunderBoltWep",
"FreezeCrackerWep"
};
str RapidWep[8]={
"QuickBoomerangWep",
"IceSlasherWep",
"WaterWaveWep",
"MetalBladeWep",
"ScrewCrusherWep",
"YamatoSpearWep",
"NeedleCannonWep"
};
str CloseWep[16]={
"BubbleLeadWep",
"WindStormWep",
"CrystalEyeWep",
"PowerStoneWep",
"RingBoomerangWep",
"RollingCutterWep",
"ChargeKickWep",
"SearchSnakeWep",
"FlameBlastWep",
"WildCoilWep",
"ShadowBladeWep",
"KnightCrushWep",
"TopSpinWep",
"AirShooterWep",
"SlashClawWep"
};
str PowerWep[10]={
"PharaohShotWep",
"SuperArmWep",
"AtomicFireWep",
"HardKnuckleWep",
"CrashBombWep",
"NapalmBombWep",
"HyperBombWep",
"DangerWrapWep",
"DrillBombWep",
"BalladeCrackerWep"
};
str ShieldWep[7]={
"LeafShieldWep",
"StarCrashWep",
"ScorchWheelWep",
"JunkShieldWep",
"MirrorBusterWep",
"PlantBarrierWep",
"SkullBarrierWep"
};

global int 0:RangedWepRandom;
global int 1:RapidWepRandom;
global int 2:CloseWepRandom;
global int 3:PowerWepRandom;
global int 4:ShieldWepRandom;

// LMS Weapon Randomization
//
script 981 (void)
{
// Check if the game is actually LMS
if(GetCvar("lastmanstanding")==1||GetCvar("teamlms")==1){
	// Ignore if game is set to instagib
	if(GetCvar("instagib")==1){terminate;}
	
	Delay(1);
	
	// Take bots Mega Buster so they actually use a different weapon (limited to ranged weapon at present)
	if(PlayerIsBot(PlayerNumber())){
		TakeInventory("MegaBuster",1);
	}
	
	// Give players one of each weapon type at random
	GiveInventory(ShieldWep[ShieldWepRandom],1);
	GiveInventory(RapidWep[RapidWepRandom],1);
	GiveInventory(CloseWep[CloseWepRandom],1);
	GiveInventory(PowerWep[PowerWepRandom],1);
	GiveInventory(RangedWep[RangedWepRandom],1);
	
	Delay(1);
	
	// Give the bot the Mega Buster back
	if(PlayerIsBot(PlayerNumber())){
		GiveInventory("MegaBuster",1);
	}
}
}

// A script to generate random numbers for LMS weapons
//
script 980 OPEN
{
	Delay(10);
	RangedWepRandom = Random(0,12);
	RapidWepRandom = Random(0,6);
	CloseWepRandom = Random(0,16);
	PowerWepRandom = Random(0,9);
	ShieldWepRandom = Random(0,6);
}

// Clientside script that is executed everytime a weapon's NoAmmo state is called.
// All weapons have it but the script is currently unused.
script 979 (void) CLIENTSIDE
{
}

// Forces a bot to select his Mega Buster.
//
script 978 (void)
{
if(PlayerIsBot(PlayerNumber())){
SetWeapon("MegaBuster");
}
}

int buttons2[32];
int fallingplayer[32];
 
// Jump Canceling script. Very awkward but it works somewhat!
//
script 977 ENTER
{
if(PlayerIsBot(PlayerNumber())){terminate;}
  while (TRUE)
  {
    buttons2[PlayerNumber()] = GetPlayerInput(-1, INPUT_BUTTONS);
	if(GetActorZ (0) - GetActorFloorZ (0)==0.0)
	{
	GiveInventory("JumpCancler",1);
	//print(s:"You're grounded!");
	}
	
	if(GetActorVelZ(0)<0.0)
	{
	TakeInventory("JumpCancler",1);
	//print(s:"You're falling!");
	}
	fallingplayer[ActivatorTID()] = GetActorZ (0);
	
	if(CheckInventory("JumpCancler")>0){
	//print(s:"You let go but are already falling!");
    if (GetPlayerInput(-1, INPUT_OLDBUTTONS) == GetPlayerInput(-1, INPUT_BUTTONS) + BT_JUMP )
    {
	TakeInventory("JumpCancler",1);
    //  print(s:"You let go!");
	  ThrustThingZ(0,0,0,0);
    }}
	
	if(CheckWeapon("SuperAdaptorWep")==1){
	if(CheckInventory("NoBoost")==0){
	if(CheckInventory("JumpCancler")==0){
    if (GetPlayerInput(-1, INPUT_OLDBUTTONS) == GetPlayerInput(-1, INPUT_BUTTONS) - BT_JUMP )
    {
	GiveInventory("Boosting",1);
    }
	}
	}
	}
    delay(1);
		
  }
}

// Quick flash script for Flash Stopper/Centaur Flash
//
script 976 (Void) clientside
{
FadeTo(255,255,255,1.0,0.0);
Delay(2);
FadeTo(255,255,255,0.0,0.0);
Delay(2);
}

// Return the current game mode. Used for checking if certain items should be available in these modes.
// 0 = Deathmatch
// 1 = Poessesion
// 2 = LMS
// 3 = Duel
// 4 = CTF/team game
script 975 (int checkmode)
{
if(checkmode==0){
	if(GetCvar("deathmatch")==1){SetResultValue(0);}
	if(GetCvar("possession")==1){SetResultValue(1);}
	if(GetCvar("teampossession")==1){SetResultValue(1);}
	if(GetCvar("lastmanstanding")==1){SetResultValue(2);}
	if(GetCvar("teamlms")==1){SetResultValue(2);}
	if(GetCvar("duel")==1){SetResultValue(3);}
	if(GetCvar("ctf")==1){SetResultValue(4);}
	if(GetCvar("oneflagctf")==1){SetResultValue(4);}
	if(GetCvar("teamgame")==1){SetResultValue(4);}
	}
if(checkmode==1){
	if(GetCvar("deathmatch")==1){SetResultValue(0);}
	if(GetCvar("possession")==1){SetResultValue(0);}
	if(GetCvar("teampossession")==1){SetResultValue(1);}
	if(GetCvar("lastmanstanding")==1){SetResultValue(0);}
	if(GetCvar("teamlms")==1){SetResultValue(1);}
	if(GetCvar("duel")==1){SetResultValue(0);}
	if(GetCvar("ctf")==1){SetResultValue(1);}
	if(GetCvar("oneflagctf")==1){SetResultValue(1);}
	if(GetCvar("teamgame")==1){SetResultValue(1);}
}
}

// Quickly freeze/unfreeze a bot. Used to force them to keep pressing the fire button
//
script 974 (void) clientside
{
	if(PlayerIsBot(PlayerNumber()))
	{
	SetPlayerProperty(0,1,4);
	Delay(5);
	SetPlayerProperty(0,0,4);
	}
}

// Force players to change certain console commands.
// Word of warning for fellow modders: BE NICE WITH CONSOLECOMMAND!
script 973 ENTER clientside
{
	// Prevent weapon names showing up on the HUD (because they all end in "wep" and it looks wrong)
	ConsoleCommand("cl_showweapnameoncycle false");
}

// Beat Call Script
// Activated on certain maps via sector actions (in pitfalls)
script 205 (void)
{
	if(CheckInventory("BeatCallCheck")>0){
		if(CheckInventory("BeatCounter")==0){
		
		// Remove Rush Jet
		TakeInventory("RushCounter",999);
		// Activate Beat (flying properties etc)
		GiveInventory("BeatActivate",1);
		GiveInventory("BeatCounter",20);
		ThingSound(ActivatorTID(),"item/beat",127);
		
		}
	}
}

// Gravity altering script for certain maps with water (horrible method)
//
script 204 (int grav)
{
	if(grav==0){SetActorProperty(ActivatorTID(), APROP_Gravity, 0.8);}
	if(grav==1){SetActorProperty(ActivatorTID(), APROP_Gravity, 0.25);}
}

// Boss music script. Boss music depends on the level's par setting.
// For custom maps, either change the par or make your own music altering script!
// Also this script is activated via the "KilledMe" actor, which is given to the killer when a player dies.
// Might be useful for other things, such as ingame achievements (GVH style)
script 203 (void)
{
	if(GetCvar("lastmanstanding")==1){terminate;}
	if(GetCvar("teamlms")==1){terminate;}
	if(GetCvar("duel")==1){
		if(PlayerFrags() == GetCVar("fraglimit") - 1){
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==1){SetMusic("MM1BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==2){SetMusic("MM2BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==3){SetMusic("MM3BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==4){SetMusic("MM4BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==5){SetMusic("MM5BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==6){SetMusic("MM6BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==7){SetMusic("MM7BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==8){SetMusic("MM7OBOS");}
	}
	terminate;
	}
	if(GetCvar("ctf")==1){
		terminate;
	}
	if(GetCvar("oneflagctf")==1){
		terminate;
	
	}
	if(GetCvar("possession")==1){terminate;}
	if(GetCvar("teampossession")==1){terminate;}

	// Check if the player has five frags remaining
	if(PlayerFrags() == GetCVar("fraglimit") - 5){
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==1){SetMusic("MM1BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==2){SetMusic("MM2BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==3){SetMusic("MM3BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==4){SetMusic("MM4BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==5){SetMusic("MM5BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==6){SetMusic("MM6BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==7){SetMusic("MM7BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==8){SetMusic("MM7OBOS");}
	}
}

// A Respawn script for check for jump cancelling (akward, might move it later) and freezing players in LMS.
// The latter is done to attempt to stop the weapon randomization messing up
script 201 RESPAWN
{
ACS_ExecuteAlways(977,0);

	if(GetCvar("lastmanstanding")==1||GetCvar("teamlms")==1){
	Delay(1);
		if(Timer()>200){
		//SetPlayerProperty(1,1,4);
		//Instead of freezing, make the player completely invincible!
		GiveInventory("LMSInvincible",1);
		}
	}
}

// Check Flame Blast for oil in Flame Man's stage
//
script 202 (void)
{
if(CheckActorFloorTexture(0, "FLAMOIL1")){
ACS_Execute(1,0,0);
}
if(CheckActorFloorTexture(0, "FLAMOIL2")){
ACS_Execute(2,0,0);
}
}


global int 0:SecretUnlock[];
global int 1: rushtime;

// Unlock Global Value (Singleplayer)
//
Script 200 (int which)
{
SecretUnlock[which]=1;
}

// Check if a global value has been unlocked
//
script 199 (int which)
{
SetResultValue( SecretUnlock[which] );
}

// Set all global values to zero (locked)
//
Script 198 (void)
{
SecretUnlock[0]=0;
SecretUnlock[1]=0;
SecretUnlock[2]=0;
SecretUnlock[3]=0;
SecretUnlock[4]=0;
SecretUnlock[5]=0;
SecretUnlock[6]=0;
SecretUnlock[7]=0;
SecretUnlock[8]=0;
SecretUnlock[9]=0;
}

// Singleplayer secret weapons
//
Script 197 ENTER
{
	// Checks if the second player is a human. Useful for checking if it is TRUELY an online game.
	if(PlayerIsBot(PlayerNumber())){terminate;}
	
	Delay(1);
	
	// Give secret weapons
	if(SecretUnlock[6]==1){
	GiveInventory("ScrewCrusherWep",1);
	}
	if(SecretUnlock[7]==1){
	GiveInventory("MirrorBusterWep",1);
	}
	if(SecretUnlock[8]==1){
	GiveInventory("BalladeCrackerWep",1);
	}
}

// Duplicate of the above, for when you respawn
//
Script 196 RESPAWN
{
ACS_Execute(197,0);
}

// Used to thrust a bot into the air (?)
//
Script 195 (void)
{
	if(PlayerIsBot(PlayerNumber())){
	ThrustThingZ(0,50,0,1);
	Delay(35);
	}
}

// Force a bot to use the Mega Buster (DUPLICATE???)
//
Script 194 (void)
{
	if(PlayerIsBot(PlayerNumber())){
	GiveInventory("MegaBuster",1);
	SetWeapon("MegaBuster");
	}
}

// Needlessly complex failsafe for the Time Stopper
//
Script 193 (void)
{
timestop=PlayerNumber();
//PrintBold(s:"Timestop failsafe started");
Delay(35*30);
//PrintBold(s:"Timestop failsafe Ended");
ACS_Terminate(986,0);
HudMessageBold(s:""; HUDMSG_PLAIN,50,CR_UNTRANSLATED,0.0,0.0,0.1);
Delay(1);
SetPlayerProperty(1,0,4);
TakeInventory("PowerTimeFreezer",1);
TakeInventory("TimeFreezer",1);
TakeInventory("TimeStopperWep",1);
timestop=0;
//PrintBold(s:"Timestop failsafe Sucess!");
}

// Failsafe continued
//
Script 192 (int who) DISCONNECT
{
//PrintBold(s:"Disconnected");
if(timestop==who){
//PrintBold(s:"Found time stopper man");
ACS_Terminate(986,0);
HudMessageBold(s:""; HUDMSG_PLAIN,50,CR_UNTRANSLATED,0.0,0.0,0.1);
SetWeapon("MegaBuster");
Delay(1);
SetPlayerProperty(1,0,4);
//PrintBold(s:"unfroze people");
TakeInventory("PowerTimeFreezer",1);
TakeInventory("TimeFreezer",1);
TakeInventory("TimeStopperWep",1);
timestop=0;
ACS_Terminate(193,0);
}
}

// Scorch Wheel speed adjuster
//
script 191 (int speed)
{
if(speed==1){
SetActorProperty(0,APROP_SPEED,1.45);
}
if(speed==0){
SetActorProperty(0,APROP_SPEED,1.0);
}
}

script 190 OPEN
{
	if(GetCvar("ctf")==1){
		if(BlueScore() == GetCVar("pointlimit") - 1 || RedScore() == GetCVar("pointlimit") - 1){
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==1){SetMusic("MM1BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==2){SetMusic("MM2BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==3){SetMusic("MM3BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==4){SetMusic("MM4BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==5){SetMusic("MM5BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==6){SetMusic("MM6BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==7){SetMusic("MM7BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==8){SetMusic("MM7OBOS");}
		}
	}
	if(GetCvar("oneflagctf")==1){
		if(BlueScore() == GetCVar("pointlimit") - 1 || RedScore() == GetCVar("pointlimit") - 1){
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==1){SetMusic("MM1BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==2){SetMusic("MM2BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==3){SetMusic("MM3BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==4){SetMusic("MM4BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==5){SetMusic("MM5BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==6){SetMusic("MM6BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==7){SetMusic("MM7BOSS");}
		if(GetLevelInfo(LEVELINFO_PAR_TIME)==8){SetMusic("MM7OBOS");}
		}
	}
	if(GetCvar("ctf")==0){
	if(GetCvar("oneflagctf")==0){
	terminate;
	}
	}
	Delay(35*2);
	restart;
}

Script 189 (void)
{
Print(s:"Circuit Board lost! Exiting match...");
consolecommand("sv_noexit 0");
Delay(35*5);
Exit_Normal(0);
}