public void HandOutRewards() { Server.zombieRound = false; lastseconds = false; timer.Enabled = false; timeleftannouncer.Enabled = false; amountOfMilliseconds = 0; string playersString = ""; if (Server.gameStatus == 0) { return; } Level actuallevel = Level.Find(currentLevelName); if (alive.Count != 0) { actuallevel.humanswon++; Level.SaveSettings(actuallevel); Player.GlobalMessage(c.green + "----------------------------------"); Player.GlobalMessage(c.green + "Humans have won this round"); Player.GlobalMessage(c.green + "Congratulations to our survivor(s)"); Server.s.Log("Humans have won on map " + currentLevelName); try { for (int index = alive.Count(); index > 0; index--) { Player winner = alive[index - 1]; playersString += winner.group.color + winner.name + c.white + ", "; switch (winner.winstreakcount) { case 0: winner.money += 15; Player.SendMessage(winner, c.green + "You got 15 " + Server.moneys + " for surviving"); break; case 1: winner.money += 17; Player.SendMessage(winner, c.green + "You got 17 " + Server.moneys + " for surviving"); break; case 2: winner.money += 20; Player.SendMessage(winner, c.green + "You got 20 " + Server.moneys + " for surviving"); break; default: winner.money += 24; Player.SendMessage(winner, c.green + "You got 24 " + Server.moneys + " for surviving"); break; } winner.winstreakcount++; if (winner.maximumsurvived < winner.winstreakcount) { winner.maximumsurvived = winner.winstreakcount; } winner.roundssurvived++; if (!winner.canrevive) { winner.Achieve("Second Chance"); } if (winner.winstreakcount == 5) { winner.Achieve("Bear Grylls"); } if ((((actuallevel.humanswon + actuallevel.zombieswon) == 0 ? 100 : ((actuallevel.humanswon * 100) / (actuallevel.humanswon + actuallevel.zombieswon))) <= 10) && ((actuallevel.humanswon + actuallevel.zombieswon) >= 10)) { winner.Achieve("Impossible"); } if (alive.Count == 1) { alive[0].Achieve("Cant touch this"); } } } catch { Server.s.Log("ERROR: #001"); } Player.GlobalMessage(playersString); Player.GlobalMessage(c.green + "----------------------------------"); } else if (alive.Count == 0) { actuallevel.zombieswon++; Level.SaveSettings(actuallevel); Player.GlobalMessage(c.red + "----------------------------------"); Player.GlobalMessage(c.red + "Zombies have won this round."); Server.s.Log("Zombies have won on map " + currentLevelName); try { int maxinfect = infectd.Max(obj => obj.infectThisRound); var maxinfectList = infectd.Where(obj => obj.infectThisRound == maxinfect); string maxinfectname = ""; foreach (Player bestzombie in maxinfectList) { maxinfectname += bestzombie.name + ","; } Player.GlobalMessage("Best zombie(s): " + c.red + maxinfectname + Server.DefaultColor + " with " + c.red + maxinfect + Server.DefaultColor + " kills"); } catch { Server.s.Log("Error: #017"); } Player.GlobalMessage(c.red + "----------------------------------"); try { for (int index = Player.players.Count(); index > 0; index--) { Player player = Player.players[index - 1]; if (player.infected && player.infectThisRound > 0) { player.SendMessage(c.green + "You helped the zombies win, here is a little reward: 2 " + Server.moneys); player.money = player.money + 2; } } } catch { Server.s.Log("ERROR: #012"); } } try { alive.Clear(); } catch { Server.s.Log("ERROR: #003"); } try { infectd.Clear(); } catch { Server.s.Log("ERROR: #004"); } try { for (int index = Player.players.Count(); index > 0; index--) { Player player = Player.players[index - 1]; player.infected = false; player.color = player.group.color; player.SetPrefix(); player.blockCount = Server.blocklimithuman; player.infectThisRound = 0; player.infectedfrom = ""; player.revivesused = 0; Player.GlobalDie(player, false); Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false); if (player.referee) { player.SendMessage("You gained 1 " + Server.moneys + " because you're a ref. Thank you!"); player.money += 1; } } } catch { Server.s.Log("ERROR: #002"); } try { if (lottery.Count > 1) { int number = rand.Next(lottery.Count - 1); Player lotterywinner = lottery[number]; Player.GlobalMessage(lotterywinner.name + " won the lottery with a price of: " + c.gold + Convert.ToString(9 * lotterycount) + Server.moneys); lotterywinner.money += 9 * lotterycount; Server.s.Log("Lottery winner " + lotterywinner.name + " with " + lottery.Count + " players"); if (lotterycount == 7) { lotterywinner.Achieve("Lucky Number 7"); } } else if (lottery.Count == 1) { Player.SendMessage(lottery[0], "Too less people joined the lottery, you get your money back"); Server.s.Log("Lottery aborted - too less players"); lottery[0].money += 10; } } catch { Server.s.Log("Error: #020"); } try { lottery.Clear(); lotterycount = 0; } catch { Server.s.Log("ERROR: #018"); } try { if ((actuallevel.humanswon + actuallevel.zombieswon) > 10) { int percantagewin = (actuallevel.humanswon * 100 / (actuallevel.humanswon + actuallevel.zombieswon)); if (percantagewin > 95) { actuallevel.roundtime = 12; } else if (percantagewin > 90) { actuallevel.roundtime = 10; } else if (percantagewin > 85) { actuallevel.roundtime = 9; } else if (percantagewin > 75) { actuallevel.roundtime = 8; } else if (percantagewin > 30) { actuallevel.roundtime = 7; } else if (percantagewin > 25) { actuallevel.roundtime = 6; } else if (percantagewin > 15) { actuallevel.roundtime = 6; } else { actuallevel.roundtime = 5; } Level.SaveSettings(actuallevel); } } catch { Server.s.Log("Error: #022"); } if (Math.Round((double)Process.GetCurrentProcess().PrivateMemorySize64 / 1048576) > 100) { Server.s.Log("Server restarting -> Memory overflow"); MCForge_.Gui.Program.ExitProgram(true); } return; }
private void MainGame() { if (Server.gameStatus == 0) { return; } GoBack: Player.GlobalMessage("Starting in %c30%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c20%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c10%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c5%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c4%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c3%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c2%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c1%e second"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } int playerscountminusref = 0; //Get players try { alive.Clear(); infectd.Clear(); } catch { } for (int index = Player.players.Count(); index > 0; index--) { Player playere = Player.players[index - 1]; playere.canrevive = true; playere.invisiblyused = 0; playere.infectThisRound = 0; playere.infected = false; playere.infectedfrom = ""; if (playere.referee) { Player.GlobalDie(playere, false); } else if (playere.level.name == currentLevelName) { if (!alive.Contains(playere)) { alive.Add(playere); } playerscountminusref += 1; } else { try { Command.all.Find("goto").Use(playere, currentLevelName); } catch { Server.s.Log("ERROR: #006"); } if (!alive.Contains(playere)) { alive.Add(playere); } playerscountminusref += 1; } } if (playerscountminusref < 2) { Server.s.Log("ERROR: #007"); Player.GlobalMessage(c.red + "ERROR: Need more than 2 players to play"); goto GoBack; } StartTime = DateTime.Now; //Choose the first Zombie to be infected Player player = null; if (Server.queZombie == true) { Server.queZombie = false; player = Player.Find(Server.nextZombie); } if (player == null || player.referee) { player = alive[new Random().Next(0, alive.Count())]; } // Timer Initializing Level actualevel = Level.Find(currentLevelName); //int amountOfMinutes = 1; int amountOfMinutes = actualevel.roundtime; //----------------------------------------------- //int amountOfMinutes = new Random().Next(Server.roundtime1, Server.roundtime2); Player.GlobalMessage("The round will last for %c" + amountOfMinutes + "%e minutes!"); amountOfMilliseconds = (60000 * amountOfMinutes); timer = new System.Timers.Timer(amountOfMilliseconds); timer.Elapsed += new ElapsedEventHandler(EndRound); timer.Enabled = true; Server.zombieRound = true; timeleftannouncer = new System.Timers.Timer(60000); timeleftannouncer.Elapsed += new ElapsedEventHandler(timleftannouncerfunction); timeleftannouncer.Enabled = true; Player.GlobalMessage(player.group.color + player.name + Server.DefaultColor + " started the infection!"); InfectPlayer(player); humangone(); //Main Loop for Game try { while (alive.Count > 0) { for (int index = infectd.Count(); index > 0; index--) { Player player1 = infectd[index - 1]; if (player1.color != c.red) { player1.color = c.red; player1.SetPrefix(); Player.GlobalDie(player1, false); Player.GlobalSpawn(player1, player1.pos[0], player1.pos[1], player1.pos[2], player1.rot[0], player1.rot[1], false); } for (int index2 = alive.Count(); index2 > 0; index2--) { Player player2 = alive[index2 - 1]; if (player2.color != c.white) { player2.color = c.white; player2.SetPrefix(); Player.GlobalDie(player2, false); Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false); } // Hitbox Detection /*if (player2.pos[0] / 32 == player1.pos[0] / 32 || player2.pos[0] / 32 == player1.pos[0] / 32 + 1 || player2.pos[0] / 32 == player1.pos[0] / 32 - 1) * { * if (player2.pos[1] / 32 == player1.pos[1] / 32 || player2.pos[1] / 32 == player1.pos[1] / 32 - 1 || player2.pos[1] / 32 == player1.pos[1] / 32 + 1) * { * if (player2.pos[2] / 32 == player1.pos[2] / 32 || player2.pos[2] / 32 == player1.pos[2] / 32 + 1 || player2.pos[2] / 32 == player1.pos[2] / 32 - 1) * { */ if (Math.Abs(player2.pos[0] - player1.pos[0]) <= Server.hitboxrangex && Math.Abs(player2.pos[1] - player1.pos[1]) <= Server.hitboxrangey && Math.Abs(player2.pos[2] - player1.pos[2]) <= Server.hitboxrangez ) { if (!player2.infected && player1.infected && !player2.referee && !player1.referee && player1 != player2) { //Infection Combo + Award if (Server.lastPlayerToInfect == player1.name) { Server.infectCombo++; if (Server.infectCombo > 0) { switch (Server.infectCombo + 1) { case 2: combomessage = "is awesome - doublekill"; break; case 3: combomessage = "is epic - triplekill"; break; case 4: combomessage = "is pro - quadruplekill"; break; case 5: combomessage = "is crazy - quintuplekill"; break; case 6: combomessage = "is unstoppable - sextuplekill"; break; case 7: combomessage = "is unbeatable - septuplekill"; break; case 8: combomessage = "is legendary - octuplekill"; break; case 9: combomessage = "is god like - nonuplekill"; break; case 10: Player.Find(player1.name).Achieve("Chuck Norris"); break; } if ((Server.infectCombo + 1) < 10) { Player.GlobalMessage(c.red + player1.name + "%b " + combomessage); } else { Player.GlobalMessage(c.red + player1.name + "%b kills like Chuck Norris himself: " + (Server.infectCombo + 1) + " kills in a row"); } Player.SendMessage(player1, "%aYou got additional " + ((Server.infectCombo + 1)) + " " + Server.moneys + " for your killstreak"); player1.money += ((Server.infectCombo + 1) * 2); } } else { Server.infectCombo = 0; } if (player1.maximuminfected < Server.infectCombo + 1) { player1.maximuminfected = Server.infectCombo + 1; } Server.lastPlayerToInfect = player1.name; player1.infectThisRound++; player1.playersinfected++; if (player2.infectedfrom == player1.name) { player1.Achieve("Deja Vu"); } player2.infectedfrom = player1.name; if (alive.Count == 1) { player1.Achieve("Finisher"); } if (player2.winstreakcount >= 3) { player1.Achieve("Dream Destroyer"); } if (player2.autoafk) { player1.Achieve("Assassin"); } if (lastseconds) { player2.Achieve("Unlucky"); } Player.SendMessage(player1, "Brains eaten this round: %c" + player1.infectThisRound); if (Server.infectCombo == 0) { Player.SendMessage(player1, "%aYou gained 1 extra cookie for eating brains"); player1.money += 1; } Player.GlobalMessage(GetInfectedmessage(player1.name, player2.name)); Server.s.Log(player1.name + " infected " + player2.name); InfectPlayer(player2); humangone(); Thread.Sleep(300); //Thread.Sleep(200); //Thread.Sleep(200); } } // } //} } } Thread.Sleep(400); } } catch { Server.s.Log("Error: #016"); } if (Server.gameStatus == 0) { Server.gameStatus = 4; return; } else if (Server.zombieRound == true) { HandOutRewards(); } }