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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(w3ddevice): -volsmoke tank gun flame is a cone, hits one burst
Olcay Seyganae1605797297
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 58a9e6e4d..b36fdb95a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -113,7 +113,7 @@ 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 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 half a second after the flash, while hot sparks streak up out of the fire in long thin lines and fall back. 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. An orange-yellow fireball, white-hot in the middle, blooms out of the muzzle along the barrel's own aim, wider than the turret, and is gone in about a sixth of a second. It leaves a grey cloud hanging 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 fireball, an Overlord's a bigger one. A shell striking armour throws a white-yellow starburst and a shower of sparks off the face it hit, back towards the tank that fired it, where the game's own sparks burst over the turret whichever side was struck, 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 cost about 0.3 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.+- 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 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 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. 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.diff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.iniindex fb4d876c5..8336a122a 100644--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini@@ -6617,13 +6617,16 @@ ParticleSystem ReforgedTankDeathSparkTailWindPingPongEndAngleMax = 6.283185End-; A shell striking armour, the way footage of a real hit looks: a shower of white-yellow sparks off-; the face it struck, thrown back out the way it came and fanning over the face. EA's TankStruckSparks-; bursts at the vehicle's middle, over its turret, whichever side was hit. Only the Smoke simulation-; setting starts these (DX11VolumeSmoke.cpp turns their x axis out of the hull's face where the shot-; met it); FX lists never name them, so with the setting Off EA's hit is untouched. Each spark is a-; soft dot dragging a short tail, so it flies as a thin line: drawn with EA's spark texture, itself a-; starburst, every spark and every point of its tail read as a little orange star.+; A shell striking armour, the way footage of a real hit looks: one dense burst of thin white-yellow+; streaks out of the impact point, thrown out of the face it struck in a cone round its normal. EA's+; TankStruckSparks bursts at the vehicle's middle, over its turret, whichever side was hit; while+; these fly the smoke volume hides it and the hit's lens flare. Only the Smoke simulation setting+; starts these (DX11VolumeSmoke.cpp turns their x axis out of the hull's face where the shot met+; it); FX lists never name them, so with the setting Off EA's hit is untouched. Each spark is a soft+; dot dragging a short tail, so it flies as a thin line: drawn with EA's spark texture, itself a+; starburst, every spark and every point of its tail read as a little orange star. Fast out of the+; point and braked hard, they stop within a few units of it, so the burst stays one radial bundle+; (thrown slower and braked less they drifted over the whole tank as loose dots).ParticleSystem ReforgedTankHitSparksPriority = UNIT_DAMAGE_FXIsOneShot = No@@ -6634,13 +6637,13 @@ ParticleSystem ReforgedTankHitSparksAngleZ = 0.00 6.28AngularRateZ = 0.00 0.00AngularDamping = 0.00 0.00- VelocityDamping = 0.93 0.97- Gravity = -0.25- Lifetime = 6.00 10.00+ VelocityDamping = 0.84 0.88+ Gravity = -0.15+ Lifetime = 5.00 8.00SystemLifetime = 2- Size = 1.60 2.20+ Size = 0.80 1.00StartSizeRate = 0.00 0.00- SizeRate = -0.08 -0.05+ SizeRate = -0.06 -0.05SizeRateDamping = 1.00 1.00Alpha1 = 0.00 0.00 0Alpha2 = 0.00 0.00 0@@ -6650,25 +6653,25 @@ ParticleSystem ReforgedTankHitSparksAlpha6 = 0.00 0.00 0Alpha7 = 0.00 0.00 0Alpha8 = 0.00 0.00 0- Color1 = R:255 G:250 B:225 0- Color2 = R:255 G:200 B:110 4- Color3 = R:220 G:100 B:30 7- Color4 = R:0 G:0 B:0 10+ Color1 = R:255 G:252 B:235 0+ Color2 = R:255 G:215 B:130 3+ Color3 = R:230 G:110 B:35 6+ Color4 = R:0 G:0 B:0 8Color5 = R:0 G:0 B:0 0Color6 = R:0 G:0 B:0 0Color7 = R:0 G:0 B:0 0Color8 = R:0 G:0 B:0 0ColorScale = 0.00 0.00BurstDelay = 99999.00 99999.00- BurstCount = 12.00 16.00+ BurstCount = 16.00 20.00InitialDelay = 0.00 0.00DriftVelocity = X:0.00 Y:0.00 Z:0.00VelocityType = ORTHO- VelOrthoX = 1.50 3.50- VelOrthoY = -2.20 2.20- VelOrthoZ = -0.50 2.50+ VelOrthoX = 3.00 6.00+ VelOrthoY = -2.40 2.40+ VelOrthoZ = -1.60 2.20VolumeType = BOX- VolBoxHalfSize = X:0.50 Y:2.00 Z:2.00+ VolBoxHalfSize = X:0.30 Y:0.60 Z:0.60IsHollow = NoIsGroundAligned = NoIsEmitAboveGroundOnly = No@@ -6682,26 +6685,26 @@ ParticleSystem ReforgedTankHitSparksWindPingPongEndAngleMax = 6.283185End-; A hit spark's tail: a soft dot a frame left where the spark is, shrinking to nothing over 0.2 s, so-; the spark reads as a thin streak (at 3 units across it was a dotted spray, at 4 and 0.3 s a cluster-; of orange stars drifting after the burst). Its life of 11 frames, past the spark's 10, ends one a-; saved game restored without its spark.+; A hit spark's tail: a point a frame left where the spark is, joined into one thin ribbon (a STREAK+; of its own points only), tapering to nothing over 0.13 s, so the spark reads as a bright line. Loose+; points read as dots wherever the spark outran their width, as stars at 4 units with EA's spark+; texture. Its life of 9 frames, past the spark's 8, ends one a saved game restored without its spark.ParticleSystem ReforgedTankHitSparkTailPriority = DEBRIS_TRAILIsOneShot = NoShader = ADDITIVE- Type = PARTICLE+ Type = STREAKParticleName = EXFuzzyDot.tgaAngleZ = 0.00 6.28AngularRateZ = 0.00 0.00AngularDamping = 0.00 0.00VelocityDamping = 1.00 1.00Gravity = 0.00- Lifetime = 6.00 7.00- SystemLifetime = 11- Size = 1.60 1.90+ Lifetime = 4.00 4.00+ SystemLifetime = 9+ Size = 0.45 0.55StartSizeRate = 0.00 0.00- SizeRate = -0.25 -0.23+ SizeRate = -0.11 -0.11SizeRateDamping = 1.00 1.00Alpha1 = 0.00 0.00 0Alpha2 = 0.00 0.00 0@@ -6711,9 +6714,9 @@ ParticleSystem ReforgedTankHitSparkTailAlpha6 = 0.00 0.00 0Alpha7 = 0.00 0.00 0Alpha8 = 0.00 0.00 0- Color1 = R:255 G:225 B:150 0- Color2 = R:230 G:120 B:40 3- Color3 = R:0 G:0 B:0 7+ Color1 = R:255 G:245 B:210 0+ Color2 = R:250 G:180 B:80 2+ Color3 = R:0 G:0 B:0 4Color4 = R:0 G:0 B:0 0Color5 = R:0 G:0 B:0 0Color6 = R:0 G:0 B:0 0@@ -6742,26 +6745,26 @@ ParticleSystem ReforgedTankHitSparkTailWindPingPongEndAngleMax = 6.283185End-; The hit's own white-yellow flash on the face it struck: EA's spark texture, which is a burst of-; radiating streaks, flung open for a sixth of a second, two of them at different turns. Started with-; ReforgedTankHitSparks, the same way.-ParticleSystem ReforgedTankHitSparkFlare+; The hit's hot white core on the face it struck, under its sparks: a soft glow gone in a tenth of+; a second. EA's spark texture in its place, a burst of streaks all round, stacked on the stock+; bursts into fireworks over the tank. Started with ReforgedTankHitSparks, the same way.+ParticleSystem ReforgedTankHitSparkCorePriority = UNIT_DAMAGE_FXIsOneShot = NoShader = ADDITIVEType = PARTICLE- ParticleName = EXSpark02.tga+ ParticleName = EXLnzFlar2.tgaAngleZ = 0.00 6.28AngularRateZ = 0.00 0.00AngularDamping = 0.00 0.00VelocityDamping = 1.00 1.00Gravity = 0.00- Lifetime = 5.00 6.00+ Lifetime = 3.00 3.00SystemLifetime = 2- Size = 4.00 6.00+ Size = 6.00 7.00StartSizeRate = 0.00 0.00- SizeRate = 3.00 4.00- SizeRateDamping = 0.80 0.85+ SizeRate = 1.50 1.50+ SizeRateDamping = 0.70 0.70Alpha1 = 0.00 0.00 0Alpha2 = 0.00 0.00 0Alpha3 = 0.00 0.00 0@@ -6770,9 +6773,9 @@ ParticleSystem ReforgedTankHitSparkFlareAlpha6 = 0.00 0.00 0Alpha7 = 0.00 0.00 0Alpha8 = 0.00 0.00 0- Color1 = R:255 G:250 B:230 0- Color2 = R:255 G:210 B:120 3- Color3 = R:0 G:0 B:0 6+ Color1 = R:255 G:250 B:235 0+ Color2 = R:255 G:200 B:110 2+ Color3 = R:0 G:0 B:0 3Color4 = R:0 G:0 B:0 0Color5 = R:0 G:0 B:0 0Color6 = R:0 G:0 B:0 0@@ -6780,11 +6783,11 @@ ParticleSystem ReforgedTankHitSparkFlareColor8 = R:0 G:0 B:0 0ColorScale = 0.00 0.00BurstDelay = 99999.00 99999.00- BurstCount = 2.00 2.00+ BurstCount = 1.00 1.00InitialDelay = 0.00 0.00DriftVelocity = X:0.00 Y:0.00 Z:0.00VelocityType = ORTHO- VelOrthoX = 0.20 0.40+ VelOrthoX = 0.00 0.00VelOrthoY = 0.00 0.00VelOrthoZ = 0.00 0.00VolumeType = POINTdiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cppindex 83f1b2114..22946a913 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp@@ -53,10 +53,11 @@// the tank's ground ring and the smoke trails behind its flying scrap are taken with them. The// scrap itself, and every gun's muzzle smoke but a tank gun's, stay the game's own.//-// A tank gun's shot has a short volume of its own on a free slab, a few at once: a fireball-// blooming along the barrel's aim, a grey-white puff ahead of it and a dust cloud blown off the-// ground round the tank's front, gone in a second and a half. A shell striking armour throws a-// shower of sparks off the face it hit, the game's own particles, which Gather starts.+// A tank gun's shot has a short volume of its own on a free slab, a few at once: a cone of flame+// out of the muzzle along the barrel's aim, a little grey smoke ahead of it and a dust cloud blown+// off the ground round the tank's front, gone in a second and a half. A shell striking armour+// throws one burst of spark streaks out of the point it hit, the game's own particles, which Gather+// starts; the stock sparks of that hit are hidden.#include "Common/GlobalData.h"#include "Common/Debug.h"#include "Common/LogicThread.h"@@ -1584,6 +1585,12 @@ std::vector<Coord3D> pendingSparks;// the attacker: `along` is the shot's heading).struct PendingHit { Coord3D at; float along[2]; };std::vector<PendingHit> pendingHits;+// The hits whose sparks we throw, for eight logic frames: the game's own sparks near one are hidden.+struct OwnedHit { Coord3D at; int frame; };+std::vector<OwnedHit> ownedHits;+// Each live shot's systems (its trigger flame and the FX that joined it), by slot, so a blast that+// takes the slab gives them their billboards back.+std::unordered_map<unsigned, std::vector<int>> gunSystems;// 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@@ -1665,6 +1672,8 @@ bool requested()shocks.clear();pendingSparks.clear();pendingHits.clear();+ ownedHits.clear();+ gunSystems.clear();hulls.clear();lastHulls.clear();solids.clear();@@ -2726,8 +2735,8 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)}} else if (volume.kind == Muzzle) {// A tank gun firing, after footage of real ones (reference/tank-shoot.jpg): an orange-yellow- // fireball blooming out ahead of the barrel, wider than the turret and gone in a tenth of a- // second, a grey-white puff of smoke in front of it, and a dust cloud the blast blows up off+ // cone of flame out of the muzzle, wider than the turret at its far end and gone in a tenth of+ // a second, a little grey smoke in front of it, and a dust cloud the blast blows up off// the ground round the gun's front, rolling out sideways along it. Placed along the barrel's// own aim (hull[0..2], the muzzle bone's axis) from the muzzle (blast), in cells.const float ax = volume.hull[0], ay = volume.hull[1], az = volume.hull[2], height = volume.hull[4];@@ -2737,32 +2746,39 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)emit(slab, count, { bx + ax * d, by + ay * d, bz + az * d + lift, radius, ax * speed, ay * speed, az * speed + rise,sootRate, heat, 0, push });};- // the fireball's middle, where the flash glows- blast[0] = bx + ax * 3.5f; blast[1] = by + ay * 3.5f; blast[2] = bz + az * 3.5f;- blast[3] = 3.0f;- // (at 6 over 3 cells for 0.05 s it was a hard white disc wider than the fireball)- flash = t < 0.03f ? 2.5f : 0.0f;- flashWide = 2.0f;+ // the flash, small, at the muzzle tip+ blast[0] = bx + ax * 0.8f; blast[1] = by + ay * 0.8f; blast[2] = bz + az * 0.8f;+ blast[3] = 1.5f;+ // (at 6 over 3 cells for 0.05 s it was a hard white disc wider than the fireball; at 2.5 over 2,+ // 3.5 cells out, a round glow off the muzzle)+ flash = t < 0.03f ? 2.0f : 0.0f;+ flashWide = 0.9f;flashTall = 1.0f;soot[0] = 0.78f; soot[1] = 0.77f; soot[2] = 0.75f; soot[3] = 1.6f + 1.4f * std::exp(-t / 0.05f);dust[0] = 0.62f; dust[1] = 0.55f; dust[2] = 0.44f; // sunlit tan- // The fireball: four hot puffs thrown out along the barrel, growing as they go, the far ones- // fastest so it stretches out from the muzzle and stays on it (thrown fastest from the muzzle- // it left a gap behind it), the middle two white-yellow, the first and the last orange. Its heat goes in a few frames- // (MuzzleHeatHalfLife), so it flares and is smoke by 0.2 s. A flame glows by the soot it- // burns in, so it lays thick smoke (at 8 a second it lit nothing, at 70 it left a brown ball): what is left once it has- // cooled is the grey-white cloud in front of the gun.- if (t < 0.14f) {- const float grow = smoothstep01(t, 0.0f, 0.08f), fade = 1 - t / 0.14f;- for (unsigned k = 0; k < 4; ++k)- along((0.3f + 2.6f * k) * (0.6f + 0.4f * grow), 0, (2.0f + 1.4f * k) * (0.55f + 0.45f * grow), (12.0f + 8.0f * k) * fade, 1.0f,- 50.0f, (k == 1 || k == 2 ? 2.5f : 1.8f) * (0.7f + 0.3f * fade), 0.6f);+ // The fireball, as the photos have it: a cone of flame straight out of the muzzle, widening+ // forward, brightest at the tip and orange-red at its fringe. Five hot puffs on the barrel's+ // line, the first just inside the tip, each wider than the one behind it, the hottest at the+ // muzzle, pushed on only gently so the cone stays on the gun. Four puffs out ahead, thrown+ // fastest from the muzzle, left a gap and then a round ball. Its heat goes in a few frames+ // (MuzzleHeatHalfLife), so it flares and is smoke by 0.15 s. A flame glows by the soot it+ // burns in (at 8 a second it lit nothing, at 70 it left a brown ball).+ if (t < 0.1f) {+ const float grow = 0.7f + 0.3f * smoothstep01(t, 0.0f, 0.05f), fade = 1 - t / 0.1f;+ // (the glow is soot times heat along the eye's ray, so laid evenly the wide far puffs outshone+ // the thin tip and the cone read as a ball ahead of the gun: the tip lays the most and the+ // hottest, the far end little and cooler)+ for (unsigned k = 0; k < 5; ++k) {+ const float d = (-0.3f + 1.5f * k) * grow;+ along(d, 0, (1.2f + 0.4f * (std::max)(d, 0.0f)) * grow, (4.0f + 4.0f * k) * fade, 0.5f, 70.0f - 13.0f * k,+ (2.9f - 0.35f * k) * (0.7f + 0.3f * fade), 0.4f);+ }}- // the smoke, pushed on ahead and spreading, lightly lifted+ // a little smoke, pushed on ahead and spreading, lightly liftedif (t > 0.02f && t < 0.45f) {const float fade = 1 - (t - 0.02f) / 0.43f;for (unsigned k = 0; k < 3; ++k)- along(2.5f + 3.0f * k, 0.6f + 0.4f * k, 1.8f + 0.8f * k + 1.5f * (1 - fade), (14.0f - 3.0f * k) * fade, 1.5f, 36.0f * fade, 0, 0.35f);+ along(2.5f + 3.0f * k, 0.6f + 0.4f * k, 1.8f + 0.8f * k + 1.5f * (1 - fade), (14.0f - 3.0f * k) * fade, 1.5f, 18.0f * fade, 0, 0.35f);}// The dust: where the blast meets the ground ahead of the muzzle, thrown out low along the// ground in a fan from straight ahead round to the gun's sides and a little behind them, so it@@ -4377,6 +4393,7 @@ bool startMuzzle(ParticleSystem *system, const Coord3D &where, float gunScale, ivolume.life = int(MuzzleLife * LOGICFRAMES_PER_SECOND);pruneSets();takenSystems.insert((int)system->getSystemID());+ gunSystems[slot] = { (int)system->getSystemID() };static unsigned gunsLogged = 0;if (gunsLogged++ < 8)DEBUG_LOG(("VOLSMOKE: frame %d, gun volume %u for '%s' at (%.0f, %.0f, %.0f), aim (%.2f, %.2f, %.2f), %.2f a cell, %s\n", now, slot,@@ -4401,7 +4418,29 @@ bool Takes(ParticleSystem *system)system->getPosition(&hit.at);hit.along[0] = turn[0][0];hit.along[1] = turn[1][0];- if (pendingHits.size() < 64 && !(hit.along[0] == 1.0f && hit.along[1] == 0.0f)) pendingHits.push_back(hit);+ if (pendingHits.size() < 64 && !(hit.along[0] == 1.0f && hit.along[1] == 0.0f)) {+ pendingHits.push_back(hit);+ ownedHits.push_back({ hit.at, (int)TheGameLogic->getFrame() });+ }+ }+ // The game's own sparks and lens flare of a hit whose sparks we throw, and of the shell that made+ // it (TankStruckSparks, the Lenzflares, in the same frame or the next and within 25 units: both go+ // off in the logic frame that struck): stacked on ours they burst over the turret and all round the+ // tank as fireworks. ponytail: by place and frame, not by victim, so a machine gun's hit (the same+ // template) on a tank parked within 25 units in that frame loses its sparks too; key on the victim+ // if that shows.+ const char *own0 = system->getTemplate()->getName().str();+ if (TheGameLogic && !ownedHits.empty() && (!std::strcmp(own0, "TankStruckSparks") || std::strstr(own0, "TankStruckLenzflare"))) {+ const int seen = firstSeen.emplace(id, (int)TheGameLogic->getFrame()).first->second;+ Coord3D where;+ system->getPosition(&where);+ for (const OwnedHit &hit : ownedHits) {+ const float dx = where.x - hit.at.x, dy = where.y - hit.at.y;+ if (std::abs(seen - hit.frame) > 1 || dx * dx + dy * dy > 25.0f * 25.0f) continue;+ pruneSets();+ takenSystems.insert(id);+ return true;+ }}if (takenSystems.count(id)) return !airOutside.count(id);// A blast is told from loose billboard systems; trails, streaks, a building's smoke and every@@ -4516,6 +4555,7 @@ bool Takes(ParticleSystem *system)if (dx * dx + dy * dy > reach * reach) continue;pruneSets();takenSystems.insert(id);+ if (volume.kind == Muzzle) gunSystems[unsigned(&volume - volumes)].push_back(id);++joinedCount;return true;}@@ -4561,6 +4601,14 @@ bool Takes(ParticleSystem *system)}Volume &volume = volumes[slot];+ // a shot whose slab this takes gets its billboards back, for what is left of them+ if (volume.live && volume.kind == Muzzle) {+ auto shot = gunSystems.find(slot);+ if (shot != gunSystems.end()) {+ for (int taken : shot->second) takenSystems.erase(taken);+ gunSystems.erase(shot);+ }+ }volume = fresh;volume.live = true;volume.reset = true;@@ -4696,13 +4744,15 @@ void Gather()system->setPosition(&at);pendingSparks.clear();}- // A shell striking armour: a shower of sparks off the hull's face that took it, thrown back out- // towards the side it came from and spreading over that face (the system's x axis is the face's- // outward normal). The hit itself goes off at the vehicle's middle, so the face is where the shot's- // line from the attacker meets the hull's box.+ ownedHits.erase(std::remove_if(ownedHits.begin(), ownedHits.end(), [now](const OwnedHit &hit) { return hit.frame < now - 8; }),+ ownedHits.end());+ // A shell striking armour: one dense burst of sparks out of the point where it struck, in a cone+ // round the face's outward normal (the system's x axis), over a white core. The hit itself goes off+ // at the vehicle's middle, so the point is where the shot's line from the attacker meets the hull's+ // box. Two systems a hit, plus a tail system on each of its 16 to 20 sparks for a quarter second.if (!pendingHits.empty() && TheParticleSystemManager) {const ParticleSystemTemplate *sparks = TheParticleSystemManager->findTemplate("ReforgedTankHitSparks");- const ParticleSystemTemplate *flare = TheParticleSystemManager->findTemplate("ReforgedTankHitSparkFlare");+ const ParticleSystemTemplate *core = TheParticleSystemManager->findTemplate("ReforgedTankHitSparkCore");static unsigned hitsLogged = 0;if (hitsLogged++ < 4)DEBUG_LOG(("VOLSMOKE: frame %d, %u armour hit spark shower(s), template %s\n", now, (unsigned)pendingHits.size(),@@ -4730,7 +4780,7 @@ void Gather()}Matrix3D turn(1);turn.Rotate_Z(std::atan2(ny, nx));- for (const ParticleSystemTemplate *made : { sparks, flare })+ for (const ParticleSystemTemplate *made : { sparks, core })if (made)if (ParticleSystem *system = TheParticleSystemManager->createParticleSystem(made)) {system->setLocalTransform(&turn);@@ -4992,6 +5042,8 @@ void Reset(){pendingSparks.clear(); // before the early return: a burst queued as the setting went OffpendingHits.clear();+ ownedHits.clear();+ gunSystems.clear();clearFires(); // the system IDs start again from 1if (!requested()) return;for (Volume &volume : volumes) volume = Volume();