Пример #1
0
        protected override void DoPurchase(Player p, string message, string[] args)
        {
            string text      = message.SplitSpaces(2)[1]; // keep spaces this way
            bool   hasAToken = false;

            for (int i = 0; i < text.Length; i++)
            {
                if (!CheckEscape(text, i, ref hasAToken))
                {
                    p.Message("You can only use {0} and {1} for tokens in infect messages."); return;
                }
            }
            if (!hasAToken)
            {
                p.Message("You need to include a \"{0}\" (placeholder for zombie player) " +
                          "and/or a \"{1}\" (placeholder for human player) in the infect message."); return;
            }

            ZSData data = ZSGame.Get(p);

            if (data.InfectMessages == null)
            {
                data.InfectMessages = new List <string>();
            }
            data.InfectMessages.Add(text);

            ZSConfig.AppendPlayerInfectMessage(p.name, text);
            p.Message("&aAdded infect message: &f" + text);
            Economy.MakePurchase(p, Price, "%3InfectMessage: " + message);
        }
Пример #2
0
        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));
        }
Пример #3
0
        protected internal override void OnBuyCommand(Player p, string message, string[] args)
        {
            if (p.money < Price)
            {
                p.Message("%WYou don't have enough &3" + Server.Config.Currency + "%W to buy a " + Name + "."); return;
            }
            if (!ZSGame.Instance.Running || !ZSGame.Instance.RoundInProgress)
            {
                p.Message("You can only buy an revive potion " +
                          "when a round of zombie survival is in progress."); return;
            }

            ZSData data = ZSGame.Get(p);

            if (!data.Infected)
            {
                p.Message("You are already a human."); return;
            }

            DateTime end = ZSGame.Instance.RoundEnd;

            if (DateTime.UtcNow.AddSeconds(ZSGame.Config.ReviveNoTime) > end)
            {
                p.Message(ZSGame.Config.ReviveNoTimeMessage); return;
            }
            int count = ZSGame.Instance.Infected.Count;

            if (count < ZSGame.Config.ReviveFewZombies)
            {
                p.Message(ZSGame.Config.ReviveFewZombiesMessage); return;
            }
            if (data.RevivesUsed >= ZSGame.Config.ReviveTimes)
            {
                p.Message("You cannot buy any more revive potions."); return;
            }
            if (data.TimeInfected.AddSeconds(ZSGame.Config.ReviveTooSlow) < DateTime.UtcNow)
            {
                p.Message("%WYou can only revive within the first {0} seconds after you were infected.",
                          ZSGame.Config.ReviveTooSlow); return;
            }

            int chance = new Random().Next(1, 101);

            if (chance <= ZSGame.Config.ReviveChance)
            {
                ZSGame.Instance.DisinfectPlayer(p);
                ZSGame.Instance.Map.Message(p.ColoredName + " %Sused a revive potion. &aIt was super effective!");
            }
            else
            {
                ZSGame.Instance.Map.Message(p.ColoredName + " %Stried using a revive potion. &cIt was not very effective..");
            }
            Economy.MakePurchase(p, Price, "%3Revive:");
            data.RevivesUsed++;
        }
Пример #4
0
        protected internal override void OnBuyCommand(Player p, string message, string[] args)
        {
            if (p.money < Price)
            {
                p.Message("%WYou don't have enough &3{1} %Wto buy a {0}.", Name, ServerConfig.Currency); 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;
            }
            if (data.InvisibilityPotions >= MaxPotions)
            {
                p.Message("You cannot buy any more invisibility potions this round."); return;
            }
            if (ForHumans && data.Infected)
            {
                p.Message("Use %T/Buy zinvisibility %Sfor buying invisibility when you are a zombie."); return;
            }
            if (!ForHumans && !data.Infected)
            {
                p.Message("Use %T/Buy invisibility %Sfor buying invisibility when you are a human."); 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;
            }

            data.Invisible       = true;
            data.InvisibilityEnd = DateTime.UtcNow.AddSeconds(Duration);
            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.Map.Message(p.ColoredName + " %Svanished. &a*POOF*");
            Entities.GlobalDespawn(p, false, false);
            Economy.MakePurchase(p, Price, "%3Invisibility: " + Duration);
        }
Пример #5
0
        unsafe static void UpdatePosition(Player p)
        {
            Player[] players = PlayerInfo.Online.Items;
            byte *   src     = stackalloc byte[16 * 256]; // 16 = size of absolute update, with extended positions
            byte *   ptr     = src;

            foreach (Player pl in players)
            {
                if (p == pl || p.level != pl.level || !p.CanSeeEntity(pl))
                {
                    continue;
                }

                Orientation rot = pl.Rot; byte pitch = rot.HeadX;
                if (Server.flipHead || p.flipHead)
                {
                    pitch = FlippedPitch(pitch);
                }

                // flip head when infected, but doesn't support model
                if (!p.hasChangeModel)
                {
                    ZSData data = ZSGame.TryGet(p);
                    if (data != null && data.Infected)
                    {
                        pitch = FlippedPitch(pitch);
                    }
                }

                rot.HeadX = pitch;
                Entities.GetPositionPacket(ref ptr, pl.id, pl.hasExtPositions, p.hasExtPositions,
                                           pl.tempPos, pl.lastPos, rot, pl.lastRot);
            }

            int count = (int)(ptr - src);

            if (count == 0)
            {
                return;
            }

            byte[] packet = new byte[count];
            for (int i = 0; i < packet.Length; i++)
            {
                packet[i] = src[i];
            }
            p.Send(packet);
        }
Пример #6
0
        protected internal override void OnPurchase(Player p, string args)
        {
            if (!CheckPrice(p, Price, "a revive potion"))
            {
                return;
            }
            if (!ZSGame.Instance.Running || !ZSGame.Instance.RoundInProgress)
            {
                p.Message("You can only buy a revive potion " +
                          "when a round of zombie survival is in progress."); return;
            }

            ZSData data = ZSGame.Get(p);

            if (!data.Infected)
            {
                p.Message("You are already a human."); return;
            }

            DateTime end = ZSGame.Instance.RoundEnd;

            if (DateTime.UtcNow.AddSeconds(ZSGame.Config.ReviveNoTime) > end)
            {
                p.Message(ZSGame.Config.ReviveNoTimeMessage); return;
            }
            int count = ZSGame.Instance.Infected.Count;

            if (count < ZSGame.Config.ReviveFewZombies)
            {
                p.Message(ZSGame.Config.ReviveFewZombiesMessage); return;
            }
            if (data.RevivesUsed >= ZSGame.Config.ReviveTimes)
            {
                p.Message("You cannot buy any more revive potions."); return;
            }
            if (data.TimeInfected.AddSeconds(ZSGame.Config.ReviveTooSlow) < DateTime.UtcNow)
            {
                p.Message("&WYou can only revive within the first {0} seconds after you were infected.",
                          ZSGame.Config.ReviveTooSlow); return;
            }

            ZSGame.Instance.AttemptRevive(p);
            data.RevivesUsed++;
            Economy.MakePurchase(p, Price, "%3Revive:");
        }
Пример #7
0
        protected internal override void OnBuyCommand(Player p, string message, string[] args)
        {
            if (p.money < Price)
            {
                p.Message("%WYou don't have enough &3{1} %Wto buy an {0}.", Name, Server.Config.Currency); 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 = data.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 = data.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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        protected internal override void OnPurchase(Player p, string args)
        {
            int          count = 1;
            const string group = "Number of groups of 10 blocks";

            if (args.Length > 0 && !CommandParser.GetInt(p, args, group, ref count, 0, 10))
            {
                return;
            }

            if (!CheckPrice(p, count * Price, (count * 10) + " blocks"))
            {
                return;
            }

            ZSData data = ZSGame.Get(p);

            data.BlocksLeft += 10 * count;
            Economy.MakePurchase(p, Price * count, "%310Blocks: " + (10 * count));
        }
Пример #10
0
        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);
        }
Пример #11
0
        protected override void DoPurchase(Player p, string message, string[] args)
        {
            int          count = 1;
            const string group = "Number of groups of 10 blocks";

            if (args.Length >= 2 && !CommandParser.GetInt(p, args[1], group, ref count, 0, 10))
            {
                return;
            }

            if (p.money < Price * count)
            {
                p.Message("%WYou don't have enough &3{2} %Wto buy {1} {0}.",
                          Name, count * 10, Server.Config.Currency); return;
            }

            ZSData data = ZSGame.Get(p);

            data.BlocksLeft += 10 * count;
            Economy.MakePurchase(p, Price * count, "%310Blocks: " + (10 * count));
        }
Пример #12
0
        protected internal override void OnPurchase(Player p, string msg)
        {
            if (msg.Length == 0)
            {
                OnStoreCommand(p); return;
            }
            bool hasAToken = false;

            for (int i = 0; i < msg.Length; i++)
            {
                if (!CheckEscape(msg, i, ref hasAToken))
                {
                    p.Message("You can only use {0} and {1} for tokens in infect messages."); return;
                }
            }
            if (!hasAToken)
            {
                p.Message("You need to include a \"{0}\" (placeholder for zombie player) " +
                          "and/or a \"{1}\" (placeholder for human player) in the infect message."); return;
            }

            if (!CheckPrice(p))
            {
                return;
            }
            ZSData data = ZSGame.Get(p);

            if (data.InfectMessages == null)
            {
                data.InfectMessages = new List <string>();
            }
            data.InfectMessages.Add(msg);

            ZSConfig.AppendPlayerInfectMessage(p.name, msg);
            p.Message("&aAdded infect message: &f" + msg);
            Economy.MakePurchase(p, Price, "%3InfectMessage: " + msg);
        }