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
fix(gameengine): helicopter hard stop unwinds its pull before a standstill
Olcay Seygan72255f9631d5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e808e9c1c..fd2346ab8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -77,7 +77,7 @@ found and fixed — EA's own, not port damage.**- 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.-- Comanches fire their rocket pods sooner. Sent at a spot 800 away, a Comanche used to ease to a stop on the very edge of range before the first rocket left; now it flies in at full speed, fires the moment the spot comes into range and brakes under its own volley. Four of them fired 6 seconds after the click, where they took 7.6 to 8.4. The rockets steer for the spot by themselves, so the helicopter no longer turns its nose to within 2 degrees of it first: a spot beside a hovering Comanche is hit 3 frames sooner, one behind it 3 frames sooner too. A Comanche whose pods are still reloading fires the moment they are full, as before. Replays recorded before this change, with a helicopter firing at the ground in them, will not play back the same.+- Comanches fire their rocket pods sooner. Sent at a spot 800 away, a Comanche used to ease to a stop on the very edge of range before the first rocket left; now it flies in at full speed, fires the moment the spot comes into range and brakes under its own volley, then holds where it stopped. Braking that hard used to carry it past a standstill: it ran 57 past the edge of range and then backed 33 of that up again while it fired. Now it settles within one unit of where it first comes to rest. Any helicopter stopped hard at full speed holds its spot the same way. Four of them fired 6 seconds after the click, where they took 7.6 to 8.4. The rockets steer for the spot by themselves, so the helicopter no longer turns its nose to within 2 degrees of it first: a spot beside a hovering Comanche is hit 3 frames sooner, one behind it 3 frames sooner too. A Comanche whose pods are still reloading fires the moment they are full, as before. Replays recorded before this change, with a helicopter firing at the ground in them, will not play back the same.- 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 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.diff --git a/GeneralsMD/Code/Data/Scenarios/comanchepods.txt b/GeneralsMD/Code/Data/Scenarios/comanchepods.txtindex 620f797b1..7722f3b50 100644--- a/GeneralsMD/Code/Data/Scenarios/comanchepods.txt+++ b/GeneralsMD/Code/Data/Scenarios/comanchepods.txt@@ -16,6 +16,12 @@# 1250 3850, 150 to the side 13-16 10-13# 1100 3700, 150 behind 28-31 25-28 the 180 degree turn is the rest#+# On the 800 run each Comanche crosses the edge of range at full speed and brakes from there. It+# came to rest 57 past the edge and then backed 33 of that up again under its own volley; with the+# helicopter's pull eased off before a standstill (steerHelicopter) it comes to rest 60 past and+# moves 0.9 after. helislide and hitrun end every leg where they did, within 0.04; helitypes plays+# to the same CRC.+## A Comanche whose pods are reloading (one fired 400 frames earlier) waits out the 30 second clip# reload before and after, 617-620 frames, while the three beside it fire on frame 1.diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cppindex bed2712a2..50338e5d4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp@@ -2573,18 +2573,27 @@ void Locomotor::moveTowardsPositionHelicopter(Object* obj, PhysicsBehavior *physHELICOPTER_VELOCITY_FRAMES, no harder than its Acceleration, or its Braking when that slows the wayit is going; and the pull it actually applies moves towards that by at most anHELICOPTER_ACCEL_EASE_FRAMES share of its Acceleration a frame, so a start, a stop or a change- of direction builds up and dies away instead of jumping.+ of direction builds up and dies away instead of jumping. The ask is also never more than the pull+ can wind down from in the velocity error left, the eased stop of the pull itself: without that a+ hard stop from full speed (a Comanche whose rocket pods come into range) carried its braking past+ a standstill and backed 33 the way it came.*/void Locomotor::steerHelicopter(Object* obj, PhysicsBehavior *physics, Real wantX, Real wantY){BodyDamageType bdt = obj->getBodyModule()->getDamageState();Real maxAccel = getMaxAcceleration(bdt);+ Real jerk = maxAccel / HELICOPTER_ACCEL_EASE_FRAMES;const Coord3D *vel = physics->getVelocity();- Real ax = (wantX - vel->x) / HELICOPTER_VELOCITY_FRAMES;- Real ay = (wantY - vel->y) / HELICOPTER_VELOCITY_FRAMES;+ Real errX = wantX - vel->x;+ Real errY = wantY - vel->y;+ Real ax = errX / HELICOPTER_VELOCITY_FRAMES;+ Real ay = errY / HELICOPTER_VELOCITY_FRAMES;Real ask = sqrt(ax*ax + ay*ay);Real limit = (ax * vel->x + ay * vel->y < 0.0f) ? getBraking() : maxAccel;+ Real unwind = sqrt(2.0f * jerk * sqrt(errX*errX + errY*errY));+ if (limit > unwind)+ limit = unwind;if (ask > limit){ax *= limit / ask;@@ -2594,7 +2603,6 @@ void Locomotor::steerHelicopter(Object* obj, PhysicsBehavior *physics, Real wantReal changeX = ax - m_driveAccelX;Real changeY = ay - m_driveAccelY;Real change = sqrt(changeX*changeX + changeY*changeY);- Real jerk = maxAccel / HELICOPTER_ACCEL_EASE_FRAMES;if (change > jerk){changeX *= jerk / change;