summaryrefslogtreecommitdiffstats
path: root/src/physics/physics.cpp
diff options
context:
space:
mode:
authorMrSimbax <simbaxlp@gmail.com>2014-03-09 14:36:39 +0100
committerMrSimbax <simbaxlp@gmail.com>2014-03-09 14:36:39 +0100
commit2ee0702d69728016593030e1b3a18d537563dab4 (patch)
tree578c8b48299f6d0fb2c620ffc39e5308104523ae /src/physics/physics.cpp
parent3dd400810f16657d1f99963f249a8b93f640fdd6 (diff)
downloadcolobot-2ee0702d69728016593030e1b3a18d537563dab4.tar.gz
colobot-2ee0702d69728016593030e1b3a18d537563dab4.tar.bz2
colobot-2ee0702d69728016593030e1b3a18d537563dab4.zip
Made some improvements to fall damage from a61da740
Fall damage on: - no energy - overheat Fall damage off: - underwater
Diffstat (limited to 'src/physics/physics.cpp')
-rw-r--r--src/physics/physics.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index 2ab7425..0d1c6fe 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -108,8 +108,8 @@ CPhysics::CPhysics(CObject* object)
m_bForceUpdate = true;
m_bLowLevel = false;
m_fallingHeight = 0.0f;
- m_fallDamageFraction = 0.0f;
- m_minFallingHeight = 0.0f;
+ m_minFallingHeight = 20.0f;
+ m_fallDamageFraction = 0.007f;
memset(&m_linMotion, 0, sizeof(Motion));
memset(&m_cirMotion, 0,sizeof(Motion));
@@ -854,6 +854,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
else
{
motorSpeed.y = -1.0f; // grave
+ SetFalling();
}
SetMotor(false);
}
@@ -915,15 +916,10 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
if ( m_reactorRange < 0.5f ) m_bLowLevel = true;
}
- m_minFallingHeight = 20.0f;
- m_fallDamageFraction = 0.007f;
-
if ( m_reactorRange == 0.0f ) // reactor tilt?
{
motorSpeed.y = -1.0f; // grave
-
- if (m_fallingHeight == 0.0f && m_floorHeight >= m_minFallingHeight)
- m_fallingHeight = m_floorHeight;
+ SetFalling();
}
}
@@ -1522,6 +1518,7 @@ bool CPhysics::EventFrame(const Event &event)
if ( pos.y < m_water->GetLevel(m_object) ) // underwater?
{
h *= 0.5f;
+ m_fallingHeight = 0.0f; // can't fall underwater
}
#endif
//? m_linMotion.terrainSpeed.x = -tAngle.z*m_linMotion.terrainForce.x*h;
@@ -3901,3 +3898,36 @@ Error CPhysics::GetError()
return ERR_OK;
}
+void CPhysics::SetFalling()
+{
+ if (m_fallingHeight == 0.0f && m_floorHeight >= m_minFallingHeight)
+ m_fallingHeight = m_floorHeight;
+}
+
+float CPhysics::GetFallingHeight()
+{
+ return m_fallingHeight;
+}
+
+void CPhysics::SetMinFallingHeight(float value)
+{
+ if (value < 0.0f) return;
+ m_minFallingHeight = value;
+}
+
+float CPhysics::GetMinFallingHeight()
+{
+ return m_minFallingHeight;
+}
+
+void CPhysics::SetFallDamageFraction(float value)
+{
+ if (value < 0.0f) return;
+ m_fallDamageFraction = value;
+}
+
+float CPhysics::GetFallDamageFraction()
+{
+ return m_fallDamageFraction;
+}
+