Esempio n. 1
0
        static bool HandleCastDestCommand(StringArguments args, CommandHandler handler)
        {
            Unit caster = handler.GetSelectedUnit();

            if (!caster)
            {
                handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
                return(false);
            }

            // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
            uint spellId = handler.ExtractSpellIdFromLink(args);

            if (spellId == 0)
            {
                return(false);
            }

            if (CheckSpellExistsAndIsValid(handler, spellId))
            {
                return(false);
            }

            float x = args.NextSingle();
            float y = args.NextSingle();
            float z = args.NextSingle();

            if (x == 0f || y == 0f || z == 0f)
            {
                return(false);
            }

            string triggeredStr = args.NextString();

            if (!string.IsNullOrEmpty(triggeredStr))
            {
                if (triggeredStr != "triggered")
                {
                    return(false);
                }
            }

            bool triggered = (triggeredStr != null);

            caster.CastSpell(x, y, z, spellId, triggered);

            return(true);
        }
Esempio n. 2
0
        static bool HandleGameObjectNearCommand(StringArguments args, CommandHandler handler)
        {
            float distance = args.Empty() ? 10.0f : args.NextSingle();
            uint  count    = 0;

            Player player = handler.GetPlayer();

            PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_GAMEOBJECT_NEAREST);

            stmt.AddValue(0, player.GetPositionX());
            stmt.AddValue(1, player.GetPositionY());
            stmt.AddValue(2, player.GetPositionZ());
            stmt.AddValue(3, player.GetMapId());
            stmt.AddValue(4, player.GetPositionX());
            stmt.AddValue(5, player.GetPositionY());
            stmt.AddValue(6, player.GetPositionZ());
            stmt.AddValue(7, distance * distance);
            SQLResult result = DB.World.Query(stmt);

            if (!result.IsEmpty())
            {
                do
                {
                    ulong  guid  = result.Read <ulong>(0);
                    uint   entry = result.Read <uint>(1);
                    float  x     = result.Read <float>(2);
                    float  y     = result.Read <float>(3);
                    float  z     = result.Read <float>(4);
                    ushort mapId = result.Read <ushort>(5);

                    GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);
                    if (gameObjectInfo == null)
                    {
                        continue;
                    }

                    handler.SendSysMessage(CypherStrings.GoListChat, guid, entry, guid, gameObjectInfo.name, x, y, z, mapId);

                    ++count;
                } while (result.NextRow());
            }

            handler.SendSysMessage(CypherStrings.CommandNearobjmessage, distance, count);
            return(true);
        }
Esempio n. 3
0
        static bool HandleCastDistCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
            uint spellId = handler.ExtractSpellIdFromLink(args);

            if (spellId == 0)
            {
                return(false);
            }

            if (CheckSpellExistsAndIsValid(handler, spellId))
            {
                return(false);
            }

            float dist = args.NextSingle();

            string triggeredStr = args.NextString();

            if (!string.IsNullOrEmpty(triggeredStr))
            {
                if (triggeredStr != "triggered")
                {
                    return(false);
                }
            }

            bool triggered = (triggeredStr != null);

            float x, y, z;

            handler.GetSession().GetPlayer().GetClosePoint(out x, out y, out z, dist);

            handler.GetSession().GetPlayer().CastSpell(x, y, z, spellId, triggered);

            return(true);
        }
Esempio n. 4
0
        static bool CheckModifySpeed(StringArguments args, CommandHandler handler, Unit target, out float speed, float minimumBound, float maximumBound, bool checkInFlight = true)
        {
            speed = 0f;
            if (args.Empty())
            {
                return(false);
            }

            speed = args.NextSingle();

            if (speed > maximumBound || speed < minimumBound)
            {
                handler.SendSysMessage(CypherStrings.BadValue);
                return(false);
            }

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.NoCharSelected);
                return(false);
            }

            Player player = target.ToPlayer();

            if (player)
            {
                // check online security
                if (handler.HasLowerSecurity(player, ObjectGuid.Empty))
                {
                    return(false);
                }

                if (player.IsInFlight() && checkInFlight)
                {
                    handler.SendSysMessage(CypherStrings.CharInFlight, handler.GetNameLink(player));
                    return(false);
                }
            }
            return(true);
        }