Core/Transports: Fixed players taking fall damage when teleporting from transports

Closes #11076
This commit is contained in:
Shauren committed 2013-10-22 17:02:01 +02:00
1 parent 0cc32e28e3
commit 3e12fe84c8
3 files changed
+32 -8

No files matched your search

+22 -3
View File
@@ -2178,8 +2178,26 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!(options & TELE_TO_NOT_LEAVE_COMBAT))
CombatStop();
// new final coordinates
float final_x = x;
float final_y = y;
float final_z = z;
float final_o = orientation;
// Calculate final positions if on transport
if (m_transport)
{
float tx, ty, tz, to;
m_movementInfo.transport.pos.GetPosition(tx, ty, tz, to);
final_x = x + tx * std::cos(orientation) - ty * std::sin(orientation);
final_y = y + ty * std::cos(orientation) + tx * std::sin(orientation);
final_z = z + tz;
final_o = Position::NormalizeOrientation(orientation + m_movementInfo.transport.pos.GetOrientation());
}
// this will be used instead of the current location in SaveToDB
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
SetFallInformation(0, z);
// code for finish transfer called in WorldSession::HandleMovementOpcodes()
@@ -2190,7 +2208,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
{
Position oldPos;
GetPosition(&oldPos);
Relocate(x, y, z, orientation);
Relocate(final_x, final_y, final_z, final_o);
SendTeleportAckPacket();
SendTeleportPacket(oldPos); // this automatically relocates to oldPos in order to broadcast the packet in the right place
}
@@ -2292,6 +2310,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
float final_z = z;
float final_o = orientation;
// Calculate final positions if on transport
if (m_transport)
{
float tx, ty, tz, to;
@@ -2304,7 +2323,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
}
m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
SetFallInformation(0, final_z);
SetFallInformation(0, z);
// if the player is saved before worldportack (at logout for example)
// this will be used instead of the current location in SaveToDB
@@ -181,8 +181,8 @@ void Transport::Update(uint32 diff)
float t = CalculateSegmentPos(float(timer) * 0.001f);
G3D::Vector3 pos, dir;
_currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
//_currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
UpdatePosition(pos.x, pos.y, pos.z, 0.0f/*atan2(dir.x, dir.y)*/);
_currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.x, dir.y));
}
}
+8 -3
View File
@@ -1150,10 +1150,15 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/)
orientation = m_targets.GetUnitTarget()->GetOrientation();
TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f\n", mapid, x, y, z, orientation);
if (mapid == unitTarget->GetMapId())
unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
else if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
unitTarget->ToPlayer()->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL : 0);
else if (mapid == unitTarget->GetMapId())
unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
else
{
TC_LOG_ERROR(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - spellId %u attempted to teleport creature to a different map.", m_spellInfo->Id);
return;
}
// post effects for TARGET_DEST_DB
switch (m_spellInfo->Id)