Skip to content

Commit fbec8eb

Browse files
committed
Fixed guard (retaliation) states.
1 parent 091ab3d commit fbec8eb

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

Generals/Code/GameEngine/Source/GameLogic/AI/AIGuard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ AIGuardMachine::AIGuardMachine( Object *owner ) :
175175
// order matters: first state is the default state.
176176
// srj sez: I made "return" the start state, so that if ordered to guard a position
177177
// that isn't the unit's current position, it moves to that position first.
178+
#if RETAIL_COMPATIBLE_CRC
178179
defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER, attackAggressors );
180+
#else
181+
// TheSuperHackers @bugfix 09/04/2026 This fixes the conflicting movement and fire behavior in Guard mode when the unit is under attack.
182+
defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER );
183+
#endif
179184
defineState( AI_GUARD_IDLE, newInstance(AIGuardIdleState)( this ), AI_GUARD_INNER, AI_GUARD_RETURN, attackAggressors );
180185
defineState( AI_GUARD_INNER, newInstance(AIGuardInnerState)( this ), AI_GUARD_OUTER, AI_GUARD_OUTER );
181186
defineState( AI_GUARD_OUTER, newInstance(AIGuardOuterState)( this ), AI_GUARD_GET_CRATE, AI_GUARD_GET_CRATE );

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGuard.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,14 @@ AIGuardMachine::AIGuardMachine( Object *owner ) :
179179
//Kris: Except that guard return is more like an attack move, and will acquire targets while moving there.
180180
//This breaks deployAI units because they have to completely unpack before realizing that there is a target in range.
181181
//So I'm making AI_GUARD_INNER the first state.
182+
#if RETAIL_COMPATIBLE_CRC
182183
defineState( AI_GUARD_INNER, newInstance(AIGuardInnerState)( this ), AI_GUARD_OUTER, AI_GUARD_OUTER, attackAggressors );
183184
defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER, attackAggressors );
185+
#else
186+
// TheSuperHackers @bugfix 09/04/2026 This fixes the conflicting movement and fire behavior in Guard mode when the unit is under attack.
187+
defineState( AI_GUARD_INNER, newInstance(AIGuardInnerState)( this ), AI_GUARD_OUTER, AI_GUARD_OUTER );
188+
defineState( AI_GUARD_RETURN, newInstance(AIGuardReturnState)( this ), AI_GUARD_IDLE, AI_GUARD_INNER );
189+
#endif
184190
defineState( AI_GUARD_IDLE, newInstance(AIGuardIdleState)( this ), AI_GUARD_INNER, AI_GUARD_RETURN, attackAggressors );
185191
defineState( AI_GUARD_OUTER, newInstance(AIGuardOuterState)( this ), AI_GUARD_GET_CRATE, AI_GUARD_GET_CRATE );
186192
defineState( AI_GUARD_GET_CRATE, newInstance(AIGuardPickUpCrateState)( this ), AI_GUARD_RETURN, AI_GUARD_RETURN );

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGuardRetaliate.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ AIGuardRetaliateMachine::AIGuardRetaliateMachine( Object *owner ) :
184184
// srj sez: I made "return" the start state, so that if ordered to guard a position
185185
// that isn't the unit's current position, it moves to that position first.
186186
defineState( AI_GUARD_RETALIATE_ATTACK_AGGRESSOR, newInstance(AIGuardRetaliateAttackAggressorState)( this ), AI_GUARD_RETALIATE_RETURN, AI_GUARD_RETALIATE_RETURN );
187+
#if RETAIL_COMPATIBLE_CRC
187188
defineState( AI_GUARD_RETALIATE_RETURN, newInstance(AIGuardRetaliateReturnState)( this ), AI_GUARD_RETALIATE_IDLE, AI_GUARD_RETALIATE_INNER, attackAggressors );
189+
#else
190+
// TheSuperHackers @bugfix 09/04/2026 This fixes the conflicting movement and fire behavior in Guard mode when the unit is under attack.
191+
defineState( AI_GUARD_RETALIATE_RETURN, newInstance(AIGuardRetaliateReturnState)( this ), AI_GUARD_RETALIATE_IDLE, AI_GUARD_RETALIATE_INNER );
192+
#endif
188193
defineState( AI_GUARD_RETALIATE_IDLE, newInstance(AIGuardRetaliateIdleState)( this ), AI_GUARD_RETALIATE_INNER, EXIT_MACHINE_WITH_SUCCESS, attackAggressors );
189194
defineState( AI_GUARD_RETALIATE_INNER, newInstance(AIGuardRetaliateInnerState)( this ), AI_GUARD_RETALIATE_OUTER, AI_GUARD_RETALIATE_OUTER );
190195
defineState( AI_GUARD_RETALIATE_OUTER, newInstance(AIGuardRetaliateOuterState)( this ), AI_GUARD_RETALIATE_GET_CRATE, AI_GUARD_RETALIATE_GET_CRATE );

0 commit comments

Comments
 (0)