diff options
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/ArrowEntity.cpp | 18 | ||||
-rw-r--r-- | src/Entities/Entity.cpp | 32 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 6 | ||||
-rw-r--r-- | src/Entities/SplashPotionEntity.h | 4 |
4 files changed, 25 insertions, 35 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index e8430090b..6259098d8 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -119,23 +119,9 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) Damage += ExtraDamage; } - // int KnockbackAmount = 1; unsigned int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch); - if (PunchLevel > 0) - { - Vector3d LookVector = GetLookVector(); - Vector3f FinalSpeed = Vector3f(0, 0, 0); - switch (PunchLevel) - { - case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5); break; - case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8); break; - default: break; - } - a_EntityHit.SetSpeed(FinalSpeed); - } - - // a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount); // TODO fix knockback. - a_EntityHit.TakeDamage(dtRangedAttack, GetCreatorUniqueID(), Damage, 0); // Until knockback is fixed. + double KnockbackAmount = 11 + 10 * PunchLevel; + a_EntityHit.TakeDamage(dtRangedAttack, GetCreatorUniqueID(), Damage, KnockbackAmount); if (IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming()) { diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 3167d2917..a38a6552d 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -345,7 +345,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R Vector3d Heading(0, 0, 0); if (a_Attacker != nullptr) { - Heading = a_Attacker->GetLookVector() * (a_Attacker->IsSprinting() ? 16 : 11); + Heading = a_Attacker->GetLookVector(); } TDI.Knockback = Heading * a_KnockbackAmount; @@ -534,21 +534,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) // Add knockback: if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != nullptr)) { - int KnockbackLevel = static_cast<int>(a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback)); // More common enchantment - if (KnockbackLevel < 1) - { - // We support punch on swords and vice versa! :) - KnockbackLevel = static_cast<int>(a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch)); - } - - Vector3d AdditionalSpeed(0, 0, 0); - switch (KnockbackLevel) - { - 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); } m_World->BroadcastEntityStatus(*this, esGenericHurt); @@ -763,9 +749,19 @@ 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; - // TODO: Enchantments - return 1; + // If we're sprinting, bump up the knockback + if (IsSprinting()) + { + Knockback = 16; + } + + // Check for knockback enchantments (punch only applies to shot arrows) + unsigned int KnockbackLevel = GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); + Knockback += 10 * KnockbackLevel; + + return Knockback; } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index aaf06fa34..a1b518cbc 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1321,10 +1321,16 @@ cTeam * cPlayer::UpdateTeam(void) void cPlayer::OpenWindow(cWindow & a_Window) { + if (cRoot::Get()->GetPluginManager()->CallHookPlayerOpeningWindow(*this, a_Window)) + { + return; + } + if (&a_Window != m_CurrentWindow) { CloseWindow(false); } + a_Window.OpenedByPlayer(*this); m_CurrentWindow = &a_Window; a_Window.SendWholeWindow(*GetClientHandle()); diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 85aa5046f..baa5da725 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -12,10 +12,12 @@ #include "ProjectileEntity.h" #include "EntityEffect.h" #include "../World.h" -#include "Entity.h" +class cEntity; + + // tolua_begin |