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(gameengine): gate shell lobs on the barrel, not the line

Olcay Seygana153406ea971
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 753809862..2deeb0d99 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -365,7 +365,7 @@ found and fixed, EA's own, not port damage.**
- Tell a tank to fire at the ground and it fires from where it stands. On any slope the game read the spot as hidden behind the very hill it was lying on, so a tank with the spot well inside its range drove off looking for a better angle, swinging its hull round under its own turret, and fired on the way. Pulled off a building to shell the ground 140 behind them, a Battlemaster took 84 frames to its first shell on the new spot and now takes 45, which is how long its turret needs to come round, and a pair of Scorpions that used to wander about 200 away over eight seconds now stay where they were put. Replays recorded before this play back differently.
- Tank shells fly straight at the target. EA's shell climbed ten over the highest ground on the way and dropped back down, so once the shells glowed, every Crusader shot looked like a lob: it left the barrel 12 degrees high, rose 7 over the line and hit coming down at 25 degrees. Now it flies the line, rising off it by nothing, and only a hill between the tank and its target still lifts it over. This goes for every tank cannon, the Battlemaster, Overlord, Scorpion and Marauder too.
- Artillery shells leave along the barrel. A Nuke Cannon's shell used to come out six and a half degrees under its raised barrel and jerk onto its arc; it now leaves the muzzle at the barrel's angle and the arc grows from there. Inferno and Nuke Cannon shells still lob as high as they did.
-- The Fire Base lobs its shells again. Its howitzer fires the tanks' shell, so once tank shells went straight it fired flat as well: the barrel stood 46 degrees up and the shell went out ten degrees down, straight along the line to the target. A shell from a barrel raised well over that line now follows the barrel, climbs 35 over the line on a 105 shot and drops onto the target at about 67 degrees. A tank tilted on a hillside still fires straight.
+- The Fire Base lobs its shells again. Its howitzer fires the tanks' shell, so once tank shells went straight it fired flat as well: the barrel stood 46 degrees up and the shell went out ten degrees down, straight along the line to the target. A shell from a raised barrel now follows the barrel, climbs 35 over the line on a 105 shot and drops onto the target at about 67 degrees, and the Air Force, Laser and Superweapon generals' Fire Bases do the same. Tank barrels sit level, so tank shells still fly straight, at a target close below them too.
- A SCUD or a Tomahawk flies one smooth curve to its target. A SCUD went straight up, flipped over the top at six degrees a frame, glided flat for a moment and then kinked again into its dive. Now it rolls over and comes down in a single sweep that only ever eases off, its sharpest turn 4.6 degrees a frame. The Scud Storm takes the same curve and lands within half a second of when it did. Replays recorded before this play back differently.
- Machine gun fire looks fast. The tracers of a Humvee, a Technical or a Quad Cannon crawled across the field at 300 a second and took half a second to reach a target 150 away; they now cross it in a tenth of a second, at 1,500, as streaks twice as long. Rangers, Rebels, Gattling Tanks and Cannons, Comanches and the Spectre got the same treatment. Only the picture changed: every bullet lands when it always did.
diff --git a/GeneralsMD/Code/Data/Scenarios/shellpaths.txt b/GeneralsMD/Code/Data/Scenarios/shellpaths.txt
index 87acab6b6..1644475f5 100644
--- a/GeneralsMD/Code/Data/Scenarios/shellpaths.txt
+++ b/GeneralsMD/Code/Data/Scenarios/shellpaths.txt
@@ -1,8 +1,10 @@
# Projectile flight paths, one launcher per lane, each shooting an unarmed target: tank shell
# (Crusader), lobbed shells (Inferno Cannon, Nuke Cannon), missiles (Scud Launcher, Tomahawk,
-# Rocket Buggy) and a tank shell out of a raised barrel (Fire Base, at about 105 and then 160). The
-# paths are only in the log with a temporary per-frame trace of each projectile's position and nose,
-# a DEBUG_LOG in DumbProjectileBehavior::update and MissileAIUpdate::update.
+# Rocket Buggy), tank shells out of raised barrels (the four Fire Bases, the base one at about 105 and
+# then 160; the demo battleship at 330) and tank shells on uneven ground (a Crusader up a slope at
+# 100, a Scorpion down one at 75, an Overlord at a car 40 away and 10 degrees below). The paths are
+# only in the log with a temporary per-frame trace of each projectile's position and nose, a
+# DEBUG_LOG in DumbProjectileBehavior::update and MissileAIUpdate::update.
#
# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
# -randommap 1 2 small -autoskirmish 2 -takeover
@@ -12,8 +14,12 @@
# Fire Base, barrel against the shell's first and last direction (2026-10-25), logged at launch from
# the path DumbProjectileBehavior::projectileFireAtObjectOrPosition built: its barrel stood 46 and 53
# degrees up while the shell flew the line, 9 to 12 degrees down, because StraightWhenClear never
-# looked at the barrel. It now leaves at 44 and 51 and comes down at 66 to 71. The Crusader's barrel
-# sits within 6 degrees of its line and still shoots straight; Inferno and Nuke Cannon shells are
+# looked at the barrel. It now leaves at 44 and 51 and comes down at 66 to 71. The Air Force, Laser
+# and Superweapon Fire Bases do the same (barrel 38 to 57, leave 1.4 under it). Every tank barrel
+# reads -2.5 or 0, since the logic never tilts a hull on a slope, and every tank shell, the Overlord's
+# at 10 degrees down included, still flies the line. The battleship's front turret is aimed 12 up but
+# its launch bone reads 12 down (its art faces backward and the logic pitches it the wrong way), so
+# its shells fly the line and land on the target as before. Inferno and Nuke Cannon shells are
# unchanged to the tenth of a degree.
#
# Sharpest nose turn in one frame, before and after straight tank shells, barrel-led lobs and the
@@ -37,6 +43,21 @@
30 spawn 0 AmericaFireBase 1 500 1500
30 spawn 1 AmericaVehicleMedic 1 630 1500
30 spawn 1 GLAVehicleRadarVan 1 740 1590
+30 spawn 0 AmericaPowerPlant 1 650 1400
+30 spawn 0 AirF_AmericaFireBase 1 1050 1400
+30 spawn 1 CarSedan01 1 1050 1540
+30 spawn 0 Lazr_AmericaFireBase 1 1650 1400
+30 spawn 1 CarCompact 1 1650 1560
+30 spawn 0 SupW_AmericaFireBase 1 250 1400
+30 spawn 1 CarSUV01 1 250 1260
+30 spawn 0 AmericaVehicleBattleShipDemo 1 1400 1550
+30 spawn 1 CarTaxiCab01 1 1000 1250
+30 spawn 0 ChinaTankOverlord 1 1150 1720
+30 spawn 1 CarTaxiCab02 1 1150 1650
+30 spawn 0 SupW_AmericaTankCrusader 1 850 1600
+30 spawn 1 CarCamaro 1 850 1470
+30 spawn 0 GLATankScorpion 1 750 1680
+30 spawn 1 CarTaxiCab04 1 750 1570
60 attack 0 AmericaTankCrusader 1 AmericaVehicleDozer
60 attack 0 ChinaVehicleInfernoCannon 1 ChinaVehicleDozer
@@ -45,4 +66,11 @@
60 attack 0 AmericaVehicleTomahawk 1 ChinaVehicleTroopCrawlerEmpty
60 attack 0 GLAVehicleRocketBuggy 1 ChinaVehicleListeningOutpost
60 attack 0 AmericaFireBase 1 AmericaVehicleMedic
+60 attack 0 AirF_AmericaFireBase 1 CarSedan01
+60 attack 0 Lazr_AmericaFireBase 1 CarCompact
+60 attack 0 SupW_AmericaFireBase 1 CarSUV01
+60 attack 0 AmericaVehicleBattleShipDemo 1 CarTaxiCab01
+60 attack 0 ChinaTankOverlord 1 CarTaxiCab02
+60 attack 0 SupW_AmericaTankCrusader 1 CarCamaro
+60 attack 0 GLATankScorpion 1 CarTaxiCab04
260 attack 0 AmericaFireBase 1 GLAVehicleRadarVan
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
index 5431e688d..58b3c33bd 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
@@ -62,10 +62,13 @@
//-----------------------------------------------------------------------------
const Int DEFAULT_MAX_LIFESPAN = 10 * LOGICFRAMES_PER_SECOND;
-// A StraightWhenClear shell whose barrel stands more than this over the line to its victim is being
-// lobbed, and takes the barrel's arc on open ground too. A tank's hull tilted on a slope leaves its
-// barrel a few degrees off the line and still shoots straight. The sine of 8 degrees.
-const Real STRAIGHT_SHOT_MAX_BARREL_RISE = 0.139f;
+// A StraightWhenClear shell whose barrel is raised steeper than this slope is being lobbed, and takes
+// the barrel's arc on open ground too. It is the barrel against level ground and not against the line
+// to the victim: a tank's barrel cannot dip, so a target close below it stands well under the barrel,
+// and measured that way a Paladin's shot 28 away and 13 degrees down went back to EA's arc. A tank's
+// barrel sits within 3 degrees of level (the logic does not tilt the hull on a slope); a Fire Base's
+// stands 38 to 57 degrees up. The tangent of 8 degrees.
+const Real STRAIGHT_SHOT_MAX_BARREL_SLOPE = 0.1405f;
//-----------------------------------------------------------------------------
DumbProjectileBehaviorModuleData::DumbProjectileBehaviorModuleData() :
@@ -471,16 +474,13 @@ Bool DumbProjectileBehavior::calcFlightPath(Bool recalcNumSegments)
controlPoints[1].z = highestInterveningTerrain + d->m_firstHeight;
controlPoints[2].z = highestInterveningTerrain + d->m_secondHeight;
- // The sine of the angle the barrel stands over the line to the victim, negative under it.
- Real barrelRise = (m_launchSlope * sqrtf( sqr(targetVector.X) + sqr(targetVector.Y) ) - targetVector.Z) / sqrtf( 1.0f + sqr(m_launchSlope) );
-
- if( d->m_straightWhenClear && barrelRise < STRAIGHT_SHOT_MAX_BARREL_RISE
+ if( d->m_straightWhenClear && m_launchSlope < STRAIGHT_SHOT_MAX_BARREL_SLOPE
&& ThePartitionManager->isClearLineOfSightTerrain( NULL, controlPoints[0], NULL, controlPoints[3] ) )
{
// A cannon shell flies the line to its victim. The arc above was ten over the highest ground on the
// way, so on flat ground a Crusader's shell climbed twelve degrees off the barrel and came down on
// the target at twenty five; with the glowing trail on it, every shot read as a lob. A hill in the
- // way still lifts it, and so does a barrel raised well over the line.
+ // way still lifts it, and so does a raised barrel.
controlPoints[1].z = controlPoints[0].z + targetVector.Z * targetDistance * d->m_firstPercentIndent;
controlPoints[2].z = controlPoints[0].z + targetVector.Z * targetDistance * d->m_secondPercentIndent;
}