diff options
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index d970956f3..770d34b5a 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1814,10 +1814,21 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ a_Entity.TakeDamage(dtExplosion, nullptr, static_cast<int>((1 / DistanceFromExplosion.Length()) * 6 * ExplosionSizeInt), 0); } - // Apply force to entities around the explosion - code modified from World.cpp DoExplosionAt() - DistanceFromExplosion.Normalize(); - DistanceFromExplosion *= ExplosionSizeInt * ExplosionSizeInt; - a_Entity.AddSpeed(DistanceFromExplosion); + double Length = DistanceFromExplosion.Length(); + if (Length <= ExplosionSizeInt) // Entity is impacted by explosion + { + float EntityExposure = a_Entity.GetExplosionExposureRate(ExplosionPos, ExplosionSizeInt); + + // Exposure reduced by armor + EntityExposure = EntityExposure * (1.0f - a_Entity.GetEnchantmentBlastKnockbackReduction()); + + double Impact = (1 - ((Length / ExplosionSizeInt) / 2)) * EntityExposure; + + DistanceFromExplosion.Normalize(); + DistanceFromExplosion *= Impact; + + a_Entity.AddSpeed(DistanceFromExplosion); + } return false; } |