1
0

Calculate crit damage properly (#4154)

This commit is contained in:
Bond-009 2018-01-17 22:12:24 +01:00 committed by Alexander Harkness
parent 701fee334c
commit ec9e0eecf6

View File

@ -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)));
}