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(w3dview): camera shake kicks on a heavy blast, with a switch

Olcay Seygan88753c6eaf98
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0533bf5c9..e3d78b475 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1847,6 +1847,8 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- 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 nuke, a Scud warhead or a bomb truck going up near the camera kicks it once, hard, and lets go. The worst of it is over in a quarter of a second, where a heavy hit used to rumble on for a whole one. One of these more than 150 paces away shook nothing at all, less than half the screen at the normal zoom; it reaches three times that now. A big building coming down close by adds a jolt of its own, a step under a nuke. Classic Graphics and the Direct3D 9 picture keep the old shake.
+- Camera Shake, under Options, Controls, turns all of it off for anyone who hates it. It is on by default.
- A damaged building's fires burn bigger, and its smoke runs darker and longer, the closer it gets to falling.
- Only the picture changed: damage, timing and what dies are what they were, and a recorded match plays back to the same checksum. In a test fight with a nuke and a Scud Storm the game carried 1631 effect particles where it carried 1610.
- Tanks and buildings come apart in more pieces, and the pieces stay. A Crusader throws 19 plates and scraps where it threw 12, an Overlord 9 where it threw 3, and a Scorpion, a Marauder or a Paladin five more bits of scrap each. A falling building adds the biggest slabs of its rubble, heavy enough to hop low and land close: a large base building throws 55 pieces where it threw 39, a War Factory 45 and a Power Plant 45. Wreckage lies on the ground for three seconds before it starts to sink, where EA gave it one, so a battlefield still shows what died on it after the smoke has gone. All of it is EA's own wreckage, thrown more often. The pieces are part of the match, so a replay recorded before this change plays back differently. In a test of rocket waves against tanks the busiest moment went from 791 things on the map to 898, and the game's rules took 3% longer a frame.
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index f6a005426..09d2b6456 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -693,6 +693,14 @@ TOOLTIP:LegacySound
"The original game's sound: no pitch bend on passing sounds, no Aurora sonic boom, no cap on battle sounds or unit replies, no limiter, no map ambience and no music following the fight. Master volume, the device and the speakers still apply. Takes effect at once."
END
+GUI:CameraShake
+"Camera Shake"
+END
+
+TOOLTIP:CameraShake
+"Blasts shake the camera. A nuke or a big building coming down nearby kicks it hard for a moment. Untick to keep the view still. Applies when you press Accept."
+END
+
GUI:IsometricCamera
"Isometric Camera"
END
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 6839ed4ee..83e77843c 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -15177,6 +15177,14 @@ TOOLTIP:LegacySound
"Özgün oyunun sesi: geçen seslerde perde kayması yok, Aurora'nın ses patlaması yok, savaş seslerine ve birlik cevaplarına sınır yok, sınırlayıcı yok, harita ambiyansı yok, müzik de çatışmayı izlemez. Ana ses, cihaz ve hoparlörler yine geçerlidir. Hemen etkili olur."
END
+GUI:CameraShake
+"Kamera Sarsıntısı"
+END
+
+TOOLTIP:CameraShake
+"Patlamalar kamerayı sarsar. Yakında bir nükleer patlama ya da büyük bir binanın yıkılması onu bir an sertçe iter. Görüntünün sabit kalması için işareti kaldır. Kabul Et'e basınca uygulanır."
+END
+
GUI:IsometricCamera
"İzometrik Kamera"
END
diff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
index 0c0e0d024..01dc0318d 100644
--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
@@ -10090,6 +10090,53 @@ WINDOW
IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
END
CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 40 434, BOTTOMRIGHT: 264 458, CREATIONRESOLUTION: 800 600;
+ NAME = "OptionsMenu.wnd:CheckCameraShake";
+ STATUS = ENABLED+IMAGE+BORDER;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;
+ HEADERTEMPLATE = "MinorTitle";
+ TOOLTIPTEXT = "TOOLTIP:CameraShake";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:CameraShake";
+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
+ CHILD
WINDOW
WINDOWTYPE = STATICTEXT;
SCREENRECT = UPPERLEFT: 282 150, BOTTOMRIGHT: 506 174, CREATIONRESOLUTION: 800 600;
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index bd3f12175..d84d66dc0 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -618,6 +618,7 @@ public:
Bool m_zoomToCursor; ///< the mouse wheel zooms toward whatever the cursor is over
Int m_zoomSpeed; ///< "ZoomSpeed" in Options.ini: percent of the height one wheel notch moves the camera; 100 is the game's own
Bool m_isometricCamera; ///< the tactical view from far off down a narrow cone, near enough orthographic
+ Bool m_cameraShake; ///< "CameraShake": blasts and scripts may shake the view (client only)
Int m_dragTolerance; ///< pixels the pointer may travel with a button held before the press is a drag; replaces Mouse.ini's DragTolerance
Bool m_formationDrag; ///< with the move, attack move or guard key armed, a left drag spreads the selection along the line drawn
Bool m_buildWithoutWorker; ///< with nothing selected the command bar shows a builder's buildings; off, an empty bar as 1.04 had it
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 1676866cb..5d45f7fde 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -1552,6 +1552,7 @@ GlobalData::GlobalData()
m_zoomToCursor = FALSE; // the wheel zooms on the middle of the screen, as 1.04 did, until ticked
m_zoomSpeed = 100; // a notch moves the camera the 60 units it always did
m_isometricCamera = FALSE;
+ m_cameraShake = TRUE;
m_dragTolerance = 25; // what Mouse.ini in INIZH.big says, so nothing moves until the slider does
// a left drag with the move, attack move or guard key armed draws a formation line
m_formationDrag = TRUE;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
index b6def0922..a3fb69089 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
@@ -68,6 +68,7 @@ OPTION_BOOL_ACCESSORS( m_nudgeBuildPlacement )
OPTION_BOOL_ACCESSORS( m_zoomToCursor )
OPTION_INT_ACCESSORS( m_zoomSpeed )
OPTION_BOOL_ACCESSORS( m_isometricCamera )
+OPTION_BOOL_ACCESSORS( m_cameraShake )
OPTION_BOOL_ACCESSORS( m_startAtMaxZoom )
// This catalog loads before there is a mouse, so the value waits in GlobalData and Mouse::parseIni
@@ -312,6 +313,12 @@ const OptionDef TheOptionCatalog[] =
OPTION_BOOL, APPLY_LIVE, 0, 1,
get_m_isometricCamera, set_m_isometricCamera },
+ // Whether blasts and scripts may shake the view; W3DView asks at each shake, and one under way
+ // settles by itself. On Options > Controls. It costs no frame time, so no quality row.
+ { "CameraShake", OPT_WND( "CheckCameraShake" ), "GUI:CameraShake",
+ OPTION_BOOL, APPLY_LIVE, 0, 1,
+ get_m_cameraShake, set_m_cameraShake },
+
// A match opens as far out as the wheel goes, or 300 over the ground (View::setZoomToStart).
// Read when the map loads, so it counts from the next match. On Options > Controls in both
// interfaces. A new key for the snaps' reason above: StartAtMaxZoom is a "yes" in old files.
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h
index 0f6c920b5..a4c906507 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h
@@ -291,6 +291,7 @@ private:
Real m_shakeAngleCos; ///< the cosine of the orientation of the oscillation
Real m_shakeAngleSin; ///< the sine of the orientation of the oscillation
Real m_shakeIntensity; ///< the intensity of the oscillation
+ Bool m_shakeKick; ///< a nuke's or a falling building's: settles at the hard rate
Vector3 m_shakerAngles; //WST 11/12/2002 new multiple instance camera shaker system
enum { MAX_SCREEN_DISTORTIONS = 4 }; ///< the post chain's warp limit
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DGameClient.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DGameClient.cpp
index 24c21013b..990c3aef7 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DGameClient.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DGameClient.cpp
@@ -53,6 +53,8 @@
#include "GameClient/RayEffect.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/Object.h"
+#include "GameClient/View.h"
+#include "WW3D2/dx11runtime.h"
#include "W3DDevice/GameClient/W3DAssetManager.h"
#include "W3DDevice/GameClient/W3DGameClient.h"
#include "W3DDevice/GameClient/W3DStatusCircle.h"
@@ -176,6 +178,12 @@ void W3DGameClient::structureFell(const Coord3D *pos, Real radius)
return;
addGroundMark(pos, radius * 1.1f, GroundMarks::STAIN);
addGroundMark(pos, radius * 0.8f, GroundMarks::CRACKS);
+
+ // a big one jolts the camera on top of what its FX shakes, a step under a nuke's kick; a barracks or
+ // a tower does not. Not under Classic or Direct3D 9, which keep the old shake.
+ const Real JOLT_FROM_RADIUS = 40.0f;
+ if (radius >= JOLT_FROM_RADIUS && TheTacticalView && !TheGlobalData->m_classicGraphics && Direct3D11_Present_Is_Enabled())
+ TheTacticalView->shake(pos, View::SHAKE_STRONG);
}
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
index 663a7a539..5cc2c2568 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
@@ -226,6 +226,7 @@ W3DView::W3DView()
m_shakeOffset.x = 0.0f;
m_shakeOffset.y = 0.0f;
m_shakeIntensity = 0.0f;
+ m_shakeKick = FALSE;
m_FXPitch = 1.0f;
m_freezeTimeForCameraMovement = false;
m_cameraHasMovedSinceRequest = true;
@@ -2042,9 +2043,10 @@ void W3DView::update(void)
// fake a stiff spring/damper. A big kick settles at EA's rate and what is left of it rumbles
// on: the damping eases from 0.75 a step at an intensity of two or more to 0.88 near rest, so
- // a heavy blast trails off over about a second instead of stopping dead after half of one.
+ // a heavy blast trails off over about a second instead of stopping dead after half of one. A
+ // kick (shake) keeps the hard rate all the way down: over in a quarter of a second, no rumble.
const Real HARD_DAMPING = 0.75f;
- const Real TAIL_DAMPING = 0.88f;
+ const Real TAIL_DAMPING = m_shakeKick ? HARD_DAMPING : 0.88f;
const Real hardness = WWMath::Clamp(m_shakeIntensity * 0.5f, 0.0f, 1.0f);
const Real dampingCoeff = TAIL_DAMPING + (HARD_DAMPING - TAIL_DAMPING) * hardness;
m_shakeIntensity *= dampingCoeff;
@@ -2060,6 +2062,7 @@ void W3DView::update(void)
m_shakeIntensity = 0.0f;
m_shakeOffset.x = 0.0f;
m_shakeOffset.y = 0.0f;
+ m_shakeKick = FALSE;
}
}
@@ -4320,6 +4323,9 @@ void W3DView::moveAlongWaypointPath(Int milliseconds)
void W3DView::shake( const Coord3D *epicenter, CameraShakeType shakeType )
{
LOGIC_CENSUS( CENSUS_TACTICALVIEW );
+ if (!TheGlobalData->m_cameraShake)
+ return;
+
Real angle = GameClientRandomValueReal( 0, 2*PI );
m_shakeAngleCos = (Real)cos( angle );
@@ -4363,18 +4369,24 @@ void W3DView::shake( const Coord3D *epicenter, CameraShakeType shakeType )
Real dist = (Real)sqrt( d.x*d.x + d.y*d.y );
- if (dist > TheGlobalData->m_maxShakeRange)
+ // Every SEVERE shake (a nuke, a Scud warhead, a bomb truck) is a kick: three times the range, since
+ // at 150 units a nuke in plain view moved nothing at all, a third harder at the epicentre, up to
+ // MaxShakeIntensity, and no rumble after it. Not under Classic or Direct3D 9.
+ const Bool kick = shakeType == SHAKE_SEVERE && !TheGlobalData->m_classicGraphics && Direct3D11_Present_Is_Enabled();
+ const Real range = TheGlobalData->m_maxShakeRange * (kick ? 3.0f : 1.0f);
+ if (dist > range)
return;
// A square of the remaining distance rather than a straight line, and half as much again at the
// epicentre: a shell landing under the camera kicks it hard, one at the edge of the range barely
// moves it. The two meet the old line at about a third of the range.
const Real SHAKE_NEAR_BOOST = 1.5f;
- const Real nearness = 1.0f - (dist/TheGlobalData->m_maxShakeRange);
- intensity *= SHAKE_NEAR_BOOST * nearness * nearness;
+ const Real nearness = 1.0f - (dist/range);
+ intensity *= SHAKE_NEAR_BOOST * nearness * nearness * (kick ? 1.33f : 1.0f);
// add intensity and clamp
m_shakeIntensity += intensity;
+ m_shakeKick = kick;
// Held at the ceiling. EA's line put it back to 3.0 once the sum passed MaxShakeIntensity, so
// the hit that took a barrage over the top shook the camera less than the one before it.
@@ -4585,6 +4597,9 @@ void W3DView::cameraDisableRealZoomMode(void) //WST added 10/18/2002
void W3DView::Add_Camera_Shake (const Coord3D & position,float radius,float duration,float power) //WST added 11/13/02
{
+ if (!TheGlobalData->m_cameraShake)
+ return;
+
Vector3 vpos;
vpos.X = position.x;
diff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.py
index adf96d6a8..8234e2777 100644
--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py
+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py
@@ -189,6 +189,7 @@ NEW_CONTROLS = [
(CHECK, "CheckEmptyBuildingPips", "GUI:EmptyBuildingPips"),
(CHECK, "CheckZoomToCursor", "GUI:ZoomToCursor"),
(CHECK, "CheckIsometricCamera", "GUI:IsometricCamera"),
+ (CHECK, "CheckCameraShake", "GUI:CameraShake"),
(CHECK, "CheckStartAtMaxZoom", "GUI:StartAtMaxZoom"),
(CHECK, "CheckSnapCamera45", "GUI:SnapCamera45"),
(CHECK, "CheckGridBuild", "GUI:GridBuild"),
@@ -411,7 +412,8 @@ GROUP_LAYOUT = [
("check", "CheckZoomToCursor"),
("check", "CheckStartAtMaxZoom"),
("check", "CheckSnapCamera45"),
- ("check", "CheckEdgeScrollWindowed")]),
+ ("check", "CheckEdgeScrollWindowed"),
+ ("check", "CheckCameraShake")]),
("GUI:OptionsGroupOrders", [
setting("LabelDragTolerance", "SliderDragTolerance", "ValueDragTolerance"),
("check", "CheckAlternateMouse"),