Ejemplo n.º 1
0
 static void UpdateConfig(Player p, TWMapConfig cfg)
 {
     cfg.Save(p.level.name);
     if (p.level == TWGame.Instance.Map)
     {
         TWGame.Instance.UpdateMapConfig();
     }
 }
Ejemplo n.º 2
0
        static TWMapConfig RetrieveConfig(Player p)
        {
            TWMapConfig cfg = new TWMapConfig();

            cfg.SetDefaults(p.level);
            cfg.Load(p.level.name);
            return(cfg);
        }
Ejemplo n.º 3
0
 static void OutputStatus(Player p, TWConfig gameCfg, TWMapConfig cfg)
 {
     p.Message("Gamemode: &a{0} &Sat difficulty &a{1}",
               gameCfg.Mode, gameCfg.Difficulty);
     p.Message("TNT per player at a time: &a{0}",
               cfg.MaxActiveTnt == 0 ? "unlimited" : cfg.MaxActiveTnt.ToString());
     p.Message("Grace period: {0} &S(for {1} seconds)",
               GetBool(cfg.GracePeriod), cfg.GracePeriodTime);
     p.Message("Team balancing: {0}&S, Team killing: {1}",
               GetBool(cfg.BalanceTeams), GetBool(cfg.TeamKills));
     p.Message("Score: &a{0} &Spoints needed to win, &a{1} &Spoints per kill",
               cfg.ScoreRequired, cfg.ScorePerKill);
     p.Message("Streaks: {0}&S, Multikill bonus: {1}",
               GetBool(cfg.Streaks), GetBool(cfg.MultiKillBonus != 0));
     p.Message("Assists: {0} &S(at {1} points)",
               GetBool(cfg.AssistScore > 0), cfg.AssistScore);
 }
Ejemplo n.º 4
0
        void twMapUse_SelectedIndexChanged(object sender, EventArgs e)
        {
            SaveTWMapSettings();
            if (tw_lstUsed.SelectedIndex == -1)
            {
                tw_grpMapSettings.Text    = "Map settings";
                tw_grpMapSettings.Enabled = false;
                twCurCfg = null;
                return;
            }

            twCurMap = tw_lstUsed.SelectedItem.ToString();
            tw_grpMapSettings.Text    = "Map settings (" + twCurMap + ")";
            tw_grpMapSettings.Enabled = true;

            try {
                twCurCfg = new TWMapConfig();
                twCurCfg.Load(twCurMap);
            } catch (Exception ex) {
                Logger.LogError(ex);
                twCurCfg = null;
            }

            if (twCurCfg == null)
            {
                return;
            }
            tw_numScoreLimit.Value   = twCurCfg.ScoreRequired;
            tw_numScorePerKill.Value = twCurCfg.ScorePerKill;
            tw_numScoreAssists.Value = twCurCfg.AssistScore;
            tw_numMultiKills.Value   = twCurCfg.MultiKillBonus;
            tw_cbStreaks.Checked     = twCurCfg.Streaks;

            tw_cbGrace.Checked   = twCurCfg.GracePeriod;
            tw_numGrace.Value    = twCurCfg.GracePeriodTime;
            tw_cbBalance.Checked = twCurCfg.BalanceTeams;
            tw_cbKills.Checked   = twCurCfg.TeamKills;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        bool HandleSetScore(Player p, TWMapConfig cfg, string[] args)
        {
            string opt = args[2], value = args[3];

            if (opt.CaselessEq("required"))
            {
                int score = 1;
                if (!CommandParser.GetInt(p, value, "Points", ref score, 0))
                {
                    return(false);
                }
                cfg.ScoreRequired = score;

                p.Message("Score required to win is now &a{0} &Spoints!", score);
            }
            else if (opt.CaselessEq("streaks"))
            {
                SetBool(p, ref cfg.Streaks, value, "Streaks");
            }
            else if (opt.CaselessEq("multi"))
            {
                int multi = 1;
                if (!CommandParser.GetInt(p, value, "Points", ref multi, 0))
                {
                    return(false);
                }
                cfg.MultiKillBonus = multi;

                if (multi == 0)
                {
                    p.Message("Multikill bonus is now &cdisabled");
                }
                else
                {
                    p.Message("Scores per extra kill is now &a{0} &Spoints", multi);
                }
            }
            else if (opt.CaselessEq("kill"))
            {
                int kill = 1;
                if (!CommandParser.GetInt(p, value, "Points", ref kill, 0))
                {
                    return(false);
                }
                cfg.ScorePerKill = kill;

                p.Message("Score per kill is now &a{0} &Spoints", kill);
            }
            else if (opt.CaselessEq("assist"))
            {
                int assist = 1;
                if (!CommandParser.GetInt(p, value, "Points", ref assist, 0))
                {
                    return(false);
                }
                cfg.AssistScore = assist;

                if (assist == 0)
                {
                    p.Message("Scores per assist is now &cdisabled");
                }
                else
                {
                    p.Message("Score per assist is now &a{0} &Spoints", assist);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }