Skip to content

bugfix: Clear stealth when driver killed by neutron/sniper#2250

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-stealthed-units-bug
Closed

bugfix: Clear stealth when driver killed by neutron/sniper#2250
Copilot wants to merge 2 commits intomainfrom
copilot/fix-stealthed-units-bug

Conversation

Copy link

Copilot AI commented Feb 3, 2026

Stealthed vehicles hit by neutron shells or Jarmen Kell remain permanently invisible, undetectable even by stealth detectors.

Root Cause

StealthUpdate::allowedToStealth() doesn't check DISABLED_UNMANNED state. When driver is killed, vehicle becomes unmanned but stealth persists.

Changes

Added disabled check in allowedToStealth() for both games:

// GeneralsMD/StealthUpdate.cpp (line 314)
if( self->isDisabledByType( DISABLED_UNMANNED ) )
{
    return FALSE;
}

// Generals/StealthUpdate.cpp (line 206) 
if( self->isDisabledByType( DISABLED_UNMANNED ) )
{
    return false;
}

Existing logic in update() automatically clears OBJECT_STATUS_STEALTHED when allowedToStealth() returns false.

Notes

  • No CRC gating needed: OBJECT_STATUS_STEALTHED is client-side visual state, not synced
  • Return style matches each codebase's convention (GeneralsMD: uppercase FALSE, Generals: lowercase false)
Original prompt

This section details on the original issue you should resolve

<issue_title>Stealthed units don't lose stealth state when driver is killed</issue_title>
<issue_description>### Prerequisites

  • I have searched for similar issues and confirmed this is not a duplicate

Game Version

  • Command & Conquer Generals
  • Command & Conquer Generals: Zero Hour
  • Other (please specify below)

Bug Description

Units that were stealthed before their driver / crew was killed by Neutron shells (and Jarmen Kell probably) remain in stealth mode indefinitely. They don't become visible for enemies even with stealth detectors.

Reproduction Steps

See content below.

Additional Context

POV player 1:

stealth_unit_without_driver.mp4

POV player 2:

Image</issue_description>

Comments on the Issue (you are @copilot in this section)

@Caball009 - May be related to: https://github.com//issues/47

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix stealthed units not losing stealth when driver is killed bugfix: Clear stealth state when driver is killed Feb 3, 2026
Copilot AI requested a review from tintinhamans February 3, 2026 13:26
Copilot AI changed the title bugfix: Clear stealth state when driver is killed bugfix: Clear stealth when driver killed by neutron/sniper Feb 3, 2026
@tintinhamans
Copy link

@greptileai

@greptile-apps
Copy link

greptile-apps bot commented Feb 3, 2026

Greptile Overview

Greptile Summary

This PR fixes a gameplay bug where vehicles hit by neutron shells or sniped by Jarmen Kell remained permanently invisible even to stealth detectors. The fix adds a check for DISABLED_UNMANNED state in StealthUpdate::allowedToStealth(), ensuring that when a vehicle's driver is killed (which sets the DISABLED_UNMANNED flag), the stealth status is automatically cleared through the existing update logic.

Key Changes:

  • Added DISABLED_UNMANNED check in allowedToStealth() for both Generals and GeneralsMD codebases
  • Fix correctly leverages existing update() logic that clears OBJECT_STATUS_STEALTHED when allowedToStealth() returns false
  • No CRC gating required as OBJECT_STATUS_STEALTHED is client-side visual state
  • Return type conventions respected (uppercase FALSE for GeneralsMD, lowercase false for Generals)

Analysis:
The root cause is confirmed - neutron shells (NeutonBlastBehavior.cpp:141) and sniper damage (ActiveBody.cpp:426) set the DISABLED_UNMANNED flag when killing vehicle drivers, but stealth persisted because allowedToStealth() didn't check this disabled state. The fix is minimal, targeted, and integrates cleanly with the existing stealth management system.

Confidence Score: 5/5

  • This PR is safe to merge - it's a focused bug fix with clear logic and minimal changes
  • The fix is surgically precise, adding only a necessary disabled state check that logically belongs in the stealth validation logic. The implementation correctly leverages existing update mechanisms, maintains codebase conventions, and addresses a confirmed gameplay bug without introducing side effects.
  • No files require special attention - both changes are identical in logic and appropriate for their respective codebases

Important Files Changed

Filename Overview
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp Added DISABLED_UNMANNED check in allowedToStealth() to prevent stealthed vehicles from remaining invisible when driver killed
Generals/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp Added DISABLED_UNMANNED check in allowedToStealth() mirroring GeneralsMD fix for vanilla game compatibility

Sequence Diagram

sequenceDiagram
    participant Neutron as Neutron Shell/Jarmen Kell
    participant Body as ActiveBody/NeutonBlastBehavior
    participant Object as Vehicle Object
    participant Stealth as StealthUpdate
    participant Status as Visual Status

    Neutron->>Body: Kill driver (DAMAGE_KILLPILOT)
    Body->>Object: setDisabled(DISABLED_UNMANNED)
    Note over Object: Vehicle now unmanned<br/>but still stealthed (BUG)
    
    loop Every frame
        Stealth->>Stealth: update()
        Stealth->>Stealth: allowedToStealth()
        Note over Stealth: NEW: Check DISABLED_UNMANNED
        alt Vehicle is unmanned
            Stealth-->>Stealth: return FALSE
            Stealth->>Status: clearStatus(OBJECT_STATUS_STEALTHED)
            Note over Status: Vehicle becomes visible
        else Vehicle has driver
            Stealth-->>Stealth: return TRUE
            Stealth->>Status: setStatus(OBJECT_STATUS_STEALTHED)
            Note over Status: Vehicle stays hidden
        end
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@tintinhamans tintinhamans removed their request for review February 3, 2026 13:46
@tintinhamans tintinhamans removed their assignment Feb 3, 2026
@tintinhamans tintinhamans marked this pull request as ready for review February 3, 2026 14:39
@tintinhamans tintinhamans marked this pull request as draft February 3, 2026 16:48
@tintinhamans tintinhamans deleted the copilot/fix-stealthed-units-bug branch February 6, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stealthed units don't lose stealth state when driver is killed

2 participants