summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Entity.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index a051b3ffc..c811988bf 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -414,8 +414,19 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this);
- // IsOnGround() only is false if the player is moving downwards
// TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
+
+ // IsOnGround() only is false if the player is moving downwards
+ // Ref: https://minecraft.gamepedia.com/Damage#Critical_Hits
+ if (!Player->IsOnGround())
+ {
+ if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack))
+ {
+ a_TDI.FinalDamage *= 1.5; // 150% damage
+ m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
+ }
+ }
+
const cEnchantments & Enchantments = Player->GetEquippedItem().m_Enchantments;
int SharpnessLevel = static_cast<int>(Enchantments.GetLevel(cEnchantments::enchSharpness));
@@ -456,7 +467,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case mtCaveSpider:
case mtSilverfish:
{
- a_TDI.RawDamage += static_cast<int>(ceil(2.5 * BaneOfArthropodsLevel));
+ a_TDI.FinalDamage += static_cast<int>(ceil(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
@@ -519,15 +530,6 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
}
}
- if (!Player->IsOnGround())
- {
- if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack))
- {
- a_TDI.FinalDamage += 2;
- m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
- }
- }
-
Player->GetStatManager().AddValue(statDamageDealt, static_cast<StatValue>(floor(a_TDI.FinalDamage * 10 + 0.5)));
}