mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Dungeon Finder: After a new player have been found for a existing LFG group, teleport player to any of the players inside dungeon not to the entrance. Also do not teleport players inside dungeon to entrance
--HG-- branch : trunk
This commit is contained in:
@@ -1811,7 +1811,8 @@ void LFGMgr::UpdateBoot(Player* plr, bool accept)
|
||||
/// </summary>
|
||||
/// <param name="Player*">Player</param>
|
||||
/// <param name="bool">Teleport out</param>
|
||||
void LFGMgr::TeleportPlayer(Player* plr, bool out)
|
||||
/// <param name="bool">Automatic or manual teleport</param>
|
||||
void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
|
||||
{
|
||||
sLog.outError("DEBUG:LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", plr->GetGUID(), out ? "out" : "in");
|
||||
if (out)
|
||||
@@ -1821,32 +1822,84 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plr->isAlive())
|
||||
{
|
||||
plr->GetSession()->SendLfgTeleportError(LFG_TELEPORTERROR_PLAYER_DEAD);
|
||||
return;
|
||||
}
|
||||
// TODO Add support for LFG_TELEPORTERROR_FATIGUE
|
||||
LfgTeleportError error = LFG_TELEPORTERROR_OK;
|
||||
Group* grp = plr->GetGroup();
|
||||
|
||||
if (plr->IsFalling() || plr->hasUnitState(UNIT_STAT_JUMPING))
|
||||
if (!grp || !grp->isLFGGroup()) // should never happen, but just in case...
|
||||
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||
else if (!plr->isAlive())
|
||||
error = LFG_TELEPORTERROR_PLAYER_DEAD;
|
||||
else if (plr->IsFalling() || plr->hasUnitState(UNIT_STAT_JUMPING))
|
||||
error = LFG_TELEPORTERROR_FALLING;
|
||||
else
|
||||
{
|
||||
plr->GetSession()->SendLfgTeleportError(LFG_TELEPORTERROR_FALLING);
|
||||
return;
|
||||
}
|
||||
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(grp->GetLfgDungeonEntry());
|
||||
|
||||
// TODO Add support for LFG_TELEPORTERROR_FATIGUE and LFG_TELEPORTERROR_INVALID_LOCATION
|
||||
if (Group* grp = plr->GetGroup())
|
||||
if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(grp->GetLfgDungeonEntry()))
|
||||
if (AreaTrigger const* at = sObjectMgr.GetMapEntranceTrigger(dungeon->map))
|
||||
if (!dungeon)
|
||||
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||
else if (plr->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance
|
||||
{
|
||||
uint32 mapid = 0;
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
float orientation = 0;
|
||||
|
||||
if (!fromOpcode)
|
||||
{
|
||||
Player *plrg;
|
||||
// Select a player inside to be teleported to
|
||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && !mapid; itr = itr->next())
|
||||
{
|
||||
plrg = itr->getSource();
|
||||
if (plrg && plrg != plr && plrg->GetMapId() == uint32(dungeon->map))
|
||||
{
|
||||
mapid = plrg->GetMapId();
|
||||
x = plrg->GetPositionX();
|
||||
y = plrg->GetPositionY();
|
||||
z = plrg->GetPositionZ();
|
||||
orientation = plrg->GetOrientation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mapid)
|
||||
{
|
||||
AreaTrigger const* at = sObjectMgr.GetMapEntranceTrigger(dungeon->map);
|
||||
if (!at)
|
||||
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||
else
|
||||
{
|
||||
mapid = at->target_mapId;
|
||||
x = at->target_X;
|
||||
y = at->target_Y;
|
||||
z = at->target_Z;
|
||||
orientation = at->target_Orientation;
|
||||
}
|
||||
}
|
||||
|
||||
if (error == LFG_TELEPORTERROR_OK)
|
||||
{
|
||||
if (!plr->GetMap()->IsDungeon() && !plr->GetMap()->IsRaid())
|
||||
plr->SetBattlegroundEntryPoint();
|
||||
plr->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
// TODO: Teleport to group
|
||||
if (plr->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation))
|
||||
|
||||
if (plr->TeleportTo(mapid, x, y, z, orientation))
|
||||
{
|
||||
plr->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
plr->CastSpell(plr, LFG_SPELL_LUCK_OF_THE_DRAW, false);
|
||||
}
|
||||
else
|
||||
sLog.outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", plr->GetGUID(), at->target_mapId);
|
||||
{
|
||||
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||
sLog.outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", plr->GetGUID(), mapid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (error != LFG_TELEPORTERROR_OK)
|
||||
plr->GetSession()->SendLfgTeleportError(error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -76,7 +76,7 @@ enum LfgLockStatusType
|
||||
|
||||
enum LfgTeleportError
|
||||
{
|
||||
//LFG_TELEPORTERROR_UNK1 = 0, // No reaction
|
||||
LFG_TELEPORTERROR_OK = 0, // Internal use
|
||||
LFG_TELEPORTERROR_PLAYER_DEAD = 1,
|
||||
LFG_TELEPORTERROR_FALLING = 2,
|
||||
//LFG_TELEPORTERROR_UNK2 = 3, // You can't do that right now
|
||||
@@ -252,7 +252,7 @@ class LFGMgr
|
||||
void Join(Player* plr);
|
||||
void Leave(Player* plr, Group* grp = NULL);
|
||||
void OfferContinue(Group* grp);
|
||||
void TeleportPlayer(Player* plr, bool out);
|
||||
void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false);
|
||||
void UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept);
|
||||
void UpdateBoot(Player* plr, bool accept);
|
||||
void UpdateRoleCheck(Group* grp, Player* plr = NULL);
|
||||
|
||||
@@ -186,7 +186,7 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket &recv_data)
|
||||
recv_data >> out;
|
||||
|
||||
sLog.outDebug("CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0);
|
||||
sLFGMgr.TeleportPlayer(GetPlayer(), out);
|
||||
sLFGMgr.TeleportPlayer(GetPlayer(), out, true);
|
||||
}
|
||||
|
||||
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
|
||||
|
||||
Reference in New Issue
Block a user