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
feat(w3ddevice): radiation pools pulse and bubble
Olcay Seyganf450580a1e77
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dcae18046..4a2746f9b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1343,7 +1343,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- A bright cloud no longer shows what is behind it as a line drawing. Inside a nuke's white cloud, or a falling War Factory's fireball, every tree and wreck under it used to come out as a thin grey outline, and the picture's sharpening ringed each dark piece in white. Both stop where the frame is bright.- Smoke and fire no longer end on a straight line where they meet the ground or a building. A puff that sinks into a hillside or drifts against a wall thins out over its last few metres, softly enough that a nuke's haze and a Scud's grey smoke no longer come out as stacked, stair-stepped terraces, and a toxin cloud lying low over the ground keeps its body instead of breaking into hard-edged green islands. This is the default renderer; Classic and the old renderer keep the hard edge they had in 2003.- Effects fade out instead of blinking off. The rings a nuke sends across the ground, and any spark, flash or puff whose own colours never reached nothing, used to vanish at full strength on their last frame. Each one now dims away over its last quarter of a second, or over a quarter of its life when it lives shorter than that. One that was already fading looks the way it always did.-- Toxin, anthrax and radiation pools lie on the ground. A pool is a carpet of puddle pictures spread up to 140 paces from where the shell or the spray came down, and every one of them was drawn dead flat at the height of that one spot: on a hillside the uphill half of the pool disappeared into the slope and the downhill half hung in the air above it. Each puddle now bends over the ground underneath it, on both renderers, and a pool on a bridge stays on the deck. The pool also holds still. It used to throb twice a second, because every half second the pool's poison fired a fresh batch of puddles that swelled out of black to full green and back to black in two seconds, each batch somewhere new. Now it comes up in half a second, stays one steady pool at full colour for as long as it does damage, and fades over its last three seconds, or over three seconds from the moment the fog of war closes over it. Four Scud warheads landing on one spot used to stack into a white-hot blotch in the middle; overlapping pools now share their light and the middle stays toxin green. The ground under it takes on its colour, green for toxin and the anthrax colours for anthrax, so it looks spilled rather than shone onto the grass.+- Toxin, anthrax and radiation pools lie on the ground. A pool is a carpet of puddle pictures spread up to 140 paces from where the shell or the spray came down, and every one of them was drawn dead flat at the height of that one spot: on a hillside the uphill half of the pool disappeared into the slope and the downhill half hung in the air above it. Each puddle now bends over the ground underneath it, on both renderers, and a pool on a bridge stays on the deck. The pool also holds still. It used to throb twice a second, because every half second the pool's poison fired a fresh batch of puddles that swelled out of black to full green and back to black in two seconds, each batch somewhere new. Now it comes up in half a second, stays one pool at full colour for as long as it does damage, and fades over its last three seconds, or over three seconds from the moment the fog of war closes over it. It is not frozen, though: each puddle fades down and back up on its own beat, so the surface shimmers like something liquid while the pool as a whole never pulses. Four Scud warheads landing on one spot used to stack into a white-hot blotch in the middle; overlapping pools now share their light and the middle stays toxin green. The ground under it takes on its colour, green for toxin and the anthrax colours for anthrax, so it looks spilled rather than shone onto the grass. China's radiation keeps its orange but glows instead of browning the grass, which made it look like a scorch mark, and small bubbles swell out of it and pop. A nuke's radiation lies on the hillside as a pool from three seconds after the blast, where its first ten seconds used to be flat squares cutting into the slope.- A Scud Storm or a carpet bomb shakes the screen as hard as it should. The game cut a pile of heavy shakes back to a mild one, so a run of missiles or bombs landing together shook less than one of them alone. Each now shakes a step lighter and the run builds up. Demo traps and Aurora bombs shake now, and a falling building shakes harder the bigger it was.- The shake knows how close you are. A shell landing in the middle of the screen kicks the camera half as hard again as it used to, one at the edge of the range barely moves it, and a heavy hit settles over about a second instead of stopping dead after half of one. The cut that put a pile of shakes back to a mild one is gone too: past the limit the camera holds at full shake.- A damaged building's fires burn bigger, and its smoke runs darker and longer, the closer it gets to falling.diff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.iniindex cfd5ce38c..f057daeb9 100644--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini@@ -3333,3 +3333,67 @@ ParticleSystem SmokeFactionLargeWindPingPongEndAngleMin = 5.497787WindPingPongEndAngleMax = 6.283185End++; A nuke's radiation for its first ten seconds, while NukeRadiationFieldWeapon holds its FX back+; (SuspendFXDelay). EA made it CRITICAL, which kept it out of the pool path in W3DParticleSys.cpp:+; flat squares that sank into a hillside, each one swelling out of black and back over three+; seconds. It is AREA_EFFECT like the other radiation fields now, so it lies on the ground as a+; pool. Only the Priority line differs from EA's.++ParticleSystem NukeRadiationInitial+ Priority = AREA_EFFECT+ IsOneShot = No+ Shader = ADDITIVE+ Type = PARTICLE+ ParticleName = EXPuddle.tga+ AngleZ = -5.00 5.00+ AngularRateZ = 0.00 0.00+ AngularDamping = 1.00 1.00+ VelocityDamping = 0.20 0.20+ Gravity = 0.00+ Lifetime = 90.00 90.00+ SystemLifetime = 400+ Size = 30.00 30.00+ StartSizeRate = 0.00 0.00+ SizeRate = 5.00 5.00+ SizeRateDamping = 0.90 0.95+ Alpha1 = 1.00 1.00 0+ Alpha2 = 0.00 0.00 100+ 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:0 G:0 B:0 0+ Color2 = R:170 G:102 B:0 50+ Color3 = R:0 G:0 B:0 90+ Color4 = R:0 G:0 B:0 0+ 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 = 3.00 3.00+ BurstCount = 1.00 1.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.01+ VelocityType = ORTHO+ VelOrthoX = 0.00 0.00+ VelOrthoY = 0.00 0.00+ VelOrthoZ = 0.00 0.00+ VolumeType = CYLINDER+ VolCylinderRadius = 200.00+ VolCylinderLength = 0.00+ IsHollow = No+ IsGroundAligned = Yes+ IsEmitAboveGroundOnly = No+ IsParticleUpTowardsEmitter = No+ WindMotion = Unused+ WindAngleChangeMin = 0.149924+ WindAngleChangeMax = 0.449946+ WindPingPongStartAngleMin = 0.000000+ WindPingPongStartAngleMax = 0.785398+ WindPingPongEndAngleMin = 5.497787+ WindPingPongEndAngleMax = 6.283185+Enddiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cppindex ed4f8a3b3..52503cae6 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp@@ -40,6 +40,7 @@#include "W3DDevice/GameClient/W3DScene.h"#include "W3DDevice/GameClient/W3DDynamicLight.h"#include "WW3D2/camera.h"+#include "W3DDevice/GameClient/W3DSmoothMotion.h"#include "WW3D2/dx8wrapper.h"#include "WW3D2/dx11runtime.h"#include "Common/JobSystem.h"@@ -610,8 +611,21 @@ static void addFieldPuddle( FieldChunk &chunk, Real cx, Real cy, Real flatZ, Boo// fades in over FIELD_FADE_IN and out over the last FIELD_FADE_OUT frames of the field object's// life, read off its LifetimeUpdate; a field with no such object (a one-off contamination) fades// with its last particle instead. This reads the logic's objects and writes nothing back.+//+// Held dead still the pool looked painted on, so each puddle stays where it is and breathes: it+// fades down by up to FIELD_PULSE and back, and swells and shrinks by FIELD_BREATHE, every puddle+// on its own period and phase, on the logic clock blended between ticks as the models are. The+// puddles fall out of step with each other, so the pool shimmers and never throbs as a whole.//-------------------------------------------------------------------------------------------------+static const Real FIELD_PULSE_PERIOD = 2.5f; ///< seconds, from 0.6 to 1.4 of it per puddle+static const Real FIELD_PULSE = 0.55f; ///< share of a puddle's brightness it fades by+static const Real FIELD_BREATHE = 0.04f; ///< share of a puddle's size it swings by+static const Real FIELD_BUBBLE_SPACING = 30.0f; ///< radius per bubble slot on a radiation pool+static const Int FIELD_MAX_BUBBLES = 8;+static const Real FIELD_BUBBLE_PERIOD = 1.5f; ///< seconds a bubble lives, from 0.7 to 1.3 of it per slot+static const Real FIELD_BUBBLE_SIZE = 5.0f; ///< half width at the pop+static const Real FIELD_BUBBLE_GAIN = 0.6f;static const Real FIELD_COVER = 2.0f; ///< puddles per (radius / puddle size) squaredstatic const Int FIELD_MAX_PUDDLES = 48;static const Real FIELD_GAIN = 0.7f; ///< of the template's brightest colour, a puddle@@ -677,6 +691,9 @@ struct FieldDrawRGBColor color;AsciiString texture;Int firstPuddle, puddleCount;+ Bool glowing; ///< a warm hue, radiation: lit rather than stained, and it bubbles+ Real radius;+ UnsignedInt seed; ///< the place's hash, for its bubbles};static std::vector<FieldPuddle> s_fieldPuddles;@@ -761,6 +778,8 @@ static Real fieldFade( FieldState &state, Int now )static Int collectGroundFields( ParticleSystemManager::ParticleSystemList &systems, const AABoxClass &view ){const Int now = (Int)TheGameLogic->getFrame();+ // between the last two logic ticks, as the models are, so a pulse does not step at the logic rate+ const Real seconds = ((Real)now + (TheSmoothMotionActive ? TheSmoothMotionAlpha : 0.0f)) / LOGICFRAMES_PER_SECOND;s_fieldPuddles.clear();s_fieldDraws.clear();@@ -887,11 +906,26 @@ static Int collectGroundFields( ParticleSystemManager::ParticleSystemList &systedraw.color.green = (key_color.green - low) * lift;draw.color.blue = (key_color.blue - low) * lift;+ // Radiation is the one warm field. Its orange stained the ground brown and glowed at 0.7 of a+ // dim keyframe, which read as a scorch; it is lit to full strength instead and leaves the+ // ground under it alone.+ draw.glowing = draw.color.red >= draw.color.green && draw.color.red >= draw.color.blue;+ if (draw.glowing)+ {+ const Real full = WWMath::Max( draw.color.red, 1.0f / 255.0f );+ draw.color.red = 1.0f;+ draw.color.green /= full;+ draw.color.blue /= full;+ draw.batch.stained = FALSE;+ }+ draw.radius = state.radius;+const Real spread = state.radius / size;const Int count = WWMath::Clamp_Int( (Int)ceilf( FIELD_COVER * spread * spread ), 1, FIELD_MAX_PUDDLES );// the same scatter every frame: a little generator seeded by the placeUnsignedInt seed = (UnsignedInt)key.x * 73856093u ^ (UnsignedInt)key.y * 19349663u ^ 0x9E3779B9u;+ draw.seed = seed;draw.firstPuddle = (Int)s_fieldPuddles.size();draw.puddleCount = count;for (Int i = 0; i < count; ++i)@@ -905,11 +939,22 @@ static Int collectGroundFields( ParticleSystemManager::ParticleSystemList &systeconst Real r = count == 1 ? 0.0f : state.radius * sqrtf( u[ 0 ] );const Real a = u[ 1 ] * 2.0f * PI;FieldPuddle puddle;+ // its own beat, from a second generator so the scatter stays where it was+ UnsignedInt h = seed * 2654435761u;+ Real w[ 3 ];+ for (Int k = 0; k < 3; ++k)+ {+ h = h * 1664525u + 1013904223u;+ w[ k ] = (Real)(h >> 8) * (1.0f / 16777216.0f);+ }+ const Real phase = w[ 0 ] * 2.0f * PI;+ const Real cycle = 2.0f * PI * seconds / (FIELD_PULSE_PERIOD * (0.6f + 0.8f * w[ 1 ]));+ const Real pulse = 0.5f + 0.5f * WWMath::Sin( cycle + phase );puddle.x = state.centre.x + r * WWMath::Cos( a );puddle.y = state.centre.y + r * WWMath::Sin( a );- puddle.size = size;+ puddle.size = size * (1.0f + FIELD_BREATHE * WWMath::Sin( 0.7f * cycle + w[ 2 ] * 2.0f * PI ));puddle.angle = u[ 2 ] * 2.0f * PI;- puddle.bright = 0.8f + 0.2f * u[ 3 ];+ puddle.bright = (0.8f + 0.2f * u[ 3 ]) * (1.0f - FIELD_PULSE * pulse);puddle.fade = fade;puddle.overlap = 0.0f;s_fieldPuddles.push_back( puddle );@@ -971,6 +1016,39 @@ static Int collectGroundFields( ParticleSystemManager::ParticleSystemList &systeglowColor, stainColor );++laid;}++ // Radiation bubbles: a few small light blobs that swell out of the pool and pop, each slot on+ // its own beat and somewhere new every time. They take no part in the overlap above.+ if (draw.glowing)+ {+ const Int bubbles = WWMath::Clamp_Int( (Int)(draw.radius / FIELD_BUBBLE_SPACING), 1, FIELD_MAX_BUBBLES );+ for (Int b = 0; b < bubbles; ++b)+ {+ UnsignedInt h = draw.seed ^ ((UnsignedInt)b * 2246822519u);+ h = h * 1664525u + 1013904223u;+ const Real period = FIELD_BUBBLE_PERIOD * (0.7f + 0.6f * (Real)(h >> 8) * (1.0f / 16777216.0f));+ h = h * 1664525u + 1013904223u;+ const Real t = seconds / period + (Real)(h >> 8) * (1.0f / 16777216.0f);+ const Real round = floorf( t );+ const Real life = t - round;++ // where this round's bubble comes up+ UnsignedInt p = h ^ ((UnsignedInt)(Int)round * 3266489917u);+ p = p * 1664525u + 1013904223u;+ const Real r = draw.radius * 0.9f * sqrtf( (Real)(p >> 8) * (1.0f / 16777216.0f) );+ p = p * 1664525u + 1013904223u;+ const Real a = (Real)(p >> 8) * (1.0f / 16777216.0f) * 2.0f * PI;++ // up over most of its life, gone in the last fifth; lighter and yellower than the pool+ const Real swell = life < 0.8f ? life / 0.8f : (1.0f - life) / 0.2f;+ const Real bright = FIELD_BUBBLE_GAIN * draw.fade * swell;+ const unsigned bubbleColor = DX8Wrapper::Convert_Color_Clamp( Vector4( bright,+ bright * (0.5f + 0.5f * draw.color.green), bright * (0.3f + 0.7f * draw.color.blue), 1.0f ) );+ addFieldPuddle( chunk, draw.centre.x + r * WWMath::Cos( a ), draw.centre.y + r * WWMath::Sin( a ),+ draw.centre.z, draw.onGround, FIELD_BUBBLE_SIZE * (0.4f + 0.6f * life), a, bubbleColor, 0 );+ ++laid;+ }+ }s_fieldChunks.push_back( chunk );batch.chunkCount = (Int)s_fieldChunks.size() - batch.firstChunk;