summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorMat <mail@mathias.is>2020-03-19 18:13:41 +0100
committerGitHub <noreply@github.com>2020-03-19 18:13:41 +0100
commit0e07e231a219fb810c100e1cd823ef7585f7e2ff (patch)
tree909e132bd66492606fc1b470284da448372f5534 /src/Entities/Entity.cpp
parentAdded myself to CONTRIBUTORS file (#4515) (diff)
downloadcuberite-0e07e231a219fb810c100e1cd823ef7585f7e2ff.tar
cuberite-0e07e231a219fb810c100e1cd823ef7585f7e2ff.tar.gz
cuberite-0e07e231a219fb810c100e1cd823ef7585f7e2ff.tar.bz2
cuberite-0e07e231a219fb810c100e1cd823ef7585f7e2ff.tar.lz
cuberite-0e07e231a219fb810c100e1cd823ef7585f7e2ff.tar.xz
cuberite-0e07e231a219fb810c100e1cd823ef7585f7e2ff.tar.zst
cuberite-0e07e231a219fb810c100e1cd823ef7585f7e2ff.zip
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 206e6af60..f0118104b 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -344,7 +344,17 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
Heading = a_Attacker->GetLookVector();
}
- TDI.Knockback = Heading * a_KnockbackAmount;
+ int KnockbackHeight = 3;
+
+ if (IsPlayer())
+ {
+ KnockbackHeight = 8;
+ }
+
+ // Apply slight height to knockback
+ Vector3d FinalKnockback = Vector3d(Heading.x * a_KnockbackAmount, Heading.y + KnockbackHeight, Heading.z * a_KnockbackAmount);
+
+ TDI.Knockback = FinalKnockback;
DoTakeDamage(TDI);
}
@@ -535,7 +545,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// Add knockback:
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != nullptr))
{
- AddSpeed(a_TDI.Knockback);
+ SetSpeed(a_TDI.Knockback);
}
m_World->BroadcastEntityStatus(*this, esGenericHurt);
@@ -772,18 +782,20 @@ int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_Dama
double cEntity::GetKnockbackAmountAgainst(const cEntity & a_Receiver)
{
- // Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit
- double Knockback = 11;
+ // Default knockback for entities
+ double Knockback = 10;
// If we're sprinting, bump up the knockback
if (IsSprinting())
{
- Knockback = 16;
+ Knockback = 15;
}
// Check for knockback enchantments (punch only applies to shot arrows)
unsigned int KnockbackLevel = GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback);
- Knockback += 10 * KnockbackLevel;
+ unsigned int KnockbackLevelMultiplier = 8;
+
+ Knockback += KnockbackLevelMultiplier * KnockbackLevel;
return Knockback;
}