Skip to content

Commit 16673ba

Browse files
committed
Some code to calculate jump height automatically, but needs work -doesn't seem so accurate just now
1 parent ccf13b5 commit 16673ba

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Source/Entities/AHuman.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,29 @@ float AHuman::EstimateDigStrength() const {
934934
}
935935

936936
float AHuman::EstimateJumpHeight() const {
937-
return 20.0f; // hardcoded for now
937+
if (!m_pJetpack) {
938+
return 0.0F;
939+
}
940+
941+
float totalMass = GetMass();
942+
float fuelTime = m_pJetpack->GetJetTimeTotal();
943+
float fuelUseMultiplier = m_pJetpack->GetThrottleFactor();
944+
float impulseBurst = m_pJetpack->EstimateImpulse(true) / totalMass;
945+
float impulseThrust = m_pJetpack->EstimateImpulse(false) / totalMass;
946+
947+
Vector globalAcc = g_SceneMan.GetGlobalAcc() * g_TimerMan.GetDeltaTimeSecs();
948+
Vector currentVelocity = Vector(0.0F, -impulseBurst);
949+
float totalHeight = 0.0F;
950+
do {
951+
currentVelocity += globalAcc;
952+
totalHeight += currentVelocity.GetY();
953+
if (fuelTime > 0.0F) {
954+
currentVelocity.m_Y -= impulseThrust;
955+
fuelTime -= g_TimerMan.GetDeltaTimeMS() * fuelUseMultiplier;
956+
}
957+
} while (currentVelocity.GetY() < 0.0F);
958+
959+
return totalHeight * -1.0F * c_MPP;
938960
}
939961

940962
bool AHuman::EquipShield() {

0 commit comments

Comments
 (0)