internal static void UpdatePrimary(ZSGame game, Player p) { int left = (int)(game.RoundEnd - DateTime.UtcNow).TotalSeconds; string status = FormatPrimary(game, left); p.SendCpeMessage(CpeMessageType.Status1, status); }
void HandleStart(Player p, ZSGame game, string[] args) { if (!CheckExtraPerm(p, 1)) { return; } if (game.Running) { Player.Message(p, "There is already a Zombie Survival game currently in progress."); return; } Level lvl = Player.IsSuper(p) ? null : p.level; if (args.Length == 2) { int rounds = 1; if (!CommandParser.GetInt(p, args[1], "Rounds", ref rounds, 0)) { return; } ZombieGameStatus status = rounds == 0 ? ZombieGameStatus.InfiniteRounds : ZombieGameStatus.VariableRounds; game.Start(status, lvl, rounds); } else { game.Start(ZombieGameStatus.SingleRound, lvl, 0); } }
public override void Use(Player p, string message, CommandData data) { if (p.Game.PledgeSurvive) { p.Message("You cannot un-pledge that you will be infected."); return; } if (ZSGame.Get(p).Infected) { p.Message("You cannot use &T/human &Sas you are currently infected."); return; } if (Economy.Enabled && p.money < 5) { p.Message("You need to have at least 5 &3" + Server.Config.Currency + " &Sto pledge that you will not be infected."); return; } if (!ZSGame.Instance.RoundInProgress) { p.Message("Can only use &T/human &Swhen a round is in progress."); return; } TimeSpan delta = ZSGame.Instance.RoundEnd - DateTime.UtcNow; if (delta < TimeSpan.FromMinutes(3)) { p.Message("Cannot use &T/human &Sin last three minutes of a round."); return; } p.Game.PledgeSurvive = true; ZSGame.Instance.Map .Message(p.ColoredName + " &Spledges that they will not succumb to the infection!"); }
public override bool CanSeeEntity(Entity other) { Player target = other as Player; if (target == null) { return(true); // not a player } if (target == this) { return(true); // always see self } // hidden via /hide or /ohide // TODO: Just use Entities.CanSee if (target.hidden) { return(Rank >= target.hideRank); } if (!ZSGame.Instance.Running || Game.Referee) { return(true); } ZSData data = ZSGame.TryGet(target); return(data == null || !(target.Game.Referee || data.Invisible)); }
internal static void UpdateAllPrimary(ZSGame game) { int left = (int)(game.RoundEnd - DateTime.UtcNow).TotalSeconds; string status = FormatPrimary(game, left); MessageAll(game, CpeMessageType.Status1, status); }
static string FormatSecondary(ZSGame game) { string pillar = "%SPillaring " + (game.Map.Config.Pillaring ? "&aYes" : "&cNo"); string type = "%S, Type is &a" + game.Map.Config.BuildType; return(pillar + type); }
public static void HandOut(ZSGame game) { Player[] alive = game.Alive.Items, dead = game.Infected.Items; game.Map.ChatLevel("&aThe game has ended!"); if (alive.Length == 0) { game.Map.ChatLevel("&4Zombies have won this round."); } else if (alive.Length == 1) { game.Map.ChatLevel("&2Congratulations to the sole survivor:"); } else { game.Map.ChatLevel("&2Congratulations to the survivors:"); } AnnounceWinners(game, alive, dead); game.Map.Config.RoundsPlayed++; if (alive.Length > 0) { game.Map.Config.RoundsHumanWon++; foreach (Player p in alive) { IncreaseAliveStats(p, game); } } GiveMoney(game, alive); }
static void HandleStatus(Player p, ZSGame game) { switch (game.Status) { case ZombieGameStatus.NotStarted: Player.Message(p, "Zombie Survival is not currently running."); break; case ZombieGameStatus.InfiniteRounds: Player.Message(p, "Zombie Survival is currently in progress with infinite rounds."); break; case ZombieGameStatus.SingleRound: Player.Message(p, "Zombie Survival game currently in progress."); break; case ZombieGameStatus.VariableRounds: Player.Message(p, "Zombie Survival game currently in progress with " + game.MaxRounds + " rounds."); break; case ZombieGameStatus.LastRound: Player.Message(p, "Zombie Survival game currently in progress, with this round being the final round."); break; } if (game.Status == ZombieGameStatus.NotStarted || game.MapName.Length == 0) { return; } Player.Message(p, "Running on map: " + game.MapName); }
public override void Use(Player p, string message) { ZSGame game = Server.zombie; if (message.CaselessEq("go")) { HandleGo(p, game); } else if (message.CaselessEq("status")) { HandleStatus(p, game); } else if (message.CaselessEq("start") || message.CaselessStarts("start ")) { string[] args = message.SplitSpaces(); HandleStart(p, game, args); } else if (message.CaselessEq("end")) { HandleEnd(p, game); } else if (message.CaselessEq("stop")) { HandleStop(p, game); } else if (message.CaselessStarts("set ")) { string[] args = message.SplitSpaces(); HandleSet(p, game, args); } else { Help(p); } }
internal static bool Handles(Player p, ushort x, ushort y, ushort z, bool placing, ExtBlock block, ExtBlock old, ZSGame game) { if (placing && !game.Map.Config.Pillaring && !p.Game.Referee) { if (NotPillaring(game.Map, block, old)) { p.Game.BlocksStacked = 0; } else if (CheckCoords(p, x, y, z)) { p.Game.BlocksStacked++; } else { p.Game.BlocksStacked = 0; } if (MessagePillaring(p, x, y, z)) { return(true); } } p.Game.LastX = x; p.Game.LastY = y; p.Game.LastZ = z; return(false); }
static void AnnounceWinners(ZSGame game, Player[] alive, Player[] dead) { if (alive.Length > 0) { string winners = alive.Join(p => p.ColoredName); game.Map.ChatLevel(winners); return; } int maxKills = 0, count = 0; for (int i = 0; i < dead.Length; i++) { maxKills = Math.Max(maxKills, dead[i].Game.CurrentInfected); } for (int i = 0; i < dead.Length; i++) { if (dead[i].Game.CurrentInfected == maxKills) { count++; } } string group = count == 1 ? " zombie " : " zombies "; string suffix = maxKills == 1 ? " %Skill" : " %Skills"; StringFormatter <Player> formatter = p => p.Game.CurrentInfected == maxKills ? p.ColoredName : null; game.Map.ChatLevel("&8Best" + group + "%S(&b" + maxKills + suffix + "%S)&8: " + dead.Join(formatter)); }
static void HandleGo(Player p, ZSGame game) { if (!game.Running) { Player.Message(p, "Zombie Survival is not running."); return; } PlayerActions.ChangeMap(p, game.Map); }
static void IncreaseAliveStats(Player p, ZSGame game) { if (p.Game.PledgeSurvive) { Player.Message(p, "You received &a5 %3" + ServerConfig.Currency + " %Sfor successfully pledging that you would survive."); p.SetMoney(p.money + 5); } p.Game.CurrentRoundsSurvived++; p.Game.TotalRoundsSurvived++; p.Game.MaxRoundsSurvived = Math.Max(p.Game.CurrentRoundsSurvived, p.Game.MaxRoundsSurvived); p.SetPrefix(); // stars before name }
public bool ShouldShowJoinMessage(Level prev) { ZSGame zs = Server.zombie; if (zs.Running && name.CaselessEq(zs.MapName) && (prev == this || zs.LastLevelName.Length == 0 || prev.name.CaselessEq(zs.LastLevelName))) { return(false); } if (Server.lava.active && Server.lava.HasMap(name)) { return(false); } return(true); }
void HandleEnd(Player p, ZSGame game) { if (!CheckExtraPerm(p, 1)) { return; } if (game.RoundInProgress) { game.EndRound(); } else { Player.Message(p, "No round is currently in progress."); } }
static string FormatPrimary(ZSGame game, int seconds) { string timespan = GetTimeLeft(seconds); if (timespan.Length > 0) { const string format = "&a{0} %Salive %S({2}, map: {1})"; return(String.Format(format, game.Alive.Count, game.MapName, timespan)); } else { const string format = "&a{0} %Salive %S(map: {1})"; return(String.Format(format, game.Alive.Count, game.MapName)); } }
static void MessageAll(ZSGame game, CpeMessageType type, string message) { if (!game.Running) { return; } Player[] online = PlayerInfo.Online.Items; foreach (Player p in online) { if (!p.level.name.CaselessEq(game.MapName)) { continue; } p.SendCpeMessage(type, message); } }
protected internal override void OnPurchase(Player p, string args) { if (!CheckPrice(p, Price, "an invisibility potion")) { return; } if (!ZSGame.Instance.Running || !ZSGame.Instance.RoundInProgress) { p.Message("You can only buy an invisiblity potion " + "when a round of zombie survival is in progress."); return; } ZSData data = ZSGame.Get(p); if (data.Invisible) { p.Message("You are already invisible."); return; } ZSConfig cfg = ZSGame.Config; int maxPotions = p.infected ? cfg.ZombieInvisibilityPotions : cfg.InvisibilityPotions; if (data.InvisibilityPotions >= maxPotions) { p.Message("You cannot buy any more invisibility potions this round."); return; } DateTime end = ZSGame.Instance.RoundEnd; if (DateTime.UtcNow.AddSeconds(60) > end) { p.Message("You cannot buy an invisibility potion during the last minute of a round."); return; } int duration = p.infected ? cfg.ZombieInvisibilityDuration : cfg.InvisibilityDuration; data.InvisibilityPotions++; int left = maxPotions - data.InvisibilityPotions; p.Message("Lasts for &a{0} &Sseconds. You can buy &a{1} &Smore this round.", duration, left); ZSGame.Instance.GoInvisible(p, duration); Economy.MakePurchase(p, Price, "%3Invisibility: " + duration); }
static void SetMaxMove(Player p, ZSGame game, string[] args) { if (args.Length == 2) { Player.Message(p, "Maxmium move distance is currently &a" + ZSConfig.MaxMoveDistance + " %Sunits apart."); return; } byte distance = 0; if (!CommandParser.GetByte(p, args[2], "Maxmimum move distance", ref distance)) { return; } ZSConfig.MaxMoveDistance = distance; Player.Message(p, "Maximum move distance set to &a" + distance + " %Sunits apart."); ZSConfig.SaveSettings(); }
static void SetHitbox(Player p, ZSGame game, string[] args) { if (args.Length == 2) { Player.Message(p, "Hitbox detection is currently &a" + ZSConfig.HitboxPrecision + " %Sunits apart."); return; } byte precision = 0; if (!CommandParser.GetByte(p, args[2], "Hitbox detection", ref precision)) { return; } ZSConfig.HitboxPrecision = precision; Player.Message(p, "Hitbox detection set to &a" + precision + " %Sunits apart."); ZSConfig.SaveSettings(); }
public override void Use(Player p, string message, CommandData data) { ZSData data_ = ZSGame.Get(p); data_.AkaMode = !data_.AkaMode; Player[] players = PlayerInfo.Online.Items; p.Message("AKA mode is now: " + (data_.AkaMode ? "&aOn" : "&cOff")); foreach (Player other in players) { if (other.level != p.level || p == other || !p.CanSeeEntity(other)) { continue; } Entities.Despawn(p, other); Entities.Spawn(p, other); } TabList.Add(p, p, Entities.SelfID); }