Add summoner information to TeleportTo function and created OnBeforeTeleport hook

This commit is contained in:
Yehonal
2017-11-16 00:13:54 +00:00
parent b340ebbec9
commit bf60f8f5c6
6 changed files with 32 additions and 15 deletions

View File

@@ -2189,8 +2189,8 @@ void Player::SendTeleportAckPacket()
GetSession()->SendPacket(&data);
}
bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options)
{
bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options /*= 0*/, Unit *target /*= nullptr*/)
{
if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation))
{
sLog->outError("TeleportTo: invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player (GUID: %u, name: %s, map: %d, X: %f, Y: %f, Z: %f, O: %f).",
@@ -2288,6 +2288,9 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (duel && GetMapId() != mapid && GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER)))
DuelComplete(DUEL_FLED);
if (!sScriptMgr->OnBeforePlayerTeleport(this, mapid, x, y, z, orientation, options, target))
return false;
if (GetMapId() == mapid)
{
//lets reset far teleport flag if it wasn't reset during chained teleports
@@ -23622,8 +23625,8 @@ void Player::UpdateForQuestWorldObjects()
GetSession()->SendPacket(&packet);
}
void Player::SummonIfPossible(bool agree)
{
void Player::SummonIfPossible(bool agree, uint32 summoner_guid)
{
if (!agree)
{
m_summon_expire = 0;
@@ -23643,7 +23646,7 @@ void Player::SummonIfPossible(bool agree)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, 1);
TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z, GetOrientation());
TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z, GetOrientation(), 0, ObjectAccessor::FindPlayer(summoner_guid));
}
void Player::RemoveItemDurations(Item* item)