Core/Players: Allow teleporting to a specific instance id
Port From (https://github.com/TrinityCore/TrinityCore/commit/25c0aaa83fede6cd5214da00bb08a21c0b28c4be)
This commit is contained in:
@@ -427,7 +427,7 @@ namespace Game.Chat
|
|||||||
// before GM
|
// before GM
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
gmPlayer.GetClosePoint(out x, out y, out z, player.GetCombatReach());
|
gmPlayer.GetClosePoint(out x, out y, out z, player.GetCombatReach());
|
||||||
player.TeleportTo(gmPlayer.GetMapId(), x, y, z, player.GetOrientation());
|
player.TeleportTo(gmPlayer.GetMapId(), x, y, z, player.GetOrientation(), 0, gmPlayer.GetInstanceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace Game.Chat
|
|||||||
float x, y, z;
|
float x, y, z;
|
||||||
target.GetClosePoint(out x, out y, out z, _player.GetCombatReach(), 1.0f);
|
target.GetClosePoint(out x, out y, out z, _player.GetCombatReach(), 1.0f);
|
||||||
|
|
||||||
_player.TeleportTo(target.GetMapId(), x, y, z, _player.GetAbsoluteAngle(target), TeleportToOptions.GMMode);
|
_player.TeleportTo(target.GetMapId(), x, y, z, _player.GetAbsoluteAngle(target), TeleportToOptions.GMMode, target.GetInstanceId());
|
||||||
PhasingHandler.InheritPhaseShift(_player, target);
|
PhasingHandler.InheritPhaseShift(_player, target);
|
||||||
_player.UpdateObjectVisibility();
|
_player.UpdateObjectVisibility();
|
||||||
}
|
}
|
||||||
@@ -1856,7 +1856,7 @@ namespace Game.Chat
|
|||||||
// before GM
|
// before GM
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
_player.GetClosePoint(out x, out y, out z, target.GetCombatReach());
|
_player.GetClosePoint(out x, out y, out z, target.GetCombatReach());
|
||||||
target.TeleportTo(_player.GetMapId(), x, y, z, target.GetOrientation());
|
target.TeleportTo(_player.GetMapId(), x, y, z, target.GetOrientation(), 0, map.GetInstanceId());
|
||||||
PhasingHandler.InheritPhaseShift(target, _player);
|
PhasingHandler.InheritPhaseShift(target, _player);
|
||||||
target.UpdateObjectVisibility();
|
target.UpdateObjectVisibility();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ namespace Game.Entities
|
|||||||
uint m_lastFallTime;
|
uint m_lastFallTime;
|
||||||
float m_lastFallZ;
|
float m_lastFallZ;
|
||||||
WorldLocation teleportDest;
|
WorldLocation teleportDest;
|
||||||
|
uint? m_teleport_instanceId;
|
||||||
TeleportToOptions m_teleport_options;
|
TeleportToOptions m_teleport_options;
|
||||||
bool mSemaphoreTeleport_Near;
|
bool mSemaphoreTeleport_Near;
|
||||||
bool mSemaphoreTeleport_Far;
|
bool mSemaphoreTeleport_Far;
|
||||||
@@ -138,6 +139,7 @@ namespace Game.Entities
|
|||||||
// Player summoning
|
// Player summoning
|
||||||
long m_summon_expire;
|
long m_summon_expire;
|
||||||
WorldLocation m_summon_location;
|
WorldLocation m_summon_location;
|
||||||
|
uint m_summon_instanceId;
|
||||||
|
|
||||||
RestMgr _restMgr;
|
RestMgr _restMgr;
|
||||||
|
|
||||||
@@ -225,6 +227,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
// Recall position
|
// Recall position
|
||||||
WorldLocation m_recall_location;
|
WorldLocation m_recall_location;
|
||||||
|
uint m_recall_instanceId;
|
||||||
WorldLocation homebind = new();
|
WorldLocation homebind = new();
|
||||||
uint homebindAreaId;
|
uint homebindAreaId;
|
||||||
uint m_HomebindTimer;
|
uint m_HomebindTimer;
|
||||||
|
|||||||
@@ -1651,11 +1651,11 @@ namespace Game.Entities
|
|||||||
void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; }
|
void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; }
|
||||||
bool IsHasDelayedTeleport() { return m_bHasDelayedTeleport; }
|
bool IsHasDelayedTeleport() { return m_bHasDelayedTeleport; }
|
||||||
void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
|
void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
|
||||||
public bool TeleportTo(WorldLocation loc, TeleportToOptions options = 0)
|
public bool TeleportTo(WorldLocation loc, TeleportToOptions options = 0, uint? instanceId = null)
|
||||||
{
|
{
|
||||||
return TeleportTo(loc.GetMapId(), loc.posX, loc.posY, loc.posZ, loc.Orientation, options);
|
return TeleportTo(loc.GetMapId(), loc.posX, loc.posY, loc.posZ, loc.Orientation, options, instanceId);
|
||||||
}
|
}
|
||||||
public bool TeleportTo(uint mapid, float x, float y, float z, float orientation, TeleportToOptions options = 0)
|
public bool TeleportTo(uint mapid, float x, float y, float z, float orientation, TeleportToOptions options = 0, uint? instanceId = null)
|
||||||
{
|
{
|
||||||
if (!GridDefines.IsValidMapCoord(mapid, x, y, z, orientation))
|
if (!GridDefines.IsValidMapCoord(mapid, x, y, z, orientation))
|
||||||
{
|
{
|
||||||
@@ -1721,7 +1721,7 @@ namespace Game.Entities
|
|||||||
if (duel != null && GetMapId() != mapid && GetMap().GetGameObject(m_playerData.DuelArbiter))
|
if (duel != null && GetMapId() != mapid && GetMap().GetGameObject(m_playerData.DuelArbiter))
|
||||||
DuelComplete(DuelCompleteType.Fled);
|
DuelComplete(DuelCompleteType.Fled);
|
||||||
|
|
||||||
if (GetMapId() == mapid)
|
if (GetMapId() == mapid && (!instanceId.HasValue || GetInstanceId() == instanceId))
|
||||||
{
|
{
|
||||||
//lets reset far teleport flag if it wasn't reset during chained teleports
|
//lets reset far teleport flag if it wasn't reset during chained teleports
|
||||||
SetSemaphoreTeleportFar(false);
|
SetSemaphoreTeleportFar(false);
|
||||||
@@ -1734,6 +1734,7 @@ namespace Game.Entities
|
|||||||
SetSemaphoreTeleportNear(true);
|
SetSemaphoreTeleportNear(true);
|
||||||
//lets save teleport destination for player
|
//lets save teleport destination for player
|
||||||
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
||||||
|
m_teleport_instanceId = null;
|
||||||
m_teleport_options = options;
|
m_teleport_options = options;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1753,6 +1754,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
// this will be used instead of the current location in SaveToDB
|
// this will be used instead of the current location in SaveToDB
|
||||||
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
||||||
|
m_teleport_instanceId = null;
|
||||||
m_teleport_options = options;
|
m_teleport_options = options;
|
||||||
SetFallInformation(0, GetPositionZ());
|
SetFallInformation(0, GetPositionZ());
|
||||||
|
|
||||||
@@ -1793,6 +1795,7 @@ namespace Game.Entities
|
|||||||
SetSemaphoreTeleportFar(true);
|
SetSemaphoreTeleportFar(true);
|
||||||
//lets save teleport destination for player
|
//lets save teleport destination for player
|
||||||
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
||||||
|
m_teleport_instanceId = instanceId;
|
||||||
m_teleport_options = options;
|
m_teleport_options = options;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1866,6 +1869,7 @@ namespace Game.Entities
|
|||||||
oldmap.RemovePlayerFromMap(this, false);
|
oldmap.RemovePlayerFromMap(this, false);
|
||||||
|
|
||||||
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
|
||||||
|
m_teleport_instanceId = instanceId;
|
||||||
m_teleport_options = options;
|
m_teleport_options = options;
|
||||||
SetFallInformation(0, GetPositionZ());
|
SetFallInformation(0, GetPositionZ());
|
||||||
// if the player is saved before worldportack (at logout for example)
|
// if the player is saved before worldportack (at logout for example)
|
||||||
@@ -2079,6 +2083,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
m_summon_expire = GameTime.GetGameTime() + PlayerConst.MaxPlayerSummonDelay;
|
m_summon_expire = GameTime.GetGameTime() + PlayerConst.MaxPlayerSummonDelay;
|
||||||
m_summon_location = new WorldLocation(summoner);
|
m_summon_location = new WorldLocation(summoner);
|
||||||
|
m_summon_instanceId = summoner.GetInstanceId();
|
||||||
|
|
||||||
SummonRequest summonRequest = new();
|
SummonRequest summonRequest = new();
|
||||||
summonRequest.SummonerGUID = summoner.GetGUID();
|
summonRequest.SummonerGUID = summoner.GetGUID();
|
||||||
@@ -2166,8 +2171,7 @@ namespace Game.Entities
|
|||||||
UpdateCriteria(CriteriaType.AcceptSummon, 1);
|
UpdateCriteria(CriteriaType.AcceptSummon, 1);
|
||||||
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Summon);
|
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Summon);
|
||||||
|
|
||||||
m_summon_location.SetOrientation(GetOrientation());
|
TeleportTo(m_summon_location, 0, m_summon_instanceId);
|
||||||
TeleportTo(m_summon_location);
|
|
||||||
|
|
||||||
broadcastSummonResponse(true);
|
broadcastSummonResponse(true);
|
||||||
}
|
}
|
||||||
@@ -5872,8 +5876,10 @@ namespace Game.Entities
|
|||||||
public void SaveRecallPosition()
|
public void SaveRecallPosition()
|
||||||
{
|
{
|
||||||
m_recall_location = new WorldLocation(this);
|
m_recall_location = new WorldLocation(this);
|
||||||
|
m_recall_instanceId = GetInstanceId();
|
||||||
}
|
}
|
||||||
public void Recall() { TeleportTo(m_recall_location); }
|
|
||||||
|
public void Recall() { TeleportTo(m_recall_location, 0, m_recall_instanceId); }
|
||||||
|
|
||||||
public uint GetSaveTimer() { return m_nextSave; }
|
public uint GetSaveTimer() { return m_nextSave; }
|
||||||
void SetSaveTimer(uint timer) { m_nextSave = timer; }
|
void SetSaveTimer(uint timer) { m_nextSave = timer; }
|
||||||
@@ -7615,10 +7621,17 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
return teleportDest;
|
return teleportDest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint? GetTeleportDestInstanceId()
|
||||||
|
{
|
||||||
|
return m_teleport_instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
public WorldLocation GetHomebind()
|
public WorldLocation GetHomebind()
|
||||||
{
|
{
|
||||||
return homebind;
|
return homebind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldLocation GetRecall()
|
public WorldLocation GetRecall()
|
||||||
{
|
{
|
||||||
return m_recall_location;
|
return m_recall_location;
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ namespace Game
|
|||||||
player.m_InstanceValid = true;
|
player.m_InstanceValid = true;
|
||||||
|
|
||||||
Map oldMap = player.GetMap();
|
Map oldMap = player.GetMap();
|
||||||
Map newMap = Global.MapMgr.CreateMap(loc.GetMapId(), player);
|
Map newMap = GetPlayer().GetTeleportDestInstanceId().HasValue ? Global.MapMgr.FindMap(loc.GetMapId(), GetPlayer().GetTeleportDestInstanceId().Value) : Global.MapMgr.CreateMap(loc.GetMapId(), GetPlayer());
|
||||||
|
|
||||||
if (player.IsInWorld)
|
if (player.IsInWorld)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user