From ec9e0eecf616bb190e4d0be76f1c120cac9eb60b Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Wed, 17 Jan 2018 22:12:24 +0100 Subject: Calculate crit damage properly (#4154) --- src/Entities/Entity.cpp | 24 +++++++++++++----------- 1 file 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(Enchantments.GetLevel(cEnchantments::enchSharpness)); @@ -456,7 +467,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) case mtCaveSpider: case mtSilverfish: { - a_TDI.RawDamage += static_cast(ceil(2.5 * BaneOfArthropodsLevel)); + a_TDI.FinalDamage += static_cast(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(floor(a_TDI.FinalDamage * 10 + 0.5))); } -- cgit v1.2.3