Fix target height computation when launching projectiles.

The Y coordinate at which to fire a projectile is currently assumed to
be the target's current Y, which is incorrect if the target is moving on
a slope.
This fixes that.

Note that this was purely visual, since projectiles still hit the target
regardless, as the height component is totally ignored, even if the
projectile is underground (in fact, the projectile's position is not
known in DelayedDamage::MissileHit, which just assumes it lands where it
said it would when fired).

As noted by bb in f737831167

Fixes #5939

Differential Revision: https://code.wildfiregames.com/D3425
This was SVN commit r24766.
This commit is contained in:
wraitii
2021-01-22 18:16:13 +00:00
parent 6b05cc9d3c
commit d92feab275
6 changed files with 21 additions and 6 deletions
@@ -439,6 +439,11 @@ public:
}
virtual entity_pos_t GetHeightFixed() const
{
return GetHeightAtFixed(m_X, m_Z);
}
virtual entity_pos_t GetHeightAtFixed(entity_pos_t x, entity_pos_t z) const
{
if (!m_RelativeToGround)
return m_Y;
@@ -447,13 +452,13 @@ public:
entity_pos_t baseY;
CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity());
if (cmpTerrain)
baseY = cmpTerrain->GetGroundLevel(m_X, m_Z);
baseY = cmpTerrain->GetGroundLevel(x, z);
if (m_Floating)
{
CmpPtr<ICmpWaterManager> cmpWaterManager(GetSystemEntity());
if (cmpWaterManager)
baseY = std::max(baseY, cmpWaterManager->GetWaterLevel(m_X, m_Z) - m_FloatDepth);
baseY = std::max(baseY, cmpWaterManager->GetWaterLevel(x, z) - m_FloatDepth);
}
return m_Y + baseY;
}
@@ -525,7 +530,7 @@ public:
return CFixedVector3D();
}
return CFixedVector3D(m_PrevX, GetHeightFixed(), m_PrevZ);
return CFixedVector3D(m_PrevX, GetHeightAtFixed(m_PrevX, m_PrevZ), m_PrevZ);
}
virtual CFixedVector2D GetPreviousPosition2D() const