Exemplo n.º 1
0
        static void DoTP(Player p, string message)
        {
            if (!Hacks.CanUseHacks(p))
            {
                p.Message("%WYou can't teleport to spawners because hacks are disabled in {0}", p.level.ColoredName);
                return;
            }
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to teleport to."); return;
            }
            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S to teleport to.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            Command.Find("tp").Use(p, "-precise " + (int)(spawner.x * 32) + " " + (int)(spawner.y * 32) + " " + (int)(spawner.z * 32));
        }
Exemplo n.º 2
0
        static void DoRemove(Player p, string message)
        {
            if (message.CaselessEq("all"))
            {
                if (PluginGoodlyEffects.EffectSpawner.CanEditAny(p))
                {
                    PluginGoodlyEffects.RemoveAllSpawners(p.level, true);
                    p.Message("Removed all spawners from {0}%S.", p.level.ColoredName);
                }
                else
                {
                    p.Message("%WYou cannot remove all spawners unless you are the owner of this map.");
                }
                return;
            }
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to remove."); return;
            }
            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            if (spawner.EditableBy(p, "remove"))
            {
                p.Message("Removed spawner {0}.", spawner.name);
                PluginGoodlyEffects.RemoveSpawner(spawner, p.level, true);
            }
        }
Exemplo n.º 3
0
        static void DoAdd(Player p, string message)
        {
            if (SpawnerCount(p.level) >= PluginGoodlyEffects.spawnerLimit)
            {
                p.Message("%WThe limit of {0} spawners per level has been reached.", PluginGoodlyEffects.spawnerLimit);
                p.Message("You may remove spawners with %T/spawner remove%S.");
                return;
            }
            string[] words = message.Split(' ');
            if (words.Length < 8)
            {
                p.Message("%WTo add a spawner you need to provide spawner name, effect, x, y, z, originX, originY, and originZ.");
                return;
            }
            string spawnerName = words[0];

            if (SpawnerNameExists(p, spawnerName))
            {
                return;
            }
            string effectName = words[1];

            PluginGoodlyEffects.EffectConfig effect;
            if (!PluginGoodlyEffects.effectAtEffectName.TryGetValue(effectName, out effect))
            {
                p.Message("%WUnknown effect \"{0}\".", effectName);
                return;
            }

            float x = 0, y = 0, z = 0;
            float originX = 0, originY = 0, originZ = 0;
            int   spawnInterval   = 0;
            int   spawnTimeOffset = 0;
            float spawnChance     = 1f;

            if (!GetCoord(p, words[2], p.Pos.BlockX, "x", out x))
            {
                return;
            }
            ;
            if (!GetCoord(p, words[3], p.Pos.FeetBlockCoords.Y, "y", out y))
            {
                return;
            }
            ;
            if (!GetCoord(p, words[4], p.Pos.BlockZ, "z", out z))
            {
                return;
            }
            ;
            if (!GetCoord(p, words[5], p.Pos.BlockX, "originX", out originX))
            {
                return;
            }
            ;
            if (!GetCoord(p, words[6], p.Pos.FeetBlockCoords.Y, "originY", out originY))
            {
                return;
            }
            ;
            if (!GetCoord(p, words[7], p.Pos.BlockZ, "originZ", out originZ))
            {
                return;
            }
            ;
            if (words.Length > 8)
            {
                if (!CommandParser.GetInt(p, words[8], "spawn interval", ref spawnInterval, 0, 600))
                {
                    return;
                }
            }
            if (words.Length > 9)
            {
                if (!CommandParser.GetInt(p, words[9], "spawn time offset", ref spawnTimeOffset, 0, 599))
                {
                    return;
                }
            }
            if (words.Length > 10)
            {
                if (!CommandParser.GetReal(p, words[10], "spawn chance", ref spawnChance, 0.01f, 100))
                {
                    return;
                }
                //convert percentage to 0-1
                spawnChance /= 100f;
            }

            //default to center of block
            x       += 0.5f;
            y       += 0.5f;
            z       += 0.5f;
            originX += 0.5f;
            originY += 0.5f;
            originZ += 0.5f;

            PluginGoodlyEffects.EffectSpawner spawner = new PluginGoodlyEffects.EffectSpawner();
            spawner.name            = spawnerName;
            spawner.effectName      = effectName;
            spawner.owner           = p.name;
            spawner.x               = x;
            spawner.y               = y;
            spawner.z               = z;
            spawner.originX         = originX;
            spawner.originY         = originY;
            spawner.originZ         = originZ;
            spawner.spawnInterval   = spawnInterval;
            spawner.spawnTimeOffset = spawnTimeOffset;
            spawner.spawnChance     = spawnChance;

            PluginGoodlyEffects.AddSpawner(spawner, p.level, true);
            p.Message("Successfully added a spawner named {0}.", spawner.name);
        }
Exemplo n.º 4
0
        static void DoSummon(Player p, string message)
        {
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to summon."); return;
            }
            string[] args        = message.SplitSpaces(2);
            string   spawnerName = args[0];
            bool     precise     = (args.Length > 1) ? args[1].CaselessEq("precise") : false;

            p.Message("precise is {0}", precise);

            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, spawnerName, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            if (spawner.EditableBy(p, "summon"))
            {
                float diffX = spawner.x - spawner.originX;
                float diffY = spawner.y - spawner.originY;
                float diffZ = spawner.z - spawner.originZ;

                if (precise)
                {
                    spawner.x = (float)(p.Pos.X) / 32f;
                    spawner.y = (float)(p.Pos.Y - Entities.CharacterHeight) / 32f;
                    spawner.z = (float)(p.Pos.Z) / 32f;
                }
                else
                {
                    spawner.x = p.Pos.BlockX;
                    spawner.y = p.Pos.FeetBlockCoords.Y;
                    spawner.z = p.Pos.BlockZ;
                    //center in block
                    spawner.x += 0.5f;
                    spawner.y += 0.5f;
                    spawner.z += 0.5f;
                }

                spawner.originX = spawner.x - diffX;
                spawner.originY = spawner.y - diffY;
                spawner.originZ = spawner.z - diffZ;
                if (precise)
                {
                    p.Message("Summoned spawner {0} to your precise feet position.", spawner.name);
                }
                else
                {
                    p.Message("Summoned spawner {0} to your block position.", spawner.name);
                }
                PluginGoodlyEffects.SpawnersFile.Save(p.level);
            }
        }