Fixed clamping issues
This commit is contained in:
parent
c7b7938c04
commit
041bfd5860
@ -1951,10 +1951,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
|
|||||||
double FinalDamage = (((1 / AbsoluteEntityPos.x) + (1 / AbsoluteEntityPos.y) + (1 / AbsoluteEntityPos.z)) * 2) * m_ExplosionSize;
|
double FinalDamage = (((1 / AbsoluteEntityPos.x) + (1 / AbsoluteEntityPos.y) + (1 / AbsoluteEntityPos.z)) * 2) * m_ExplosionSize;
|
||||||
|
|
||||||
// Clip damage values
|
// Clip damage values
|
||||||
if (FinalDamage > a_Entity->GetMaxHealth())
|
FinalDamage = Clamp(FinalDamage, 0.0, (double)a_Entity->GetMaxHealth());
|
||||||
FinalDamage = a_Entity->GetMaxHealth();
|
|
||||||
else if (FinalDamage < 0)
|
|
||||||
FinalDamage = 0;
|
|
||||||
|
|
||||||
if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
|
if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
|
||||||
{
|
{
|
||||||
|
@ -470,18 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
|
|||||||
{
|
{
|
||||||
int Y = a_BlockY;
|
int Y = a_BlockY;
|
||||||
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
|
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
|
||||||
if (Y < 0)
|
a_BlockY = Clamp<unsigned char>(Y, 0, 255);
|
||||||
{
|
|
||||||
a_BlockY = 0;
|
|
||||||
}
|
|
||||||
else if (Y > 255)
|
|
||||||
{
|
|
||||||
a_BlockY = 255;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
a_BlockY = (unsigned char)Y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,10 +327,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
|
|
||||||
// TODO: Apply damage to armor
|
// TODO: Apply damage to armor
|
||||||
|
|
||||||
if (m_Health < 0)
|
m_Health = std::max(m_Health, 0);
|
||||||
{
|
|
||||||
m_Health = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
|
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
|
||||||
{
|
{
|
||||||
|
@ -382,10 +382,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta)
|
|||||||
m_CurrentXp += a_Xp_delta;
|
m_CurrentXp += a_Xp_delta;
|
||||||
|
|
||||||
// Make sure they didn't subtract too much
|
// Make sure they didn't subtract too much
|
||||||
if (m_CurrentXp < 0)
|
m_CurrentXp = std::max<short int>(m_CurrentXp, 0);
|
||||||
{
|
|
||||||
m_CurrentXp = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update total for score calculation
|
// Update total for score calculation
|
||||||
if (a_Xp_delta > 0)
|
if (a_Xp_delta > 0)
|
||||||
|
@ -44,10 +44,7 @@ public:
|
|||||||
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
|
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
|
||||||
// TODO: better equation
|
// TODO: better equation
|
||||||
double Reduction = -0.25 * SplashDistance + 1.0;
|
double Reduction = -0.25 * SplashDistance + 1.0;
|
||||||
if (Reduction < 0)
|
Reduction = std::max(Reduction, 0.0);
|
||||||
{
|
|
||||||
Reduction = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
|
((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
|
||||||
return false;
|
return false;
|
||||||
|
@ -414,11 +414,7 @@ void cMonster::HandleFalling()
|
|||||||
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
|
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
|
||||||
{
|
{
|
||||||
int PosY = POSY_TOINT;
|
int PosY = POSY_TOINT;
|
||||||
|
PosY = Clamp(PosY, 0, cChunkDef::Height);
|
||||||
if (PosY < 0)
|
|
||||||
PosY = 0;
|
|
||||||
else if (PosY > cChunkDef::Height)
|
|
||||||
PosY = cChunkDef::Height;
|
|
||||||
|
|
||||||
if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
|
if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user