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): unarmed units drive to the rally point

Olcay Seyganaf213058f7b5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b4f30b80c..6d5f871b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -100,6 +100,7 @@ found and fixed — EA's own, not port damage.**
- A unit on attack move looks half as far again as it can shoot, and nothing to do with how far it can see. The two have nothing to do with each other: artillery outranges its own eyes and found nothing this way, while a scout with a long view stopped for things it would spend a minute driving to. One rule, measured against the gun.
- An aircraft only makes that long look forward. It cannot stop and it turns in a wide circle, so a target off to one side or behind is one it has to come all the way round for - which is how a flight of bombers ends up orbiting a corner of the map instead of arriving. Inside sixty degrees of the nose it looks the full distance; outside it, no further than it can already shoot, so it still takes what it is passing.
- Attack-moving through a base shoots the base; buildings were filtered out.
+- A new unit heading for its rally point attack-moves there, so it fights what it meets on the way. A dozer, a supply truck or an empty ambulance has nothing to fight with, and it now just drives there instead of wearing the attack-move order and its colour the whole trip.
- Aircraft make their pass, fly home, rearm and resume your order.
- Nothing walks off the map chasing a target that keeps retreating.
- Being pulled off a chase no longer blinds a unit on the way back. It owes the order a stretch of ground before it is allowed to drive to another fight, and it used to spend that stretch refusing to see anything at all - so a tank rolled past an enemy parked beside it without firing a shot. It still will not go chasing during that stretch. It will shoot whatever is already in front of its gun, which costs the advance nothing.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index 6883b1267..37e679652 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -1138,11 +1138,16 @@ UpdateSleepTime AIUpdateInterface::update( void )
// set a rally point, attack moves to it - so it stops and fights whatever it runs into on the way
// instead of taking the shots and walking on. This is checked right after the machine ran,
// because finishing (or failing) the exit path is what drops us into idle in the first place.
+ // Something with nothing to fight with - a dozer, a supply truck, an empty ambulance - has no
+ // reason to stop for what it meets, so it takes the plain move instead.
if (m_hasExitProductionRallyPoint && getAIStateType() == AI_IDLE)
{
Coord3D rallyPoint = m_exitProductionRallyPoint;
m_hasExitProductionRallyPoint = FALSE;
- privateAttackMoveToPosition( &rallyPoint, NO_MAX_SHOTS_LIMIT, CMD_FROM_AI );
+ if (getObject()->isAbleToAttack())
+ privateAttackMoveToPosition( &rallyPoint, NO_MAX_SHOTS_LIMIT, CMD_FROM_AI );
+ else
+ privateMoveToPosition( &rallyPoint, CMD_FROM_AI );
stRet = STATE_CONTINUE;
}