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.

fix(w3ddevice): -volsmoke a nuke's cloud lasts as long as the game's own

Olcay Seygand277eb70e128
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 453632384..ccfe82ea8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -114,8 +114,8 @@ found and fixed, EA's own, not port damage.**
- 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. 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. Two round near-black blobs stand on each long side of the hull at its top, in front of the fire, apart from each other with flame showing between them and their rims glowing red, and slump away inside a second; the soot laid there before burned with the fire beside it and from the side read as a haze. White-hot sparks streak up out of the fire and out over the fan in long thin straight lines and fall back, where they were short orange beaded comets. The wreck's black column is gone about two seconds after the death, and a thin wisp over a glowing ember fades out by three and a half, a quarter as long as the game's own smoke with the setting Off, so a fast game is never fighting through last minute's smoke; 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 every gun but a tank's keeps the soft grey muzzle puff it always had, where it had turned into a flat tan disc on the ground.
- A tank gun fires the way footage of a real one does. A cone of flame comes straight out of the muzzle along the barrel's own aim, white-hot at the tip and orange-red at its fringe, widening forward, and is gone in about a sixth of a second; the first version blew a round ball a gun's length ahead of the barrel with a gap behind it. It leaves a little grey smoke in front of the gun over the dust the blast blows off the ground round the tank's front, and both are gone in a second and a half. A Battlemaster's or a Scorpion's smaller gun throws a smaller flame, an Overlord's a bigger one. A shell striking armour throws one dense burst of thin white-yellow streaks out of the point it struck, over a hot white core, back towards the tank that fired it. The game's own sparks used to burst over the turret whichever side was struck, and stacked on the new ones they read as fireworks all over the tank: for those hits they are gone, and the white oval that used to flash over the whole tank is a small flash now. In a fight of fifteen tanks the shots and hits cost about 0.2 ms of GPU time a frame on High and next to nothing on Low, on an RTX 2060. Six shots at a time draw this way on High and three on Low; past that a shot keeps the game's own flash, and a shot whose slab a bigger blast takes gets its own flash back.
-- 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 wave runs out through every smoke it reaches, the other blasts' clouds, the burning buildings' flames and the smoke hanging in the air, and moves it while it passes: a Scud Launcher's missile lands in the last one's smoke and shoves it aside, and a second nuke's wave tears into the first one's mushroom, which lets go of its cauliflower shape and is shoved aside and upward as a soft tan cloud, still plain to see eleven seconds after the second hit, and thins away until it is gone 18 seconds after it was let go; it used to hang on untouched for over a minute. On Low the second nuke takes the first one's place in the air, so there the first cloud goes the moment the second lands. Before, a wave's push was mostly lost in the first frame, a nuke's cap pulled itself straight back into shape, and a Scud's warheads pushed nothing at all. Units you cannot see push nothing, and a blast in the shroud sends no wave, so the smoke never gives away a stealthed tank, an unscouted base or a strike out of sight.
+- 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, stands whole for ten seconds, then softens and thins away and is gone 22 seconds after the blast, when the game's own nuke is gone with the setting Off. The old one was a dark brown disc that had thinned away inside twelve seconds, and the first version of this one stood for a minute and a half. 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 wave runs out through every smoke it reaches, the other blasts' clouds, the burning buildings' flames and the smoke hanging in the air, and moves it while it passes: a Scud Launcher's missile lands in the last one's smoke and shoves it aside, and a second nuke's wave tears into the first one's mushroom, which lets go of its cauliflower shape and is shoved aside and upward as a soft tan cloud, and thins away until it is gone 12 seconds after it was let go and never later than a nuke left alone; it used to hang on untouched for over a minute. On Low the second nuke takes the first one's place in the air, so there the first cloud goes the moment the second lands. Before, a wave's push was mostly lost in the first frame, a nuke's cap pulled itself straight back into shape, and a Scud's warheads pushed nothing at all. Units you cannot see push nothing, and a blast in the shroud sends no wave, so the smoke never gives away a stealthed tank, an unscouted base or a strike out of sight.
- Aircraft thin the smoke they fly through, at any height. A jet drags clean air along the last two and a half seconds of its path, through a nuke's stem or a burning column; its wake used to fade out as it climbed, and at its usual 100 units over the ground it was down to about half. A helicopter's downwash now reaches down from wherever it flies and thins what it blows through: a Helix crossing a nuke's stem leaves it visibly thinner, and one over a Scud Storm's cloud shoves it down and out along the ground. A helicopter more than about ten rotor radii up used to do nothing at all.
- 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 fades out along its length as it goes, the oldest end first, so a Rocket Buggy salvo no longer leaves a tan haze over the field: a Tomahawk's arc over Heartland Shield is gone about 2 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 that read as beams of light, and at night on Dark Night the trails stood out pale blue as if lit from inside. Now a big missile, a Scud's, a Tomahawk's or the nuclear missile's, leaves a white plume that billows out wider as it ages, lumpy and shaded on its far side, while a Rocket Buggy's, a Stinger's or a Comanche's rocket leaves a thin grey trail. The infantry rockets follow the RPG-7 photo: a Tunnel Defender's, a Tank Hunter's or a Missile Defender's rocket carries a small bright flame right at its tail and draws a thin grey wisp straight along its path, where the game's own trail was a bright white rope with a regular wiggle (the rocket flies within a unit of a straight line; the game threw each point of its line sideways) and its glow burned as two orange dots a rocket's length behind it. The launcher puffs a white backblast behind the soldier instead of a yellow-white flash as big as he is. Every one burns at the nozzle, a short white-yellow flame that is gone a few frames behind the missile. A launch throws a cloud: a Scud Storm, a Scud Launcher, a Tomahawk launcher and the nuclear silo blow a white cloud out sideways over the pad and the ground round it, under a flash at the nozzle, and it is gone in about four seconds. A rocket's backblast leaves a white puff at the launcher, where before it was gone before it showed. 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.
- Buildings come down in their own shape. The smoke reads the building's model: the moment one dies, a white-yellow fireball bursts out of each of its parts, a War Factory's hall and its two stacks, a Speaker Tower's mast, bigger than the part it came from and pushed out through its walls, cools to orange under a sooty edge and is gone in well under a second, while a ragged plume climbs out of the tops and cools to smoke. Before, the parts filled with dull dust that slumped and only three small fires came off the roof. The chunks the building throws trail thin pale dust as they fly, gone before the column is, where they used to fly bare, and the white shower of shards that burst over the fall like a firework is gone while the smoke draws it; with the smoke Off both stay as they were. The collapse throws a pale dust cloud that rolls out along the ground on every side, heavier than the air and hugging the terrain, two to three times the building's width out before it thins, and runs round the buildings beside it, between their real walls and stacks rather than over one box. Before, the dust had nowhere to go but up, and a fall was only a column. The ruin burns under a thick black-grey column with the fire still glowing in its foot, where it used to be a thin pale wisp, for two seconds, so a fall's own smoke and dust are off the screen 3 to 4 s after it and only the game's own column is left in the air until about 6, sooner than the game's own at 7 to 8 (it stayed for fourteen at first, and in a fast game that hid the next fight); a damaged building's own smoke and the dust round it thin within a couple of seconds of their puffs. The size follows the building: an American Power Plant's is about half the width of a War Factory's or a Particle Cannon's. Each damaged stage on the way down blows fire out of the top of the standing building with a little smoke, where it used to leave a big black cloud over the roof, and the shells landing on it in that moment no longer leave their fireballs floating over the cloud. A Rocket Buggy's rockets hitting the rubble throw their dirt for a second and it falls back, where their brown fountains stood beside a fallen War Factory as tan fingers for six seconds after everything else had gone. The fall's smoke is lit on its sunny side: on Winter Wolf's snow it had stood as one block of pure black across the middle of the screen. The game's own fireball sprites, flare and flat shock ring for that moment are gone while the smoke is on; flying debris keeps its sparks.
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.h
index 8166804d6..801069ac0 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.h
@@ -25,6 +25,26 @@ const float DisperseScale = 150.0f; // a passage that moves smoke this far mixe
const float StirShare = 0.15f; // the eddies a passage leaves, as a share of its particle speed
const float CapRelease = 60.0f; // units another blast must move a nuclear cap's middle to let it go
+// A nuclear cloud lasts as long as the game's own nuke with the setting Off, seconds. The last smoke of
+// FX_Nuke, FX_NukeGLA and SupW_FX_Nuke is the MushroomCloudRing: InitialDelay 2000 ms, then SystemLifetime
+// 10 + Lifetime 600 retail frames at 30 a second, its alpha reaching 0 on the last. (The Shockwave ends
+// at 20.2 s and the stem at 16.2. Only the Flare runs longer, 50 + 700 frames to 25 s, an additive lens
+// flare already down to 21 of 255 at 20 s.)
+const float NukeLife = 2.0f + (10 + 600) / 30.0f;
+// Whole until NukeFadeFrom; from there nothing lays it again as thick and its soot thins at
+// NukeFadeHalfLife, down to under a fifth when the end fade takes the rest.
+const float NukeFadeFrom = 10.0f, NukeFadeHalfLife = 5.0f;
+// A cap another blast has let go of (capHold) is free smoke thinning at this half-life, and its volume
+// ends this long after, or at NukeLife if that is sooner. The same half-life as the fade, so the
+// cloud a second nuke shoves away is there as long as one left alone; at 90 s of life these were 10
+// and 18 s, and at 6 s with the cap's hard surface the cap's body was gone two seconds after its release.
+const float NukeDisperseHalfLife = 5.0f, NukeDisperseLife = 12.0f;
+inline int releasedLife(int life, int age, int framesPerSecond)
+{
+ const int end = age + int(NukeDisperseLife * framesPerSecond);
+ return end < life ? end : life;
+}
+
// speed units/s, push units at the blast, r0 units (where D has halved), seconds it runs, the most of
// the smoke one passage mixes away
struct ShockClass { float speed, push, r0, seconds, disperse; };
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
index f9892fce0..89e1e5ded 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
@@ -178,13 +178,9 @@ const float ShortEndFade = 1.5f; // seconds a tank's, a building's, a launch's
// At most this many at once (Low, High), on free slabs only: past that a shot keeps the game's own flash.
const float MuzzleHeatHalfLife = 0.07f, MuzzleLife = 1.6f, MuzzleEndFade = 0.6f;
const unsigned MuzzleCap[3] = { 0, 3, 6 };
-// A nuclear cap another blast has let go of (VolumeShock::capHold) is free smoke, thinning out at this
-// half-life, and its volume ends this long after. At 6 s the cap's body was gone two seconds after
-// its release and only a veil stayed; 18 s ends it, end fade included, just before volshock's third
-// nuke lands 19 s after the second. One only loosened spills what the front pushed off it at up to
-// LoosenedSpillHalfLife, the 4 s it had before the released cloud was slowed: a cap that stays
-// loosened keeps that spill for the rest of its 90 s.
-const float NukeDisperseHalfLife = 10.0f, NukeDisperseLife = 18.0f, LoosenedSpillHalfLife = 4.0f;
+// A nuclear cap only loosened by another blast spills what the front pushed off it at up to this: a cap
+// that stays loosened keeps it for the rest of its life. (VolumeShockCore.h has the cloud's length.)
+const float LoosenedSpillHalfLife = 4.0f;
// A rotor's column under its disc, units/s down (MoverPass), the same at any height; the sheet along
// the ground and the dust ring take it as close as the ground is. Air particles in a jet's or a
// rotor's wake move at this share of its speed there (nudge).
@@ -3024,7 +3020,7 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
const float capR = (std::min)(6.5f * (1 - std::exp(-t / 0.12f)) + 7.0f * (1 - std::exp(-(std::max)(t - 1.0f, 0.0f) / 5.0f))
+ 0.04f * (std::max)(t - 20.0f, 0.0f), 16.0f);
const float capH = capR * (0.95f - 0.57f * smoothstep01(t, 1.0f, 9.0f));
- const float fade = 1 - smoothstep01(t, 50.0f, 85.0f);
+ const float fade = 1 - smoothstep01(t, VolumeShock::NukeFadeFrom, VolumeShock::NukeLife);
// thin while it is fire, so its hot middle shows through the cooler rim; thick smoke once it
// has cooled. At 0.35 the eye saw only the rim's outer cells, and at its first heat those
// burned the whole ball one flat white
@@ -3046,7 +3042,7 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
flashWide = (std::max)(capR, 4.0f);
flashTall = 1.2f;
// the cap's heat: a white-yellow middle for the first second, yellow-orange at two, red embers by ten
- power[2] = 1.2f * std::exp(-t / 0.6f) + 1.9f * std::exp(-t / 9.0f);
+ power[2] = (1.2f * std::exp(-t / 0.6f) + 1.9f * std::exp(-t / 9.0f)) * fade;
if (t < 1.0f) { power[0] = 70.0f * std::exp(-t / 0.5f); power[3] = 0.3f; }
// the base surge: a ring front of dust racing out along the ground, far past the fireball,
// slowing as it goes, 42 cells (420 units) out over a 1.6 s constant. It drops dust all
@@ -3079,10 +3075,13 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
// take, where at 0.26 and 0.75 the cooled cap read as one flat grey-brown
shade = 0.34f;
sunShare = 1.0f;
- billows = smoothstep01(t, 5.0f, 9.0f); // once it is thick smoke: the thin fireball keeps its soft glow
- spared = 1 - smoothstep01(t, 4.0f, 8.0f);
- // dark smoke round the fire at first, cream once it is lit only by the sun, greyer late
- const float cream = smoothstep01(t, 3.0f, 12.0f), grey = smoothstep01(t, 20.0f, 50.0f);
+ // once it is thick smoke: the thin fireball keeps its soft glow, and as the soot fades the hard
+ // surface softens to half and the thin dust is spared, as a cap let go does below. Under the
+ // surface's 0.3 to 0.55 the whole cloud would go in a moment, a hard cut.
+ billows = smoothstep01(t, 5.0f, 9.0f) * (0.5f + 0.5f * fade);
+ spared = (std::max)(1 - smoothstep01(t, 4.0f, 8.0f), 1 - fade);
+ // dark smoke round the fire at first, cream once it is lit only by the sun, greyer as it goes
+ const float cream = smoothstep01(t, 3.0f, 12.0f), grey = smoothstep01(t, VolumeShock::NukeFadeFrom, VolumeShock::NukeLife);
const float early[3] = { 0.32f, 0.22f, 0.16f }, lit[3] = { 0.88f, 0.84f, 0.78f }, late[3] = { 0.80f, 0.79f, 0.78f };
for (unsigned i = 0; i < 3; ++i) soot[i] = early[i] + (lit[i] - early[i]) * cream + (late[i] - lit[i]) * grey;
// the fire's gain low while the fireball is hottest, so its lumps and its cooler rim show
@@ -3306,7 +3305,8 @@ void step(ID3D11DeviceContext *context, unsigned t, int now, float dt, float sec
sim.Thin[slab][0] = std::pow(0.5f, dt / TankSootHalfLife);
// a nuclear cap another blast let go of thins out as free smoke, and while it is only loosened what
// the front pushed off it drifts aside instead of fading at the cap's own spill rate
- if (volume.kind == Nuclear && volume.hold < 0.05f) sim.Thin[slab][0] = std::pow(0.5f, dt / NukeDisperseHalfLife);
+ if (volume.kind == Nuclear && volume.hold < 0.05f) sim.Thin[slab][0] = std::pow(0.5f, dt / VolumeShock::NukeDisperseHalfLife);
+ else if (volume.kind == Nuclear && volume.live && secondsSince(volume, now) > VolumeShock::NukeFadeFrom) sim.Thin[slab][0] = std::pow(0.5f, dt / VolumeShock::NukeFadeHalfLife);
sim.Spill[slab][0] = std::pow(0.5f, dt / (CapSpillHalfLife + (LoosenedSpillHalfLife - CapSpillHalfLife) * (1 - volume.hold)));
const bool rolls = (volume.kind == Structure && !volume.standing) || volume.kind == Launch || volume.kind == Muzzle;
// (not a bomb's: its small mushroom's stem would fall out of it)
@@ -3621,25 +3621,19 @@ void holdCaps(int now)
const float capZ = volume.blast[2] + 2.0f + 20.0f * (1 - std::exp(-t / 3.2f)); // schedule's
const float middle[3] = { volume.origin[0] + (volume.blast[0] + 0.5f) * volume.cell,
volume.origin[1] + (volume.blast[1] + 0.5f) * volume.cell, volume.origin[2] + (capZ + 0.5f) * volume.cell };
- const Shock *hardest = nullptr; // TEMPORARY (stage 1 retune): named in the log line below
- float hardestShift = 0;
for (const Shock &shock : shocks) {
const float age = float(now - shock.born) / LOGICFRAMES_PER_SECOND;
if (!shock.checked || age < 0 || age > shock.c.seconds || spares(volume, (int)slot, shock)) continue;
const float d[3] = { middle[0] - shock.at[0], middle[1] - shock.at[1], middle[2] - shock.at[2] };
- const float shift = VolumeShock::shiftAt(shock.c, age, std::sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]),
+ volume.capPushed += VolumeShock::shiftAt(shock.c, age, std::sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]),
(float)frames / LOGICFRAMES_PER_SECOND);
- volume.capPushed += shift;
- if (shift > hardestShift) { hardest = &shock; hardestShift = shift; }
}
volume.hold = VolumeShock::capHold(volume.capPushed);
if (volume.hold < 0.05f) {
- volume.life = (std::min)(volume.life, now - volume.born + int(NukeDisperseLife * LOGICFRAMES_PER_SECOND));
+ volume.life = VolumeShock::releasedLife(volume.life, now - volume.born, LOGICFRAMES_PER_SECOND);
static unsigned released = 0;
if (released++ < 8)
- DEBUG_LOG(("VOLSMOKE: frame %d, nuclear cap %u (born %d) let go: other blasts moved it %.0f units, the last by a push %.0f front born %d at (%.0f, %.0f, %.0f), owner %d\n",
- now, slot, volume.born, volume.capPushed, hardest ? hardest->c.push : 0.0f, hardest ? hardest->born : -1,
- hardest ? hardest->at[0] : 0.0f, hardest ? hardest->at[1] : 0.0f, hardest ? hardest->at[2] : 0.0f, hardest ? hardest->owner : -1));
+ DEBUG_LOG(("VOLSMOKE: frame %d, nuclear cap %u let go: other blasts moved it %.0f units\n", now, slot, volume.capPushed));
}
}
}
@@ -4403,7 +4397,7 @@ bool screenRect(const float boxLow[3], const float boxHigh[3], const float viewP
// fall 3.5, its ground roll the half second past the old 3. A launch's 4, its cloud's roll.
float lifeOf(Kind kind, float scale)
{
- return kind == TankDeath ? 4.25f : kind == Structure ? 3.5f : kind == Nuclear ? 90.0f : kind == Launch ? 4.0f
+ return kind == TankDeath ? 4.25f : kind == Structure ? 3.5f : kind == Nuclear ? VolumeShock::NukeLife : kind == Launch ? 4.0f
: kind == Muzzle ? MuzzleLife : kind == Shell && scale < 2.0f ? 4.0f : 12.0f;
}
// (a gun's at 1.5 units, its 48 cells 72 units across: the dust round the tank's front and the fireball's whole reach)
@@ -4899,12 +4893,6 @@ bool Takes(ParticleSystem *system)
Coord3D where;
system->getPosition(&where);
addShock(where, *known->second, (int)TheGameLogic->getFrame());
- // TEMPORARY (stage 1 retune): what starts each nuclear front, for the cap a nuke's own later
- // front lets go 3 to 4 s after it lands in the cost runs
- static unsigned nuclearFronts = 0;
- if (known->second->push >= VolumeShock::Nuclear.push && nuclearFronts++ < 16)
- DEBUG_LOG(("VOLSMOKE: frame %d, nuclear front from '%s' at (%.0f, %.0f, %.0f)\n", (int)TheGameLogic->getFrame(),
- tmplate->getName().str(), where.x, where.y, where.z));
}
}
// a building's or a wreck's fire burns in a fire slab, or keeps its billboards; never the air's
@@ -5142,10 +5130,6 @@ bool Takes(ParticleSystem *system)
|| (rankOf(volumes[i]) == rankOf(volumes[slot]) && volumes[i].born < volumes[slot].born))
slot = i;
++droppedCount;
- // TEMPORARY (stage 1 retune): which blast a nuke's slab goes to
- if (volumes[slot].kind == Nuclear || type == Nuclear)
- DEBUG_LOG(("VOLSMOKE: frame %d, '%s' (kind %d) %s slab %u from a kind %d born at frame %d\n", now, own, (int)type,
- rankOf(volumes[slot]) > rank ? "dropped, not taking" : "takes", slot, (int)volumes[slot].kind, volumes[slot].born));
if (rankOf(volumes[slot]) > rank) {
if (type == Structure) DEBUG_LOG(("VOLSMOKE: frame %d, a structure's blast dropped: every slab held a higher rank\n", now));
pruneSets();
@@ -5267,7 +5251,7 @@ bool Takes(ParticleSystem *system)
addShock(where, kind.scale >= 3.0f ? VolumeShock::NukeCannon : VolumeShock::shell(kind.scale), now, (int)slot);
pruneSets();
takenSystems.insert(id);
- if (claimedCount++ < 8 || type == Nuclear) // TEMPORARY (stage 1 retune): every nuclear one
+ if (claimedCount++ < 8)
DEBUG_LOG(("VOLSMOKE: frame %d, %s volume %u for '%s' at (%.0f, %.0f, %.0f), %.0f units wide\n", now,
type == TankDeath ? "tank" : type == Shell ? "shell" : type == Airburst ? "airburst" : type == Structure ? "structure"
: type == Launch ? "launch" : "nuclear", slot,
diff --git a/GeneralsMD/Code/Tests/test_volume_fire_policy.cpp b/GeneralsMD/Code/Tests/test_volume_fire_policy.cpp
index bef8bdb29..308ff0388 100644
--- a/GeneralsMD/Code/Tests/test_volume_fire_policy.cpp
+++ b/GeneralsMD/Code/Tests/test_volume_fire_policy.cpp
@@ -229,6 +229,25 @@ TEST(volume_shock_passage_mixes_away_its_share)
CHECK(capHold(10.0f) > 0.8f);
}
+TEST(volume_shock_nuclear_cloud_lasts_as_long_as_the_games_own)
+{
+ using namespace VolumeShock;
+ CHECK_NEAR(NukeLife, 22.33f, 0.01f);
+ // the fade leaves under a fifth of the soot for the end fade to take, not a thick cloud to cut
+ CHECK(NukeFadeFrom < NukeLife);
+ CHECK(std::pow(0.5f, (NukeLife - NukeFadeFrom) / NukeFadeHalfLife) < 0.2f);
+ // a second nuke at any moment ends the first's cloud sooner or leaves it be, and never makes it outlast
+ // that; let go early it stays for as long as a cap's own fade would thin it
+ const int fps = 60, life = int(NukeLife * fps);
+ for (int age = 0; age <= life; age += 30) {
+ CHECK(releasedLife(life, age, fps) <= life);
+ CHECK(releasedLife(life, age, fps) >= age);
+ }
+ CHECK_EQ(releasedLife(life, 3 * fps, fps), int((3.0f + NukeDisperseLife) * fps));
+ CHECK_EQ(releasedLife(life, 15 * fps, fps), life);
+ CHECK(NukeDisperseLife >= NukeLife - NukeFadeFrom - 1.0f);
+}
+
TEST(volume_shock_templates_that_start_a_front)
{
using namespace VolumeShock;