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(gamelogic): men in a building search as far as the hill lets them

Olcay Seygan1536cb5bf564
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d6db2fab..e78c6c194 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -987,7 +987,7 @@ found and fixed, EA's own, not port damage.**
- A Comanche can no longer hide behind a hill or over a building and shoot your army to pieces. The hill hid the ground behind it, and the helicopter hovering over that ground went into the fog with it, while from up there it saw your tanks and fired down on them; your Gattling tanks and Stingers could neither see it nor shoot back. A ridge or a roof now hides only the ground. Anything flying within a unit's sight is seen and can be shot at, whatever stands between them, the same in skirmish and online. Not yet measured in a staged fight. Replays recorded before this change play out differently.
- A bridge is ground you can see, not a wall. Sight judged a bridge by the valley floor under it, so a bridge over a gorge sat hidden behind the gorge's own edge and a tank on the bank could not see the deck it was about to cross. A standing deck counts at its own height now; a bridge knocked down to rubble goes back to the ground beneath it.
- The spy satellite, the radar van scan and the spy drone see everything in their circle again. They were blocked by hills and buildings like a tank on the ground, so a scan dropped on an enemy base came back with holes behind every building in it.
-- High ground pays. A tank on a ridge now shoots, sees and picks its targets further down the slope than it could on the flat: three steps of range for every step of height over its target, up to twice its usual reach. Firing uphill costs nothing, and aircraft get no bonus from flying. Defences count too, and the range ring you see while placing one bends outward wherever the ground falls away, so you can site a Gattling Cannon on a hill and see exactly what it covers.
+- High ground pays. A tank on a ridge now shoots, sees and picks its targets further down the slope than it could on the flat: three steps of range for every step of height over its target, up to twice its usual reach. Firing uphill costs nothing, and aircraft get no bonus from flying. Defences count too, and the range ring you see while placing one bends outward wherever the ground falls away, so you can site a Gattling Cannon on a hill and see exactly what it covers. Men inside a building get it too. A Bunker on a hill looked for targets as if it stood on the flat, so five Red Guard inside one watched Rangers 180 paces down the slope that the same five on foot on the same spot shot dead; now the Bunker kills them, out to 195 where the men on foot get one of three. A man firing out of a helicopter still gets nothing from how high it flies.
- Rocket Buggies left on a hill stay on the hill. When a friend nearby got shot, every buggy around it went after the shooter, and after anything else in reach, even a tank down below that the edge of the hill hid. A buggy has to see what it fires at, so it drove to the lip to get a look, sat there unable to shoot, and then went down the slope and died. A unit that needs a clear view to fire now only answers back at what it can see from where you parked it. A buggy that picks up a salvage crate still drives to the crate.
- The five soldiers in an Overlord's battle bunker live through the Overlord's death again. A rule added in this build, that nobody gets out of a vehicle which is itself being carried, caught the bunker too, so all five died on the spot where they used to take half damage and climb out.
- Pro Rules hold for the nuke and the carpet bomb whoever fires them. The refusal stopped the recharge but not the missile: a computer player or a map script could launch a neutron missile the rules forbid, and because the timer never started, launch it again straight away.
diff --git a/GeneralsMD/Code/Data/Scenarios/hillbunker.txt b/GeneralsMD/Code/Data/Scenarios/hillbunker.txt
new file mode 100644
index 000000000..916253622
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/hillbunker.txt
@@ -0,0 +1,19 @@
+# Five Red Guard in a Bunker on a hill, three Rangers on the slope below them, 180 away.
+#
+# The hill on Dark Mountain stands 28 above the ground the Rangers are on, which stretches a 100 rifle
+# to 184. The same men on foot on the same spot reach them. Inside the Bunker they used to stand and
+# watch, because the search for a target left the high ground out for anything inside a building.
+#
+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
+# -map "Maps\Dark Mountain\Dark Mountain.map" -autoskirmish 2 -takeover
+# -side 0 FactionChina -side 1 FactionAmerica -seed 1 -maxframes 3100
+# -scenario hillbunker -logPrefix hillbunker_
+#
+# Read the HEADLESS TALLY at 1500: 0 Rangers alive, all 5 Red Guard inside. It was 3 Rangers alive.
+
+30 spawn 0 ChinaBunker 1 760 1840
+30 spawn 0 ChinaInfantryRedguard 5 760 1880 8
+60 enter 0 ChinaInfantryRedguard 0 ChinaBunker
+30 spawn 1 AmericaInfantryRanger 3 760 1660 6
+1500 tally 1 AmericaInfantryRanger
+1500 tally 0 ChinaInfantryRedguard
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index 5c486da1c..b4c4da90c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -7108,7 +7108,7 @@ Object* AIUpdateInterface::getNextMoodTarget( Bool calledByAI, Bool calledDuring
PartitionFilter *arc = NULL;
if( allowOutOfWeaponRangeTargets && obj->isKindOf( KINDOF_AIRCRAFT ) )
arc = &filterArc;
- else if( !obj->isKindOf( KINDOF_AIRCRAFT ) && container == NULL )
+ else if( !obj->isKindOf( KINDOF_AIRCRAFT ) )
{
arc = &filterHeight;
rangeToFindWithin += Weapon_elevationRangeBonus( rangeToFindWithin, FLT_MAX );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
index 7b9c88017..600c6bc1a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
@@ -130,7 +130,9 @@ Real Weapon_elevationRangeBonus( Real range, Real heightAboveTarget )
Real Weapon_elevatedRange( const Object *source, Real range, Real targetZ )
{
- if( source->isKindOf( KINDOF_AIRCRAFT ) )
+ // a man firing out of a helicopter is as high as it flies and stands on no hill
+ const Object *container = source->getContainedBy();
+ if( source->isKindOf( KINDOF_AIRCRAFT ) || ( container && container->isKindOf( KINDOF_AIRCRAFT ) ) )
return range;
return range + Weapon_elevationRangeBonus( range, source->getPosition()->z - targetZ );
@@ -2492,7 +2494,7 @@ Bool Weapon::isSourceObjectWithGoalPositionWithinAttackRange( const Object *sour
else
return false;
- Real attackRangeSqr = sqr( getAttackRange( source ) );
+ Real attackRangeSqr = sqr( Weapon_elevatedRange( source, getAttackRange( source ), target ? target->getPosition()->z : targetPos->z ) );
Real minAttackRangeSqr = sqr(m_template->getMinimumAttackRange());
#ifdef RATIONALIZE_ATTACK_RANGE
if (distSqr < minAttackRangeSqr)