Fixed Guard Retaliation#2197
Open
CookieLandProjects wants to merge 1 commit intoTheSuperHackers:mainfrom
Open
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGuard.cpp | Removed attackAggressors condition from AI_GUARD_INNER and AI_GUARD_RETURN states to prevent incorrect retaliation behavior |
| GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGuardRetaliate.cpp | Removed attackAggressors condition from AI_GUARD_RETALIATE_RETURN state to prevent incorrect retaliation behavior during return movement |
Sequence Diagram
sequenceDiagram
participant Unit as Guard Unit
participant Idle as IDLE State
participant Inner as INNER State
participant Return as RETURN State
participant AttackAgg as ATTACK_AGGRESSOR State
Note over Unit,AttackAgg: Before Fix
Unit->>Return: Move to guard position
Return-->>AttackAgg: Unit gets attacked (attackAggressors)
AttackAgg->>AttackAgg: Retaliate inappropriately
Note over Unit,AttackAgg: After Fix
Unit->>Return: Move to guard position
Note over Return: No retaliation while returning
Return->>Idle: Reach guard position
Idle-->>AttackAgg: Unit gets attacked (attackAggressors)
AttackAgg->>AttackAgg: Retaliate correctly
AttackAgg->>Inner: Return to guard
Note over Unit,AttackAgg: State Transition Logic
Idle->>Inner: Enemy detected in range
Inner->>Inner: Engage enemy
Inner->>Return: Combat complete
Return->>Idle: Reached guard position
Stubbjax
requested changes
Jan 26, 2026
Comment on lines
+182
to
+183
| defineState( AI_GUARD_INNER, newInstance(AIGuardInnerState)( this ), AI_GUARD_OUTER, AI_GUARD_OUTER ); | ||
| defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER ); |
There was a problem hiding this comment.
Needs to check RETAIL_COMPATIBLE_CRC to maintain retail compatibility.
Suggested change
| defineState( AI_GUARD_INNER, newInstance(AIGuardInnerState)( this ), AI_GUARD_OUTER, AI_GUARD_OUTER ); | |
| defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER ); | |
| #if RETAIL_COMPATIBLE_CRC | |
| defineState( AI_GUARD_INNER, newInstance(AIGuardInnerState)( this ), AI_GUARD_OUTER, AI_GUARD_OUTER, attackAggressors ); | |
| defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER, attackAggressors ); | |
| #else | |
| defineState( AI_GUARD_INNER, newInstance(AIGuardInnerState)( this ), AI_GUARD_OUTER, AI_GUARD_OUTER ); | |
| defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER ); | |
| #endif |
There was a problem hiding this comment.
Also needs // TheSuperHackers @bugfix ... comment in the #else block.
| @@ -184,7 +184,7 @@ AIGuardRetaliateMachine::AIGuardRetaliateMachine( Object *owner ) : | |||
| // srj sez: I made "return" the start state, so that if ordered to guard a position | |||
| // that isn't the unit's current position, it moves to that position first. | |||
| defineState( AI_GUARD_RETALIATE_ATTACK_AGGRESSOR, newInstance(AIGuardRetaliateAttackAggressorState)( this ), AI_GUARD_RETALIATE_RETURN, AI_GUARD_RETALIATE_RETURN ); | |||
| defineState( AI_GUARD_RETALIATE_RETURN, newInstance(AIGuardRetaliateReturnState)( this ), AI_GUARD_RETALIATE_IDLE, AI_GUARD_RETALIATE_INNER, attackAggressors ); | |||
| defineState( AI_GUARD_RETALIATE_RETURN, newInstance(AIGuardRetaliateReturnState)( this ), AI_GUARD_RETALIATE_IDLE, AI_GUARD_RETALIATE_INNER ); | |||
There was a problem hiding this comment.
Needs to check RETAIL_COMPATIBLE_CRC to maintain retail compatibility.
Suggested change
| defineState( AI_GUARD_RETALIATE_RETURN, newInstance(AIGuardRetaliateReturnState)( this ), AI_GUARD_RETALIATE_IDLE, AI_GUARD_RETALIATE_INNER ); | |
| #if RETAIL_COMPATIBLE_CRC | |
| defineState( AI_GUARD_RETALIATE_RETURN, newInstance(AIGuardRetaliateReturnState)( this ), AI_GUARD_RETALIATE_IDLE, AI_GUARD_RETALIATE_INNER, attackAggressors ); | |
| #else | |
| defineState( AI_GUARD_RETALIATE_RETURN, newInstance(AIGuardRetaliateReturnState)( this ), AI_GUARD_RETALIATE_IDLE, AI_GUARD_RETALIATE_INNER ); | |
| #endif |
There was a problem hiding this comment.
Also needs // TheSuperHackers @bugfix ... comment in the #else block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Made Guard do what its supposed to instead of retaliating when its not supposed to.
Fix for:
#2097