From 8efe55c62c6737f3a22bbfce867b5a0aa942600f Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 6 Apr 2021 12:16:31 -0400 Subject: Change to Cuboid calculation for splash distance (#5176) * Change to Cuboid calculation for splash distance * Use ForEachEntityInBox when splash entities * Remove TODO comment, calculation verified * Added self to contributors --- CONTRIBUTORS | 1 + src/Entities/SplashPotionEntity.cpp | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f5ee91b89..f8fa2fac5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -71,6 +71,7 @@ theophriene tigerw (Tiger Wang) tonibm19 TooAngel +tympaniplayer(Nate Palmer) UltraCoderRU Warmist WebFreak001 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); -- cgit v1.2.3