Skip to content

Send PERC_ASSESSREMOVEWEAPON when the player's weapon is away - #1087

Open
pieterdeschepper wants to merge 1 commit into
Try:masterfrom
pieterdeschepper:remove-weapon-perc-after-sheathe
Open

pieterdeschepper wants to merge 1 commit into
Try:masterfrom
pieterdeschepper:remove-weapon-perc-after-sheathe

Conversation

@pieterdeschepper

@pieterdeschepper pieterdeschepper commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes item 16 of #944 (NPCs keep their weapons drawn):

If the player draws a weapon inside a camp, nearby NPCs usually draw their own weapons and tell the player to put theirs away. Frequently, after the player sheathes their weapon, only some NPCs return to their normal state. Others permanently keep their weapons drawn.

Cause

Npc::closeWeapon sent PERC_ASSESSREMOVEWEAPON as soon as the sheathe animation started. The player still counts as armed until the animation's fight-mode event, which comes about 0.5 s later.

An npc whose perception runs in that window (in Gothic 1: B_AssessSC → B_AssessFighter → ZS_AssessFighter) starts reacting after the signal has already been sent. While it was still in its routine state the signal was ignored, and no second one comes. ZS_AssessFighter only stands down on that perception or on distance, so the npc keeps its weapon drawn. If the player stays within HAI_DIST_ABORT_MELEE, it goes to ZS_AssessFighterWait and then ZS_Attack against the unarmed player.

Change

  • implSetFightMode sends PERC_ASSESSREMOVEWEAPON when the player's fight mode becomes NONE, i.e. when the weapon is actually away.
  • closeWeapon still sends it directly for noAnim, since no animation event follows.

Testing

Gothic 1 on macOS (Apple M3 Pro). In a test build the hero was scripted to draw and immediately sheathe next to an Old Camp crossbow guard (GRD_229), with logging of the guard's perceptions and states:

  • Before: when the guard's perception fell during the sheathe animation, it entered ZS_AssessFighter after the signal, never stood down, and switched to ZS_Attack with the crossbow drawn.
  • After: in all runs, including those where the guard reacted during the animation, the guard received the signal, put the crossbow away and returned to its routine.

It was also checked in normal play. These were local builds.

🤖 Generated with Claude Code

The perception was sent when the sheathe animation started. Until the
animation's fight-mode event, the player still counts as armed. An npc
whose B_AssessSC runs in that window (Gothic 1: ZS_AssessFighter via
B_AssessFighter) starts reacting after the signal has already gone, and
then never gets one. It keeps its weapon drawn, waits, and eventually
attacks the unarmed player (Try#944, item 16).

Send the perception from implSetFightMode when the player's fight mode
becomes NONE, and from closeWeapon only when there is no animation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant