Beispiel #1
0
 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);
 }
Beispiel #2
0
        public Player HarmedBy; // For Assists

        public void Reset(TWDifficulty diff)
        {
            bool easyish = diff == TWDifficulty.Easy || diff == TWDifficulty.Normal;

            Score      = 0;
            Health     = easyish ? 2 : 1;
            KillStreak = 0;
            LastKillStreakAnnounced = 0;
            TNTCounter      = 0;
            ScoreMultiplier = 1f;
            HarmedBy        = null;
        }
Beispiel #3
0
        public void SetDifficulty(TWDifficulty diff)
        {
            Config.Difficulty = diff;
            MessageMap(CpeMessageType.Announcement,
                       "&4Difficulty changed to &f" + diff);
            Config.Save();

            bool teamKill = diff >= TWDifficulty.Hard;

            if (cfg.TeamKills == teamKill)
            {
                return;
            }

            cfg.TeamKills = teamKill;
            cfg.Save(Map.name);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        void KillPlayers(Player killer, TWData data, List <Player> inRange)
        {
            List <Player> killed = new List <Player>();
            int           damage = 1, kills = 0, penalty = 0;
            TWDifficulty  diff = Config.Difficulty;

            if (diff == TWDifficulty.Hard || diff == TWDifficulty.Extreme)
            {
                damage = 2;
            }

            foreach (Player pl in inRange)
            {
                if (!cfg.TeamKills && TeamKill(killer, pl))
                {
                    continue;
                }
                TWData plData = Get(pl);

                if (plData.Health <= damage)
                {
                    killed.Add(pl);
                }
                else
                {
                    plData.Health  -= damage;
                    plData.HarmedBy = killer;

                    killer.Message("TNT Wars: You harmed " + pl.ColoredName);
                    pl.Message("TNT Wars: You were harmed by " + killer.ColoredName);
                }
            }

            foreach (Player pl in killed)
            {
                string suffix = "";
                TWData plData = Get(pl);

                if (plData.HarmedBy != null && plData.HarmedBy != killer)
                {
                    Player assistant = plData.HarmedBy;
                    suffix = " &S(with help from " + assistant.ColoredName + ")";

                    if (TeamKill(assistant, pl))
                    {
                        assistant.Message("TNT Wars: - " + cfg.AssistScore + " points for team kill assist!");
                        ChangeScore(assistant, -cfg.AssistScore);
                    }
                    else
                    {
                        assistant.Message("TNT Wars: + " + cfg.AssistScore + " points for assist!");
                        ChangeScore(assistant, cfg.AssistScore);
                    }
                }

                if (TeamKill(killer, pl))
                {
                    Map.Message("TNT Wars: " + killer.ColoredName + " &Steam killed " + pl.ColoredName + suffix);
                    penalty += cfg.ScorePerKill;
                }
                else
                {
                    Map.Message("TNT Wars: " + killer.ColoredName + " &Skilled " + pl.ColoredName + suffix);
                    kills += 1;
                }

                plData.HarmedBy = null;
                PlayerActions.Respawn(pl);
            }

            int points = 0;

            data.KillStreak += kills;

            if (kills > 0 && cfg.Streaks)
            {
                if (data.KillStreak >= cfg.StreakOneAmount && data.KillStreak < cfg.StreakTwoAmount && data.LastKillStreakAnnounced != cfg.StreakOneAmount)
                {
                    killer.Message("TNT Wars: Kill streak of " + data.KillStreak + " (Multiplier of " + cfg.StreakOneMultiplier + ")");
                    Map.Message(killer.ColoredName + " &Shas a kill streak of " + data.KillStreak);
                    data.ScoreMultiplier         = cfg.StreakOneMultiplier;
                    data.LastKillStreakAnnounced = cfg.StreakOneAmount;
                }
                else if (data.KillStreak >= cfg.StreakTwoAmount && data.KillStreak < cfg.StreakThreeAmount && data.LastKillStreakAnnounced != cfg.StreakTwoAmount)
                {
                    killer.Message("TNT Wars: Kill streak of " + data.KillStreak + " (Multiplier of " + cfg.StreakTwoMultiplier + " and a bigger explosion!)");
                    Map.Message(killer.ColoredName + " &Shas a kill streak of " + data.KillStreak + " and now has a bigger explosion for their TNT!");
                    data.ScoreMultiplier         = cfg.StreakTwoMultiplier;
                    data.LastKillStreakAnnounced = cfg.StreakTwoAmount;
                }
                else if (data.KillStreak >= cfg.StreakThreeAmount && data.LastKillStreakAnnounced != cfg.StreakThreeAmount)
                {
                    killer.Message("TNT Wars: Kill streak of " + data.KillStreak + " (Multiplier of " + cfg.StreakThreeMultiplier + " and you now have 1 extra health!)");
                    Map.Message(killer.ColoredName + " &Shas a kill streak of " + data.KillStreak + " and now has 1 extra health!");
                    data.ScoreMultiplier         = cfg.StreakThreeMultiplier;
                    data.LastKillStreakAnnounced = cfg.StreakThreeAmount;

                    if (diff == TWDifficulty.Hard || diff == TWDifficulty.Extreme)
                    {
                        data.Health += 2;
                    }
                    else
                    {
                        data.Health += 1;
                    }
                }
                else
                {
                    killer.Message("TNT Wars: Kill streak of " + data.KillStreak);
                }
            }

            points += kills * cfg.ScorePerKill;
            if (kills > 1)
            {
                points += kills * cfg.MultiKillBonus;
            }

            if (points > 0)
            {
                points = (int)(points * data.ScoreMultiplier);
                ChangeScore(killer, points);
                killer.Message("TNT Wars: + " + points + " points for " + kills + " kills");
            }
            if (penalty > 0)
            {
                ChangeScore(killer, -penalty);
                killer.Message("TNT Wars: - " + penalty + " points for team killing!");
            }
        }