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(gameengine): helicopters turn their nose into nearly every move

Olcay Seygan0ee379af3afe
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 79c7e920f..b2b15a39a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -73,13 +73,13 @@ found and fixed — EA's own, not port damage.**
## Helicopters fly like helicopters
-- Every helicopter in the game, on every side and for every general, used to drive like a tank with rotors. Told to go somewhere behind it, a Comanche swung its nose all the way round on the spot and only then flew off nose first. Now it flies where it is sent, backwards or sideways, with its nose left where it was. Sent 300 behind itself, a Comanche turned 178 degrees before it went and was 30 out after a second and a half; now it goes tail first, never turns, and is 30 out after one second. On a long flight the nose comes round into the direction of travel while the helicopter is already on its way.
+- Every helicopter in the game, on every side and for every general, used to drive like a tank with rotors. Told to go somewhere behind it, a Comanche swung its nose all the way round on the spot and only then flew off nose first. Now it sets off at once wherever it is sent and brings its nose round on the way. Sent 300 behind itself, a Comanche turned 178 degrees before it went and was 30 out after a second and a half; now it is 30 out after one second with its nose already two thirds of the way round, and flies nose first a second and a half in. Players told us the first version of this flew backwards and sideways too much, so the nose now turns into every move longer than a helicopter's own length. A hop shorter than that is still flown sideways or backwards with the nose left alone, which is what you want when nudging one into place.
- A Comanche keeps its guns on what it is shooting at while it flies. Its cannon and missiles only fire straight ahead, so a Comanche ordered to move in the middle of a fight turned away from its target. It now holds its nose on the target and slides along beside it: one sent across in front of an Overlord it had been shooting stayed within a degree of the tank the whole way, where it used to point 84 degrees off on average. One flying past a supply truck 120 off its line now turns to it and shoots, where it used to fly straight by.
- The Comanche's chin gun turns, as the real one does, 120 degrees either side of the nose. EA bolted the cannon and the missiles straight ahead, so a Comanche had to swing its whole body round to shoot anything. Now the missiles still fly where the nose points, and the cannon tracks on its own: making a pass along four Red Guards, a Comanche turned 34 degrees where it used to turn 132, and its gun held within 4 degrees of the target while the nose stayed on the flight. A target behind the gun's reach turns the helicopter just far enough to bring it back in.
- Pull a helicopter out of a fight and it keeps shooting on the way out. Told to move while attacking, it used to drop the target at once; now it holds its gun on it for as long as the target is alive and in range, and the move goes exactly where and when it would have. A Comanche backs or slides away with its nose on the target: sent 350 straight back from three Battlemasters it fired 10 more rounds before they fell out of range, and 14 sliding off to the side, where it used to fire one. A plain move never starts a new fight; a helicopter that was not attacking anything just flies.
- A Helix with the gattling cannon on its back lets the cannon do the aiming. The cannon sits on a turret that turns all the way round, yet the whole Helix used to swing round to point at whatever it was shooting. Now it holds its heading and only the turret tracks. With a Crusader driving circles round it, a Helix that used to turn 336 degrees following the tank does not turn at all, and its cannon fired 458 times where it fired 251. Infantry shooting out of a Helix bunker leave the Helix just as free once they are on its target. The Helix's own nose gun only fires forward, so while the cannon has the target it fires only when the target crosses in front.
- A helicopter leans into the move. It dips its nose to speed up and lifts it to stop, rolls into a slide sideways and comes level again in a hover, never past about 12 degrees and never with a jerk: the lean moves by at most a degree and a half from one frame to the next.
-- Helicopters ease in and out of everything they do. Speed builds up over a moment instead of all at once, a stop flares out and settles on the exact spot it was sent to, and a turn winds up to full speed over a third of a second and winds down again before the nose arrives. Sent on a long flight behind itself, a helicopter sets off backwards at once and brings its nose round as it picks up speed; 30 out, the nose is still about 90 degrees off its course, where it used to have finished the whole turn before it got anywhere. Chinooks and Helixes fly the same way as the Comanche, and a gattling Helix keeps its gun on a tank while it slides past. A replay recorded before this change plays back differently.
+- Helicopters ease in and out of everything they do. Speed builds up over a moment instead of all at once, a stop flares out and settles on the exact spot it was sent to, and a turn winds up to full speed over a third of a second and winds down again before the nose arrives. Sent on a long flight behind itself, a helicopter sets off backwards at once and brings its nose round as it picks up speed; 30 out, the nose is still about 50 degrees off its course, where it used to have finished the whole turn before it got anywhere. Chinooks and Helixes fly the same way as the Comanche, and a gattling Helix keeps its gun on a tank while it slides past. A replay recorded before this change plays back differently.
## The frame rate cap is gone
diff --git a/GeneralsMD/Code/Data/Scenarios/helislide.txt b/GeneralsMD/Code/Data/Scenarios/helislide.txt
index 4f616364b..1450475c0 100644
--- a/GeneralsMD/Code/Data/Scenarios/helislide.txt
+++ b/GeneralsMD/Code/Data/Scenarios/helislide.txt
@@ -1,11 +1,12 @@
# Three Comanches on open ground. The first is sent 300 behind itself, then 300 beside itself, then
-# on two long flights, east and back west. The second is sent past a supply truck that cannot shoot
-# back, 120 off its line and inside its guns' 200. The third is put on an Overlord, which cannot
-# shoot at aircraft, and a second later ordered across in front of it.
+# on two long flights, east and back west, then 100 behind, 30 beside and 60 beside. The second is
+# sent past a supply truck that cannot shoot back, 120 off its line and inside its guns' 200. The
+# third is put on an Overlord, which cannot shoot at aircraft, and a second later ordered across in
+# front of it.
#
# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2 -takeover
-# -side 0 FactionAmerica -side 1 FactionChina -seed 7 -maxframes 1800
+# -side 0 FactionAmerica -side 1 FactionChina -seed 7 -maxframes 2300
# -scenario helislide -logPrefix helislide_
#
# Measured 2026-10-03 with a temporary per-frame log of position, facing and velocity. Before
@@ -26,12 +27,26 @@
# On the westward flight the nose used to finish its 170 degree turn by the time the Comanche was
# 30 out (34 frames). With the turn rate held down until the speed builds it is 85 degrees off the
# course at that point and comes round by frame 55, while the travel itself is unchanged.
+#
+# Players found the backwards and sideways flying too much, and on 2026-10-05 the nose turns into
+# every move longer than 40, starting at half the turn rate from a hover where it started at a
+# quarter. Measured the same way: sent 300 behind, the first Comanche turns 179 degrees, is 64 off
+# its course 30 out (frame 32) and within 10 by frame 44; of the 299 it flies, 20 go more than 90
+# degrees off the nose and 20 more past 45. 300 beside, the nose is on the course by frame 23. On
+# the westward flight it is 49 off at 30 out and within 10 by frame 43. 100 behind turns 178 and is
+# within 10 by frame 44; 60 beside turns 88 by frame 24; 30 beside still slides with the nose where
+# it was. Every leg finished before the next order ends within 1.1 of its goal. The truck took no damage in this run. The third
+# Comanche is shooting and keeps the old rule, under which a move of 400 or less leaves its nose on
+# the Overlord, and it does not turn at all.
30 spawn 0 AmericaVehicleComanche 1 1100 3500
150 move 0 AmericaVehicleComanche 800 3500
400 move 0 AmericaVehicleComanche 800 3800
650 move 0 AmericaVehicleComanche 2500 3500
1150 move 0 AmericaVehicleComanche 800 3500
+1750 move 0 AmericaVehicleComanche 900 3500
+1950 move 0 AmericaVehicleComanche 900 3530
+2100 move 0 AmericaVehicleComanche 900 3590
30 spawn 1 ChinaVehicleSupplyTruck 1 1300 4170
30 spawn 0 AirF_AmericaVehicleComanche 1 800 4050
150 move 0 AirF_AmericaVehicleComanche 1800 4050
diff --git a/GeneralsMD/Code/Data/Scenarios/helitypes.txt b/GeneralsMD/Code/Data/Scenarios/helitypes.txt
index 2c4477529..dceb19b54 100644
--- a/GeneralsMD/Code/Data/Scenarios/helitypes.txt
+++ b/GeneralsMD/Code/Data/Scenarios/helitypes.txt
@@ -16,6 +16,13 @@
# winding up to 6 degrees a frame. Acceleration changes by at most 0.01 a frame. Their lean,
# replayed from the logged motion, tops out at 12.5 degrees and moves 1.5 a frame at most. The
# gattling Helix takes the Crusader from 448 to 378 health while it slides across in front of it.
+#
+# From 2026-10-05 a move longer than 40 turns the nose into the flight (helislide.txt has why).
+# Sent 300 behind, the Chinook turns 179 degrees and is within 10 of its course by frame 46, the
+# Helix by frame 40; 300 beside, both by frame 25. On the westward flight the Chinook is 59 off at
+# 30 out and the Helix 36. Every leg still ends within 1.1 of the goal. The gattling Helix is
+# shooting and keeps the old rule, which on its move of 240 leaves the nose alone; the Crusader
+# goes from 448 to 378 as before.
30 spawn 0 AmericaVehicleChinook 1 1100 3200
150 move 0 AmericaVehicleChinook 800 3200
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
index f902ee9c8..41962ab95 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
@@ -232,12 +232,14 @@ public:
/**
faceTarget, when not null, is where a helicopter keeps its nose while it flies to goalPos.
- Every other locomotor ignores it. bendDist and bendCos are the next bend in the route
+ fighting says a helicopter is shooting at something, nose on it or not; it then turns its
+ nose into the flight only on a long one, so a short pull-back keeps the target in its sights.
+ Every other locomotor ignores both. bendDist and bendCos are the next bend in the route
(ClosestPointOnPathInfo), which a ground vehicle brakes into; the defaults mean none.
*/
void locoUpdate_moveTowardsPosition(Object* obj, const Coord3D& goalPos,
Real onPathDistToGoal, Real desiredSpeed, Bool *blocked, const Coord3D *faceTarget = NULL,
- Real bendDist = 0.0f, Real bendCos = 1.0f);
+ Bool fighting = FALSE, Real bendDist = 0.0f, Real bendCos = 1.0f);
void locoUpdate_moveTowardsAngle(Object* obj, Real angle);
/**
Kill any current (2D) velocity (but stay at current position, or as close as possible)
@@ -399,8 +401,8 @@ protected:
void moveTowardsPositionWheels(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
void moveTowardsPositionTreads(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
void moveTowardsPositionOther(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
- void moveTowardsPositionHover(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget);
- void moveTowardsPositionHelicopter(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget);
+ void moveTowardsPositionHover(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget, Bool fighting);
+ void moveTowardsPositionHelicopter(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget, Bool fighting);
void brakeHelicopter(Object* obj, PhysicsBehavior *physics);
PhysicsTurningType turnHelicopter(Object* obj, const Coord3D *toward, Real rateShare = 1.0f);
void steerHelicopter(Object* obj, PhysicsBehavior *physics, Real wantX, Real wantY);
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
index cf5c65188..bed2712a2 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
@@ -1147,7 +1147,7 @@ Bool Locomotor::isGroundVehicle(const Object* obj) const
//-------------------------------------------------------------------------------------------------
void Locomotor::locoUpdate_moveTowardsPosition(Object* obj, const Coord3D& goalPos,
Real onPathDistToGoal, Real desiredSpeed, Bool *blocked,
- const Coord3D *faceTarget, Real bendDist, Real bendCos)
+ const Coord3D *faceTarget, Bool fighting, Real bendDist, Real bendCos)
{
setFlag(MAINTAIN_POS_IS_VALID, false);
@@ -1297,7 +1297,7 @@ void Locomotor::locoUpdate_moveTowardsPosition(Object* obj, const Coord3D& goalP
moveTowardsPositionTreads(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);
break;
case LOCO_HOVER:
- moveTowardsPositionHover(obj, physics, goalPos, onPathDistToGoal, desiredSpeed, faceTarget);
+ moveTowardsPositionHover(obj, physics, goalPos, onPathDistToGoal, desiredSpeed, faceTarget, fighting);
break;
case LOCO_WINGS:
moveTowardsPositionWings(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);
@@ -2437,11 +2437,11 @@ void Locomotor::moveTowardsPositionWings(Object* obj, PhysicsBehavior *physics,
}
//-------------------------------------------------------------------------------------------------
-void Locomotor::moveTowardsPositionHover(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget)
+void Locomotor::moveTowardsPositionHover(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget, Bool fighting)
{
// handle the 2D component.
if (isHelicopter(obj))
- moveTowardsPositionHelicopter(obj, physics, goalPos, onPathDistToGoal, desiredSpeed, faceTarget);
+ moveTowardsPositionHelicopter(obj, physics, goalPos, onPathDistToGoal, desiredSpeed, faceTarget, fighting);
else
moveTowardsPositionOther(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);
@@ -2474,10 +2474,13 @@ void Locomotor::moveTowardsPositionHover(Object* obj, PhysicsBehavior *physics,
The planned stop is gentler than Braking (getHelicopterStopDecel), starts early enough for the
eased braking to build up, and fades out over the last HELICOPTER_STOP_EASE_FRAMES, so the
helicopter flares to a halt on the goal instead of slamming into one. The nose is a separate
- choice: on the target when there is one, turned into the flight while the goal is more than
- LONG_FLIGHT_SECONDS out at full speed and LONG_FLIGHT_MIN_DIST away, and otherwise left where it
- is, so a short hop behind or beside the helicopter is flown backwards or sideways and a long one
- turns as it goes.
+ choice: on the target when there is one, and otherwise turned into the flight as it goes. Only a
+ hop of TURN_INTO_FLIGHT_MIN_DIST or less is flown backwards or sideways with the nose left where
+ it is; a turn that has started inside a longer move carries on until the helicopter is over its
+ goal. A helicopter fighting with a gun that reaches its target without the nose turns into the
+ flight only while the goal is more than FIGHTING_TURN_SECONDS out at full speed and
+ FIGHTING_TURN_MIN_DIST away, so a short pull-back or slide keeps its nose and its missiles on
+ the target.
*/
static const Real HELICOPTER_STOP_EASE_FRAMES = 6.0f; // the planned braking fades out over about this many frames
static const Real HELICOPTER_YAW_EASE_FRAMES = 10.0f; // frames for the nose to wind up to TurnRate, or back down from it
@@ -2494,12 +2497,13 @@ Real Locomotor::getHelicopterStopDecel(BodyDamageType condition) const
return decel;
}
-void Locomotor::moveTowardsPositionHelicopter(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget)
+void Locomotor::moveTowardsPositionHelicopter(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed, const Coord3D *faceTarget, Bool fighting)
{
- const Real LONG_FLIGHT_SECONDS = 3.0f;
- const Real LONG_FLIGHT_MIN_DIST = 400.0f; // so a slow Helix still slides a short hop instead of turning for it
+ const Real TURN_INTO_FLIGHT_MIN_DIST = 40.0f; // a hop this short slides; about a helicopter's length
+ const Real FIGHTING_TURN_SECONDS = 3.0f;
+ const Real FIGHTING_TURN_MIN_DIST = 400.0f;
const Real TOO_CLOSE_TO_AIM = 1.0f; // right over the target the bearing to it is noise
- const Real LONG_FLIGHT_TURN_FROM_HOVER = 0.25f; // share of TurnRate a long flight's turn starts at from a hover
+ const Real TURN_INTO_FLIGHT_FROM_HOVER = 0.5f; // share of TurnRate the turn into the flight starts at from a hover
BodyDamageType bdt = obj->getBodyModule()->getDamageState();
Real maxSpeed = getMaxSpeedForCondition(bdt);
@@ -2516,16 +2520,18 @@ void Locomotor::moveTowardsPositionHelicopter(Object* obj, PhysicsBehavior *phys
if (fabs(faceTarget->x - pos->x) > TOO_CLOSE_TO_AIM || fabs(faceTarget->y - pos->y) > TOO_CLOSE_TO_AIM)
noseToward = faceTarget;
}
- else if (onPathDistToGoal > maxSpeed * LOGICFRAMES_PER_SECOND * LONG_FLIGHT_SECONDS
- && onPathDistToGoal > LONG_FLIGHT_MIN_DIST)
+ else if (fighting ? onPathDistToGoal > maxSpeed * LOGICFRAMES_PER_SECOND * FIGHTING_TURN_SECONDS && onPathDistToGoal > FIGHTING_TURN_MIN_DIST
+ : onPathDistToGoal > TURN_INTO_FLIGHT_MIN_DIST
+ || (m_yawRate != 0.0f && (fabs(goalPos.x - pos->x) > TOO_CLOSE_TO_AIM || fabs(goalPos.y - pos->y) > TOO_CLOSE_TO_AIM)))
{
- /* Turning into the flight is no hurry: the nose comes round as the speed builds, at
- LONG_FLIGHT_TURN_FROM_HOVER of TurnRate from a hover and all of it at full speed. At full
- TurnRate a Comanche swings 180 degrees before it has gone 30, and the turn reads as done on
- the spot. */
+ /* The nose comes round as the speed builds, at TURN_INTO_FLIGHT_FROM_HOVER of TurnRate from
+ a hover and all of it at full speed. At full TurnRate a Comanche swings 180 degrees before
+ it has gone 30, and the turn reads as done on the spot. A nose still turning when the goal
+ comes within TURN_INTO_FLIGHT_MIN_DIST keeps turning, or a hop a little longer than that
+ would stop its turn halfway and come in sideways. */
noseToward = &goalPos;
if (speed < maxSpeed)
- rateShare = LONG_FLIGHT_TURN_FROM_HOVER + (1.0f - LONG_FLIGHT_TURN_FROM_HOVER) * speed / maxSpeed;
+ rateShare = TURN_INTO_FLIGHT_FROM_HOVER + (1.0f - TURN_INTO_FLIGHT_FROM_HOVER) * speed / maxSpeed;
}
physics->setTurning(turnHelicopter(obj, noseToward, rateShare));
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index c320a677b..7a819a300 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -4011,6 +4011,7 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
turret is already on: a Helix flies where it likes while its gattling cannon tracks. */
Coord3D faceTargetPos;
const Coord3D *faceTarget = NULL;
+ Bool fighting = FALSE; // shooting at something, whether or not the nose has to point at it
updateWithdrawTarget();
if (m_curLocomotor->isHelicopter(getObject()))
{
@@ -4027,10 +4028,14 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
if (target == NULL)
target = getCurrentVictim();
}
- if (target && !target->isEffectivelyDead() && !isCarriedGunOn(target))
+ if (target && !target->isEffectivelyDead())
{
- faceTargetPos = *target->getPosition();
- faceTarget = &faceTargetPos;
+ fighting = TRUE;
+ if (!isCarriedGunOn(target))
+ {
+ faceTargetPos = *target->getPosition();
+ faceTarget = &faceTargetPos;
+ }
}
else if (!noseAims)
{
@@ -4041,6 +4046,7 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
turretTarget = getCurrentVictim();
if (turretTarget && !turretTarget->isEffectivelyDead())
{
+ fighting = TRUE;
Real shortfall = getTurretArcShortfall(tur, ThePartitionManager->getRelativeAngle2D(getObject(), turretTarget->getPosition()));
if (shortfall != 0.0f)
{
@@ -4063,7 +4069,7 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
if( speed == FAST_AS_POSSIBLE || speed > myMaxSpeed )
speed = myMaxSpeed;
m_curLocomotor->locoUpdate_moveTowardsPosition(getObject(),
- m_locomotorGoalData, 0.0f, speed, &blocked, faceTarget);
+ m_locomotorGoalData, 0.0f, speed, &blocked, faceTarget, fighting);
m_doFinalPosition = FALSE;
}
break;
@@ -4207,7 +4213,7 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
}
m_curLocomotor->locoUpdate_moveTowardsPosition(getObject(), goalPos,
- onPathDistToGoal+getPathExtraDistance(), speed, &blocked, faceTarget, bendDist, bendCos);
+ onPathDistToGoal+getPathExtraDistance(), speed, &blocked, faceTarget, fighting, bendDist, bendCos);
m_doFinalPosition = FALSE;
}