Use tracing for explosions (#4845)
* TNT: Implement tracing algorithm + Add intensity tracing * Fix iterating over all players to SendExplosion, even those not in range * Implemented TNT entity interaction * Fixed misaligned destruction tracing * Finalise TNT algorithm - Remove BlockArea and just use chunks Using SetBlock makes it so that we can update everything properly, and does appear to be faster. * BlockInfo learns about explosion attentuation * Rename Explodinator parameters * TNT: pull block destruction into common function Co-authored-by: Alexander Harkness <me@bearbin.net>
This commit is contained in:
@@ -2637,7 +2637,7 @@ void cClientHandle::SendEntityVelocity(const cEntity & a_Entity)
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendExplosion(const Vector3d a_Pos, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d a_PlayerMotion)
|
||||
void cClientHandle::SendExplosion(const Vector3f a_Position, const float a_Power)
|
||||
{
|
||||
if (m_NumExplosionsThisTick > MAX_EXPLOSIONS_PER_TICK)
|
||||
{
|
||||
@@ -2648,7 +2648,27 @@ void cClientHandle::SendExplosion(const Vector3d a_Pos, float a_Radius, const cV
|
||||
// Update the statistics:
|
||||
m_NumExplosionsThisTick++;
|
||||
|
||||
m_Protocol->SendExplosion(a_Pos.x, a_Pos.y, a_Pos.z, a_Radius, a_BlocksAffected, a_PlayerMotion);
|
||||
auto & Random = GetRandomProvider();
|
||||
const auto SoundPitchMultiplier = 1.0f + (Random.RandReal() - Random.RandReal()) * 0.2f;
|
||||
|
||||
// Sound:
|
||||
SendSoundEffect("entity.generic.explode", a_Position, 4.0f, SoundPitchMultiplier * 0.7f);
|
||||
|
||||
const auto ParticleFormula = a_Power * 0.33f;
|
||||
auto Spread = ParticleFormula * 0.5f;
|
||||
auto ParticleCount = std::min(static_cast<int>(ParticleFormula * 125), 600);
|
||||
|
||||
// Dark smoke particles:
|
||||
SendParticleEffect("largesmoke", a_Position.x, a_Position.y, a_Position.z, 0, 0, 0, Spread, static_cast<int>(ParticleCount));
|
||||
|
||||
Spread = ParticleFormula * 0.35f;
|
||||
ParticleCount = std::min(static_cast<int>(ParticleFormula * 550), 1800);
|
||||
|
||||
// Light smoke particles:
|
||||
SendParticleEffect("explode", a_Position.x, a_Position.y, a_Position.z, 0, 0, 0, Spread, static_cast<int>(ParticleCount));
|
||||
|
||||
// Shockwave effect:
|
||||
m_Protocol->SendExplosion(a_Position, a_Power);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user