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(gamelogic): a nuke cannon unpacks only for what stays in reach
Olcay Seygan196c9839141a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e78c6c194..25fe4c86d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1321,6 +1321,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- A Supply Drop Zone's cargo plane shot down on its way off the map no longer says "unit lost". Nor does a paradrop plane, an A-10, a B-52 or any other plane a general's power sends over, nor a single member of an angry mob. None of them is a unit you command, and the score never counted them as lost; only the announcer did, so with six drop zones up a "unit lost" could come every twenty seconds for planes that had already delivered.- A match no longer freezes when a unit attacking or hunting with its team changes its orders at the wrong moment. Switching targets could throw away the unit's order logic while it was still being used; the log then filled with "no state 0, in state 10" and the game stopped on one frame until Windows closed it. The order logic now lives until the switch is done.- A Nuke Cannon on guard stays deployed between targets. After every kill it packed up to drive back to the spot it was already standing on, then set up again, so a guarding cannon spent most of a fight folding and unfolding: four Technicals driven into its range one after another cost it four pack-ups and four set-ups, and now cost it none. It still packs up for a move order or a target out of reach. The Sentry Drone guards the same way. Replays recorded before this change play out differently.+- A Nuke Cannon no longer sets up for something that is about to leave. It took 3.3 seconds to unpack for any target in reach that instant, so a Humvee driving through was gone when it finished, and it packed again without a shot: 6.7 seconds with the barrel in the air for nothing. It now looks at where the target is headed and unpacks only if that target will still be in reach. Over three Hard matches the median time a cannon stayed set up rose from 75 to 140 frames in the middle one, and the set-ups that lasted under a second fell from 15 to 10. Replays recorded before this change play out differently.- Pressing Continue after a campaign mission goes straight to the next one. The main menu used to wake up behind the score screen on the way out, show its buttons and start loading its own background battle, so the menu sat on screen over the next mission's load.- The main menu no longer opens with a man screaming. The battle behind it is staged the way EA laid it out: Jarmen Kell sits on the cliff over the GLA infantry as scenery, and the extra reach high ground gives in a match let his rifle hit them from nearly twice its range a quarter of a second after the menu came up. High ground adds nothing behind the menu now, so the first soldier falls about six seconds in, under the battleship's shells, as he always did. Soldiers' death cries on the battlefield also sit back at their own volume; the boost that lifts your units' replies over the guns had been catching them too.- A civilian car no longer drives into your base in the first minute of every game. A map's civilians are owned by a computer player like any other, and the scouting pass looks for anything of that player's that can drive - so it was picking a parked car out of the scenery and sending it to a start position. A side with no faction and no build list has nothing to learn from the map and does not scout.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeployStyleAIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeployStyleAIUpdate.hindex dfbded3e7..6f4ec190a 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeployStyleAIUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeployStyleAIUpdate.h@@ -110,6 +110,7 @@ public:Bool doTurretsFunctionOnlyWhenDeployed() const { return getDeployStyleAIUpdateModuleData()->m_turretsFunctionOnlyWhenDeployed; }Bool doTurretsHaveToCenterBeforePacking() const { return getDeployStyleAIUpdateModuleData()->m_turretsMustCenterBeforePacking; }void setMyState( DeployStateTypes StateID, Bool reverseDeploy = FALSE );+ Bool willTargetStayInRange( const Weapon *weapon ) const;protected:diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cppindex 574fb64b2..bf45340fd 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp@@ -97,6 +97,26 @@ void DeployStyleAIUpdate::aiDoCommand( const AICommandParms* parms )AIUpdateInterface::aiDoCommand( parms );}+//-------------------------------------------------------------------------------------------------+/** Setting up takes as long as the data says, and a Nuke Cannon's is 3.3 seconds, then as long again+ * to pack. One that unpacked for anything in reach this instant finished just as a Humvee drove out+ * of reach and packed again without a shot, 6.7 seconds gone. So it unpacks only for a target still+ * in reach by the time it is ready, if the target keeps on going the way it is going. */+//-------------------------------------------------------------------------------------------------+Bool DeployStyleAIUpdate::willTargetStayInRange( const Weapon *weapon ) const+{+ const Object *victim = getCurrentVictim();+ if( victim == NULL || victim->getPhysics() == NULL )+ return TRUE;++ const Coord3D *velocity = victim->getPhysics()->getVelocity();+ const Real frames = (Real)getUnpackTime();+ Coord3D then = *victim->getPosition();+ then.x += velocity->x * frames;+ then.y += velocity->y * frames;+ return weapon->isWithinAttackRange( getObject(), &then );+}+//-------------------------------------------------------------------------------------------------UpdateSleepTime DeployStyleAIUpdate::update( void ){@@ -158,7 +178,8 @@ UpdateSleepTime DeployStyleAIUpdate::update( void ){case READY_TO_MOVE://We're need to deploy before we can attack.- setMyState( DEPLOY );+ if( isInGuardIdleState || willTargetStayInRange( weapon ) )+ setMyState( DEPLOY );break;case READY_TO_ATTACK://Let the AI handle attacking.