summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChunkMap.cpp2
-rw-r--r--src/Entities/ArrowEntity.cpp8
-rw-r--r--src/Entities/Entity.cpp24
-rw-r--r--src/Entities/Player.cpp4
-rw-r--r--src/Mobs/AggressiveMonster.cpp4
5 files changed, 28 insertions, 14 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 32c7d548f..364dfbb3d 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1319,7 +1319,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
DistanceFromExplosion.Normalize();
DistanceFromExplosion *= Impact;
- a_Entity.AddSpeed(DistanceFromExplosion);
+ a_Entity.SetSpeed(DistanceFromExplosion);
}
return false;
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 249ff42d0..6fef2c7ee 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -115,9 +115,13 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
Damage += ExtraDamage;
}
+ double Knockback = 10;
+
unsigned int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
- double KnockbackAmount = 11 + 10 * PunchLevel;
- a_EntityHit.TakeDamage(dtRangedAttack, GetCreatorUniqueID(), Damage, KnockbackAmount);
+ unsigned int PunchLevelMultiplier = 8;
+
+ Knockback += PunchLevelMultiplier * PunchLevel;
+ a_EntityHit.TakeDamage(dtRangedAttack, GetCreatorUniqueID(), Damage, Knockback);
if (IsOnFire() && !a_EntityHit.IsInWater())
{
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;
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 07342bd52..b182629ea 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1000,10 +1000,6 @@ void cPlayer::ApplyArmorDamage(int a_DamageBlocked)
bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- SetSpeed(0, 0, 0);
- // Prevents knocking the player in the wrong direction due to
- // the speed vector problems, see #2865
- // In the future, the speed vector should be fixed
if ((a_TDI.DamageType != dtInVoid) && (a_TDI.DamageType != dtPlugin))
{
if (IsGameModeCreative() || IsGameModeSpectator())
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 9b13615de..da2b02a6d 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -102,7 +102,9 @@ bool cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
// Setting this higher gives us more wiggle room for attackrate
ResetAttackCooldown();
- GetTarget()->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
+
+ double KnockbackAmount = 9;
+ GetTarget()->TakeDamage(dtMobAttack, this, m_AttackDamage, KnockbackAmount);
return true;
}