Skip to content

Bug: IsInCombat() returns true persistently even in peaceful situations #65

@winteryu21

Description

@winteryu21

Observed Behavior
Some pawns have IsInCombat() = true (causing [IN DANGER] tag and aggressive dialogue) despite being in a clearly peaceful situation:

  • No hostiles on the map
  • Combat ended a long time ago
  • Persists even after save/reload
  • Pawn is not drafted
  • Pawn is healthy (no injuries, not downed)
  • Occurs regardless of current job (e.g., wandering, socializing)
  • Only affects pawns who previously participated in combat

Does not occur consistently; exact trigger is unknown

Expected Behavior
IsInCombat() should return false when there are no nearby hostiles and the pawn is not actively engaged in combat.

Suspected Cause
Looking at PawnUtil.IsInCombat():

public static bool IsInCombat(this Pawn pawn)
{
    if (pawn == null) return false;
    if (pawn.mindState.enemyTarget != null) return true;  // ← Suspect
    if (pawn.stances?.curStance is Stance_Busy busy && busy.verb != null) return true;
    
    Pawn hostilePawn = pawn.GetHostilePawnNearBy();
    return hostilePawn != null && pawn.Position.DistanceTo(hostilePawn.Position) <= 20f;
}

The first condition (mindState.enemyTarget != null) may be returning true due to stale data from a previous combat encounter. However, this has not been debugged in-game, so the exact cause is unconfirmed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions