Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(w3ddevice): -volsmoke tank death throws hot sparks over its fire

Olcay Seygan1f540972b3ad
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27f593cc9..627a362ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -112,7 +112,7 @@ found and fixed, EA's own, not port damage.**
## Smoke simulation
- Options > Effects has a Smoke Simulation box. On Low or High a tank's cook-off, a shell's dirt fountain and a nuclear mushroom are a moving body of air rather than flat sprites: the smoke rolls, rises with the heat, settles as dust and parts round the buildings in its way. Off is the default, and Off draws exactly the picture the game drew before. The box works mid-match, the next frame after you press Accept, on the default renderer; the Direct3D 9 renderer and the Classic graphics setting hide it.
-- A tank goes up the way the footage of a real one does. Orange flame and black smoke burst out low along its own hull, long under an Overlord and short under a Crusader, and roll along the ground off both ends over a skirt of pale dust. A ragged fan of blown-out white fire with orange edges rises straight off the hull and opens wider as it climbs, tallest in the middle, on High about twice as tall as the fire is wide and on Low a shorter fan of the same shape, and in about a second it has cooled through orange to grey-brown smoke. Near-black soot banks up low along the hull, licked red by the fire under it, and swells for nearly two seconds after the flash. The wreck's black column is gone about eight seconds after the death, as quickly as the game's own smoke with the setting Off; it used to stand for half a minute, which in a fast game left a field of black pillars. A Crusader's fan no longer stands on a thin stem or grows horns at its edges. The glowing ball and the rays round it are gone, and so is the ring on the ground. Shells that hit a tank's armour no longer throw a fountain of dirt off it. The scrap flying off a dead tank keeps its own sparks but no longer drags thick grey arcs across the fire, and a gun's muzzle smoke is the soft grey puff it always was, where it had turned into a flat tan disc on the ground.
+- A tank goes up the way the footage of a real one does. Orange flame and black smoke burst out low along its own hull, long under an Overlord and short under a Crusader, and roll along the ground off both ends over a skirt of pale dust. A ragged fan of blown-out white fire with orange edges rises straight off the hull and opens wider as it climbs, tallest in the middle, on High about twice as tall as the fire is wide and on Low a shorter fan of the same shape, and in about a second it has cooled through orange to grey-brown smoke. Near-black soot banks up low along the hull, licked red by the fire under it, and swells for nearly two seconds after the flash, while a scatter of hot sparks flies up out of the fire and falls back. The wreck's black column is gone about eight seconds after the death, as quickly as the game's own smoke with the setting Off; it used to stand for half a minute, which in a fast game left a field of black pillars. A Crusader's fan no longer stands on a thin stem or grows horns at its edges. The glowing ball and the rays round it are gone, and so is the ring on the ground. Shells that hit a tank's armour no longer throw a fountain of dirt off it. The scrap flying off a dead tank keeps its own sparks but no longer drags thick grey arcs across the fire, and a gun's muzzle smoke is the soft grey puff it always was, where it had turned into a flat tan disc on the ground.
- A nuke builds a mushroom you can read. The flash is light: the ground, the buildings and the missile's own smoke trail go white for a third of a second, where a flat white disc used to cover half the screen for most of a second. From the first frame a lumpy ball of fire sits on the ground, yellow-white inside an orange-red rim, with a thin white dome running out round it, and the orange disc that lay on the ground under it is gone. The ball rises and slows, and by five seconds is an orange cap on a thin grey-brown stem. A white collar rings the stem for a few seconds. The cap cools to cream and lumpy cauliflower, three to four times as wide as the stem, and it stays up for over a minute; the old one was a dark brown disc that had thinned away inside twelve seconds. The dark dust that used to bury the whole base under the cloud is gone, and a low wall of dust runs out along the ground between the buildings instead. The missile's own trail is smoke in the same air now, a thick pale column behind it on the way up from the silo and on the way down, drifting with the wind and spreading as it thins, where it used to stay a column of flat sprites.
- Every other smoke goes the same way while it is on: missile and rocket trails, the dust behind a tank, a burning building's column, muzzle smoke. They are fed into one body of air round the camera instead of being drawn as sprites, and a unit moving through it pushes it. A tank's hull shoves the smoke aside and leaves a turning wake, a jet drags a sheet of it down between two wingtip vortices, and a helicopter hovering low flattens a burning column into a dark ring on the ground and lifts a band of dust round itself. A blast's front pushes the smoke already hanging round it outwards. Units you cannot see push nothing, so the smoke never gives away a stealthed tank or an unscouted base.
- Missile and rocket trails are thin ribbons of real smoke. A Tomahawk's, a Rocket Buggy's and a Scud Launcher's lay a pale line that breaks into puffs, widens towards its old end, stirs and drifts off with the wind, and is gone about as soon as the game's own trail would be, so a Rocket Buggy salvo no longer leaves a tan haze over the field: a Tomahawk's arc over Heartland Shield is gone about 3.5 s after the launch, where it hung on for 5 to 6 and the game's own lasts about 3. A trail that climbs high, a Scud's arc or the nine columns a Scud Storm puts up, goes into a second, taller body of air over the battlefield, a thousand units high, where it thins just as fast. The trails are lit by the sun like any smoke: the Scud Storm's columns had stood as straight glowing pillars of one width, and at night on Dark Night the trails stood out pale blue as if lit from inside. Before, a fast missile's trail broke into a dotted line of brown blobs, and once a missile climbed past about 200 units over the ground the top of its trail simply vanished.
diff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
index 9af8b3227..8d829d7aa 100644
--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
@@ -6483,6 +6483,69 @@ End
; EA's photographed fireballs are back, and the column kept its shape on EA's soft smoke. EXCloud01
; was tried first: its alpha is too thin for a column, which all but vanished.
+; Hot sparks thrown up out of a tank's cook-off, over its fire, the thin bright points the footage of
+; a real one shows. Only the Smoke simulation setting starts it (DX11VolumeSmoke.cpp, once a tank's
+; blast is laid on its hull); FX lists never name it, so with the setting Off EA's death is untouched.
+; About 25, short-lived, spread over the hull rather than from one point, so the burst never reads
+; as a starburst, and fast enough to leave the fan: slower and smaller they stayed inside the white
+; fire and could not be seen. Its name holds "Spark", which keeps the smoke volume from taking it.
+ParticleSystem ReforgedTankDeathSparks
+ Priority = UNIT_DAMAGE_FX
+ IsOneShot = No
+ Shader = ADDITIVE
+ Type = PARTICLE
+ ParticleName = EXSpark02.tga
+ AngleZ = 0.00 6.28
+ AngularRateZ = 0.00 0.00
+ AngularDamping = 0.00 0.00
+ VelocityDamping = 0.96 0.98
+ Gravity = -0.30
+ Lifetime = 18.00 30.00
+ SystemLifetime = 4
+ Size = 2.60 4.00
+ StartSizeRate = 0.00 0.00
+ SizeRate = -0.04 -0.02
+ SizeRateDamping = 1.00 1.00
+ Alpha1 = 0.00 0.00 0
+ Alpha2 = 0.00 0.00 0
+ Alpha3 = 0.00 0.00 0
+ Alpha4 = 0.00 0.00 0
+ Alpha5 = 0.00 0.00 0
+ Alpha6 = 0.00 0.00 0
+ Alpha7 = 0.00 0.00 0
+ Alpha8 = 0.00 0.00 0
+ Color1 = R:255 G:245 B:215 0
+ Color2 = R:255 G:190 B:90 12
+ Color3 = R:210 G:90 B:25 22
+ Color4 = R:0 G:0 B:0 30
+ Color5 = R:0 G:0 B:0 0
+ Color6 = R:0 G:0 B:0 0
+ Color7 = R:0 G:0 B:0 0
+ Color8 = R:0 G:0 B:0 0
+ ColorScale = 0.00 0.00
+ BurstDelay = 1.00 2.00
+ BurstCount = 5.00 8.00
+ InitialDelay = 0.00 0.00
+ DriftVelocity = X:0.00 Y:0.00 Z:0.00
+ VelocityType = ORTHO
+ VelOrthoX = -4.00 4.00
+ VelOrthoY = -4.00 4.00
+ VelOrthoZ = 5.00 9.00
+ VolumeType = BOX
+ VolBoxHalfSize = X:11.00 Y:7.00 Z:3.00
+ IsHollow = No
+ IsGroundAligned = No
+ IsEmitAboveGroundOnly = No
+ IsParticleUpTowardsEmitter = No
+ WindMotion = Unused
+ WindAngleChangeMin = 0.149924
+ WindAngleChangeMax = 0.449946
+ WindPingPongStartAngleMin = 0.000000
+ WindPingPongStartAngleMax = 0.785398
+ WindPingPongEndAngleMin = 5.497787
+ WindPingPongEndAngleMax = 6.283185
+End
+
ParticleSystem ReforgedTankSmoke
Priority = DEATH_EXPLOSION
IsOneShot = No
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
index c8ad49099..789b30d5f 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
@@ -1139,6 +1139,10 @@ unsigned moverPeak = 0;
// so a tank dying now finds its hull: where it stands, its heading and its template's box.
struct Hull { float x, y, heading, major, minor, tall; };
std::vector<Hull> hulls, lastHulls;
+// Where a tank's blast started since the last Gather, for its death sparks (ReforgedTankDeathSparks
+// in ParticleSystemReforged.ini). A system cannot be made in Takes, which runs inside the particle
+// manager's own loop, so Gather makes them next frame, outside the logic window.
+std::vector<Coord3D> pendingSparks;
// The structures the smoke flows round, read by Gather every two seconds outside the logic
// thread's window (the render runs inside it, where walking the object list is a counted read).
// A structure goes in once the player whose view is drawn has seen it, so smoke parting round
@@ -1175,6 +1179,7 @@ bool requested()
tallSystems.clear();
movers.clear();
shocks.clear();
+ pendingSparks.clear();
hulls.clear();
lastHulls.clear();
solids.clear();
@@ -1748,6 +1753,8 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
if (t < 1.8f) {
const float fade = 1 - t / 1.8f, swell = 1 + 0.5f * (std::min)(t / 1.2f, 1.0f);
for (unsigned k = 0; k < 4; ++k) {
+ // the inner pair waits for the jets to stop: laid in their roots it burned at their heat
+ if (!(k & 1) && t < 0.35f) continue;
const float s = (k < 2 ? -1.0f : 1.0f) * ((k & 1) ? 1.05f : 0.7f) * (0.95f + 0.1f * unit(980 + k));
const float across = ((k & 1) ? 0.3f : -0.3f) * W;
onHull(s * L, across, H * (0.4f + 0.2f * unit(984 + k)), (std::max)(W * 0.9f, 2.6f) * swell,
@@ -3027,9 +3034,10 @@ bool Takes(ParticleSystem *system)
// a nuclear blast's fire cards are its own FX's only, not a shell's that lands in its reach
const char *joiner = system->getTemplate()->getName().str();
if (volume.kind == Nuclear && !alpha && !std::strstr(joiner, "Nuke") && !std::strstr(joiner, "MOAB")) continue;
- // sparks off the shells still hitting a dead tank (TankStruckSparks) stay the game's own
- // billboards: taken, the fire swallowed the only hot sparks near it
- if (volume.kind == TankDeath && !alpha && std::strstr(joiner, "Spark")) continue;
+ // Sparks stay the game's own billboards, a dead tank's own (ReforgedTankDeathSparks) and the
+ // shells' still hitting it (TankStruckSparks): taken, the fire swallowed the only hot sparks
+ // near it. A building's fall nearby would take them too.
+ if ((volume.kind == TankDeath || volume.kind == Structure) && !alpha && std::strstr(joiner, "Spark")) continue;
if (system->isSystemForever()) continue;
if (kind.trigger && (kindNow == TankDeath) != (volume.kind == TankDeath)) continue;
if (kind.trigger && (kindNow == Nuclear) != (volume.kind == Nuclear)) continue;
@@ -3133,6 +3141,8 @@ bool Takes(ParticleSystem *system)
if (hullsLogged++ < 8)
DEBUG_LOG(("VOLSMOKE: frame %d, tank hull %s, %.0f by %.0f by %.0f units, heading %.2f\n", now,
found ? "found" : "not found", volume.hull[2] * 2 * cell, volume.hull[3] * 2 * cell, volume.hull[4] * cell, heading));
+ // its sparks, started by Gather outside the particle loop this runs in
+ pendingSparks.push_back({ where.x, where.y, (std::min)(where.z, ground) + volume.hull[4] * cell * 0.8f });
}
if (type == Structure) {
const float cell = volume.cell, heading = building ? building->angle : hashUnit(volume.seed, 7) * 6.2831853f;
@@ -3202,6 +3212,19 @@ void Gather()
gatherSolids(now); // every two seconds, so a blast that starts finds its buildings
// every frame, idle or not, so a tank that dies now finds its hull; never where no volume can be
if (Direct3D11_Present_Is_Enabled()) collectMovers(now);
+ // A dead tank's hot sparks: client particles only, the client's random stream, no logic state.
+ if (!pendingSparks.empty() && TheParticleSystemManager) {
+ const ParticleSystemTemplate *sparks = TheParticleSystemManager->findTemplate("ReforgedTankDeathSparks");
+ static unsigned sparksLogged = 0;
+ if (sparksLogged++ < 4)
+ DEBUG_LOG(("VOLSMOKE: frame %d, %u tank death spark burst(s), template %s\n", now, (unsigned)pendingSparks.size(),
+ sparks ? "found" : "missing"));
+ if (sparks)
+ for (const Coord3D &at : pendingSparks)
+ if (ParticleSystem *system = TheParticleSystemManager->createParticleSystem(sparks))
+ system->setPosition(&at);
+ pendingSparks.clear();
+ }
}
void Render(const HazardCloud::Camera &camera)
@@ -3419,6 +3442,7 @@ void Render(const HazardCloud::Camera &camera)
void Reset()
{
+ pendingSparks.clear(); // before the early return: a burst queued as the setting went Off
if (!requested()) return;
for (Volume &volume : volumes) volume = Volume();
airVolume = Volume();