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): keep the spectre orbit and re-aim on the called area

Olcay Seygan964e6f1e6ecf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d26cd2d3..141001f1f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -304,7 +304,7 @@ found and fixed — EA's own, not port damage.**
- Losing the airfield no longer leaves its aircraft circling rubble forever.
- Repaired aircraft fly to the rally point instead of hovering over the pad.
- Infantry leaving a captured building follow its rally point too.
-- The Spectre gunship goes where you point it. A right click used to slide the gun's crosshair only inside the first circle while the plane kept circling the old one, and the gun only walked its fire over while it was already shooting, so a crosshair dragged out of reach froze on the old spot for the rest of the orbit. Now every right click is a new orbit: the plane banks over to it, the cannon rakes across to the click, and the howitzer follows it there. It also opens up on enemies around the crosshair instead of hosing empty ground beside them, the way EA had only let the computer's gunships do. Measured on Alpine Assault: re-aimed twice inside one orbit, the shells were landing on each new spot about two and a half seconds after the click, and three of four Battlemasters parked just beside the first new spot were dead by the end of the orbit.
+- The Spectre gunship's crosshair answers your right click. Its gun only walked its fire toward a new spot while it was already shooting, so moving the crosshair onto ground the gun could not reach that moment froze the fire on the old spot for the rest of the orbit. Now the cannon rakes across to every click inside the target circle and the howitzer follows it there; a click outside the circle stops at its edge, as before, and the plane keeps circling where you called it. It also opens up on enemies anywhere in the circle when the crosshair sits on empty ground, which EA had only let the computer's gunships do. Yours and the computer's now follow the same rules. Measured on Alpine Assault: moved three times in one orbit, the first move had shells on the new spot under two seconds after the click, and four Battlemasters parked in the circle were all dead before the plane left.
- Right-click a selected factory or barracks and its rally point is gone. Before, a rally point could be moved and that was all.
- A Chinook unloads its passengers one at a time, not stacked in one frame.
- Campaign reinforcements flown in by Chinook land again. That one-at-a-time unloading sent a mission's scripted Chinooks home with their cargo still aboard, so on the second American mission the dozers announced at the docks never got off, and neither did the next one.
diff --git a/GeneralsMD/Code/Data/Scenarios/spectre_reaim.txt b/GeneralsMD/Code/Data/Scenarios/spectre_reaim.txt
index 4105736b6..d628deb82 100644
--- a/GeneralsMD/Code/Data/Scenarios/spectre_reaim.txt
+++ b/GeneralsMD/Code/Data/Scenarios/spectre_reaim.txt
@@ -1,15 +1,18 @@
-# Spectre Gunship re-aimed twice with the right click. Called on the town crossroads of Alpine
-# Assault (1310,1290), moved at frame 360 to the rail yard (760,920), where four Battlemasters
-# stand 60 units off the click, then at frame 520 to the street at 1100,1500. The SPECTRE line of
-# each re-aim is in the log; the orbit opens around frame 300 and closes 450 frames later.
+# Spectre Gunship re-aimed with the right click inside the area it was called to. Called on the
+# town crossroads of Alpine Assault (1310,1290), moved at frame 360 to 1180,1200, where four
+# Battlemasters stand, then at frame 480 to 1420,1380, then at frame 600 far out to the rail yard
+# (760,920), which the gunship keeps on the edge of its own circle, 175 units from the call.
+# The orbit stays round 1310,1290 throughout. The SPECTRE line of each re-aim is in the log; the
+# orbit opens around frame 300 and closes 450 frames later.
#
# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
# -map "Maps\Alpine Assault\Alpine Assault.map" -autoskirmish 2 -takeover
# -side 0 FactionAmerica -side 1 FactionChina -seed 1 -maxframes 900
# -scenario spectre_reaim -logPrefix spectre_
10 spawn 0 AmericaCommandCenter 1 start0:240:60
-10 spawn 1 ChinaTankBattleMaster 4 800 980 30
+10 spawn 1 ChinaTankBattleMaster 4 1190 1210 30
20 power 0 AmericaCommandCenter 1310 1290 SuperweaponSpectreGunship
-360 reaim 0 AmericaJetSpectreGunship 760 920
-520 reaim 0 AmericaJetSpectreGunship 1100 1500
+360 reaim 0 AmericaJetSpectreGunship 1180 1200
+480 reaim 0 AmericaJetSpectreGunship 1420 1380
+600 reaim 0 AmericaJetSpectreGunship 760 920
880 tally 1 ChinaTankBattleMaster
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp
index a34cf8df4..cc35572ff 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp
@@ -299,18 +299,10 @@ void SpectreGunshipUpdate::setSpecialPowerOverridableDestination( const Coord3D
Object *me = getObject();
if( !me->isDisabled() )
{
- // The new aim is the new centre: the orbit, the attack area and the wide acquire all follow it,
- // where EA kept them on the first click and clamped every later one to 175 units of it.
- Region3D mapRegion;
- TheTerrainLogic->getExtent( &mapRegion );
- Coord3D aim = *loc;
- aim.x = min( mapRegion.hi.x, max( mapRegion.lo.x, aim.x ) );
- aim.y = min( mapRegion.hi.y, max( mapRegion.lo.y, aim.y ) );
- m_overrideTargetDestination = aim;
- m_initialTargetPosition = aim;
- m_positionToShootAt = aim;
- DEBUG_LOG(("SPECTRE: frame %d gunship %d re-aimed at (%.0f,%.0f)\n",
- TheGameLogic->getFrame(), (Int)me->getID(), aim.x, aim.y));
+ // The orbit stays on the area the gunship was called to; update() clamps this aim inside it.
+ m_overrideTargetDestination = *loc;
+ DEBUG_LOG(("SPECTRE: frame %d gunship %d re-aimed at (%.0f,%.0f), area (%.0f,%.0f)\n",
+ TheGameLogic->getFrame(), (Int)me->getID(), loc->x, loc->y, m_initialTargetPosition.x, m_initialTargetPosition.y));
if( me->getControllingPlayer() && me->getControllingPlayer()->isLocalPlayer() )
{
@@ -458,7 +450,23 @@ UpdateSleepTime SpectreGunshipUpdate::update()
if ( shipAI)
{
- shipAI->aiMoveToPosition( &m_satellitePosition, CMD_FROM_AI );
+ shipAI->aiMoveToPosition( &m_satellitePosition, CMD_FROM_AI );
+ }
+
+ Real constraintRadius = data->m_attackAreaRadius - data->m_targetingReticleRadius;
+
+ //Constrain Target Override to the targeting radius
+ Coord3D overrideTargetDelta = m_initialTargetPosition;
+ overrideTargetDelta.sub( &m_overrideTargetDestination );
+ if ( overrideTargetDelta.length() > constraintRadius )
+ {
+ overrideTargetDelta.normalize();
+ overrideTargetDelta.x *= constraintRadius;
+ overrideTargetDelta.y *= constraintRadius;
+
+ m_overrideTargetDestination.x = m_initialTargetPosition.x - overrideTargetDelta.x;
+ m_overrideTargetDestination.y = m_initialTargetPosition.y - overrideTargetDelta.y;
+
}
m_attackAreaDecal.setPosition( m_initialTargetPosition );
@@ -605,8 +613,7 @@ UpdateSleepTime SpectreGunshipUpdate::update()
attackPositionWithRandomOffset.x = m_gattlingTargetPosition.x + GameLogicRandomValue( -offs, offs );
attackPositionWithRandomOffset.y = m_gattlingTargetPosition.y + GameLogicRandomValue( -offs, offs );
attackPositionWithRandomOffset.z = m_gattlingTargetPosition.z;
- TheWeaponStore->createAndFireTempWeapon( wt, gunship, &attackPositionWithRandomOffset );
- m_howitzerFireSound.setObjectID(gunship->getID());
+ TheWeaponStore->createAndFireTempWeapon( wt, gunship, &attackPositionWithRandomOffset ); m_howitzerFireSound.setObjectID(gunship->getID());
TheAudio->addAudioEvent( &m_howitzerFireSound );
}