public static void ApoLost(C3Player player, int reason) { switch (reason) { case 0: { C3Tools.BroadcastMessageToGametype("apoc", "You lost! All died!", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "The Apocalypse failed, because all are dead! Wimps!", Color.Cyan); break; } case 1: { C3Tools.BroadcastMessageToGametype("apoc", "Lost! Idiots! Your not fast enough!", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "The Apocalypse was not defeated in time! Wimps!", Color.Cyan); break; } } TpToSpawns(false); C3Tools.ResetGameType("apoc"); Running = false; Intermission = false; StartCount = 3; //NEW CODE TO EXPAND THE APOCAYLPSE MonsterApocalypseIntermissionTimeCache = C3Mod.C3Config.MonsterApocalypseIntermissionTime; //NEW CODE TO EXPAND THE APOCAYLPSE List <C3Player> Players = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "apoc") { Players.Add(player); } } C3Events.GameEnd(new List <C3Player>(), Players, "apoc", 0, Wave); }
public static void OnUpdate() { lock (C3Mod.C3Players) { if (C3Mod.VoteRunning && C3Mod.VoteType == "ctf") { int VotedPlayers = 0; int TotalPlayers = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "" || player.GameType == "ctf") { TotalPlayers++; } if (player.GameType == "ctf") { VotedPlayers++; } } if (VotedPlayers == TotalPlayers) { C3Tools.BroadcastMessageToGametype("ctf", "Vote to play Capture the Flag passed, Teleporting to start positions", Color.DarkCyan); C3Mod.VoteRunning = false; C3Mod.VoteType = ""; CTF.Team2FlagCarrier = null; CTF.Team1FlagCarrier = null; CTF.Team2Score = 0; CTF.Team1Score = 0; bool[] playersDead = new bool[Main.maxNetPlayers]; CTF.TpToSpawn(); CTF.countDownTick = DateTime.UtcNow; CTF.CTFGameCountdown = true; return; } double tick = (DateTime.UtcNow - voteCountDown).TotalMilliseconds; if (tick > (C3Mod.C3Config.VoteNotifyInterval * 1000) && VoteCount > 0) { if (VoteCount != 1 && VoteCount < (C3Mod.C3Config.VoteTime / C3Mod.C3Config.VoteNotifyInterval)) { C3Tools.BroadcastMessageToGametype("ctf", "Vote still in progress, please be patient", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "Vote to play Capture the Flag in progress, type /join to join the lobby", Color.Cyan); } VoteCount--; voteCountDown = DateTime.UtcNow; } else if (VoteCount == 0) { C3Mod.VoteRunning = false; int team1players = 0; int team2players = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.Team == 1) { team1players++; } else if (player.Team == 2) { team2players++; } } if (team1players >= C3Mod.C3Config.VoteMinimumPerTeam && team2players >= C3Mod.C3Config.VoteMinimumPerTeam) { C3Tools.BroadcastMessageToGametype("ctf", "Vote to play Capture the Flag passed, Teleporting to start positions", Color.DarkCyan); CTF.Team2FlagCarrier = null; CTF.Team1FlagCarrier = null; CTF.Team2Score = 0; CTF.Team1Score = 0; bool[] playersDead = new bool[Main.maxNetPlayers]; CTF.TpToSpawn(); CTF.countDownTick = DateTime.UtcNow; CTF.CTFGameCountdown = true; } else { C3Tools.BroadcastMessageToGametype("ctf", "Vote to play Capture the Flag failed, Not enough players", Color.DarkCyan); } } } if (CTFGameCountdown) { double tick = (DateTime.UtcNow - countDownTick).TotalMilliseconds; if (tick > 1000 && StartCount > -1) { if (TpToSpawn() > 0) { if (StartCount == 0) { C3Tools.BroadcastMessageToGametype("ctf", "Capture...The...Flag!!!", Color.Cyan); StartCount = 5; CTFGameCountdown = false; CTFGameRunning = true; } else { C3Tools.BroadcastMessageToGametype("ctf", "Game starting in " + StartCount.ToString() + "...", Color.Cyan); countDownTick = DateTime.UtcNow; StartCount--; } } else { StartCount = 5; C3Tools.ResetGameType("ctf"); return; } } } if (CTFGameRunning) { int team1players = 0; int team2players = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.TSPlayer == null) { C3Mod.C3Players.Remove(player); break; } if (player.GameType == "ctf") { if (!player.TSPlayer.TpLock) { if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } if (player.Team == 1) { team1players++; } else if (player.Team == 2) { team2players++; } if ((player.Team == 1 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor1)) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor1); } if ((player.Team == 2 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor2)) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor2); } if (!Main.player[player.Index].hostile) { Main.player[player.Index].hostile = true; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index, 0f, 0f, 0f); } //Respawn on flag if (Main.player[player.Index].dead) { player.Dead = true; } else { if (player.Dead) { player.Dead = false; player.TSPlayer.TpLock = false; if (player.Team == 1) { TShock.Players[player.Index].Teleport((int)spawnPoints[0].X, (int)spawnPoints[0].Y); } else if (player.Team == 2) { TShock.Players[player.Index].Teleport((int)spawnPoints[1].X, (int)spawnPoints[1].Y); } NetMessage.SendData(4, -1, player.Index, player.PlayerName, player.Index, 0f, 0f, 0f, 0); if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } } //Grab flag if (!player.Dead) { if (player.Team == 1 && Team1FlagCarrier == null) { if ((int)player.tileX >= flagPoints[1].X - 2 && (int)player.tileX <= flagPoints[1].X + 2 && (int)player.tileY == (int)(flagPoints[1].Y - 3)) { Team1FlagCarrier = player; switch (C3Mod.C3Config.TeamColor1) { case 1: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.OrangeRed); break; } case 2: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.LightGreen); break; } case 3: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.LightBlue); break; } case 4: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.LightYellow); break; } } C3Events.FlagGrabbed(player, "ctf"); } } if (player.Team == 2 && Team2FlagCarrier == null) { if ((int)player.tileX >= flagPoints[0].X - 2 && (int)player.tileX <= flagPoints[0].X + 2 && (int)player.tileY == (int)(flagPoints[0].Y - 3)) { Team2FlagCarrier = player; switch (C3Mod.C3Config.TeamColor2) { case 1: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.OrangeRed); break; } case 2: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.LightGreen); break; } case 3: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.LightBlue); break; } case 4: { C3Tools.BroadcastMessageToGametype("ctf", Main.player[player.Index].name + " has the flag!", Color.LightYellow); break; } } C3Events.FlagGrabbed(player, "ctf"); } } } } } if (team1players == 0 || team2players == 0) { C3Tools.BroadcastMessageToGametype("ctf", "Capture the Flag stopped, Not enough players to continue", Color.DarkCyan); CTFGameRunning = false; TpToSpawns(false); C3Tools.ResetGameType("ctf"); flagPoints = new Vector2[2]; spawnPoints = new Vector2[2]; return; } //Check on flag carriers if (Team2FlagCarrier != null) { //Make them drop the flag if (Team2FlagCarrier.TerrariaDead) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Dropped the flag!", Color.LightBlue); Team2FlagCarrier = null; } //Capture the flag else { if ((int)Team2FlagCarrier.tileX >= flagPoints[1].X - 2 && (int)Team2FlagCarrier.tileX <= flagPoints[1].X + 2 && (int)Team2FlagCarrier.tileY == (int)(flagPoints[1].Y - 3)) { Team2Score++; switch (C3Mod.C3Config.TeamColor2) { case 1: { if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Red - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Green", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Red - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Blue", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Red - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Yellow", Color.OrangeRed); } break; } case 2: { if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Green - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Red", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Green - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Blue", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Green - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Yellow", Color.LightGreen); } break; } case 3: { if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Blue - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Red", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Blue - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Green", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Blue - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Yellow", Color.LightBlue); } break; } case 4: { if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Yellow - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Red", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Yellow - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Green", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("ctf", Team2FlagCarrier.PlayerName + ": Scores! Yellow - " + Team2Score.ToString() + " --- " + Team1Score.ToString() + " - Blue", Color.LightYellow); } break; } } C3Events.FlagCapture(Team2FlagCarrier, "ctf", "Team2", Team2Score, Team1Score); Team2FlagCarrier = null; if (C3Mod.C3Config.RespawnPlayersOnFlagCapture && Team2Score != C3Mod.C3Config.CTFScoreLimit) { Team1FlagCarrier = null; TpToSpawn(); } if (C3Mod.C3Config.ReCountdownOnFlagCapture && Team2Score != C3Mod.C3Config.CTFScoreLimit) { Team1FlagCarrier = null; CTFGameRunning = false; CTFGameCountdown = true; } if (C3Mod.C3Config.HealPlayersOnFlagCapture) { Item heart = TShock.Utils.GetItemById(58); Item star = TShock.Utils.GetItemById(184); foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "ctf") { player.GiveItem(heart.type, heart.name, heart.width, heart.height, 20); player.GiveItem(star.type, star.name, star.width, star.height, 20); } } } } } } if (Team1FlagCarrier != null) { if (Team1FlagCarrier.TerrariaDead) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Dropped the flag!", Color.OrangeRed); Team1FlagCarrier = null; } else { if ((int)Team1FlagCarrier.tileX >= flagPoints[0].X - 2 && (int)Team1FlagCarrier.tileX <= flagPoints[0].X + 2 && (int)Team1FlagCarrier.tileY == (int)(flagPoints[0].Y - 3)) { Team1Score++; switch (C3Mod.C3Config.TeamColor1) { case 1: { if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Red - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Green", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Red - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Blue", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Red - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Yellow", Color.OrangeRed); } break; } case 2: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Green - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Red", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Green - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Blue", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Green - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Yellow", Color.LightGreen); } break; } case 3: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Blue - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Red", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Blue - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Green", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Blue - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Yellow", Color.LightBlue); } break; } case 4: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Yellow - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Red", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Yellow - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Green", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("ctf", Team1FlagCarrier.PlayerName + ": Scores! Yellow - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Blue", Color.LightYellow); } break; } } C3Events.FlagCapture(Team1FlagCarrier, "ctf", "Team1", Team1Score, Team2Score); Team1FlagCarrier = null; if (C3Mod.C3Config.RespawnPlayersOnFlagCapture && Team1Score != C3Mod.C3Config.CTFScoreLimit) { Team2FlagCarrier = null; TpToSpawn(); } if (C3Mod.C3Config.ReCountdownOnFlagCapture && Team1Score != C3Mod.C3Config.CTFScoreLimit) { Team2FlagCarrier = null; CTFGameRunning = false; CTFGameCountdown = true; } if (C3Mod.C3Config.HealPlayersOnFlagCapture) { Item heart = TShock.Utils.GetItemById(58); Item star = TShock.Utils.GetItemById(184); foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "ctf") { player.GiveItem(heart.type, heart.name, heart.width, heart.height, 20); player.GiveItem(star.type, star.name, star.width, star.height, 20); } } } } } } } if (Team2Score == C3Mod.C3Config.CTFScoreLimit) { CTFGameRunning = false; if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("ctf", "RED TEAM WINS!", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("ctf", "GREEN TEAM WINS!", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("ctf", "BLUE TEAM WINS!", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("ctf", "YELLOW TEAM WINS!", Color.LightYellow); } List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "ctf") { if (player1.Team == 2) { WonPlayers.Add(player1); } if (player1.Team == 1) { LostPlayers.Add(player1); } } } C3Events.GameEnd(WonPlayers, LostPlayers, "ctf", Team2Score, Team1Score); TpToSpawns(false); C3Tools.ResetGameType("ctf"); flagPoints = new Vector2[2]; spawnPoints = new Vector2[2]; return; } if (Team1Score == C3Mod.C3Config.CTFScoreLimit) { CTFGameRunning = false; if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("ctf", "RED TEAM WINS!", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("ctf", "GREEN TEAM WINS!", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("ctf", "BLUE TEAM WINS!", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("ctf", "YELLOW TEAM WINS!", Color.LightYellow); } List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "ctf") { if (player1.Team == 1) { WonPlayers.Add(player1); } if (player1.Team == 2) { LostPlayers.Add(player1); } } } C3Events.GameEnd(WonPlayers, LostPlayers, "ctf", Team1Score, Team2Score); TpToSpawns(false); C3Tools.ResetGameType("ctf"); flagPoints = new Vector2[2]; spawnPoints = new Vector2[2]; return; } } }
public static void OnUpdate(EventArgs args) { lock (C3Mod.C3Players) { if (C3Mod.VoteRunning && C3Mod.VoteType == "ffa") { int VotedPlayers = 0; int TotalPlayers = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "" || player.GameType == "ffa") { TotalPlayers++; } if (player.GameType == "ffa") { VotedPlayers++; } } if (VotedPlayers == TotalPlayers) { C3Tools.BroadcastMessageToGametype("ffa", "Vote to play Free For All passed, Teleporting to start position", Color.DarkCyan); C3Mod.VoteRunning = false; C3Mod.VoteType = ""; bool[] playersDead = new bool[Main.maxNetPlayers]; TpToSpawnPoint(); countDownTick = DateTime.UtcNow; FFACountdown = true; return; } double tick = (DateTime.UtcNow - voteCountDown).TotalMilliseconds; if (tick > (C3Mod.C3Config.VoteNotifyInterval * 1000) && VoteCount > 0) { if (VoteCount != 1 && VoteCount < (C3Mod.C3Config.VoteTime / C3Mod.C3Config.VoteNotifyInterval)) { C3Tools.BroadcastMessageToGametype("ffa", "Vote still in progress, please be patient", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "Vote to play Free For All in progress, type /join to join the lobby", Color.Cyan); } VoteCount--; voteCountDown = DateTime.UtcNow; } else if (VoteCount == 0) { C3Mod.VoteRunning = false; int players = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "ffa") { players++; } } if (players >= C3Mod.C3Config.VoteMinimumPerTeam) { C3Tools.BroadcastMessageToGametype("ffa", "Vote to play Free For All passed, Teleporting to start position", Color.DarkCyan); bool[] playersDead = new bool[Main.maxNetPlayers]; TpToSpawnPoint(); countDownTick = DateTime.UtcNow; FFACountdown = true; } else { C3Tools.BroadcastMessageToGametype("ffa", "Vote to play Free For All failed, Not enough players", Color.DarkCyan); FFASpawn = new Vector2(); } } } if (FFACountdown) { double tick = (DateTime.UtcNow - countDownTick).TotalMilliseconds; if (tick > 1000 && StartCount > -1) { if (TpToSpawnPoint() > 0) { if (StartCount == 0) { C3Tools.BroadcastMessageToGametype("ffa", "Fight!!!", Color.Cyan); foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "ffa") { player.SpawnProtectionEnabled = true; player.LastSpawn = DateTime.UtcNow; } } StartCount = 5; FFACountdown = false; FFARunning = true; } else { C3Tools.BroadcastMessageToGametype("ffa", "Game starting in " + StartCount + "...", Color.Cyan); countDownTick = DateTime.UtcNow; StartCount--; } } else { StartCount = 5; C3Tools.ResetGameType("ffa"); return; } } } if (FFARunning) { int players = 0; double tick = (DateTime.UtcNow - scoreNotify).TotalMilliseconds; lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.TSPlayer == null) { C3Mod.C3Players.Remove(player); break; } if (player.GameType == "ffa") { if (!player.TSPlayer.TpLock) { if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } players++; if (Main.player[player.Index].team != 0) { TShock.Players[player.Index].SetTeam(0); } if (!Main.player[player.Index].hostile) { Main.player[player.Index].hostile = true; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index, 0f, 0f, 0f); } double tick2 = (DateTime.UtcNow - player.LastSpawn).TotalMilliseconds; if (player.SpawnProtectionEnabled && tick2 >= (C3Mod.C3Config.FFASpawnProtectionTime * 1000)) { player.SpawnProtectionEnabled = false; } if (!Main.player[player.Index].dead && player.Dead) { player.LastSpawn = DateTime.UtcNow; player.SpawnProtectionEnabled = true; player.Dead = false; player.TSPlayer.TpLock = false; TShock.Players[player.Index].Teleport((int)FFASpawn.X * 16, (int)FFASpawn.Y * 16); NetMessage.SendData(4, -1, player.Index, player.PlayerName, player.Index, 0f, 0f, 0f, 0); if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } if (player.FFAScore == C3Mod.C3Config.FFAScorelimit) { FFARunning = false; C3Tools.BroadcastMessageToGametype("ffa", player.TSPlayer.Name + " WINS!", Color. Blue); List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> Winner = new List <C3Player>(); Winner.Add(player); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "ffa") { if (player1 != player) { LostPlayers.Add(player); } } } C3Events.GameEnd(Winner, LostPlayers, "ffa", player.FFAScore, -1); TpToSpawns(false); C3Tools.ResetGameType("ffa"); TDM.TDMSpawns = new Vector2[2]; return; } } } } if (players == 1) { C3Tools.BroadcastMessageToGametype("ffa", "Not enough players to continue, ending game", Color.DarkCyan); FFARunning = false; TpToSpawns(false); C3Tools.ResetGameType("ffa"); TDM.TDMSpawns = new Vector2[2]; } } } }
public static void OnUpdate(EventArgs args) { lock (C3Mod.C3Players) { if (C3Mod.VoteRunning && C3Mod.VoteType == "tdm") { int VotedPlayers = 0; int TotalPlayers = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "" || player.GameType == "tdm") { TotalPlayers++; } if (player.GameType == "tdm") { VotedPlayers++; } } if (VotedPlayers == TotalPlayers) { C3Tools.BroadcastMessageToGametype("tdm", "Vote to play Team Deathmatch passed! Teleporting to start positions!", Color.DarkCyan); C3Mod.VoteRunning = false; C3Mod.VoteType = ""; Team2Score = 0; Team1Score = 0; bool[] playersDead = new bool[Main.maxNetPlayers]; TpToSpawnPoint(); countDownTick = DateTime.UtcNow; TDMCountdown = true; return; } double tick = (DateTime.UtcNow - voteCountDown).TotalMilliseconds; if (tick > (C3Mod.C3Config.VoteNotifyInterval * 1000) && VoteCount > 0) { if (VoteCount != 1 && VoteCount < (C3Mod.C3Config.VoteTime / C3Mod.C3Config.VoteNotifyInterval)) { C3Tools.BroadcastMessageToGametype("tdm", "Vote still in progress, please be patient!", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "Vote to play Team Deathmatch in progress, type /join to join the lobby!", Color.Cyan); } VoteCount--; voteCountDown = DateTime.UtcNow; } else if (VoteCount == 0) { C3Mod.VoteRunning = false; int team1players = 0; int team2players = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.Team == 7) { team1players++; } else if (player.Team == 8) { team2players++; } } if (team1players >= C3Mod.C3Config.VoteMinimumPerTeam && team2players >= C3Mod.C3Config.VoteMinimumPerTeam) { C3Tools.BroadcastMessageToGametype("tdm", "Vote to play Team Deathmatch passed! Teleporting to start positions!", Color.DarkCyan); Team2Score = 0; Team1Score = 0; bool[] playersDead = new bool[Main.maxNetPlayers]; TpToSpawnPoint(); countDownTick = DateTime.UtcNow; TDMCountdown = true; } else { C3Tools.BroadcastMessageToGametype("tdm", "Vote to play Team Deathmatch failed. Not enough players!", Color.DarkCyan); TDM.TDMSpawns = new Vector2[2]; } } } if (TDMCountdown) { double tick = (DateTime.UtcNow - countDownTick).TotalMilliseconds; if (tick > 1000 && StartCount > -1) { if (TpToSpawnPoint() > 0) { if (StartCount == 0) { C3Tools.BroadcastMessageToGametype("tdm", "Fight!!!", Color.Cyan); StartCount = 5; TDMCountdown = false; TDMRunning = true; } else { C3Tools.BroadcastMessageToGametype("tdm", "Game starting in " + StartCount.ToString() + "...", Color.Cyan); countDownTick = DateTime.UtcNow; StartCount--; } } else { StartCount = 5; C3Tools.ResetGameType("tdm"); return; } } } if (TDMRunning) { int Team1Players = 0; int Team2Players = 0; double tick = (DateTime.UtcNow - scoreNotify).TotalMilliseconds; if (tick > (C3Mod.C3Config.TDMScoreNotifyInterval * 1000)) { switch (C3Mod.C3Config.TeamColor1) { case 1: { if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Red - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Green", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Red - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Blue", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Red - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Yellow", Color.Cyan); } break; } case 2: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Green - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Red", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Green - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Blue", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Green - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Yellow", Color.Cyan); } break; } case 3: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Blue - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Red", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Blue - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Green", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Blue - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Blue", Color.Cyan); } break; } case 4: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Yellow - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Red", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Yellow - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Green", Color.Cyan); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("tdm", "Current score: Yellow - " + Team1Score.ToString() + " --- " + Team2Score.ToString() + " - Blue", Color.Cyan); } break; } } scoreNotify = DateTime.UtcNow; } lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.TSPlayer == null) { C3Mod.C3Players.Remove(player); break; } if (player.GameType == "tdm") { if (!player.TSPlayer.TpLock) { if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } if (player.Team == 7) { Team1Players++; } else if (player.Team == 8) { Team2Players++; } if ((player.Team == 7 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor1)) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor1); } if ((player.Team == 8 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor2)) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor2); } if (!Main.player[player.Index].hostile) { Main.player[player.Index].hostile = true; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index, 0f, 0f, 0f); } //Respawn on flag if (Main.player[player.Index].dead && !player.Dead) { if (player.Team == 7) { Team2Score++; player.Dead = true; } else if (player.Team == 8) { Team1Score++; player.Dead = true; } } if (!Main.player[player.Index].dead && player.Dead) { player.Dead = false; player.TSPlayer.TpLock = false; if (player.Team == 7) { TShock.Players[player.Index].Teleport((int)TDMSpawns[0].X * 16, (int)TDMSpawns[0].Y * 16); } else if (player.Team == 8) { TShock.Players[player.Index].Teleport((int)TDMSpawns[1].X * 16, (int)TDMSpawns[1].Y * 16); } NetMessage.SendData(4, -1, player.Index, player.PlayerName, player.Index, 0f, 0f, 0f, 0); if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } } } } if (Team1Players == 0 || Team2Players == 0) { C3Tools.BroadcastMessageToGametype("tdm", "Ending game, because not enough players to continue!!", Color.DarkCyan); TDMRunning = false; TpToSpawns(false); C3Tools.ResetGameType("tdm"); TDM.TDMSpawns = new Vector2[2]; return; } if (Team2Score == C3Mod.C3Config.TeamDeathmatchScorelimit) { TDMRunning = false; if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("tdm", "Red Team wins!", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("tdm", "Green Team wins!", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("tdm", "Blue Team wins!", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("tdm", "Yellow Team wins!", Color.LightYellow); } List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "tdm") { if (player1.Team == 8) { WonPlayers.Add(player1); } if (player1.Team == 7) { LostPlayers.Add(player1); } } } C3Events.GameEnd(WonPlayers, LostPlayers, "tdm", Team2Score, Team1Score); TpToSpawns(false); C3Tools.ResetGameType("tdm"); TDM.TDMSpawns = new Vector2[2]; return; } if (Team1Score == C3Mod.C3Config.TeamDeathmatchScorelimit) { TDMRunning = false; if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("tdm", "Red Team wins!", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("tdm", "Green Team wins!", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("tdm", "Blue Team wins!", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("tdm", "Yellow Team wins!", Color.LightYellow); } List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "tdm") { if (player1.Team == 7) { WonPlayers.Add(player1); } if (player1.Team == 8) { LostPlayers.Add(player1); } } } C3Events.GameEnd(WonPlayers, LostPlayers, "tdm", Team1Score, Team2Score); TpToSpawns(false); C3Tools.ResetGameType("tdm"); TDM.TDMSpawns = new Vector2[2]; return; } } } }
public static void OnUpdate() { if (C3Mod.VoteRunning && C3Mod.VoteType == "apoc") { int VotedPlayers = 0; int TotalPlayers = 0; lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "" || player.GameType == "apoc") { TotalPlayers++; } if (player.GameType == "apoc") { VotedPlayers++; } } } if (VotedPlayers == TotalPlayers) { C3Tools.BroadcastMessageToGametype("apoc", "Vote to play Monster Apocalypse passed, Teleporting to start positions", Color.DarkCyan); bool[] playersDead = new bool[Main.maxNetPlayers]; TpToSpawnPoint(); countDownTick = DateTime.UtcNow; Intermission = true; C3Mod.VoteType = ""; C3Mod.VoteRunning = false; ChooseNPC(); return; } double tick = (DateTime.UtcNow - voteCountDown).TotalMilliseconds; if (tick > (C3Mod.C3Config.VoteNotifyInterval * 1000) && VoteCount > 0) { if (VoteCount != 1 && VoteCount < (C3Mod.C3Config.VoteTime / C3Mod.C3Config.VoteNotifyInterval)) { C3Tools.BroadcastMessageToGametype("apoc", "Vote still in progress, please be patient", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "Vote to play Monster Apocalypse in progress, type /join to join the lobby", Color.Cyan); } VoteCount--; voteCountDown = DateTime.UtcNow; } else if (VoteCount == 0) { C3Mod.VoteRunning = false; int players = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "apoc") { players++; } } if (players >= C3Mod.C3Config.MonsterApocalypseMinimumPlayers) { C3Tools.BroadcastMessageToGametype("apoc", "Vote to play Monster Apocalypse passed, Teleporting to start positions", Color.DarkCyan); bool[] playersDead = new bool[Main.maxNetPlayers]; TpToSpawnPoint(); countDownTick = DateTime.UtcNow; Intermission = true; C3Mod.VoteType = ""; C3Mod.VoteRunning = false; ChooseNPC(); return; } else { C3Tools.BroadcastMessageToGametype("apoc", "Vote to play Monster Apocalypse failed, Not enough players", Color.DarkCyan); } } } if (Intermission) { double tick = (DateTime.UtcNow - countDownTick).TotalMilliseconds; if (tick > 5000 && StartCount > -1) { if (TpToSpawnPoint() > 0) { if (StartCount == 0) { C3Tools.BroadcastMessageToGametype("apoc", "Fight!!!", Color.Cyan); StartCount = 3; Intermission = false; Running = true; SpawnMonsters(); playersdead = 0; foreach (C3Player player in C3Mod.C3Players) { player.Dead = false; player.LivesUsed = 0; } } else { Random r = new Random(); switch (r.Next(20) + 1) { case 1: { C3Tools.BroadcastMessageToGametype("apoc", "Apocalypse in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 2: { C3Tools.BroadcastMessageToGametype("apoc", "World's demise in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 3: { C3Tools.BroadcastMessageToGametype("apoc", "You are dead in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 4: { C3Tools.BroadcastMessageToGametype("apoc", "Goodbye. Wave starting in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 5: { C3Tools.BroadcastMessageToGametype("apoc", "Are you ready? No. Wave starting in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 6: { C3Tools.BroadcastMessageToGametype("apoc", "DOOOM! Wave starting in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 7: { C3Tools.BroadcastMessageToGametype("apoc", "Once upon a time.. You died. Wave starting in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 8: { C3Tools.BroadcastMessageToGametype("apoc", "The year 2012 in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 9: { C3Tools.BroadcastMessageToGametype("apoc", "Space Ship's Leaving in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 10: { C3Tools.BroadcastMessageToGametype("apoc", "Rawr! Wave starting in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 11: { C3Tools.BroadcastMessageToGametype("apoc", "Twitchy is awesome! Wave starting in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 12: { C3Tools.BroadcastMessageToGametype("apoc", "Umm... " + (StartCount * 5).ToString() + " till...death?", Color.Cyan); break; } case 13: { C3Tools.BroadcastMessageToGametype("apoc", "It hurts ok? Dont believe otherwise! Pain in: " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 14: { C3Tools.BroadcastMessageToGametype("apoc", "Fun in: " + (StartCount * 5).ToString() + ".... Oh wait. Nvm. You'll find out.", Color.Cyan); break; } case 15: { C3Tools.BroadcastMessageToGametype("apoc", "MWAHAHAHA. Oh, hi there. Ignore that... " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 16: { C3Tools.BroadcastMessageToGametype("apoc", "The Twitchy god spites you! " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 17: { C3Tools.BroadcastMessageToGametype("apoc", "Peanut butter. Best cure for all cuts and bruises " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 19: { C3Tools.BroadcastMessageToGametype("apoc", "Hehehe... " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } case 20: { C3Tools.BroadcastMessageToGametype("apoc", "C3 Apocalypse. Leading the way since 2010! " + (StartCount * 5).ToString() + "...", Color.Cyan); break; } } C3Tools.BroadcastMessageToGametype("apoc", "Next Monster: " + CurMonster.name, Color.Cyan); countDownTick = DateTime.UtcNow; StartCount--; } } else { StartCount = 3; C3Tools.ResetGameType("apoc"); return; } } } if (Running) { double tick = (DateTime.UtcNow - scoreNotify).TotalMilliseconds; if (tick > (C3Mod.C3Config.MonsterApocalypseScoreNotifyInterval * 1000)) { C3Tools.BroadcastMessageToGametype("apoc", CurMonster.name + "'s Left: " + MonstersLeft.ToString(), Color.Cyan); scoreNotify = DateTime.UtcNow; } if (MonstersLeft == 0) { Running = false; Intermission = true; ChooseNPC(); Wave++; List <C3Player> AlivePlayers = new List <C3Player>(); List <C3Player> SpecatingPlayers = new List <C3Player>(); foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "apoc") { if (player.Spectator) { SpecatingPlayers.Add(player); } else { AlivePlayers.Add(player); } } } C3Events.WaveAdvance(AlivePlayers, SpecatingPlayers, Wave); return; } foreach (NPC npc in MonsterWhoAmI) { if (!npc.active) { MonsterWhoAmI.Remove(npc); MonstersLeft--; if (MonstersLeft == 0) { Running = false; Intermission = true; Running = false; Wave++; ChooseNPC(); return; } break; } } int apocplayers = 0; lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "apoc") { apocplayers++; player.TSPlayer.SetPvP(false); if (player.TerrariaTeam != 3) { player.TSPlayer.SetTeam(3); } if (!player.TSPlayer.TpLock) { if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } if (Main.player[player.Index].dead) { player.LivesUsed++; player.TSPlayer.TpLock = false; if (player.LivesUsed >= C3Mod.C3Config.MonsterApocalypseLivesPerWave && !player.Dead) { playersdead++; if (playersdead == apocplayers) { C3Tools.BroadcastMessageToGametype("apoc", "Your team failed to survive the Apocalypse!", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "Players on this server failed to survive the apocalypse!", Color.Cyan); TpToSpawns(false); C3Tools.ResetGameType("apoc"); Running = false; Intermission = false; List <C3Player> Players = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "apoc") { Players.Add(player); } } C3Events.GameEnd(new List <C3Player>(), Players, "apoc", 0, Wave); } else { C3Tools.BroadcastMessageToGametype("apoc", player.PlayerName + ": Is out!", Color.Cyan); player.TSPlayer.Teleport((int)SpectatorArea.X, (int)SpectatorArea.Y); player.Dead = true; } } else { player.SendMessage("Lives left: " + (C3Mod.C3Config.MonsterApocalypseLivesPerWave - player.LivesUsed).ToString(), Color.Cyan); player.TSPlayer.Teleport((int)PlayerSpawn.X, (int)PlayerSpawn.Y); } } } } } } }
public static void OnUpdate(EventArgs args) { lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.Challenging != null) { double tick = (DateTime.UtcNow - player.ChallengeTick).TotalMilliseconds; if (tick > (C3Mod.C3Config.DuelNotifyInterval * 1000)) { if (player.ChallengeNotifyCount != 1) { player.Challenging.SendMessage("You have been challenged to a duel by: " + player.PlayerName + " in Arena: " + Arenas[player.Challenging.ChallengeArena - 1].Name, Color.Cyan); player.Challenging.SendMessage("Type /accept to accept this challenge!", Color.Cyan); } player.ChallengeNotifyCount--; player.ChallengeTick = DateTime.UtcNow; } else if (player.ChallengeNotifyCount == 0) { player.Challenging.SendMessage("Challenge by: " + player.PlayerName + " timed out!", Color.Cyan); player.SendMessage(player.Challenging.PlayerName + ": Did not answer your challenge in the required amount of time!", Color.DarkCyan); player.Challenging = null; player.ChallengeNotifyCount = 5; } } } } if (DuelCountdown) { double tick = (DateTime.UtcNow - countDownTick).TotalMilliseconds; if (tick > 1000 && StartCount > -1) { if (TpToSpawnPoint() > 0) { if (StartCount == 0) { C3Tools.BroadcastMessageToGametype("1v1", "Fight!!!", Color.Cyan); StartCount = 5; DuelCountdown = false; DuelRunning = true; } else { C3Tools.BroadcastMessageToGametype("1v1", "Game starting in " + StartCount.ToString() + "...", Color.Cyan); countDownTick = DateTime.UtcNow; StartCount--; } } else { StartCount = 5; C3Tools.ResetGameType("1v1"); return; } } } if (DuelRunning) { int Team1PlayerCount = 0; int Team2PlayerCount = 0; lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.TSPlayer == null) { C3Mod.C3Players.Remove(player); break; } if (player.GameType == "1v1") { if (!player.TSPlayer.TpLock) { if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } if (player.Team == 3) { Team1PlayerCount++; } else if (player.Team == 4) { Team2PlayerCount++; } if ((player.Team == 3 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor1)) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor1); } else if (player.Team == 4 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor2) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor2); } if (!Main.player[player.Index].hostile) { Main.player[player.Index].hostile = true; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index, 0f, 0f, 0f); } //Respawn on flag if (Main.player[player.Index].dead) { if (player.Team == 3) { Team2PlayerScore++; if (Team2PlayerScore != C3Mod.C3Config.DuelScoreLimit) { C3Tools.BroadcastMessageToGametype("1v1", Team2Player.PlayerName + " Scores!", Color.DarkCyan); C3Tools.BroadcastMessageToGametype("1v1", Team1Player.PlayerName + " (" + Team1PlayerScore + ") - (" + Team2PlayerScore + ") " + Team2Player.PlayerName, Color.DarkCyan); TpToSpawnPoint(); DuelRunning = false; DuelCountdown = true; Item heart = TShock.Utils.GetItemById(58); Item star = TShock.Utils.GetItemById(184); foreach (C3Player players in C3Mod.C3Players) { if (players.GameType == "1v1") { players.GiveItem(heart.type, heart.name, heart.width, heart.height, 20); players.GiveItem(star.type, star.name, star.width, star.height, 20); } } } } else if (player.Team == 4) { Team1PlayerScore++; if (Team1PlayerScore != C3Mod.C3Config.DuelScoreLimit) { C3Tools.BroadcastMessageToGametype("1v1", Team1Player.PlayerName + " Scores!", Color.DarkCyan); C3Tools.BroadcastMessageToGametype("1v1", Team1Player.PlayerName + " (" + Team1PlayerScore + ") - (" + Team2PlayerScore + ") " + Team2Player.PlayerName, Color.DarkCyan); TpToSpawnPoint(); DuelRunning = false; DuelCountdown = true; Item heart = TShock.Utils.GetItemById(58); Item star = TShock.Utils.GetItemById(184); foreach (C3Player players in C3Mod.C3Players) { if (players.GameType == "1v1") { players.GiveItem(heart.type, heart.name, heart.width, heart.height, 20); players.GiveItem(star.type, star.name, star.width, star.height, 20); } } } } } } } } if (Team1PlayerCount == 0 || Team2PlayerCount == 0) { C3Tools.BroadcastMessageToGametype("1v1", "Ending game because the opponent left!", Color.DarkCyan); DuelRunning = false; TpToSpawns(false); C3Tools.ResetGameType("1v1"); Team1Player = null; Team2Player = null; DuelSpawns = new Vector2[2]; return; } if (Team2PlayerScore == C3Mod.C3Config.DuelScoreLimit) { DuelRunning = false; C3Tools.BroadcastMessageToGametype("1v1", Team2Player.PlayerName + " won!", Color.DarkCyan); C3Tools.BroadcastMessageToGametype("", Team2Player.PlayerName + " defeated " + Team1Player.PlayerName + " in a duel!", Color.DarkCyan); List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); WonPlayers.Add(Team2Player); LostPlayers.Add(Team1Player); C3Events.GameEnd(WonPlayers, LostPlayers, "1v1", Team2Player.FFAScore, Team1Player.FFAScore); TpToSpawns(false); C3Tools.ResetGameType("1v1"); Team1Player = null; Team2Player = null; DuelSpawns = new Vector2[2]; return; } if (Team1PlayerScore == C3Mod.C3Config.DuelScoreLimit) { DuelRunning = false; C3Tools.BroadcastMessageToGametype("1v1", Team1Player.PlayerName + " won!", Color.DarkCyan); C3Tools.BroadcastMessageToGametype("", Team1Player.PlayerName + " defeated " + Team2Player.PlayerName + " in a duel!", Color.DarkCyan); List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); WonPlayers.Add(Team1Player); LostPlayers.Add(Team2Player); C3Events.GameEnd(WonPlayers, LostPlayers, "1v1", Team1Player.FFAScore, Team2Player.FFAScore); TpToSpawns(false); C3Tools.ResetGameType("1v1"); Team1Player = null; Team2Player = null; DuelSpawns = new Vector2[2]; return; } } }
public static void OnUpdate(EventArgs args) { lock (C3Mod.C3Players) { if (C3Mod.VoteRunning && C3Mod.VoteType == "oneflag") { int VotedPlayers = 0; int TotalPlayers = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "" || player.GameType == "oneflag") { TotalPlayers++; } if (player.GameType == "oneflag") { VotedPlayers++; } } if (VotedPlayers == TotalPlayers) { C3Tools.BroadcastMessageToGametype("oneflag", "Vote to play Capture One Flag passed! Teleporting to start positions!", Color.DarkCyan); C3Mod.VoteRunning = false; C3Mod.VoteType = ""; FlagCarrier = null; Team1Score = 0; Team2Score = 0; bool[] playersDead = new bool[Main.maxNetPlayers]; TpToOneFlagSpawns(); countDownTick = DateTime.UtcNow; OneFlagGameCountdown = true; return; } double tick = (DateTime.UtcNow - voteCountDown).TotalMilliseconds; if (tick > (C3Mod.C3Config.VoteNotifyInterval * 1000) && VoteCount > 0) { if (VoteCount != 1 && VoteCount < (C3Mod.C3Config.VoteTime / C3Mod.C3Config.VoteNotifyInterval)) { C3Tools.BroadcastMessageToGametype("oneflag", "Vote still in progress, please be patient!", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "Vote to play Capture One Flag in progress, type /join to join the lobby!", Color.Cyan); } VoteCount--; voteCountDown = DateTime.UtcNow; } else if (VoteCount == 0) { C3Mod.VoteRunning = false; int redteamplayers = 0; int blueteamplayers = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.Team == 5) { redteamplayers++; } else if (player.Team == 6) { blueteamplayers++; } } if (redteamplayers >= C3Mod.C3Config.VoteMinimumPerTeam && blueteamplayers >= C3Mod.C3Config.VoteMinimumPerTeam) { C3Tools.BroadcastMessageToGametype("oneflag", "Vote to play Capture One Flag passed! Teleporting to start positions!", Color.DarkCyan); FlagCarrier = null; Team1Score = 0; Team2Score = 0; bool[] playersDead = new bool[Main.maxNetPlayers]; TpToOneFlagSpawns(); countDownTick = DateTime.UtcNow; OneFlagGameCountdown = true; } else { C3Tools.BroadcastMessageToGametype("oneflag", "Vote to play Capture One Flag failed. Not enough players!", Color.DarkCyan); } } } if (OneFlagGameCountdown) { double tick = (DateTime.UtcNow - countDownTick).TotalMilliseconds; if (tick > 1000 && StartCount > -1) { if (TpToOneFlagSpawns() > 0) { if (StartCount == 0) { C3Tools.BroadcastMessageToGametype("oneflag", "Capture the flag!!!", Color.Cyan); StartCount = 5; OneFlagGameCountdown = false; OneFlagGameRunning = true; } else { C3Tools.BroadcastMessageToGametype("oneflag", "Game starting in " + StartCount.ToString() + "...", Color.Cyan); countDownTick = DateTime.UtcNow; StartCount--; } } else { StartCount = 5; C3Tools.ResetGameType("oneflag"); return; } } } if (OneFlagGameRunning) { int team1players = 0; int team2players = 0; lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.TSPlayer == null) { C3Mod.C3Players.Remove(player); break; } if (player.GameType == "oneflag") { if (!player.TSPlayer.TpLock) { if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } if (player.Team == 5) { team1players++; } else if (player.Team == 6) { team2players++; } if ((player.Team == 5 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor1)) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor1); } else if (player.Team == 6 && Main.player[player.Index].team != C3Mod.C3Config.TeamColor2) { TShock.Players[player.Index].SetTeam(C3Mod.C3Config.TeamColor2); } if (!Main.player[player.Index].hostile) { Main.player[player.Index].hostile = true; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index, 0f, 0f, 0f); } //Respawn on flag if (Main.player[player.Index].dead) { player.Dead = true; } else { if (player.Dead) { player.Dead = false; player.TSPlayer.TpLock = false; if (player.Team == 5) { TShock.Players[player.Index].Teleport((int)SpawnPoint[0].X * 16, (int)SpawnPoint[0].Y * 16); } else if (player.Team == 6) { TShock.Players[player.Index].Teleport((int)SpawnPoint[1].X * 16, (int)SpawnPoint[1].Y * 16); } NetMessage.SendData(4, -1, player.Index, player.PlayerName, player.Index, 0f, 0f, 0f, 0); if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } } //Grab flag if (!player.Dead) { if (FlagCarrier == null) { if ((int)player.tileX <= (int)FlagPoint.X + 2 && (int)player.tileX >= (int)FlagPoint.X - 2 && (int)player.tileY == (int)FlagPoint.Y - 3) { FlagCarrier = player; if (player.Team == 5) { switch (C3Mod.C3Config.TeamColor1) { case 1: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.OrangeRed); break; } case 2: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.LightGreen); break; } case 3: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.LightBlue); break; } case 4: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.LightYellow); break; } } } else if (player.Team == 6) { switch (C3Mod.C3Config.TeamColor2) { case 1: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.OrangeRed); break; } case 2: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.LightGreen); break; } case 3: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.LightBlue); break; } case 4: { C3Tools.BroadcastMessageToGametype("oneflag", Main.player[player.Index] .name + " has the flag!", Color.LightYellow); break; } } } C3Events.FlagGrabbed(FlagCarrier, "oneflag"); } } } } } } if (team1players == 0 || team2players == 0) { C3Tools.BroadcastMessageToGametype("oneflag", "Ending game, because not enough players to continue!", Color.DarkCyan); OneFlagGameRunning = false; SendToSpawn(false); C3Tools.ResetGameType("oneflag"); return; } //Check on flag carrier if (FlagCarrier != null) { //Make them drop the flag if (Main.player[FlagCarrier.Index].dead) { if (FlagCarrier.Team == 5) { switch (C3Mod.C3Config.TeamColor1) { case 1: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.OrangeRed); break; } case 2: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.LightGreen); break; } case 3: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.LightBlue); break; } case 4: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.LightYellow); break; } } } else if (FlagCarrier.Team == 6) { switch (C3Mod.C3Config.TeamColor2) { case 1: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.OrangeRed); break; } case 2: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.LightGreen); break; } case 3: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.LightBlue); break; } case 4: { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " dropped the flag!", Color.LightYellow); break; } } } FlagCarrier = null; } //Capture the flag else { if (FlagCarrier.Team == 5) { if ((int)FlagCarrier.tileX <= (int)SpawnPoint[0].X + 2 && (int)FlagCarrier.tileX >= (int)SpawnPoint[0].X - 2 && (int)FlagCarrier.tileY == (int)SpawnPoint[0].Y - 3) { Team1Score++; switch (C3Mod.C3Config.TeamColor1) { case 1: { if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Red (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Green", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Red (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Blue", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Red (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Yellow", Color.OrangeRed); } break; } case 2: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Green (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Red", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Green (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Blue", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Green (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Yellow", Color.LightGreen); } break; } case 3: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Blue (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Red", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Blue (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Green", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Blue (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Yellow", Color.LightBlue); } break; } case 4: { if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Yellow (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Red", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Yellow (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Green", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Yellow (" + Team1Score.ToString() + ") - (" + Team2Score.ToString() + ") Blue", Color.LightYellow); } break; } } C3Events.FlagCapture(FlagCarrier, "oneflag", "Team1", Team1Score, Team2Score); FlagCarrier = null; if (C3Mod.C3Config.RespawnPlayersOnFlagCapture && Team1Score != C3Mod.C3Config.CTFScoreLimit) { TpToOneFlagSpawns(); } if (C3Mod.C3Config.ReCountdownOnFlagCapture && Team1Score != C3Mod.C3Config.CTFScoreLimit) { OneFlagGameRunning = false; OneFlagGameCountdown = true; } if (C3Mod.C3Config.HealPlayersOnFlagCapture) { Item heart = TShock.Utils.GetItemById(58); Item star = TShock.Utils.GetItemById(184); foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "ctf") { player.GiveItem(heart.type, heart.name, heart.width, heart.height, 20); player.GiveItem(star.type, star.name, star.width, star.height, 20); } } } } } else if (FlagCarrier.Team == 6) { if ((int)FlagCarrier.tileX <= (int)SpawnPoint[1].X + 2 && (int)FlagCarrier.tileX >= (int)SpawnPoint[1].X - 2 && (int)FlagCarrier.tileY == (int)SpawnPoint[1].Y - 3) { Team2Score++; switch (C3Mod.C3Config.TeamColor2) { case 1: { if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Red (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Green", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Red (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Blue", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Red (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Yellow", Color.OrangeRed); } break; } case 2: { if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Green (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Red", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Green (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Blue", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Green (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Yellow", Color.LightGreen); } break; } case 3: { if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Blue (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Red", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Blue (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Green", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Blue (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Yellow", Color.LightBlue); } break; } case 4: { if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Yellow (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Red", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Yellow (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Green", Color.LightYellow); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("oneflag", FlagCarrier.PlayerName + " Scores! Yellow (" + Team2Score.ToString() + ") - (" + Team1Score.ToString() + ") Blue", Color.LightYellow); } break; } } C3Events.FlagCapture(FlagCarrier, "oneflag", "Team2", Team2Score, Team1Score); FlagCarrier = null; if (C3Mod.C3Config.RespawnPlayersOnFlagCapture && Team2Score != C3Mod.C3Config.CTFScoreLimit) { TpToOneFlagSpawns(); } if (C3Mod.C3Config.ReCountdownOnFlagCapture && Team2Score != C3Mod.C3Config.CTFScoreLimit) { OneFlagGameRunning = false; OneFlagGameCountdown = true; } if (C3Mod.C3Config.HealPlayersOnFlagCapture) { Item heart = TShock.Utils.GetItemById(58); Item star = TShock.Utils.GetItemById(184); foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "ctf") { player.GiveItem(heart.type, heart.name, heart.width, heart.height, 20); player.GiveItem(star.type, star.name, star.width, star.height, 20); } } } } } } } if (Team1Score == C3Mod.C3Config.CTFScoreLimit) { OneFlagGameRunning = false; if (C3Mod.C3Config.TeamColor2 == 1) { C3Tools.BroadcastMessageToGametype("ctf", "Red Team wins!", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor2 == 2) { C3Tools.BroadcastMessageToGametype("ctf", "Green Team wins!", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor2 == 3) { C3Tools.BroadcastMessageToGametype("ctf", "Blue Team wins!", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor2 == 4) { C3Tools.BroadcastMessageToGametype("ctf", "Yellow Team wins!", Color.LightYellow); } List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "oneflag") { if (player1.Team == 6) { WonPlayers.Add(player1); } if (player1.Team == 5) { LostPlayers.Add(player1); } } } C3Events.GameEnd(WonPlayers, LostPlayers, "oneflag", Team2Score, Team1Score); SendToSpawn(false); C3Tools.ResetGameType("oneflag"); OneFlagCTF.FlagPoint = new Vector2(); OneFlagCTF.SpawnPoint = new Vector2[2]; return; } if (Team2Score == C3Mod.C3Config.CTFScoreLimit) { OneFlagGameRunning = false; if (C3Mod.C3Config.TeamColor1 == 1) { C3Tools.BroadcastMessageToGametype("ctf", "Red Team wins!", Color.OrangeRed); } else if (C3Mod.C3Config.TeamColor1 == 2) { C3Tools.BroadcastMessageToGametype("ctf", "Green Team wins!", Color.LightGreen); } else if (C3Mod.C3Config.TeamColor1 == 3) { C3Tools.BroadcastMessageToGametype("ctf", "Blue Team wins!", Color.LightBlue); } else if (C3Mod.C3Config.TeamColor1 == 4) { C3Tools.BroadcastMessageToGametype("ctf", "Yellow Team wins!", Color.LightYellow); } List <C3Player> LostPlayers = new List <C3Player>(); List <C3Player> WonPlayers = new List <C3Player>(); foreach (C3Player player1 in C3Mod.C3Players) { if (player1.GameType == "oneflag") { if (player1.Team == 5) { WonPlayers.Add(player1); } if (player1.Team == 6) { LostPlayers.Add(player1); } } } C3Events.GameEnd(WonPlayers, LostPlayers, "oneflag", Team1Score, Team2Score); SendToSpawn(false); C3Tools.ResetGameType("oneflag"); OneFlagCTF.FlagPoint = new Vector2(); OneFlagCTF.SpawnPoint = new Vector2[2]; return; } } } }
//NEW CODE TO EXPAND THE APOCAYLPSE public static void OnUpdate(EventArgs args) { if (C3Mod.VoteRunning && C3Mod.VoteType == "apoc") { int VotedPlayers = 0; int TotalPlayers = 0; lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "" || player.GameType == "apoc") { TotalPlayers++; } if (player.GameType == "apoc") { VotedPlayers++; } } } if (VotedPlayers == TotalPlayers) { C3Tools.BroadcastMessageToGametype("apoc", "Vote to play Monster Apocalypse passed! Teleporting to start positions!", Color.DarkCyan); bool[] playersDead = new bool[Main.maxNetPlayers]; TpToSpawnPoint(); countDownTick = DateTime.UtcNow; //NEW CODE TO EXPAND THE APOCAYLPSE //Must reset all after NEW vote! Wave = 1; VoteCount = 0; MonstersLeft = -1; CurMonster = null; MonsterWhoAmI.Clear(); StartCount = 3; LastMonster = 0; playersdead = 0; monsterIntermission = DateTime.UtcNow; MonsterApocalypseIntermissionTimeCache = 0; //NEW CODE TO EXPAND THE APOCAYLPSE Intermission = true; C3Mod.VoteType = ""; C3Mod.VoteRunning = false; ChooseNPC(); return; } double tick = (DateTime.UtcNow - voteCountDown).TotalMilliseconds; if (tick > (C3Mod.C3Config.VoteNotifyInterval * 1000) && VoteCount > 0) { if (VoteCount != 1 && VoteCount < (C3Mod.C3Config.VoteTime / C3Mod.C3Config.VoteNotifyInterval)) { C3Tools.BroadcastMessageToGametype("apoc", "Vote still in progress, please be patient!", Color.Cyan); C3Tools.BroadcastMessageToGametype("", "Vote to play Monster Apocalypse in progress, type /join to join the lobby!", Color.Cyan); } VoteCount--; voteCountDown = DateTime.UtcNow; } else if (VoteCount == 0) { C3Mod.VoteRunning = false; int players = 0; foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "apoc") { players++; } } if (players >= C3Mod.C3Config.MonsterApocalypseMinimumPlayers) { C3Tools.BroadcastMessageToGametype("apoc", "Vote to play Monster Apocalypse passed! Teleporting to start positions!", Color.DarkCyan); bool[] playersDead = new bool[Main.maxNetPlayers]; //NEW CODE TO EXPAND THE APOCAYLPSE //Must reset all after NEW vote! Wave = 1; VoteCount = 0; MonstersLeft = -1; CurMonster = null; MonsterWhoAmI.Clear(); StartCount = 3; LastMonster = 0; playersdead = 0; monsterIntermission = DateTime.UtcNow; MonsterApocalypseIntermissionTimeCache = 0; //NEW CODE TO EXPAND THE APOCAYLPSE TpToSpawnPoint(); countDownTick = DateTime.UtcNow; Intermission = true; C3Mod.VoteType = ""; C3Mod.VoteRunning = false; ChooseNPC(); return; } else { C3Tools.BroadcastMessageToGametype("apoc", "Vote to play Monster Apocalypse failed. Not enough players!", Color.DarkCyan); } } } if (Intermission) { double tick = (DateTime.UtcNow - countDownTick).TotalMilliseconds; if (tick > 1000 && StartCount > -1) { if (TpToSpawnPoint() > 0) { if (StartCount == 0) { C3Tools.BroadcastMessageToGametype("apoc", "Fight!!!", Color.Cyan); StartCount = 3; //NEW CODE TO EXPAND THE APOCAYLPSE C3Tools.BroadcastMessageToGametype("apoc", "Wave: " + Wave.ToString() + ": " + CurMonster.name, Color.Red); MonsterApocalypseIntermissionTimeCache = C3Mod.C3Config.MonsterApocalypseIntermissionTime; //NEW CODE TO EXPAND THE APOCAYLPSE Intermission = false; Running = true; SpawnMonsters(); playersdead = 0; foreach (C3Player player in C3Mod.C3Players) { player.Dead = false; player.LivesUsed = 0; } } else { Random r = new Random(); switch (r.Next(2) + 1) //Change the 2 into the number of your variations! And add the same number of cases! { case 1: { C3Tools.BroadcastMessageToGametype("apoc", "Apocalypse in: " + StartCount.ToString() + "...", Color.Cyan); break; } case 2: { C3Tools.BroadcastMessageToGametype("apoc", "You will die in: " + StartCount.ToString() + "...", Color.Cyan); break; } } //C3Tools.BroadcastMessageToGametype("apoc", "Nächste Monster sind: " + CurMonster.name, Color.Cyan); //Removed because WRONG Line //ADDED some lines above countDownTick = DateTime.UtcNow; StartCount--; } } else { StartCount = 3; C3Tools.ResetGameType("apoc"); return; } } } if (Running) { double tick = (DateTime.UtcNow - scoreNotify).TotalMilliseconds; if (tick > (C3Mod.C3Config.MonsterApocalypseScoreNotifyInterval * 1000)) { C3Tools.BroadcastMessageToGametype("apoc", MonstersLeft.ToString() + " Monsters left: ", Color.Cyan); scoreNotify = DateTime.UtcNow; } //NEW CODE TO EXPAND THE APOCAYLPSE double tickmonsterIntermission = (DateTime.UtcNow - monsterIntermission).TotalMilliseconds; if (tickmonsterIntermission > 1000) { MonsterApocalypseIntermissionTimeCache--; monsterIntermission = DateTime.UtcNow; if (C3Mod.C3Config.MonsterApocalypseIntermissionTime >= 3 && MonsterApocalypseIntermissionTimeCache <= 10 && MonsterApocalypseIntermissionTimeCache > 0) //MonsterApocalypseIntermissionTime must be larger then 3 or it makes no sence ;-) { C3Tools.BroadcastMessageToGametype("apoc", MonsterApocalypseIntermissionTimeCache.ToString() + " seconds left!", Color.Yellow); } } //NEW CODE TO EXPAND THE APOCAYLPSE foreach (NPC npc in MonsterWhoAmI) { if (!npc.active) { MonsterWhoAmI.Remove(npc); MonstersLeft--; if (MonstersLeft == 0) { Running = false; Intermission = true; Wave++; ChooseNPC(); return; } break; } } if (MonstersLeft == 0) { Running = false; Intermission = true; ChooseNPC(); Wave++; List <C3Player> AlivePlayers = new List <C3Player>(); List <C3Player> SpecatingPlayers = new List <C3Player>(); foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "apoc") { if (player.Spectator) { SpecatingPlayers.Add(player); } else { AlivePlayers.Add(player); } } } C3Events.WaveAdvance(AlivePlayers, SpecatingPlayers, Wave); return; } apocplayers = 0; lock (C3Mod.C3Players) { foreach (C3Player player in C3Mod.C3Players) { if (player.GameType == "apoc") { apocplayers++; player.TSPlayer.TPlayer.hostile = false; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.TSPlayer.Index); if (player.TerrariaTeam != 3) { player.TSPlayer.SetTeam(3); } if (!player.TSPlayer.TpLock) { if (C3Mod.C3Config.TPLockEnabled) { player.TSPlayer.TpLock = true; } } if (Main.player[player.Index].dead) { player.LivesUsed++; player.TSPlayer.TpLock = false; if (player.LivesUsed >= C3Mod.C3Config.MonsterApocalypseLivesPerWave && !player.Dead) { playersdead++; if (playersdead == apocplayers) { //NEW CODE TO EXPAND THE APOCAYLPSE ApoLost(player, 0); //0 = All death //NEW CODE TO EXPAND THE APOCAYLPSE } else { C3Tools.BroadcastMessageToGametype("apoc", player.PlayerName + " is out!", Color.Cyan); player.TSPlayer.Teleport((int)SpectatorArea.X * 16, (int)SpectatorArea.Y * 16); player.Dead = true; } } else { player.SendMessage("Lives left: " + (C3Mod.C3Config.MonsterApocalypseLivesPerWave - player.LivesUsed).ToString(), Color.Cyan); player.TSPlayer.Teleport((int)PlayerSpawn.X * 16, (int)PlayerSpawn.Y * 16); } } //NEW CODE TO EXPAND THE APOCAYLPSE if (MonsterApocalypseIntermissionTimeCache < 0) { ApoLost(player, 1); //1 = Not in time } //NEW CODE TO EXPAND THE APOCAYLPSE } } } } }