public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));

            if (player == null)
            {
                queue.HandleError(entry, "Invalid player!");
                return;
            }
            ItemAssetTag item = ItemAssetTag.For(entry.GetArgument(queue, 1));

            if (item == null)
            {
                queue.HandleError(entry, "Invalid item!");
                return;
            }
            byte amount = 1;

            if (entry.Arguments.Count > 2)
            {
                amount = (byte)Utilities.StringToUInt(entry.GetArgument(queue, 2));
            }
            if (ItemTool.tryForceGiveItem(player.Internal.player, item.Internal.id, amount))
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully gave a " + TagParser.Escape(item.Internal.name) + "!");
                }
            }
            else
            {
                queue.HandleError(entry, "Failed to give item (is the inventory full?)!");
            }
        }
Beispiel #2
0
 public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1));
         if (num == null)
         {
             queue.HandleError(entry, "Invalid amount number!");
             return;
         }
         PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));
         if (player == null)
         {
             queue.HandleError(entry, "Invalid player!");
             return;
         }
         player.Internal.player.life.askWarm((uint)num.Internal);
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully adjusted the warmth level of a player!");
         }
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to adjust player's warmth level: " + ex.ToString());
     }
 }
Beispiel #3
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));

            if (player == null)
            {
                queue.HandleError(entry, "Invalid player!");
                return;
            }
            ItemAssetTag item = ItemAssetTag.For(entry.GetArgument(queue, 1));

            if (item == null)
            {
                queue.HandleError(entry, "Invalid item!");
                return;
            }
            byte amount = 1;

            if (entry.Arguments.Count > 2)
            {
                amount = (byte)Utilities.StringToUInt(entry.GetArgument(queue, 2));
            }
            PlayerInventory inventory       = player.Internal.player.inventory;
            byte            remainingAmount = amount;
            InventorySearch search;

            while (remainingAmount > 0 && (search = inventory.has(item.Internal.id)) != null) // TODO: Less awkward code!?
            {
                if (search.jar.item.amount <= remainingAmount)
                {
                    inventory.removeItem(search.page, inventory.getIndex(search.page, search.jar.x, search.jar.y));
                    remainingAmount -= search.jar.item.amount;
                }
                else
                {
                    inventory.sendUpdateAmount(search.page, search.jar.x, search.jar.y, (byte)(search.jar.item.amount - remainingAmount));
                    remainingAmount = 0;
                }
            }
            if (remainingAmount == 0)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully took " + amount + " " + TagParser.Escape(item.Internal.name) + "!");
                }
            }
            else if (remainingAmount < amount)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully took " + (amount - remainingAmount) + " " + TagParser.Escape(item.Internal.name) + "! (" + remainingAmount + " more not found!)");
                }
            }
            else
            {
                queue.HandleError(entry, "Failed to take item (does the inventory contain any?)!");
            }
        }
        public override TemplateObject Handle(TagData data)
        {
            string    pname = data.GetModifier(0);
            PlayerTag ptag  = PlayerTag.For(pname);

            if (ptag == null)
            {
                return(new TextTag("&{NULL}").Handle(data.Shrink()));
            }
            return(ptag.Handle(data.Shrink()));
        }
Beispiel #5
0
        public override void Execute(CommandQueue queue, CommandEntry entry)
        {
            if (entry.Arguments.Count < 2)
            {
                ShowUsage(queue, entry);
                return;
            }
            ListTag          players  = ListTag.For(entry.GetArgumentObject(queue, 0));
            ListTag          items    = ListTag.For(entry.GetArgumentObject(queue, 1));
            List <ItemStack> itemlist = new List <ItemStack>();

            for (int i = 0; i < items.ListEntries.Count; i++)
            {
                ItemTag item = ItemTag.For(TheServer, items.ListEntries[i]);
                if (item == null)
                {
                    queue.HandleError(entry, "Invalid item!");
                    return;
                }
                itemlist.Add(item.Internal);
            }
            List <PlayerEntity> playerlist = new List <PlayerEntity>();

            for (int i = 0; i < players.ListEntries.Count; i++)
            {
                PlayerTag player = PlayerTag.For(TheServer, players.ListEntries[i]);
                if (player == null)
                {
                    queue.HandleError(entry, "Invalid player: " + TagParser.Escape(items.ListEntries[i].ToString()));
                    return;
                }
                playerlist.Add(player.Internal);
            }
            foreach (PlayerEntity player in playerlist)
            {
                foreach (ItemStack item in itemlist)
                {
                    player.Items.GiveItem(item);
                }
            }
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, itemlist.Count + " item(s) given to " + playerlist.Count + " player(s)!");
            }
        }
 public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         BooleanTag boolean = BooleanTag.TryFor(entry.GetArgumentObject(queue, 1));
         if (boolean == null)
         {
             queue.HandleError(entry, "Invalid boolean!");
             return;
         }
         PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));
         if (player == null)
         {
             queue.HandleError(entry, "Invalid player!");
             return;
         }
         bool       value = boolean.Internal;
         PlayerLife life  = player.Internal.player.life;
         if (life.isBroken != value)
         {
             if (value)
             {
                 life.breakLegs();
             }
             else
             {
                 life._isBroken = false;
                 life.channel.send("tellBroken", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                 {
                     life._isBroken
                 });
             }
             entry.Good(queue, "Successfully adjusted the broken legs of player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(boolean.ToString()) + "!");
         }
         else
         {
             entry.Good(queue, "Player " + TagParser.Escape(player.ToString()) + " already has their broken legs set to " + TagParser.Escape(boolean.ToString()) + "!");
         }
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to adjust player's broken legs: " + ex.ToString());
     }
 }
Beispiel #7
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 2));

            if (num == null)
            {
                queue.HandleError(entry, "Invalid amount number!");
                return;
            }
            PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));

            if (player == null)
            {
                queue.HandleError(entry, "Invalid player!");
                return;
            }
            bool award = entry.GetArgument(queue, 1) == "award";

            if (num.Internal > 0)
            {
                PlayerSkills skills = player.Internal.player.skills;
                if (award)
                {
                    skills._experience += (uint)num.Internal;
                }
                else
                {
                    skills._experience -= (uint)num.Internal;
                }
                skills.channel.send("tellExperience", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                {
                    skills.experience
                });
            }
            else
            {
                queue.HandleError(entry, "Amount must be positive!");
                return;
            }
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, "Successfully " + (award ? "awarded experience to" : "took experience from") + " a player!");
            }
        }
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            PlayerTag player  = PlayerTag.For(entry.GetArgument(queue, 0));
            bool      primary = entry.GetArgument(queue, 1) == "primary";
            bool      start   = BooleanTag.TryFor(entry.GetArgumentObject(queue, 2)).Internal;

            if (player.Internal.player.equipment.useable == null)
            {
                entry.Bad(queue, "Failed to use item, holding nothing.");
                return;
            }
            if (primary)
            {
                if (start)
                {
                    player.Internal.player.equipment.useable.startPrimary();
                }
                else
                {
                    player.Internal.player.equipment.useable.stopPrimary();
                }
            }
            else
            {
                if (start)
                {
                    player.Internal.player.equipment.useable.startSecondary();
                }
                else
                {
                    player.Internal.player.equipment.useable.stopSecondary();
                }
            }
            player.Internal.player.equipment.useable.tick();
            player.Internal.player.equipment.useable.tock(player.Internal.player.input.clock);
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, "Player is " + (start ? "now" : "no longer") + " using the " + (primary ? "primary" : "secondary") + " mode on their held item!");
            }
        }
Beispiel #9
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            ListTag        players = ListTag.For(entry.GetArgument(queue, 0));
            TemplateObject tcolor  = entry.GetArgumentObject(queue, 1);
            ColorTag       color   = ColorTag.For(tcolor);

            if (color == null)
            {
                queue.HandleError(entry, "Invalid color: " + TagParser.Escape(tcolor.ToString()));
                return;
            }
            string    tchatter = entry.GetArgument(queue, 2);
            PlayerTag chatter  = PlayerTag.For(tchatter);

            if (chatter == null)
            {
                queue.HandleError(entry, "Invalid chatting player: " + TagParser.Escape(tchatter));
                return;
            }
            string message = entry.GetArgument(queue, 3);

            foreach (TemplateObject tplayer in players.ListEntries)
            {
                PlayerTag player = PlayerTag.For(tplayer.ToString());
                if (player == null)
                {
                    queue.HandleError(entry, "Invalid player: " + TagParser.Escape(tplayer.ToString()));
                    continue;
                }
                ChatManager.manager.channel.send("tellChat", player.Internal.playerID.steamID, ESteamPacket.UPDATE_UNRELIABLE_BUFFER,
                                                 chatter.Internal.playerID.steamID, (byte)0 /* TODO: Configurable mode? */, color.Internal, message);
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully sent a message.");
                }
            }
        }
Beispiel #10
0
 public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1));
         if (num == null)
         {
             queue.HandleError(entry, "Invalid amount number!");
             return;
         }
         PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));
         if (player == null)
         {
             queue.HandleError(entry, "Invalid player!");
             return;
         }
         int        amount = (int)num.Internal;
         PlayerLife life   = player.Internal.player.life;
         if (amount >= 0)
         {
             life.askRest((byte)amount);
         }
         else
         {
             life.askTire((byte)-amount);
         }
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully adjusted the stamina level of a player!");
         }
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to adjust player's stamina level: " + ex.ToString());
     }
 }