static bool CheckZoneCallback(Player p, Vec3S32[] marks, object state, BlockID block) { ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z; List <TWGame.TWZone> zones = (List <TWGame.TWZone>)state; TWGame game = TWGame.Instance; if (zones == game.tntFreeZones) { if (game.InZone(x, y, z, zones)) { p.Message("TNT Wars: You are currently in a no TNT zone!"); } else { p.Message("TNT Wars: You are not currently in a no TNT zone!"); } } else if (zones == game.tntImmuneZones) { if (game.InZone(x, y, z, zones)) { p.Message("TNT Wars: You are currently in a no TNT block explosion zone (explosions won't destroy blocks)!"); } else { p.Message("TNT Wars: You are currently in a TNT block explosion zone (explosions will destroy blocks)!"); } } return(false); }
bool HandleZone(Player p, TWGame game, bool noTntZone, string[] args) { string type = noTntZone ? "no TNT" : "no blocks deleted on explosions"; List <TWGame.TWZone> zones = noTntZone ? game.tntFreeZones : game.tntImmuneZones; string opt = args[3]; if (IsCreateCommand(opt)) { p.Message("Place 2 blocks to create a {0} zone", type); p.MakeSelection(2, zones, AddZoneCallback); } else if (IsDeleteCommand(opt)) { if (args.Length > 4 && args[4].CaselessEq("all")) { zones.Clear(); p.Message("Deleted all {0} zones", type); } else { p.Message("Place a block to delete a {0} zone", type); p.MakeSelection(1, zones, DeleteZoneCallback); } } else if (opt.CaselessEq("check")) { p.Message("Place a block to check for {0} zones", type); p.MakeSelection(1, zones, CheckZoneCallback); } else { return(false); } return(true); }
void SaveTWMapSettings() { if (twCurCfg == null) { return; } twCurCfg.ScoreRequired = (int)tw_numScoreLimit.Value; twCurCfg.ScorePerKill = (int)tw_numScorePerKill.Value; twCurCfg.AssistScore = (int)tw_numScoreAssists.Value; twCurCfg.MultiKillBonus = (int)tw_numMultiKills.Value; twCurCfg.Streaks = tw_cbStreaks.Checked; twCurCfg.GracePeriod = tw_cbGrace.Checked; twCurCfg.GracePeriodTime = tw_numGrace.Value; twCurCfg.BalanceTeams = tw_cbBalance.Checked; twCurCfg.TeamKills = tw_cbKills.Checked; twCurCfg.Save(twCurMap); TWGame game = TWGame.Instance; if (game.Running && game.Map.name == twCurMap) { game.UpdateMapConfig(); } }
static void SetDifficulty(TWGame game, TWDifficulty diff, Player p) { if (p.level != game.Map) { p.Message("Changed TNT wars difficulty to {0}", diff); } game.SetDifficulty(diff); }
static void Explode(Level lvl, ushort x, ushort y, ushort z, int size, Random rand, int prob, TWGame game) { for (int xx = (x - size); xx <= (x + size); ++xx) { for (int yy = (y - size); yy <= (y + size); ++yy) { for (int zz = (z - size); zz <= (z + size); ++zz) { int index; BlockID b = lvl.GetBlock((ushort)xx, (ushort)yy, (ushort)zz, out index); if (b == Block.Invalid) { continue; } bool doDestroy = prob < 0 || rand.Next(1, 10) < prob; if (doDestroy && Block.Convert(b) != Block.TNT) { if (game != null && b != Block.Air && !IsFuse(b, xx - x, yy - y, zz - z)) { if (game.InZone((ushort)xx, (ushort)yy, (ushort)zz, game.tntImmuneZones)) { continue; } } int mode = rand.Next(1, 11); if (mode <= 4) { lvl.AddUpdate(index, Block.TNT_Explosion, default(PhysicsArgs)); } else if (mode <= 8) { lvl.AddUpdate(index, Block.Air, default(PhysicsArgs)); } else { PhysicsArgs args = default(PhysicsArgs); args.Type1 = PhysicsArgs.Drop; args.Value1 = 50; args.Type2 = PhysicsArgs.Dissipate; args.Value2 = 8; lvl.AddCheck(index, false, args); } } else if (b == Block.TNT) { lvl.AddUpdate(index, Block.TNT_Small, default(PhysicsArgs)); } else if (b == Block.TNT_Small || b == Block.TNT_Big || b == Block.TNT_Nuke) { lvl.AddCheck(index); } } } } }
void HandleScores(Player p) { TWGame game = (TWGame)Game; if (!game.RoundInProgress) { p.Message("Round is not in progress!"); return; } PlayerAndScore[] top = game.SortedByScore(); int count = Math.Min(top.Length, 5); p.Message("Top {0} scores:", count); for (int i = 0; i < count; i++) { p.Message(game.FormatTopScore(top, i)); } }
public static void MakeExplosion(Level lvl, ushort x, ushort y, ushort z, int size, bool force = false, TWGame game = null) { Random rand = new Random(); if ((lvl.physics < 2 || lvl.physics == 5) && !force) { return; } int index; BlockID block = lvl.GetBlock(x, y, z, out index); if (index >= 0 && !lvl.Props[block].OPBlock) { lvl.AddUpdate(index, Block.TNT_Explosion, default(PhysicsArgs), true); } Explode(lvl, x, y, z, size + 1, rand, -1, game); Explode(lvl, x, y, z, size + 2, rand, 7, game); Explode(lvl, x, y, z, size + 3, rand, 3, game); }
protected override void HandleSet(Player p, RoundsGame game_, string[] args) { TWGame game = (TWGame)game_; TWMapConfig cfg = new TWMapConfig(); TWConfig gameCfg = TWGame.Config; LoadMapConfig(p, cfg); if (args.Length == 1) { Help(p, "set"); return; } if (args.Length == 2) { OutputStatus(p, gameCfg, cfg); return; } string prop = args[1], value = args[2]; if (prop.CaselessEq("spawn")) { if (gameCfg.Mode == TWGameMode.FFA) { p.Message("&WCannot set spawns in Free For All mode"); return; } if (value.CaselessEq("red")) { cfg.RedSpawn = (Vec3U16)p.Pos.FeetBlockCoords; p.Message("Set &cRed &Sspawn"); } else if (value.CaselessEq("blue")) { cfg.BlueSpawn = (Vec3U16)p.Pos.FeetBlockCoords; p.Message("Set &9Blue &Sspawn"); } else { Help(p, "team"); return; } } else if (prop.CaselessEq("tnt")) { int amount = 1; if (!CommandParser.GetInt(p, value, "TNT at a time", ref amount, 0)) { return; } cfg.MaxActiveTnt = amount; p.Message("Number of TNTs placeable by a player at a time is now {0}", amount == 0 ? "unlimited" : value); } else if (prop.CaselessEq("graceperiod")) { SetBool(p, ref cfg.GracePeriod, value, "Grace period"); } else if (prop.CaselessEq("gracetime")) { TimeSpan time = default(TimeSpan); if (!CommandParser.GetTimespan(p, value, ref time, "set grace time to", "s")) { return; } cfg.GracePeriodTime = time; p.Message("Grace period is now {0}", time.Shorten(true, true)); } else if (prop.CaselessEq("gamemode")) { if (value.CaselessEq("tdm")) { if (gameCfg.Mode == TWGameMode.FFA) { if (p.level != game.Map) { p.Message("Changed gamemode to Team Deathmatch"); } game.ModeTDM(); } else { p.Message("&cGamemode is already Team Deathmatch"); return; } } else if (value.CaselessEq("ffa")) { if (gameCfg.Mode == TWGameMode.TDM) { if (p.level != game.Map) { p.Message("Changed gamemode to Free For All"); } game.ModeFFA(); } else { p.Message("&cGamemode is already Free For All"); return; } } else { Help(p, "other"); return; } } else if (prop.CaselessEq("difficulty")) { TWDifficulty diff = TWDifficulty.Easy; if (!CommandParser.GetEnum(p, value, "Difficulty", ref diff)) { return; } SetDifficulty(game, diff, p); } else if (prop.CaselessEq("score")) { if (args.Length < 4) { Help(p, "score"); return; } if (!HandleSetScore(p, cfg, args)) { return; } } else if (prop.CaselessEq("balanceteams")) { SetBool(p, ref cfg.BalanceTeams, value, "Team balancing"); } else if (prop.CaselessEq("teamkill")) { SetBool(p, ref cfg.TeamKills, value, "Team killing"); } else if (prop.CaselessEq("zone")) { if (args.Length < 4) { Help(p, "zone"); return; } if (value.CaselessEq("notnt")) { if (!HandleZone(p, game, true, args)) { return; } } else if (value.CaselessEq("nodestroy")) { if (!HandleZone(p, game, false, args)) { return; } } else { Help(p, "zone"); return; } } else { OutputStatus(p, gameCfg, cfg); return; } SaveMapConfig(p, cfg); }