summaryrefslogtreecommitdiffstats
path: root/src/Entities/SplashPotionEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/SplashPotionEntity.cpp')
-rw-r--r--src/Entities/SplashPotionEntity.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 35d79e6cd..ce081aed1 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -57,7 +57,11 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
void cSplashPotionEntity::Splash(Vector3d a_HitPos)
{
- m_World->ForEachEntity([=](cEntity & a_Entity)
+ double XZCalculation = 8.25/2;
+ double YCalculation = 4.25/2;
+ cBoundingBox SplashDistanceBox = cBoundingBox(a_HitPos.x - XZCalculation, a_HitPos.x + XZCalculation, a_HitPos.y - YCalculation, a_HitPos.y + YCalculation, a_HitPos.z - XZCalculation, a_HitPos.z + XZCalculation);
+
+ m_World->ForEachEntityInBox(SplashDistanceBox, [=](cEntity & a_Entity)
{
if (!a_Entity.IsPawn())
{
@@ -65,15 +69,8 @@ void cSplashPotionEntity::Splash(Vector3d a_HitPos)
return false;
}
- double SplashDistance = (a_Entity.GetPosition() - a_HitPos).Length();
- if (SplashDistance >= 20)
- {
- // Too far away
- return false;
- }
-
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
- // TODO: better equation
+ double SplashDistance = (a_Entity.GetPosition() - a_HitPos).Length();
double Reduction = -0.25 * SplashDistance + 1.0;
Reduction = std::max(Reduction, 0.0);