cPawn: Reset last ground height in ResetPosition (#4261)
Prevents fall damage after teleporting/portaling to a lower height. Fixes #3457
This commit is contained in:
parent
01e72ddb65
commit
e27290f7d2
@ -681,7 +681,7 @@ protected:
|
|||||||
|
|
||||||
/** Set the entities position and last sent position.
|
/** Set the entities position and last sent position.
|
||||||
Only to be used when the caller will broadcast a teleport or equivalent to clients. */
|
Only to be used when the caller will broadcast a teleport or equivalent to clients. */
|
||||||
void ResetPosition(Vector3d a_NewPos);
|
virtual void ResetPosition(Vector3d a_NewPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -486,3 +486,13 @@ cEntityEffect * cPawn::GetEntityEffect(cEntityEffect::eType a_EffectType)
|
|||||||
auto itr = m_EntityEffects.find(a_EffectType);
|
auto itr = m_EntityEffects.find(a_EffectType);
|
||||||
return (itr != m_EntityEffects.end()) ? itr->second.get() : nullptr;
|
return (itr != m_EntityEffects.end()) ? itr->second.get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cPawn::ResetPosition(Vector3d a_NewPosition)
|
||||||
|
{
|
||||||
|
super::ResetPosition(a_NewPosition);
|
||||||
|
m_LastGroundHeight = GetPosY();
|
||||||
|
}
|
||||||
|
@ -77,6 +77,8 @@ protected:
|
|||||||
double m_LastGroundHeight;
|
double m_LastGroundHeight;
|
||||||
bool m_bTouchGround;
|
bool m_bTouchGround;
|
||||||
|
|
||||||
|
virtual void ResetPosition(Vector3d a_NewPosition) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** A list of all monsters that are targeting this pawn. */
|
/** A list of all monsters that are targeting this pawn. */
|
||||||
|
@ -1650,7 +1650,6 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
|
|||||||
{
|
{
|
||||||
ResetPosition({a_PosX, a_PosY, a_PosZ});
|
ResetPosition({a_PosX, a_PosY, a_PosZ});
|
||||||
FreezeInternal(GetPosition(), false);
|
FreezeInternal(GetPosition(), false);
|
||||||
m_LastGroundHeight = a_PosY;
|
|
||||||
m_bIsTeleporting = true;
|
m_bIsTeleporting = true;
|
||||||
|
|
||||||
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
|
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
|
||||||
|
Loading…
Reference in New Issue
Block a user