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): spectre gunship orbits and fires where you right-click

Olcay Seygan84aeadb22ed4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b6aace6a3..9d26cd2d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -304,6 +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.
- 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
new file mode 100644
index 000000000..4105736b6
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/spectre_reaim.txt
@@ -0,0 +1,15 @@
+# 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.
+#
+# 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
+20 power 0 AmericaCommandCenter 1310 1290 SuperweaponSpectreGunship
+360 reaim 0 AmericaJetSpectreGunship 760 920
+520 reaim 0 AmericaJetSpectreGunship 1100 1500
+880 tally 1 ChinaTankBattleMaster
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h
index 424d05467..c8f519b81 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h
@@ -87,6 +87,7 @@ enum ScenarioActionType
SCENARIO_ACTION_FORCEATTACK, ///< forceattack <slot> <selector> <targetSlot> <targetSelector>; the attack key's click on one unit, as MSG_DO_FORCE_ATTACK_OBJECT
SCENARIO_ACTION_WEAPONAT, ///< weaponat <slot> <selector> <position> [primary|secondary|tertiary]; a FIRE_WEAPON button's click on the ground, as MSG_DO_WEAPON_AT_LOCATION; tertiary when left out
SCENARIO_ACTION_FORCEGROUND, ///< forceground <slot> <selector> <position>; the attack key's click on the ground, as MSG_DO_FORCE_ATTACK_GROUND
+ SCENARIO_ACTION_REAIM, ///< reaim <slot> <selector> <position>; a right click that moves a running power's aim (the Spectre Gunship's), as MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION
SCENARIO_ACTION_RESPOND ///< respond <slot> <selector> <position>; from now, how long each unit takes to point its gun at the position, fire with it pointed there, and get closer to it
};
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp
index 6b788e666..a34cf8df4 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp
@@ -299,7 +299,18 @@ void SpectreGunshipUpdate::setSpecialPowerOverridableDestination( const Coord3D
Object *me = getObject();
if( !me->isDisabled() )
{
- m_overrideTargetDestination = *loc;
+ // 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));
if( me->getControllingPlayer() && me->getControllingPlayer()->isLocalPlayer() )
{
@@ -450,22 +461,6 @@ UpdateSleepTime SpectreGunshipUpdate::update()
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 );
m_targetingReticleDecal.setPosition( m_overrideTargetDestination );
@@ -558,9 +553,8 @@ UpdateSleepTime SpectreGunshipUpdate::update()
- // WE WANT THE WIDE_RANGE AUTOACQUIRE POWER DISABLED FOR HUMAN PLAYERS
- // SO THAT THE SPECTREGUNSHIP REQUIRES BABYSITTING AT ALL TIMES
- if (gunship->getControllingPlayer()->getPlayerType() != PLAYER_HUMAN )
+ // EA kept this wide acquire from human players so the gunship needed babysitting, which
+ // left it hosing the empty reticle while enemies stood beside it. Everyone gets it now.
{
if ( ! validTargetObject )
{
@@ -612,7 +606,6 @@ UpdateSleepTime SpectreGunshipUpdate::update()
attackPositionWithRandomOffset.y = m_gattlingTargetPosition.y + GameLogicRandomValue( -offs, offs );
attackPositionWithRandomOffset.z = m_gattlingTargetPosition.z;
TheWeaponStore->createAndFireTempWeapon( wt, gunship, &attackPositionWithRandomOffset );
-
m_howitzerFireSound.setObjectID(gunship->getID());
TheAudio->addAudioEvent( &m_howitzerFireSound );
@@ -629,22 +622,20 @@ UpdateSleepTime SpectreGunshipUpdate::update()
// GATTLING TARGETING LOGIC------------------------------------------
// TheSuperHackers @fix A missing client-side particle template used to switch off the
// gattling's aiming and its howitzer counter, which are logic state and CRC'd.
- if (gattling && gattling->testStatus( OBJECT_STATUS_IS_FIRING_WEAPON) )
+ // The aim walks toward the next good spot whether or not the gun is firing: EA's walked only
+ // while it fired, so a re-aim beyond the gun's reach left it stuck on the old spot for good.
+ // The howitzer still waits for the gattling to have plinked the spot.
+ Bool gattlingFiring = gattling && gattling->testStatus( OBJECT_STATUS_IS_FIRING_WEAPON );
+ if (gattling)
{
-
-
-
- // I am going to wind my gattling gun toward the next good spot,
- //whether an object's position or a cursor position
-
-
Coord3D delta = m_positionToShootAt;
delta.sub( &m_gattlingTargetPosition );
Real dist = delta.length();
if ( dist < data->m_strafingIncrement )
{
m_gattlingTargetPosition = m_positionToShootAt;
- ++m_okToFireHowitzerCounter;
+ if ( gattlingFiring )
+ ++m_okToFireHowitzerCounter;
}
else
{
@@ -653,6 +644,10 @@ UpdateSleepTime SpectreGunshipUpdate::update()
delta.scale( data->m_strafingIncrement );
m_gattlingTargetPosition.add( &delta );
}
+ }
+
+ if (gattlingFiring)
+ {
const Player *localPlayer = ThePlayerList->getLocalPlayer();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
index 74541655d..5be0d9f80 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
@@ -219,6 +219,8 @@ static Bool parseActionType( const AsciiString &token, ScenarioActionType *actio
*action = SCENARIO_ACTION_WEAPONAT;
else if (token == "forceground")
*action = SCENARIO_ACTION_FORCEGROUND;
+ else if (token == "reaim")
+ *action = SCENARIO_ACTION_REAIM;
else if (token == "respond")
*action = SCENARIO_ACTION_RESPOND;
else
@@ -305,6 +307,7 @@ static Int tokensNeededFor( ScenarioActionType action )
case SCENARIO_ACTION_CONSTRUCT: return SCENARIO_TOKENS_MOVE;
case SCENARIO_ACTION_WEAPONAT: return SCENARIO_TOKENS_MOVE;
case SCENARIO_ACTION_FORCEGROUND: return SCENARIO_TOKENS_MOVE;
+ case SCENARIO_ACTION_REAIM: return SCENARIO_TOKENS_MOVE;
case SCENARIO_ACTION_RESPOND: return SCENARIO_TOKENS_MOVE;
case SCENARIO_ACTION_STANCE: return SCENARIO_TOKENS_STANCE;
case SCENARIO_ACTION_SHIFTATTACK: return SCENARIO_TOKENS_ATTACK;
@@ -390,6 +393,7 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *a
case SCENARIO_ACTION_CONSTRUCT:
case SCENARIO_ACTION_WEAPONAT:
case SCENARIO_ACTION_FORCEGROUND:
+ case SCENARIO_ACTION_REAIM:
case SCENARIO_ACTION_RESPOND:
{
Int next = SCENARIO_ORDER_POSITION_TOKEN;
@@ -1610,6 +1614,21 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Co
return TRUE;
}
+ case SCENARIO_ACTION_REAIM:
+ {
+ // the right click CommandXlat sends while a power's aim can be moved; the dispatcher destroys the group
+ GameMessage *msg = newInstance( GameMessage )( GameMessage::MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION );
+ msg->friend_setPlayerIndex( player->getPlayerIndex() );
+ msg->appendLocationArgument( dest );
+ msg->appendIntegerArgument( SPECIAL_INVALID );
+ msg->appendObjectIDArgument( INVALID_ID );
+ TheGameLogic->logicMessageDispatcher( msg, group );
+ msg->deleteInstance();
+ DEBUG_LOG(("SCENARIO: frame %d reaim slot %d '%s' x%d at (%.0f,%.0f)\n",
+ action.frame, action.slot, action.selector.str(), taken, dest.x, dest.y));
+ return TRUE;
+ }
+
case SCENARIO_ACTION_STOP:
{
group->groupIdle( CMD_FROM_SCRIPT );