예제 #1
0
        static bool HandleTeleCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player me = handler.GetPlayer();

            GameTele tele = handler.ExtractGameTeleFromLink(args);

            if (tele == null)
            {
                handler.SendSysMessage(CypherStrings.CommandTeleNotfound);
                return(false);
            }

            if (me.IsInCombat() && !handler.GetSession().HasPermission(RBACPermissions.CommandTeleName))
            {
                handler.SendSysMessage(CypherStrings.YouInCombat);
                return(false);
            }

            var map = CliDB.MapStorage.LookupByKey(tele.mapId);

            if (map == null || (map.IsBattlegroundOrArena() && (me.GetMapId() != tele.mapId || !me.IsGameMaster())))
            {
                handler.SendSysMessage(CypherStrings.CannotTeleToBg);
                return(false);
            }

            // stop flight if need
            if (me.IsInFlight())
            {
                me.GetMotionMaster().MovementExpired();
                me.CleanupAfterTaxiFlight();
            }
            // save only in non-flight case
            else
            {
                me.SaveRecallPosition();
            }

            me.TeleportTo(tele.mapId, tele.posX, tele.posY, tele.posZ, tele.orientation);
            return(true);
        }
예제 #2
0
        static bool HandleTeleDelCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
            GameTele tele = handler.ExtractGameTeleFromLink(args);

            if (tele == null)
            {
                handler.SendSysMessage(CypherStrings.CommandTeleNotfound);
                return(false);
            }

            Global.ObjectMgr.DeleteGameTele(tele.name);
            handler.SendSysMessage(CypherStrings.CommandTpDeleted);
            return(true);
        }
예제 #3
0
        static bool HandleTeleNameCommand(StringArguments args, CommandHandler handler)
        {
            handler.ExtractOptFirstArg(args, out string nameStr, out string teleStr);
            if (teleStr.IsEmpty())
            {
                return(false);
            }

            if (!handler.ExtractPlayerTarget(new StringArguments(nameStr), out Player target, out ObjectGuid targetGuid, out string targetName))
            {
                return(false);
            }

            if (teleStr.Equals("$home"))    // References target's homebind
            {
                if (target)
                {
                    target.TeleportTo(target.GetHomebind());
                }
                else
                {
                    PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_HOMEBIND);
                    stmt.AddValue(0, targetGuid.GetCounter());
                    SQLResult result = DB.Characters.Query(stmt);

                    if (!result.IsEmpty())
                    {
                        WorldLocation loc    = new(result.Read <ushort>(0), result.Read <float>(2), result.Read <float>(3), result.Read <float>(4), 0.0f);
                        uint          zoneId = result.Read <ushort>(1);

                        Player.SavePositionInDB(loc, zoneId, targetGuid, null);
                    }
                }

                return(true);
            }

            // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
            GameTele tele = handler.ExtractGameTeleFromLink(new StringArguments(teleStr));

            if (tele == null)
            {
                handler.SendSysMessage(CypherStrings.CommandTeleNotfound);
                return(false);
            }

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

                string chrNameLink = handler.PlayerLink(targetName);

                if (target.IsBeingTeleported() == true)
                {
                    handler.SendSysMessage(CypherStrings.IsTeleported, chrNameLink);
                    return(false);
                }

                handler.SendSysMessage(CypherStrings.TeleportingTo, chrNameLink, "", tele.name);
                if (handler.NeedReportToTarget(target))
                {
                    target.SendSysMessage(CypherStrings.TeleportedToBy, handler.GetNameLink());
                }

                // stop flight if need
                if (target.IsInFlight())
                {
                    target.GetMotionMaster().MovementExpired();
                    target.CleanupAfterTaxiFlight();
                }
                // save only in non-flight case
                else
                {
                    target.SaveRecallPosition();
                }

                target.TeleportTo(tele.mapId, tele.posX, tele.posY, tele.posZ, tele.orientation);
            }
            else
            {
                // check offline security
                if (handler.HasLowerSecurity(null, targetGuid))
                {
                    return(false);
                }

                string nameLink = handler.PlayerLink(targetName);

                handler.SendSysMessage(CypherStrings.TeleportingTo, nameLink, handler.GetCypherString(CypherStrings.Offline), tele.name);

                Player.SavePositionInDB(new WorldLocation(tele.mapId, tele.posX, tele.posY, tele.posZ, tele.orientation),
                                        Global.MapMgr.GetZoneId(PhasingHandler.EmptyPhaseShift, tele.mapId, tele.posX, tele.posY, tele.posZ), targetGuid, null);
            }

            return(true);
        }
예제 #4
0
        static bool HandleTeleGroupCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player target = handler.GetSelectedPlayer();

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

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

            // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
            GameTele tele = handler.ExtractGameTeleFromLink(args);

            if (tele == null)
            {
                handler.SendSysMessage(CypherStrings.CommandTeleNotfound);
                return(false);
            }

            MapRecord map = CliDB.MapStorage.LookupByKey(tele.mapId);

            if (map == null || map.IsBattlegroundOrArena())
            {
                handler.SendSysMessage(CypherStrings.CannotTeleToBg);
                return(false);
            }

            string nameLink = handler.GetNameLink(target);

            Group grp = target.GetGroup();

            if (!grp)
            {
                handler.SendSysMessage(CypherStrings.NotInGroup, nameLink);
                return(false);
            }

            for (GroupReference refe = grp.GetFirstMember(); refe != null; refe = refe.Next())
            {
                Player player = refe.GetSource();
                if (!player || !player.GetSession())
                {
                    continue;
                }

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

                string plNameLink = handler.GetNameLink(player);

                if (player.IsBeingTeleported())
                {
                    handler.SendSysMessage(CypherStrings.IsTeleported, plNameLink);
                    continue;
                }

                handler.SendSysMessage(CypherStrings.TeleportingTo, plNameLink, "", tele.name);
                if (handler.NeedReportToTarget(player))
                {
                    player.SendSysMessage(CypherStrings.TeleportedToBy, nameLink);
                }

                // stop flight if need
                if (player.IsInFlight())
                {
                    player.GetMotionMaster().MovementExpired();
                    player.CleanupAfterTaxiFlight();
                }
                // save only in non-flight case
                else
                {
                    player.SaveRecallPosition();
                }

                player.TeleportTo(tele.mapId, tele.posX, tele.posY, tele.posZ, tele.orientation);
            }

            return(true);
        }