Made some improvements to fall damage from a61da740
Fall damage on: - no energy - overheat Fall damage off: - underwaterdev-ui
parent
3dd400810f
commit
2ee0702d69
|
@ -108,8 +108,8 @@ CPhysics::CPhysics(CObject* object)
|
||||||
m_bForceUpdate = true;
|
m_bForceUpdate = true;
|
||||||
m_bLowLevel = false;
|
m_bLowLevel = false;
|
||||||
m_fallingHeight = 0.0f;
|
m_fallingHeight = 0.0f;
|
||||||
m_fallDamageFraction = 0.0f;
|
m_minFallingHeight = 20.0f;
|
||||||
m_minFallingHeight = 0.0f;
|
m_fallDamageFraction = 0.007f;
|
||||||
|
|
||||||
memset(&m_linMotion, 0, sizeof(Motion));
|
memset(&m_linMotion, 0, sizeof(Motion));
|
||||||
memset(&m_cirMotion, 0,sizeof(Motion));
|
memset(&m_cirMotion, 0,sizeof(Motion));
|
||||||
|
@ -854,6 +854,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
motorSpeed.y = -1.0f; // grave
|
motorSpeed.y = -1.0f; // grave
|
||||||
|
SetFalling();
|
||||||
}
|
}
|
||||||
SetMotor(false);
|
SetMotor(false);
|
||||||
}
|
}
|
||||||
|
@ -915,15 +916,10 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
||||||
if ( m_reactorRange < 0.5f ) m_bLowLevel = true;
|
if ( m_reactorRange < 0.5f ) m_bLowLevel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_minFallingHeight = 20.0f;
|
|
||||||
m_fallDamageFraction = 0.007f;
|
|
||||||
|
|
||||||
if ( m_reactorRange == 0.0f ) // reactor tilt?
|
if ( m_reactorRange == 0.0f ) // reactor tilt?
|
||||||
{
|
{
|
||||||
motorSpeed.y = -1.0f; // grave
|
motorSpeed.y = -1.0f; // grave
|
||||||
|
SetFalling();
|
||||||
if (m_fallingHeight == 0.0f && m_floorHeight >= m_minFallingHeight)
|
|
||||||
m_fallingHeight = m_floorHeight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,6 +1518,7 @@ bool CPhysics::EventFrame(const Event &event)
|
||||||
if ( pos.y < m_water->GetLevel(m_object) ) // underwater?
|
if ( pos.y < m_water->GetLevel(m_object) ) // underwater?
|
||||||
{
|
{
|
||||||
h *= 0.5f;
|
h *= 0.5f;
|
||||||
|
m_fallingHeight = 0.0f; // can't fall underwater
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//? m_linMotion.terrainSpeed.x = -tAngle.z*m_linMotion.terrainForce.x*h;
|
//? m_linMotion.terrainSpeed.x = -tAngle.z*m_linMotion.terrainForce.x*h;
|
||||||
|
@ -3901,3 +3898,36 @@ Error CPhysics::GetError()
|
||||||
return ERR_OK;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,14 @@ public:
|
||||||
void CreateInterface(bool bSelect);
|
void CreateInterface(bool bSelect);
|
||||||
Error GetError();
|
Error GetError();
|
||||||
|
|
||||||
|
float GetFallingHeight();
|
||||||
|
|
||||||
|
void SetMinFallingHeight(float value);
|
||||||
|
float GetMinFallingHeight();
|
||||||
|
|
||||||
|
void SetFallDamageFraction(float value);
|
||||||
|
float GetFallDamageFraction();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool EventFrame(const Event &event);
|
bool EventFrame(const Event &event);
|
||||||
void WaterFrame(float aTime, float rTime);
|
void WaterFrame(float aTime, float rTime);
|
||||||
|
@ -191,6 +199,7 @@ protected:
|
||||||
void MotorParticle(float aTime, float rTime);
|
void MotorParticle(float aTime, float rTime);
|
||||||
void WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn);
|
void WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn);
|
||||||
void WheelParticle(int color, float width);
|
void WheelParticle(int color, float width);
|
||||||
|
void SetFalling();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Gfx::CEngine* m_engine;
|
Gfx::CEngine* m_engine;
|
||||||
|
@ -240,16 +249,16 @@ protected:
|
||||||
float m_restBreakParticle;
|
float m_restBreakParticle;
|
||||||
float m_floorLevel; // ground level
|
float m_floorLevel; // ground level
|
||||||
float m_floorHeight; // height above the ground
|
float m_floorHeight; // height above the ground
|
||||||
int m_soundChannel;
|
int m_soundChannel;
|
||||||
int m_soundChannelSlide;
|
int m_soundChannelSlide;
|
||||||
float m_soundTimePshhh;
|
float m_soundTimePshhh;
|
||||||
float m_soundTimeJostle;
|
float m_soundTimeJostle;
|
||||||
float m_soundTimeBoum;
|
float m_soundTimeBoum;
|
||||||
bool m_bSoundSlow;
|
bool m_bSoundSlow;
|
||||||
bool m_bForceUpdate;
|
bool m_bForceUpdate;
|
||||||
bool m_bLowLevel;
|
bool m_bLowLevel;
|
||||||
float m_fallingHeight;
|
float m_fallingHeight;
|
||||||
float m_fallDamageFraction;
|
float m_fallDamageFraction;
|
||||||
float m_minFallingHeight;
|
float m_minFallingHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue