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

Monsters prefer artifacts over same type ordinary weapons - #1688

Open
crissman wants to merge 9 commits into
NetHack:NetHack-5.0from
crissman:artifact-weapon-swap
Open

crissman wants to merge 9 commits into
NetHack:NetHack-5.0from
crissman:artifact-weapon-swap

Conversation

@crissman

@crissman crissman commented Sep 29, 2026 •

Copy link
Copy Markdown

Monsters do not wield artifacts if wielding an ordinary weapon of the same type.

The wielding code compares base weapon types and incorrectly treats a artifacts and an ordinary item of the same type as the same.

For weapons of the same base type, switch only from an ordinary weapon to an artifact; retain an already-wielded artifact. Sunsword and Vorpal Blade cannot replace each other through this same-type rule. Selecting the object already wielded consumes no turn. Ordinary weapons of the same type never cause a switch, regardless of enchantment or inventory order. Different-type selection and the existing cursed-weapon restriction remain unchanged. The change is recorded in doc/fixes5-0-1.txt.

Validation: tested the revised code in terminal and Qt builds using disposable wizard games and the real selection and wielding routines. In each build, eight combinations of inventory order, starting weapon, and equal or different enchantments passed 100 repeated ordinary-weapon checks each with no switches. A +0 longsword switched to +7 Sunsword, with worn flags and artifact light verified; 100 subsequent checks consumed no turns and did not cycle. An additional 100 repeated checks in each direction confirmed that Sunsword never switched to Vorpal Blade and Vorpal Blade never switched to Sunsword. The test used a monster eligible to touch both artifacts and verified that selection chose the other artifact, so alignment restrictions could not mask a failure. A cursed current weapon blocked the artifact switch, and a different-type ordinary weapon upgrade still succeeded. Qt tests used its terminal interface, not its graphical UI. git diff --check passes. This revision is not installed in the live game.

@crissman crissman changed the title Monsters prefer relics over same type ordinary weapons Monsters prefer artifacts over same type ordinary weapons Sep 29, 2026
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