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): empty the assault transport and keep it moving

Olcay Seygan4c48797fded5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62ea116cf..a3bd1a163 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,7 +38,8 @@ found and fixed — EA's own, not port damage.**
- Ctrl on the attack-move click no longer shells the ground instead.
- Troop Crawlers wait for their squad to climb back in, up to ten seconds.
- Their squad stays out until the area is clear, instead of piling back in after every kill.
-- Every man aboard gets out to fight; a scratch or a late boarding used to bench him.
+- Every man aboard gets out to fight; nobody sits out the battle waiting to be patched up.
+- An emptied Crawler carries on with your order instead of idling behind the fight.
- Attack-move state is saved now, instead of coming back as random memory.
## Your units stop shooting corpses
@@ -211,7 +212,7 @@ found and fixed — EA's own, not port damage.**
- Widescreen resolutions are back in the options menu.
- Zoom further out, with the whole map drawn instead of black corners.
- The zoom-out ceiling is the same for everyone; no setting buys you a wider view.
-- The wheel covers that whole range in about thirteen notches instead of thirty-eight.
+- The wheel covers that whole range in about six notches instead of thirty-eight.
- Zoom toward the cursor works; the spot under your pointer stays there.
- The camera turns in whole 45-degree steps, instantly, while you hold the key.
- Edge scrolling works windowed, and scroll speed no longer follows your frame rate.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.h
index d4c6b4377..126c48142 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.h
@@ -49,7 +49,7 @@ enum AssaultStateTypes
class AssaultTransportAIUpdateModuleData : public AIUpdateModuleData
{
public:
- Real m_membersGetHealedAtLifeRatio;
+ Real m_membersGetHealedAtLifeRatio; // parsed for the shipped INI's sake; nobody rides back in to heal any more
Real m_clearRangeRequiredToContinueAttackMove;
AssaultTransportAIUpdateModuleData()
@@ -103,8 +103,6 @@ public:
UpdateSleepTime calcSleepTime();
void reset();
- Bool isMemberWounded( const Object *member ) const; //Member requires medical attention?
- Bool isMemberHealthy( const Object *member ) const; //Member has full health?
Bool isAssaultAreaClear() const; //Nothing hostile left near the transport?
void retrieveMembers();
void giveFinalOrders();
@@ -112,7 +110,6 @@ public:
protected:
ObjectID m_memberIDs[ MAX_TRANSPORT_SLOTS ];
- Bool m_memberHealing[ MAX_TRANSPORT_SLOTS ];
Coord3D m_attackMoveGoalPos;
mutable ObjectID m_designatedTarget;
AssaultStateTypes m_state;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp
index be207eecd..704330972 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp
@@ -63,12 +63,11 @@ Bool AssaultTransport_shouldRetrieveMembers( Bool membersOutside, Bool membersFi
}
//-------------------------------------------------------------------------------------------------
-/** Does this passenger get out and fight?
- * Everybody aboard does, whatever he is and however scratched he is - the only man who stays in
- * is one who is still being patched up. */
-Bool AssaultTransport_shouldDeployMember( Bool contained, Bool beingHealed )
+/** Is the transport standing there attacking with nobody left to put on the ground?
+ * Its own weapon only deploys troops, so once it is empty the attack is theatre - drive on. */
+Bool AssaultTransport_nothingLeftToDeploy( Bool isAttacking, Bool anyoneInside )
{
- return contained && !beingHealed;
+ return isAttacking && !anyoneInside;
}
//-------------------------------------------------------------------------------------------------
@@ -97,7 +96,6 @@ void AssaultTransportAIUpdate::reset()
for( int i = 0; i < m_currentMembers; i++ )
{
m_memberIDs[ i ] = INVALID_ID;
- m_memberHealing[ i ] = FALSE;
}
m_currentMembers = 0;
m_attackMoveGoalPos.zero();
@@ -200,14 +198,12 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )
if( m_currentMembers - 1 > i )
{
//Move the last slot to this slot to keep array contiguous.
- m_memberIDs[ i ] = m_memberIDs[ m_currentMembers - 1 ];
- m_memberHealing[ i ] = m_memberHealing[ m_currentMembers - 1 ];
+ m_memberIDs[ i ] = m_memberIDs[ m_currentMembers - 1 ];
}
else
{
//Just clean out last slot.
- m_memberIDs[ i ] = INVALID_ID;
- m_memberHealing[ i ] = FALSE;
+ m_memberIDs[ i ] = INVALID_ID;
}
if( ai )
{
@@ -262,18 +258,27 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )
//Generally only player commands allow this, so this flag allows AI commands to do the same.
passenger->getAI()->setAllowedToChase( TRUE );
}
-
- //Check if the passenger is wounded below threshhold (if so make sure we heal him before ordering him to fight!)
- if( isMemberWounded( passenger ) )
- {
- m_memberHealing[ m_currentMembers ] = TRUE;
- }
m_currentMembers++;
}
}
}
+ //Nobody left to put on the ground: stop posing with the deploy weapon and get on with the order.
+ if( AssaultTransport_nothingLeftToDeploy( transport->testStatus( OBJECT_STATUS_IS_ATTACKING ),
+ contain && contain->getContainCount() > 0 ) )
+ {
+ if( m_isAttackMove && getAIStateType() != AI_ATTACK_MOVE_TO )
+ {
+ aiAttackMoveToPosition( &m_attackMoveGoalPos, NO_MAX_SHOTS_LIMIT, CMD_FROM_AI );
+ }
+ else if( !m_isAttackMove )
+ {
+ aiIdle( CMD_FROM_AI );
+ }
+ return UPDATE_SLEEP_NONE;
+ }
+
//Keep track of the average position of all combat units assigned to me.
Coord3D fighterCentroidPos;
UnsignedInt fightingMembers = 0;
@@ -296,44 +301,24 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )
if( member && ai )
{
- Bool contained = member->isContained();
- Bool wounded = isMemberWounded( member );
- if( isMemberHealthy( member ) )
+ if( member->isContained() )
{
- //Patched up - he is a fighter again.
- m_memberHealing[ i ] = FALSE;
- }
- if( AssaultTransport_shouldDeployMember( contained, m_memberHealing[ i ] ) )
- {
- //Everyone rides out to fight - a scratch or a late boarding used to keep a man
- //inside for the whole battle.
+ //Everyone rides out to fight, however scratched up he is. Retail kept anyone
+ //short of full health inside and sent the wounded back in to be patched up.
ai->aiExit( transport, CMD_FROM_AI );
}
- if( !contained )
+ else
{
- if( wounded )
- {
- //Order wounded members back to get healed, and keep them in until they are
- //whole again rather than bouncing them straight back out.
- m_memberHealing[ i ] = TRUE;
- if( ai->getAIStateType() != AI_ENTER )
- {
- ai->aiEnter( transport, CMD_FROM_AI );
- }
- }
- else
- {
- //Increment the number of fighters and their position.
- fighterCentroidPos.add( member->getPosition() );
- fightingMembers++;
+ //Increment the number of fighters and their position.
+ fighterCentroidPos.add( member->getPosition() );
+ fightingMembers++;
- if( !ai->isMoving() )
+ if( !ai->isMoving() )
+ {
+ if( ai->getGoalObject() != designatedTarget )
{
- if( ai->getGoalObject() != designatedTarget )
- {
- //Okay, this dude is outside and waiting... order him to attack the designated target
- ai->aiAttackObject( designatedTarget, NO_MAX_SHOTS_LIMIT, CMD_FROM_AI );
- }
+ //Okay, this dude is outside and waiting... order him to attack the designated target
+ ai->aiAttackObject( designatedTarget, NO_MAX_SHOTS_LIMIT, CMD_FROM_AI );
}
}
}
@@ -460,36 +445,6 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )
return UPDATE_SLEEP_NONE;
}
-//-------------------------------------------------------------------------------------------------
-Bool AssaultTransportAIUpdate::isMemberWounded( const Object *member ) const
-{
- const AssaultTransportAIUpdateModuleData *data = getAssaultTransportAIUpdateModuleData();
- BodyModuleInterface *body = member->getBodyModule();
- if( body )
- {
- Real ratio = body->getHealth() / body->getMaxHealth();
- if( ratio < data->m_membersGetHealedAtLifeRatio )
- {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-//-------------------------------------------------------------------------------------------------
-Bool AssaultTransportAIUpdate::isMemberHealthy( const Object *member ) const
-{
- BodyModuleInterface *body = member->getBodyModule();
- if( body )
- {
- if( body->getHealth() == body->getMaxHealth() )
- {
- return TRUE;
- }
- }
- return FALSE;
-}
-
//-------------------------------------------------------------------------------------------------
/** Is there anything left worth fighting near the transport? ClearRangeRequiredToContinueAttackMove
* is the INI knob EA declared for exactly this and never read. */
@@ -585,7 +540,8 @@ void AssaultTransportAIUpdate::xfer( Xfer *xfer )
for( int i = 0; i < m_currentMembers; i++ )
{
xfer->xferObjectID( &(m_memberIDs[ i ]) );
- xfer->xferBool( &(m_memberHealing[ i ]) );
+ Bool obsoleteHealingFlag = FALSE; // members no longer go back in to heal; keeps the format
+ xfer->xferBool( &obsoleteHealingFlag );
}
xfer->xferCoord3D( &m_attackMoveGoalPos );
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index a257e8c4f..43b57b060 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -785,20 +785,19 @@ TEST(ctrl_is_force_fire_only_while_the_attack_move_cursor_is_down)
orders now board on this one rule. */
extern Bool AssaultTransport_shouldRetrieveMembers( Bool membersOutside, Bool membersFighting, Bool areaClear );
extern Bool AssaultTransport_waitingForBoarding( Bool membersOutside, UnsignedInt framesRemaining );
-extern Bool AssaultTransport_shouldDeployMember( Bool contained, Bool beingHealed );
+extern Bool AssaultTransport_nothingLeftToDeploy( Bool isAttacking, Bool anyoneInside );
-TEST(troop_crawler_deploys_everyone_aboard)
+TEST(troop_crawler_drives_on_once_it_is_empty)
{
- /* aboard and fit to fight: out he goes, whatever he is and however scratched. Retail wanted
- full health and exempted anyone who boarded after the attack order, so a squad that had
- fought once rode the rest of the battle out inside. */
- CHECK( AssaultTransport_shouldDeployMember( true, false ) );
+ /* attacking with an empty hold: the crawler's own weapon only unloads troops, so it is
+ standing there doing nothing - resume the order instead. */
+ CHECK( AssaultTransport_nothingLeftToDeploy( true, false ) );
- /* still being patched up: he stays in until whole, or he would bounce straight back out. */
- CHECK( !AssaultTransport_shouldDeployMember( true, true ) );
+ /* somebody still aboard: stay put, he is about to be deployed. */
+ CHECK( !AssaultTransport_nothingLeftToDeploy( true, true ) );
- /* already outside: nothing to order. */
- CHECK( !AssaultTransport_shouldDeployMember( false, false ) );
+ /* not attacking at all: whatever it is doing is not our business. */
+ CHECK( !AssaultTransport_nothingLeftToDeploy( false, false ) );
}
TEST(troop_crawler_picks_its_troops_back_up_only_when_the_fight_is_over)