diff options
author | madmaxoft <github@xoft.cz> | 2014-07-17 22:23:08 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-07-17 22:23:08 +0200 |
commit | 7a9f9ab744e88267299b347ac6c9171acfe3afaa (patch) | |
tree | 7cc853f2e143ec42948e5b44f207d286cc9db039 /src/Entities/Entity.cpp | |
parent | Initial version of a script to check basic style. (diff) | |
parent | Merge pull request #1204 from Howaner/Blocks (diff) | |
download | cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.gz cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.bz2 cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.lz cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.xz cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.zst cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.zip |
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r-- | src/Entities/Entity.cpp | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 0a85537bf..bb584cb9e 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -334,36 +334,21 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { - int KnockbackLevel = 0; - if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW) + int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment + if (KnockbackLevel < 1) { + // We support punch on swords and vice versa! :) KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch); } - else - { - KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); - } - Vector3d additionalSpeed(0, 0, 0); + Vector3d AdditionalSpeed(0, 0, 0); switch (KnockbackLevel) { - case 1: - { - additionalSpeed.Set(5, .3, 5); - break; - } - case 2: - { - additionalSpeed.Set(8, .3, 8); - break; - } - default: - { - additionalSpeed.Set(2, .3, 2); - break; - } + case 1: AdditionalSpeed.Set(5, 0.3, 5); break; + case 2: AdditionalSpeed.Set(8, 0.3, 8); break; + default: break; } - AddSpeed(a_TDI.Knockback * additionalSpeed); + AddSpeed(a_TDI.Knockback + AdditionalSpeed); } m_World->BroadcastEntityStatus(*this, esGenericHurt); |