Sitelet https://github.com/NetHack/NetHack/pull/1683
Skip to content

Respect petrification during blind inspection - #1683

Open
crissman wants to merge 5 commits into
NetHack:NetHack-5.0from
crissman:blind-corpse-inspection
Open

crissman wants to merge 5 commits into
NetHack:NetHack-5.0from
crissman:blind-corpse-inspection

Conversation

@crissman

@crissman crissman commented Sep 21, 2026 •

Copy link
Copy Markdown

Blind characters can inspect cockatrice corpses at pickup and looting prompts without risking petrification.

This addresses an existing BUG comment in the source. The change is recorded in doc/fixes5-0-1.txt.

Using : at the traditional pickup or container-looting category prompt lists cockatrice corpses while blind without checking whether feeling them causes petrification. The ordinary look-here path performs that check, but simple_look() only prints object names.

Apply the existing will_feel_cockatrice() and feel_cockatrice() rules when inspecting objects outside inventory. Stop at the dangerous corpse, close the menu before processing petrification, and stop the enclosing selection even if life-saving or polymorph allows the hero to survive. Do not mark the entire container as inspected after an interrupted look. Gloves, stone resistance, sighted inspection, and inventory inspection retain their existing behavior.

Validation: source-extracted C tests compiled with AddressSanitizer and UndefinedBehaviorSanitizer reproduce eight failing expectations in the baseline; the patched version passes all 19 checks. Cases cover floor and container chains, a single corpse, returning from the touch handler, menu cleanup, hidden later objects, and the four safe cases above. The complete modified pickup.c translation unit passes clang syntax checking, and the exported patch applies to the installed build's source.

Full-game integration on macOS x86-64 now passes all 12 corpse-inspection scenarios: floor and container inspection, each tested unprotected, wearing gloves, with stone resistance, sighted, wearing an amulet of life-saving, and in flesh-golem form. Unprotected touch caused petrification; life-saving consumed the amulet; flesh golems transformed into stone golems. Inspection stopped after survival and the container remained unknown. These tests ran in fresh disposable games with wizard-only fixture hooks and the real pickup/looting UI and petrification code; no petrification handler was stubbed.

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