コード例 #1
0
ファイル: TeleCommands.cs プロジェクト: ryancheung/CypherCore
        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.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
ファイル: TeleCommands.cs プロジェクト: ryancheung/CypherCore
        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);
        }