Fix for Deployed units (Nuke Cannon) - #3035
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGuard.cpp | Reuses guard attack behavior across successive targets and skips unnecessary return movement when already near the guard center; no independently actionable defect was established. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp | Adds out-of-range deploy reversal, but its placement after timer completion misses the final deployment frame. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Deploy update] --> B{Deploy timer expired?}
B -- Yes --> C[State becomes READY_TO_ATTACK]
B -- No --> D[State remains DEPLOY]
C --> E{Trying to attack out of range<br/>and state is DEPLOY?}
D --> E
E -- Yes --> F[Reverse to UNDEPLOY]
E -- No after timer expiry --> G[Remain fully deployed]
Prompt To Fix All With AI
### Issue 1
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp:149
**Deployment reversal misses expiry frame**
When the target leaves range on the update where the deployment timer expires, the preceding timer block changes `m_state` from `DEPLOY` to `READY_TO_ATTACK` before this condition runs. The `m_state == DEPLOY` check then prevents reversal, causing the unit to finish deploying despite its target already being out of range.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Fix for Deployed units (Nuke Cannon)" | Re-trigger Greptile
| // TheSuperHackers @bugfix CookieLandProjects 31/07/2026 - This keeps deployed units from fully deploying even though their target exited the range, | ||
| // instead reverse the deploy. | ||
| #if !RETAIL_COMPATIBLE_CRC | ||
| if (m_state == DEPLOY && isTryingToAttack && !isInRange) |
There was a problem hiding this comment.
Deployment reversal misses expiry frame
When the target leaves range on the update where the deployment timer expires, the preceding timer block changes m_state from DEPLOY to READY_TO_ATTACK before this condition runs. The m_state == DEPLOY check then prevents reversal, causing the unit to finish deploying despite its target already being out of range.
Knowledge Base Used: GameLogic simulation
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp
Line: 149
Comment:
**Deployment reversal misses expiry frame**
When the target leaves range on the update where the deployment timer expires, the preceding timer block changes `m_state` from `DEPLOY` to `READY_TO_ATTACK` before this condition runs. The `m_state == DEPLOY` check then prevents reversal, causing the unit to finish deploying despite its target already being out of range.
**Knowledge Base Used:** [GameLogic simulation](https://app.greptile.com/thesuperhackers/-/custom-context/knowledge-base/thesuperhackers/generalsgamecode/-/docs/gamelogic-simulation.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| m_exitConditions.m_center = *targetToGuard->getPosition(); | ||
| } | ||
|
|
||
| // TheSuperHackers @bugfix CookieLandProjects 31/07/2026 - This keeps deployed units from moving/undeploying immediately |
There was a problem hiding this comment.
a more concise comment would be easier to read and understand
| // If attack finished successfully (target died), check instantly for another enemy in guard range. | ||
| if (ret == STATE_SUCCESS) | ||
| { | ||
| // If we find another enemy in guard range. Recreate the attack state and continue attacking. |
There was a problem hiding this comment.
imperative mood is preferred over first person plural ("we")
| StateReturnType enterRet = m_attackState->onEnter(); | ||
| if (enterRet == STATE_CONTINUE) | ||
| return STATE_CONTINUE; | ||
| return enterRet; |
| // If attack finished successfully (target died), check instantly for another enemy in guard range. | ||
| if (ret == STATE_SUCCESS) | ||
| { | ||
| // If we find another enemy in guard range. Recreate the attack state and continue attacking. |
There was a problem hiding this comment.
Shouldn't the cannon be deployed anyways in guard or stop mode,, even if there is no enemy?
There was a problem hiding this comment.
Yes. But on every kill the nuke cannon decides to redeploy then retarget. Check the mentioned issue for reference.
There was a problem hiding this comment.
Yes, I'm aware of that. But what if the nuke cannon has a kill, but there are no other targets in range. What I make up from your code is that it will still redeploy - as you only seem to stop the redeploy if there is another target. Or am I reading that wrong?
There was a problem hiding this comment.
The nuke cannon will ONLY redeploy if he is not near the guard center (expected behavior)
Since if u set to guard a specific area, he has to first clear out every enemy within that guard area before going to center and deploying for the last time, never to undeploy again (unless something gets in its MinimumAttackRange).
| } | ||
| } | ||
|
|
||
| // TheSuperHackers @bugfix CookieLandProjects 31/07/2026 - This keeps deployed units from fully deploying even though their target exited the range, |
There was a problem hiding this comment.
The comment is confusing. "This keeps deployed units from fully deploying"
| area->getCenterPoint(&m_goalPosition); | ||
| } | ||
|
|
||
| // TheSuperHackers @bugfix CookieLandProjects 31/07/2026 - This keeps deployed units from moving/undeploying even though we are already |
| { | ||
| if (m_frameToWaitForDeploy != 0) | ||
| { | ||
| // Reverse the deploy at its current frame so we dont finish deploying fully. |
| } | ||
| else | ||
| { | ||
| // No pending deploy timer? Make sure we transition to undeploy state. |
|
(Some of) these changes should probably be evaluated by the design committee. |
Deployable unit fixes!
This PR fixes:
Deployed unit redeploys after each kill when guarding. #377
Deployed unit redeploys when there are no targets nearby even though he is at the center of guard area.
Deployed unit fully deploys even though target exited the weapon range.
Instead it now:
Deployed unit doesn't redeploy after each kill, only when no enemies are in guard range.
Deployed unit stays deployed if he is already at the center of guard area.
Deployed unit reverses deploy animation if target exits weapon range.
Additionally, setting a deployed unit to guard right under its already deployed position will NOT make him redeploy, he will stay where he is.
#377 can be closed.
Videos:
This one was over 10MB ;p
https://youtu.be/Nu5hc7ALM0g?si=Vl2WK28kRuIlnkcw
2026-07-31.10-44-25.mp4