Esempio n. 1
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     bool enable = BooleanTag.TryFor(entry.GetArgumentObject(queue, 1)).Internal;
     EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
     if (entity == null)
     {
         queue.HandleError(entry, "Invalid entity!");
         return;
     }
     ZombieTag zombie;
     if (entity.TryGetZombie(out zombie))
     {
         zombie.Internal.UFM_AIDisabled = !enable;
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "AI for a zombie " + (enable ? "enabled!" : "disabled!"));
         }
         return;
     }
     AnimalTag animal;
     if (entity.TryGetAnimal(out animal))
     {
         animal.Internal.UFM_AIDisabled = !enable;
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "AI for an animal " + (enable ? "enabled!" : "disabled!"));
         }
         return;
     }
     queue.HandleError(entry, "That entity doesn't have AI!");
 }
Esempio n. 2
0
 public override void Execute(CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(entry);
     }
     else
     {
         string modechoice = entry.GetArgument(0);
         switch (modechoice.ToLower())
         {
             case "full":
                 entry.Queue.Debug = DebugMode.FULL;
                 entry.Good("Queue debug mode set to <{color.emphasis}>full<{color.base}>.");
                 break;
             case "minimal":
                 entry.Queue.Debug = DebugMode.MINIMAL;
                 entry.Good("Queue debug mode set to <{color.emphasis}>minimal<{color.base}>.");
                 break;
             case "none":
                 entry.Queue.Debug = DebugMode.NONE;
                 entry.Good("Queue debug mode set to <{color.emphasis}>none<{color.base}>.");
                 break;
             default:
                 entry.Bad("Unknown debug mode '<{color.emphasis}>" + modechoice + "<{color.base}>'.");
                 break;
         }
     }
 }
Esempio n. 3
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            bool      enable = BooleanTag.TryFor(entry.GetArgumentObject(queue, 1)).Internal;
            EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));

            if (entity == null)
            {
                queue.HandleError(entry, "Invalid entity!");
                return;
            }
            ZombieTag zombie;

            if (entity.TryGetZombie(out zombie))
            {
                zombie.Internal.UFM_AIDisabled = !enable;
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "AI for a zombie " + (enable ? "enabled!" : "disabled!"));
                }
                return;
            }
            AnimalTag animal;

            if (entity.TryGetAnimal(out animal))
            {
                animal.Internal.UFM_AIDisabled = !enable;
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "AI for an animal " + (enable ? "enabled!" : "disabled!"));
                }
                return;
            }
            queue.HandleError(entry, "That entity doesn't have AI!");
        }
Esempio n. 4
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1));

            if (num.Internal <= 0)
            {
                queue.HandleError(entry, "Must provide a number that is greater than 0!");
                return;
            }
            EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));

            if (entity == null)
            {
                queue.HandleError(entry, "Invalid entity!");
                return;
            }
            ZombieTag zombie;

            if (entity.TryGetZombie(out zombie))
            {
                Zombie inZomb = zombie.Internal;
                inZomb.maxHealth = (ushort)num.Internal;
                if (inZomb.health > inZomb.maxHealth)
                {
                    inZomb.health = inZomb.maxHealth;
                }
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully set health of a zombie to " + inZomb.maxHealth + "!");
                }
                return;
            }
            PlayerTag player;

            if (entity.TryGetPlayer(out player))
            {
                GameObject          playerObj  = player.Internal.player.gameObject;
                UFMHealthController controller = playerObj.GetComponent <UFMHealthController>();
                if (controller == null)
                {
                    controller = playerObj.AddComponent <UFMHealthController>();
                }
                controller.maxHealth = (uint)num.Internal;
                PlayerLife life = player.Internal.player.life;
                byte       curr = life.health;
                controller.health = curr >= controller.maxHealth ? controller.maxHealth : curr;
                life._health      = controller.Translate();
                life.channel.send("tellHealth", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                {
                    life.health
                });
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully set max health of a player to " + controller.maxHealth + "!");
                }
                return;
            }
            queue.HandleError(entry, "That entity can't be healed!");
        }
Esempio n. 5
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 void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
         if (loc == null)
         {
             queue.HandleError(entry, "Invalid location!");
             return;
         }
         EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
         if (entity == null)
         {
             queue.HandleError(entry, "Invalid entity!");
             return;
         }
         PlayerTag player;
         if (entity.TryGetPlayer(out player))
         {
             player.Internal.player.gameObject.AddComponent <LaunchComponent>().LaunchPlayer(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ZombieTag zombie;
         if (entity.TryGetZombie(out zombie))
         {
             zombie.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched zombie " + TagParser.Escape(zombie.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         AnimalTag animal;
         if (entity.TryGetAnimal(out animal))
         {
             animal.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched animal " + TagParser.Escape(animal.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ItemEntityTag item;
         if (entity.TryGetItem(out item))
         {
             // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID?
         }
         queue.HandleError(entry, "That entity can't be launched!");
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to launch entity: " + ex.ToString());
     }
 }
Esempio n. 7
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));

            if (loc == null)
            {
                queue.HandleError(entry, "Invalid location!");
                return;
            }
            EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));

            if (entity == null)
            {
                queue.HandleError(entry, "Invalid entity!");
                return;
            }
            ZombieTag zombie;

            if (entity.TryGetZombie(out zombie))
            {
                zombie.Internal.target.position  = loc.ToVector3();
                zombie.Internal.seeker.canMove   = true;
                zombie.Internal.seeker.canSearch = true;
                zombie.Internal.path             = EZombiePath.RUSH; // TODO: Option for this?
                if (!zombie.Internal.isTicking)
                {
                    zombie.Internal.isTicking = true;
                    ZombieManager.tickingZombies.Add(zombie.Internal);
                }
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully started a zombie walking to " + TagParser.Escape(loc.ToString()) + "!");
                }
                return;
            }
            AnimalTag animal;

            if (entity.TryGetAnimal(out animal))
            {
                animal.Internal.target = loc.ToVector3();
                if (!animal.Internal.isTicking)
                {
                    animal.Internal.isTicking = true;
                    AnimalManager.tickingAnimals.Add(animal.Internal);
                }
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully started an animal walking to " + TagParser.Escape(loc.ToString()) + "!");
                }
                return;
            }
            queue.HandleError(entry, "That entity can't be made to walk!");
        }
Esempio n. 8
0
 public override void Execute(CommandEntry entry)
 {
     if (MouseHandler.MouseCaptured)
     {
         entry.Good("Mouse released.");
         MouseHandler.ReleaseMouse();
     }
     else
     {
         entry.Good("Mouse captured.");
         MouseHandler.CaptureMouse();
     }
 }
Esempio n. 9
0
        public override void Execute(CommandQueue queue, CommandEntry entry)
        {
            TemplateObject cb = entry.GetArgumentObject(queue, 0);

            if (cb.ToString() == "\0CALLBACK")
            {
                return;
            }
            if (entry.InnerCommandBlock == null)
            {
                queue.HandleError(entry, "Invalid or missing command block!");
                return;
            }
            ListTag          mode  = ListTag.For(cb);
            List <ItemStack> items = new List <ItemStack>();

            for (int i = 1; i < entry.Arguments.Count; i++)
            {
                ItemTag required = ItemTag.For(TheServer, entry.GetArgumentObject(queue, i));
                if (required == null)
                {
                    queue.HandleError(entry, "Invalid required item!");
                    return;
                }
                items.Add(required.Internal);
            }
            TheServer.Recipes.AddRecipe(RecipeRegistry.ModeFor(mode), entry.InnerCommandBlock, entry.BlockStart, items.ToArray());
            queue.CurrentEntry.Index = entry.BlockEnd + 2;
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, "Added recipe!");
            }
        }
Esempio n. 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;
         }
         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());
     }
 }
Esempio n. 11
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     string key = entry.GetArgument(queue, 0);
     Key k = KeyHandler.GetKeyForName(key);
     KeyHandler.BindKey(k, (string)null);
     entry.Good(queue, "Keybind removed for " + k + ".");
 }
Esempio n. 12
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            Client TheClient = (entry.Command as ConnectCommand).TheClient;

            entry.Good(queue, "Connecting...");
            TheClient.Network.Connect(entry.GetArgument(queue, 0), entry.GetArgument(queue, 1), false, entry.GetArgument(queue, 2));
        }
Esempio n. 13
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));
            }
            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?)!");
            }
        }
Esempio n. 14
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(queue, entry);
         return;
     }
     Location start = TheClient.Player.GetEyePosition();
     Location forward = TheClient.Player.ForwardVector();
     Location end = start + forward * 5;
     switch (entry.GetArgument(queue, 0).ToLowerFast())
     {
         case "cylinder":
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.CYLINDER, (o) => start, (o) => end, (o) => 0.01f, 5f, Location.One, Location.One, true, TheClient.Textures.GetTexture("common/smoke"));
             break;
         case "line":
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => start, (o) => end, (o) => 1f, 5f, Location.One, Location.One, true, TheClient.Textures.GetTexture("common/smoke"));
             break;
         case "explosion_small":
             TheClient.Particles.Explode(end, 2, 40);
             break;
         case "explosion_large":
             TheClient.Particles.Explode(end, 5);
             break;
         case "path_mark":
             TheClient.Particles.PathMark(end, () => TheClient.Player.GetPosition());
             break;
         default:
             entry.Bad(queue, "Unknown effect name.");
             return;
     }
     entry.Good(queue, "Created effect.");
 }
Esempio n. 15
0
 public override void Execute(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?)!");
     }
 }
Esempio n. 16
0
        public override void Execute(CommandQueue queue, CommandEntry entry)
        {
            if (entry.Arguments.Count < 1)
            {
                ShowUsage(queue, entry);
                return;
            }
            string key = entry.GetArgument(queue, 0);

            if (key == "\0CALLBACK")
            {
                return;
            }
            if (entry.InnerCommandBlock == null)
            {
                queue.HandleError(entry, "Must have a block of commands!");
                return;
            }
            Key k = KeyHandler.GetKeyForName(key);

            KeyHandler.BindKey(k, entry.InnerCommandBlock, entry.BlockStart);
            entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + ".");
            CommandStackEntry cse = queue.CommandStack.Peek();

            cse.Index = entry.BlockEnd + 2;
        }
Esempio n. 17
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            Client TheClient = (entry.Command as BindCommand).TheClient;
            string key       = entry.GetArgument(queue, 0);
            Key    k         = KeyHandler.GetKeyForName(key);

            // TODO: Bad key error
            if (entry.Arguments.Count == 1)
            {
                CommandScript cs = KeyHandler.GetBind(k);
                if (cs == null)
                {
                    queue.HandleError(entry, "That key is not bound, or does not exist.");
                }
                else
                {
                    entry.Info(queue, TagParser.Escape(KeyHandler.keystonames[k] + ": {\n" + cs.FullString() + "}"));
                }
            }
            else if (entry.Arguments.Count >= 2)
            {
                KeyHandler.BindKey(k, entry.GetArgument(queue, 1));
                entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + ".");
            }
        }
Esempio n. 18
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            Client TheClient = (entry.Command as PlayCommand).TheClient;

            if (entry.Arguments.Count < 1)
            {
                ShowUsage(queue, entry);
                return;
            }
            string   sfx   = entry.GetArgument(queue, 0);
            float    pitch = 1f;
            float    gain  = 1f;
            Location loc   = Location.NaN;

            if (entry.Arguments.Count > 1)
            {
                pitch = (float)Utilities.StringToFloat(entry.GetArgument(queue, 1));
            }
            if (entry.Arguments.Count > 2)
            {
                gain = (float)Utilities.StringToFloat(entry.GetArgument(queue, 2));
            }
            if (entry.Arguments.Count > 3)
            {
                loc = Location.FromString(entry.GetArgument(queue, 3));
            }
            float seek = 0;

            if (entry.Arguments.Count > 4)
            {
                seek = (float)(float)Utilities.StringToFloat(entry.GetArgument(queue, 4));
            }
            entry.Good(queue, "Requesting audio...");
            TheClient.Sounds.Play(TheClient.Sounds.GetSound(sfx), false, loc, pitch, gain, seek);
        }
 public override void Execute(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());
     }
 }
Esempio n. 20
0
 public override void Execute(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.");
         }
     }
 }
Esempio n. 21
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            Client TheClient = (entry.Command as StartlocalserverCommand).TheClient;
            string arg0      = "28010";

            if (entry.Arguments.Count >= 1)
            {
                arg0 = entry.GetArgument(queue, 0);
            }
            string game = "default";

            if (entry.Arguments.Count >= 2)
            {
                game = entry.GetArgument(queue, 1);
            }
            if (TheClient.LocalServer != null)
            {
                entry.Good(queue, "Shutting down pre-existing server.");
                TheClient.LocalServer.ShutDown();
                TheClient.LocalServer = null;
            }
            entry.Good(queue, "Generating new server...");
            TheClient.LocalServer = new Server(Utilities.StringToInt(arg0));
            Server.Central        = TheClient.LocalServer;
            Action callback = null;

            if (entry.WaitFor && queue.WaitingOn == entry)
            {
                callback = () =>
                {
                    queue.WaitingOn = null;
                };
            }
            Task.Factory.StartNew(() =>
            {
                try
                {
                    TheClient.LocalServer.StartUp(game, callback);
                }
                catch (Exception ex)
                {
                    Utilities.CheckException(ex);
                    SysConsole.Output("Running local server", ex);
                }
            });
        }
Esempio n. 22
0
        public override void Execute(CommandQueue queue, CommandEntry entry)
        {
            string key = entry.GetArgument(queue, 0);
            Key    k   = KeyHandler.GetKeyForName(key);

            KeyHandler.BindKey(k, (string)null);
            entry.Good(queue, "Keybind removed for " + k + ".");
        }
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     try
     {
         LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
         if (loc == null)
         {
             queue.HandleError(entry, "Invalid location!");
             return;
         }
         EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
         if (entity  == null)
         {
             queue.HandleError(entry, "Invalid entity!");
             return;
         }
         PlayerTag player;
         if (entity.TryGetPlayer(out player))
         {
             player.Internal.player.gameObject.AddComponent<LaunchComponent>().LaunchPlayer(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ZombieTag zombie;
         if (entity.TryGetZombie(out zombie))
         {
             zombie.Internal.gameObject.AddComponent<LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched zombie " + TagParser.Escape(zombie.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         AnimalTag animal;
         if (entity.TryGetAnimal(out animal))
         {
             animal.Internal.gameObject.AddComponent<LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched animal " + TagParser.Escape(animal.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ItemEntityTag item;
         if (entity.TryGetItem(out item))
         {
             // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID?
         }
         queue.HandleError(entry, "That entity can't be launched!");
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to launch entity: " + ex.ToString());
     }
 }
Esempio n. 24
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(queue, entry);
         return;
     }
     entry.Good(queue, "'<{color.emphasis}>" + TagParser.Escape(entry.GetArgument(queue, 0)) + "<{color.base}>' to you as well from " + ThePlugin.Name + "!");
 }
Esempio n. 25
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(queue, entry);
         return;
     }
     entry.Good(queue, "'<{color.emphasis}>" + TagParser.Escape(entry.GetArgument(queue, 0)) + "<{color.base}>' to you as well from " + ThePlugin.Name + "!");
 }
 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());
     }
 }
Esempio n. 27
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 2)
     {
         ShowUsage(queue, entry);
         return;
     }
     entry.Good(queue, "Connecting...");
     TheClient.Network.Connect(entry.GetArgument(queue, 0), entry.GetArgument(queue, 1));
 }
Esempio n. 28
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     IntegerTag itag = IntegerTag.TryFor(entry.GetArgumentObject(queue, 0));
     uint ti = (uint)itag.Internal;
     SDG.Unturned.LightingManager.time = ti;
     if (entry.ShouldShowGood(queue))
     {
         entry.Good(queue, "World time set to " + ti + "!");
     }
 }
Esempio n. 29
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            Client TheClient = (entry.Command as UnbindCommand).TheClient;
            string key       = entry.GetArgument(queue, 0);
            Key    k         = KeyHandler.GetKeyForName(key);

            // TODO: Bad-key error.
            KeyHandler.BindKey(k, (string)null);
            entry.Good(queue, "Keybind removed for " + k + ".");
        }
Esempio n. 30
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 2)
     {
         ShowUsage(queue, entry);
         return;
     }
     entry.Good(queue, "Connecting...");
     TheClient.Network.Connect(entry.GetArgument(queue, 0), entry.GetArgument(queue, 1));
 }
Esempio n. 31
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(queue, entry);
         return;
     }
     TheServer.Files.LoadDir(entry.GetArgument(queue, 0));
     entry.Good(queue, "Added path.");
 }
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1));
     if (num.Internal <= 0)
     {
         queue.HandleError(entry, "Must provide a number that is greater than 0!");
         return;
     }
     EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
     if (entity == null)
     {
         queue.HandleError(entry, "Invalid entity!");
         return;
     }
     ZombieTag zombie;
     if (entity.TryGetZombie(out zombie))
     {
         Zombie inZomb = zombie.Internal;
         inZomb.maxHealth = (ushort)num.Internal;
         if (inZomb.health > inZomb.maxHealth)
         {
             inZomb.health = inZomb.maxHealth;
         }
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully set health of a zombie to " + inZomb.maxHealth + "!");
         }
         return;
     }
     PlayerTag player;
     if (entity.TryGetPlayer(out player))
     {
         GameObject playerObj = player.Internal.player.gameObject;
         UFMHealthController controller = playerObj.GetComponent<UFMHealthController>();
         if (controller == null)
         {
             controller = playerObj.AddComponent<UFMHealthController>();
         }
         controller.maxHealth = (uint)num.Internal;
         PlayerLife life = player.Internal.player.life;
         byte curr = life.health;
         controller.health = curr >= controller.maxHealth ? controller.maxHealth : curr;
         life._health = controller.Translate();
         life.channel.send("tellHealth", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
         {
             life.health
         });
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully set max health of a player to " + controller.maxHealth + "!");
         }
         return;
     }
     queue.HandleError(entry, "That entity can't be healed!");
 }
Esempio n. 33
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            IntegerTag itag = IntegerTag.TryFor(entry.GetArgumentObject(queue, 0));
            uint       ti   = (uint)itag.Internal;

            SDG.Unturned.LightingManager.time = ti;
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, "World time set to " + ti + "!");
            }
        }
Esempio n. 34
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            if (entry.Arguments.Count < 1)
            {
                ShowUsage(queue, entry);
                return;
            }
            Server TheServer = (entry.Command as AddpathCommand).TheServer;

            TheServer.Files.LoadDir(entry.GetArgument(queue, 0));
            entry.Good(queue, "Added path.");
        }
Esempio n. 35
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            Client TheClient = (entry.Command as GP_UnbindCommand).TheClient;
            string key       = entry.GetArgument(queue, 0);

            if (!Enum.TryParse(key, true, out GamePadButton btn))
            {
                queue.HandleError(entry, "Unknown button: " + key);
                return;
            }
            TheClient.Gamepad.BindButton(btn, null);
            entry.Good(queue, "Gamepad-button-bind removed for " + btn + ".");
        }
Esempio n. 36
0
 public override void Execute(CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(entry);
     }
     else
     {
         bool modechoice = entry.GetArgument(0).ToLower() == "on";
         entry.Queue.ParseTags = modechoice;
         entry.Good("Queue parsing <{color.emphasis}>" + (modechoice ? "enabled" : "disabled") + "<{color.base}>.");
     }
 }
Esempio n. 37
0
 public override void Execute(CommandEntry entry)
 {
     if (entry.Arguments.Count > 0 && entry.GetArgument(0).ToLower() == "all")
     {
         int qCount = entry.Queue.CommandSystem.Queues.Count;
         if (!entry.Queue.CommandSystem.Queues.Contains(entry.Queue))
         {
             qCount++;
         }
         entry.Good("Stopping <{color.emphasis}>" + qCount + "<{color.base}> queue" + (qCount == 1 ? "." : "s."));
         foreach (CommandQueue queue in entry.Queue.CommandSystem.Queues)
         {
             queue.Stop();
         }
         entry.Queue.Stop();
     }
     else
     {
         entry.Good("Stopping current queue.");
         entry.Queue.Stop();
     }
 }
Esempio n. 38
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     string arg0 = "28010";
     if (entry.Arguments.Count >= 1)
     {
         arg0 = entry.GetArgument(queue, 0);
     }
     if (TheClient.LocalServer != null)
     {
         entry.Good(queue, "Shutting down pre-existing server.");
         TheClient.LocalServer.ShutDown();
         TheClient.LocalServer = null;
     }
     entry.Good(queue, "Generating new server...");
     TheClient.LocalServer = new Server(Utilities.StringToInt(arg0));
     Server.Central = TheClient.LocalServer;
     Action callback = null;
     if (entry.WaitFor && queue.WaitingOn == entry)
     {
         callback = () =>
         {
             queue.WaitingOn = null;
         };
     }
     Task.Factory.StartNew(() =>
     {
         try
         {
             TheClient.LocalServer.StartUp(callback);
         }
         catch (Exception ex)
         {
             Utilities.CheckException(ex);
             SysConsole.Output("Running local server", ex);
         }
     });
 }
Esempio n. 39
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
     if (loc == null)
     {
         queue.HandleError(entry, "Invalid location!");
         return;
     }
     EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
     if (entity == null)
     {
         queue.HandleError(entry, "Invalid entity!");
         return;
     }
     ZombieTag zombie;
     if (entity.TryGetZombie(out zombie))
     {
         zombie.Internal.target.position = loc.ToVector3();
         zombie.Internal.seeker.canMove = true;
         zombie.Internal.seeker.canSearch = true;
         zombie.Internal.path = EZombiePath.RUSH; // TODO: Option for this?
         if (!zombie.Internal.isTicking)
         {
             zombie.Internal.isTicking = true;
             ZombieManager.tickingZombies.Add(zombie.Internal);
         }
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully started a zombie walking to " + TagParser.Escape(loc.ToString()) + "!");
         }
         return;
     }
     AnimalTag animal;
     if (entity.TryGetAnimal(out animal))
     {
         animal.Internal.target = loc.ToVector3();
         if (!animal.Internal.isTicking)
         {
             animal.Internal.isTicking = true;
             AnimalManager.tickingAnimals.Add(animal.Internal);
         }
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully started an animal walking to " + TagParser.Escape(loc.ToString()) + "!");
         }
         return;
     }
     queue.HandleError(entry, "That entity can't be made to walk!");
 }
Esempio n. 40
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(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());
     }
 }
Esempio n. 42
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(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._isBleeding != value)
         {
             life._isBleeding = value;
             if (value)
             {
                 uint sim = life.player.input.simulation;
                 life.lastBleeding = sim;
                 life.lastBleed = sim;
             }
             life.channel.send("tellBleeding", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 life.isBleeding
             });
             entry.Good(queue, "Successfully adjusted the bleeding of player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(boolean.ToString()) + "!");
         }
         else
         {
             entry.Good(queue, "Player " + TagParser.Escape(player.ToString()) + " already has their bleeding set to " + TagParser.Escape(boolean.ToString()) + "!");
         }
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to adjust player's bleeding state: " + ex.ToString());
     }
 }
Esempio n. 44
0
 public override void Execute(CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(entry);
     }
     else
     {
         string fname = entry.GetArgument(0);
         CommandScript script = entry.Queue.CommandSystem.GetScript(fname);
         if (script != null)
         {
             entry.Good("Inserting '<{color.emphasis}>" + TagParser.Escape(fname) + "<{color.base}>'...");
             entry.Queue.AddCommandsNow(script.GetEntries());
         }
         else
         {
             entry.Bad("Cannot insert script '<{color.emphasis}>" + TagParser.Escape(fname) + "<{color.base}>': file does not exist!");
         }
     }
 }
Esempio n. 45
0
 public override void Execute(CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(entry);
     }
     else
     {
         string delay = entry.GetArgument(0);
         float seconds = StringToFloat(delay);
         if (entry.Queue.Delayable)
         {
             entry.Good("Delaying for <{color.emphasis}>" + seconds + "<{color.base}> seconds.");
             entry.Queue.Wait = seconds;
         }
         else
         {
             entry.Bad("Cannot delay, inside an instant queue!");
         }
     }
 }
Esempio n. 46
0
        public static void Execute(CommandQueue queue, CommandEntry entry)
        {
            if (entry.Arguments.Count < 1)
            {
                ShowUsage(queue, entry);
                return;
            }
            Client   TheClient = (entry.Command as TesteffectCommand).TheClient;
            Location start     = TheClient.Player.GetEyePosition();
            Location forward   = TheClient.Player.ForwardVector();
            Location end       = start + forward * 5;

            switch (entry.GetArgument(queue, 0).ToLowerFast())
            {
            case "cylinder":
                TheClient.Particles.Engine.AddEffect(ParticleEffectType.CYLINDER, (o) => start, (o) => end, (o) => 0.01f, 5f, Location.One, Location.One, true, TheClient.Textures.GetTexture("common/smoke"));
                break;

            case "line":
                TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => start, (o) => end, (o) => 1f, 5f, Location.One, Location.One, true, TheClient.Textures.GetTexture("common/smoke"));
                break;

            case "explosion_small":
                TheClient.Particles.Explode(end, 2, 40);
                break;

            case "explosion_large":
                TheClient.Particles.Explode(end, 5);
                break;

            case "path_mark":
                TheClient.Particles.PathMark(end, () => TheClient.Player.GetPosition());
                break;

            default:
                entry.Bad(queue, "Unknown effect name.");
                return;
            }
            entry.Good(queue, "Created effect.");
        }
        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!");
            }
        }
Esempio n. 48
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            if (entry.Arguments[0].ToString() == "\0CALLBACK")
            {
                return;
            }
            if (entry.Arguments.Count < 3)
            {
                ShowUsage(queue, entry);
                return;
            }
            bool   servermode = entry.GetArgument(queue, 0).ToLowerFast() == "server";
            string name       = entry.GetArgument(queue, 1).ToLowerFast();
            string help       = entry.GetArgument(queue, 2);

            if (entry.InnerCommandBlock == null)
            {
                queue.HandleError(entry, "Event command invalid: No block follows!");
                return;
            }
            // NOTE: Commands are compiled!
            CommandScript script = new CommandScript("ut_command_" + name, entry.InnerCommandBlock, entry.BlockStart, queue.CurrentEntry.Types, true)
            {
                Debug = DebugMode.MINIMAL
            };
            UnturnedCustomCommand ucc = new UnturnedCustomCommand(name, help, script);

            if (servermode)
            {
                Commander.commands.Insert(1, ucc);
            }
            else
            {
                UnturnedFreneticMod.Instance.PlayerCommands.Add(ucc);
            }
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, "Registered command!");
            }
        }
Esempio n. 49
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     string key = entry.GetArgument(queue, 0);
     Key k = KeyHandler.GetKeyForName(key);
     if (entry.Arguments.Count == 1)
     {
         CommandScript cs = KeyHandler.GetBind(k);
         if (cs == null)
         {
             queue.HandleError(entry, "That key is not bound, or does not exist.");
         }
         else
         {
             entry.Info(queue, TagParser.Escape(KeyHandler.keystonames[k] + ": {\n" + cs.FullString() + "}"));
         }
     }
     else if (entry.Arguments.Count >= 2)
     {
         KeyHandler.BindKey(k, entry.GetArgument(queue, 1));
         entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + ".");
     }
 }
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
     if (loc == null)
     {
         queue.HandleError(entry, "Invalid location!");
         return;
     }
     string targetAssetType = entry.GetArgument(queue, 0).ToLower();
     EffectAssetTag effectType = EffectAssetTag.For(targetAssetType);
     if (effectType == null)
     {
         queue.HandleError(entry, "Invalid effect type!");
         return;
     }
     EffectManager.sendEffect(effectType.Internal.id, EffectManager.INSANE, loc.ToVector3());
     // TODO: radius option instead of always 512 units (INSANE)!
     if (entry.ShouldShowGood(queue))
     {
         entry.Good(queue, "Played effect " + TagParser.Escape(effectType.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
     }
 }
Esempio n. 51
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(queue, entry);
         return;
     }
     string key = entry.GetArgument(queue, 0);
     if (key == "\0CALLBACK")
     {
         return;
     }
     if (entry.InnerCommandBlock == null)
     {
         queue.HandleError(entry, "Must have a block of commands!");
         return;
     }
     Key k = KeyHandler.GetKeyForName(key);
     KeyHandler.BindKey(k, entry.InnerCommandBlock, entry.BlockStart);
     entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + ".");
     CommandStackEntry cse = queue.CommandStack.Peek();
     cse.Index = entry.BlockEnd + 2;
 }
Esempio n. 52
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.");
                }
            }
        }
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));

            if (loc == null)
            {
                queue.HandleError(entry, "Invalid location!");
                return;
            }
            string         targetAssetType = entry.GetArgument(queue, 0).ToLower();
            EffectAssetTag effectType      = EffectAssetTag.For(targetAssetType);

            if (effectType == null)
            {
                queue.HandleError(entry, "Invalid effect type!");
                return;
            }
            EffectManager.sendEffect(effectType.Internal.id, EffectManager.INSANE, loc.ToVector3());
            // TODO: radius option instead of always 512 units (INSANE)!
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, "Played effect " + TagParser.Escape(effectType.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
            }
        }
 public override void Execute(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.askBreath((byte)amount);
         }
         else
         {
             life.askSuffocate((byte)-amount);
         }
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully adjusted the oxygen level of a player!");
         }
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to adjust player's oxygen level: " + ex.ToString());
     }
 }
Esempio n. 55
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(queue, entry);
         return;
     }
     switch (entry.GetArgument(queue, 0))
     {
         case "lightDebug":
             {
                 Location pos = TheClient.Player.GetPosition();
                 pos.Z = pos.Z + 1;
                 int XP = (int)Math.Floor(pos.X / Chunk.CHUNK_SIZE);
                 int YP = (int)Math.Floor(pos.Y / Chunk.CHUNK_SIZE);
                 int ZP = (int)Math.Floor(pos.Z / Chunk.CHUNK_SIZE);
                 int x = (int)(Math.Floor(pos.X) - (XP * Chunk.CHUNK_SIZE));
                 int y = (int)(Math.Floor(pos.Y) - (YP * Chunk.CHUNK_SIZE));
                 int z = (int)(Math.Floor(pos.Z) - (ZP * Chunk.CHUNK_SIZE));
                 while (true)
                 {
                     Chunk ch = TheClient.TheRegion.GetChunk(new Vector3i(XP, YP, ZP));
                     if (ch == null)
                     {
                         entry.Good(queue, "Passed with flying light sources!");
                         goto end;
                     }
                     while (z < Chunk.CHUNK_SIZE)
                     {
                         if (ch.GetBlockAt((int)x, (int)y, (int)z).IsOpaque())
                         {
                             entry.Info(queue, "Died: " + x + ", " + y + ", " + z + " -- " + XP + ", " + YP + ", " + ZP);
                             goto end;
                         }
                         z++;
                     }
                     ZP++;
                     z = 0;
                 }
                 end:
                 break;
             }
         case "vramUsage":
             {
                 long c = 0;
                 foreach (Tuple<string, long> val in TheClient.CalculateVRAMUsage())
                 {
                     entry.Info(queue, "-> " + val.Item1 + ": " + val.Item2 + " (" + (val.Item2 / 1024 / 1024) + "MB)");
                     c += val.Item2;
                 }
                 entry.Info(queue, "-> Total: " + c + " (" + (c / 1024 / 1024) + "MB)");
                 break;
             }
         case "speakText":
             {
                 if (entry.Arguments.Count < 3)
                 {
                     ShowUsage(queue, entry);
                     break;
                 }
                 bool male = !entry.GetArgument(queue, 1).ToString().ToLowerFast().StartsWith("f");
                 TextToSpeech.Speak(entry.GetArgument(queue, 2), male);
                 break;
             }
         case "chunkInfo":
             {
                 Chunk ch = TheClient.TheRegion.GetChunk(TheClient.TheRegion.ChunkLocFor(TheClient.Player.GetPosition()));
                 if (ch == null)
                 {
                     entry.Info(queue, "Chunk is null!");
                     break;
                 }
                 entry.Info(queue, "Plants: " + ch.Plant_C + ", generated as ID: " + ch.Plant_VAO);
                 int c = 0;
                 foreach (Chunk chunk in TheClient.TheRegion.LoadedChunks.Values)
                 {
                     if (chunk._VBO != null && ch._VBO != null && chunk._VBO._VAO == ch._VBO._VAO)
                     {
                         c++;
                     }
                 }
                 entry.Info(queue, "Chunk rendering as " + (ch._VBO == null ? "{NULL}" : ch._VBO._VAO.ToString()) + ", which is seen in " + c + " chunks!");
                 break;
             }
         case "blockInfo":
             {
                 BlockInternal bi = TheClient.TheRegion.GetBlockInternal(TheClient.Player.GetPosition());
                 entry.Info(queue, "BLOCK: Material=" + bi.Material + ", Shape=" + bi.BlockData + ", Damage=" + bi.Damage + ", Paint=" + bi.BlockPaint + ",Light=" + bi.BlockLocalData);
                 break;
             }
         case "igniteBlock":
             {
                 Location pos = TheClient.Player.GetPosition().GetUpperBlockBorder();
                 FireEntity fe = new FireEntity(pos, null, TheClient.TheRegion);
                 TheClient.TheRegion.SpawnEntity(fe);
                 break;
             }
         case "torchBlocks":
             {
                 Location pos = TheClient.Player.GetPosition().GetUpperBlockBorder();
                 for (int x = -3; x <= 3; x++)
                 {
                     for (int y = -3; y <= 3; y++)
                     {
                         FireEntity fe = new FireEntity(pos + new Location(x, y, 0), null, TheClient.TheRegion);
                         TheClient.TheRegion.SpawnEntity(fe);
                     }
                 }
                 break;
             }
         default:
             ShowUsage(queue, entry);
             break;
     }
 }
Esempio n. 56
0
 public override void Execute(CommandQueue queue, CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(queue, entry);
         return;
     }
     string arg = entry.GetArgument(queue, 0).ToLowerFast();
     bool success = false;
     bool is_all = arg == "all";
     if (arg == "blocks" || is_all)
     {
         success = true;
         MaterialHelpers.Populate(TheClient.Files);
         TheClient.TBlock.Generate(TheClient, TheClient.CVars, TheClient.Textures);
         TheClient.TheRegion.RenderingNow.Clear();
         foreach (Chunk chunk in TheClient.TheRegion.LoadedChunks.Values)
         {
             chunk.OwningRegion.UpdateChunk(chunk);
         }
     }
     if (arg == "chunks" || is_all)
     {
         success = true;
         TheClient.TheRegion.RenderingNow.Clear();
         foreach (Chunk chunk in TheClient.TheRegion.LoadedChunks.Values)
         {
             chunk.OwningRegion.UpdateChunk(chunk);
         }
     }
     if (arg == "screen" || is_all)
     {
         success = true;
         TheClient.UpdateWindow();
     }
     if (arg == "shaders" || is_all)
     {
         success = true;
         TheClient.Shaders.Clear();
         TheClient.ShadersCheck();
     }
     if (arg == "audio" || is_all)
     {
         success = true;
         TheClient.Sounds.Init(TheClient, TheClient.CVars);
     }
     if (arg == "textures" || is_all)
     {
         success = true;
         TheClient.Textures.Empty();
         TheClient.Textures.InitTextureSystem(TheClient);
         TheClient.TBlock.Generate(TheClient, TheClient.CVars, TheClient.Textures);
     }
     if (!success)
     {
         entry.Bad(queue, "Invalid argument.");
     }
     else
     {
         entry.Good(queue, "Successfully reloaded specified values.");
     }
 }
Esempio n. 57
0
 public override void Execute(CommandEntry entry)
 {
     if (entry.Arguments.Count < 1)
     {
         ShowUsage(entry);
         return;
     }
     string type = entry.GetArgument(0).ToLower();
     if (type == "removescript")
     {
         if (entry.Arguments.Count < 2)
         {
             ShowUsage(entry);
             return;
         }
         string target = entry.GetArgument(1).ToLower();
         if (target == "all")
         {
             int count = entry.Queue.CommandSystem.Scripts.Count;
             entry.Queue.CommandSystem.Scripts.Clear();
             entry.Good("Script cache cleared of <{color.emphasis}>" +
                 count + "<{color.base}> script" + (count == 1 ? ".": "s."));
         }
         else
         {
             if (entry.Queue.CommandSystem.Scripts.Remove(target))
             {
                 entry.Good("Script '<{color.emphasis}>" +
                     TagParser.Escape(target) + "<{color.base}>' removed from the script cache.");
             }
             else
             {
                 if (entry.Arguments.Count > 2 && entry.GetArgument(2).ToLower() == "quiet_fail")
                 {
                     entry.Good("Script '<{color.emphasis}>" +
                         TagParser.Escape(target) + "<{color.base}>' does not exist in the script cache!");
                 }
                 else
                 {
                     entry.Bad("Script '<{color.emphasis}>" +
                         TagParser.Escape(target) + "<{color.base}>' does not exist in the script cache!");
                 }
             }
         }
     }
     else if (type == "removefunction")
     {
         if (entry.Arguments.Count < 2)
         {
             ShowUsage(entry);
             return;
         }
         string target = entry.GetArgument(1).ToLower();
         if (target == "all")
         {
             int count = entry.Queue.CommandSystem.Functions.Count;
             entry.Queue.CommandSystem.Functions.Clear();
             entry.Good("Script cache cleared of <{color.emphasis}>" +
                 count + "<{color.base}> function" + (count == 1 ? "." : "s."));
         }
         else
         {
             if (entry.Queue.CommandSystem.Functions.Remove(target))
             {
                 entry.Good("Function '<{color.emphasis}>" +
                     TagParser.Escape(target) + "<{color.base}>' removed from the script cache.");
             }
             else
             {
                 if (entry.Arguments.Count > 2 && entry.GetArgument(2).ToLower() == "quiet_fail")
                 {
                     entry.Good("Function '<{color.emphasis}>" +
                         TagParser.Escape(target) + "<{color.base}>' does not exist in the script cache!");
                 }
                 else
                 {
                     entry.Bad("Function '<{color.emphasis}>" +
                         TagParser.Escape(target) + "<{color.base}>' does not exist in the script cache!");
                 }
             }
         }
     }
     else
     {
         ShowUsage(entry);
     }
 }
Esempio n. 58
0
 public override void Execute(CommandEntry entry)
 {
     int count = 1;
     if (entry.Arguments.Count > 0)
     {
         count = StringToInt(entry.GetArgument(0));
     }
     if (count <= 0)
     {
         ShowUsage(entry);
         return;
     }
     CommandEntry Owner = entry.BlockOwner;
     while (entry.Queue.CommandList.Length > 0 && count > 0)
     {
         if (Owner == null)
         {
             entry.Bad("Tried to break <{color.emphasis}>" + count +
                 "<{color.base}> more brace" + (count == 1 ? "" : "s") + " than there are!");
             return;
         }
         CommandEntry compOwner = entry.Queue.GetCommand(0).BlockOwner;
         if (compOwner == Owner)
         {
             entry.Queue.RemoveCommand(0);
         }
         else
         {
             Owner = compOwner;
             count--;
         }
     }
     count--;
     if (count > 0)
     {
         entry.Bad("Tried to break <{color.emphasis}>" + count +
             "<{color.base}> more brace" + (count == 1 ? "": "s") + " than there are!");
     }
     else
     {
         entry.Good("Broke through all layers.");
     }
 }
Esempio n. 59
0
 public override void Execute(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 void Execute(CommandQueue queue, CommandEntry entry)
        {
            EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
            if (entity == null)
            {
                queue.HandleError(entry, "Invalid entity!");
                return;
            }
            PlayerTag player;
            if (entity.TryGetPlayer(out player)) // TODO: Kick?
            {
                Provider.kick(player.Internal.playerID.steamID, "Removed forcibly.");
                if (entry.ShouldShowGood(queue))
                {

                    entry.Good(queue, "Successfully removed a player!");
                }
                return;
            }
            ZombieTag zombie;
            if (entity.TryGetZombie(out zombie)) // TODO: Remove!
            {
                zombie.Internal.health = 0;
                ZombieManager.sendZombieDead(zombie.Internal, new Vector3(9999, 9999, -9999));
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully removed a zombie!");
                }
                return;
            }
            AnimalTag animal;
            if (entity.TryGetAnimal(out animal))
            {
                animal.Internal.health = 0;
                AnimalManager.sendAnimalDead(animal.Internal, new Vector3(9999, 9999, -9999));
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully removed an animal!");
                }
                return;
            }
            BarricadeTag barricade;
            if (entity.TryGetBarricade(out barricade))
            {
                // TODO: Use BarricadeManager magic to remove properly?
                barricade.InternalData.barricade.askDamage(barricade.InternalData.barricade.health);
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully destroyed a barricade!");
                }
                return;
            }
            ResourceTag resource;
            if (entity.TryGetResource(out resource)) // TODO: Remove!
            {
                // TODO: Use ResourceManager magic to remove properly?
                resource.Internal.askDamage(resource.Internal.health);
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully destroyed a resource!");
                }
                return;
            }
            StructureTag structure;
            if (entity.TryGetStructure(out structure)) // TODO: Remove!
            {
                // TODO: Use StructureManager magic to remove properly?
                structure.InternalData.structure.askDamage(structure.InternalData.structure.health);
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully destroyed a structure!");
                }
                return;
            }
            VehicleTag vehicle;
            if (entity.TryGetVehicle(out vehicle)) // TODO: Remove!
            {
                vehicle.Internal.health = 0;
                VehicleManager.sendVehicleExploded(vehicle.Internal);
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully removed a vehicle!");
                }
                return;
            }
            queue.HandleError(entry, "That entity can't be damaged!");
        }