From 466d986e5e7a01679e70a7affd5beaba401ae305 Mon Sep 17 00:00:00 2001 From: Aplaus228 <33102433+Aplaus228@users.noreply.github.com> Date: Thu, 8 Aug 2019 13:51:38 +0300 Subject: Change TakeDamageInfo::FinalDamage from int to float (#4359) Closes #4357 --- src/Entities/Entity.cpp | 10 +++++----- src/Entities/Entity.h | 4 ++-- src/Entities/Minecart.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c0c381d41..7546cc402 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -319,7 +319,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, UInt32 a_AttackerID, int a_Ra -void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount) +void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, float a_FinalDamage, double a_KnockbackAmount) { TakeDamageInfo TDI; TDI.DamageType = a_DamageType; @@ -427,7 +427,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if (SharpnessLevel > 0) { - a_TDI.FinalDamage += static_cast(ceil(1.25 * SharpnessLevel)); + a_TDI.FinalDamage += 1.25 * SharpnessLevel; } else if (SmiteLevel > 0) { @@ -441,7 +441,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) case mtWither: case mtZombiePigman: { - a_TDI.FinalDamage += static_cast(ceil(2.5 * SmiteLevel)); + a_TDI.FinalDamage += 2.5 * SmiteLevel; break; } default: break; @@ -459,7 +459,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) case mtCaveSpider: case mtSilverfish: { - a_TDI.FinalDamage += static_cast(ceil(2.5 * BaneOfArthropodsLevel)); + a_TDI.FinalDamage += 2.5 * BaneOfArthropodsLevel; // The duration of the effect is a random value between 1 and 1.5 seconds at level I, // increasing the max duration by 0.5 seconds each level // Ref: https://minecraft.gamepedia.com/Enchanting#Bane_of_Arthropods @@ -525,7 +525,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) Player->GetStatManager().AddValue(statDamageDealt, static_cast(floor(a_TDI.FinalDamage * 10 + 0.5))); } - m_Health -= static_cast(a_TDI.FinalDamage); + m_Health -= a_TDI.FinalDamage; m_Health = std::max(m_Health, 0.0f); // Add knockback: diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index bb6efcbbd..282e8368a 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -57,7 +57,7 @@ struct TakeDamageInfo eDamageType DamageType; // Where does the damage come from? Being hit / on fire / contact with cactus / ... cEntity * Attacker; // The attacking entity; valid only for dtAttack int RawDamage; // What damage would the receiver get without any armor. Usually: attacker mob type + weapons - int FinalDamage; // What actual damage will be received. Usually: m_RawDamage minus armor + float FinalDamage; // What actual damage will be received. Usually: m_RawDamage minus armor Vector3d Knockback; // The amount and direction of knockback received from the damage // TODO: Effects - list of effects that the hit is causing. Unknown representation yet } ; @@ -279,7 +279,7 @@ public: void TakeDamage(eDamageType a_DamageType, UInt32 a_Attacker, int a_RawDamage, double a_KnockbackAmount); /** Makes this entity take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage() */ - void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount); + void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, float a_FinalDamage, double a_KnockbackAmount); float GetGravity(void) const { return m_Gravity; } diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 1c1cc484e..83fbe56de 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -1039,12 +1039,12 @@ bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI) if ((TDI.Attacker != nullptr) && TDI.Attacker->IsPlayer() && static_cast(TDI.Attacker)->IsGameModeCreative()) { Destroy(); - TDI.FinalDamage = static_cast(GetMaxHealth()); // Instant hit for creative + TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative SetInvulnerableTicks(0); return super::DoTakeDamage(TDI); // No drops for creative } - m_LastDamage = TDI.FinalDamage; + m_LastDamage = static_cast(TDI.FinalDamage); if (!super::DoTakeDamage(TDI)) { return false; -- cgit v1.2.3