Commit Graph

10337 Commits

Author SHA1 Message Date
PatR
8f344a30b5 github PR #1399 - add "Murphy" to ghost names
Pull request from greg-kennedy:  add "Murphy" to the list of random
ghost names.

Closes #1399
2025-04-12 12:33:10 -07:00
PatR
ab8ab7b344 more THEMERM and THEMERMFILL
Give a little more information if environment variable THEMERM or
THEMERMFILL has an invalid value.
2025-04-12 10:22:52 -07:00
Pasi Kallinen
8f7258dc35 Buff Grimtooth with poison
Grimtooth is now permanently poisoned, protects the wielder from
poison, and can be invoked to throw poison.

Permapoison code comes from xNetHack by copperwater <aosdict@gmail.com>.
2025-04-12 19:24:36 +03:00
copperwater
47e6edc663 Enable generating specific themed rooms for debugging
A common pain point I encounter when working on themed rooms is making
specific rooms generate. The only ways to do this were mass commenting
out the rooms not being tested, or hacking in different room frequency
values (even more annoying when testing a fill, not a room, or testing
pure-function rooms/fills that have no frequency).

This change solves that problem by allowing a wizard-mode user to define
THEMERM or THEMERMFILL environment variables to make specific rooms or
fills generate.

The first part of this change is converting all themed rooms and fills
that were plain functions into tables, and converting their comment
names into actual names in those tables. The names are not intended to
be shown during gameplay, but instead serve as values that THEMERM or
THEMERMFILL can be matched to to generate those rooms. It's no longer
possible to have a function themeroom; this will raise an impossible.
As far as I'm concerned, this is a good change because it allows some
code simplification of themerooms_generate and makes it easier to add
difficulty or eligibility parameters to rooms.

The second part of this change is adding a new nh.debug_themerm function
to make the environment variable values accessible to themerms.lua. I
looked for an existing way to do this but didn't see one (nh.variable
is the closest but appears to be for variables that get saved).

The final part is inserting behavior into the actual themeroom
generation code that changes how they generate when either a room or a
fill is set. I don't think it's safe to generate every single room with
the requested type or fill - that might lead to cases where the stairs
or a magic portal cannot generate. So it creates ordinary rooms half of
the time, which still results in plenty of themed rooms on levels.

Another thing to note is that any themed room using filler_region will
still only pick a fill 30% of the time. If one specifies both a fill and
a room that uses filler_region, many of those rooms will appear without
a themed fill.
2025-04-11 16:27:34 -07:00
Pasi Kallinen
7138af00ba Praying on an altar with pet statue on it can revive the pet 2025-04-10 23:38:44 +03:00
disperse
67d58202ad Silver maces
Added the silver mace to be the base weapon type of Demonbane.  It is appropriate that an artifact weapon designed to slay Demons would be made of (or plated with) silver.  This helps to offset the damage reduction when Demonbane was changed from a longsword to a mace and makes it more specialized against silver-haters.
Set the probability to 2, equal to that of a silver spear.
Increased the weight of the silver mace by 120% -- equal to the weight increase from a normal spear to a silver spear. (Assuming the weapon is silver plated rather than made entirely out of silver.)
Increased the base cost to 60, a similar increase as spear to silver spear, to be an even number between silver spear and silver saber.
Monsters will prefer silver maces over regular maces.
Otherwise, identical in function to a normal mace.
2025-04-09 19:46:05 +03:00
Pasi Kallinen
2065d2d392 Avoid premapping outside Sokoban map to prevent showing stone glyphs
If user has changed the stone glyph to something other than a space
(or uses a tileset), Sokoban levels showed the unreachable stone outside
the map area.  Prevent marking those areas as seen, so the stone
glyphs aren't shown.
2025-04-09 18:41:00 +03:00
PatR
3aecc90b2d commit 46b98bab5b951c16f3c6766f23acb22c3046608c
Author: PatR <rankin@nethack.org>
Date:   Mon Apr 7 13:58:28 2025 -0700

    fix issue #1404 - re-tamed feral pet starves

    Issue reported by k21971:  changes in 'struct edog' initialization
    resulted in re-taming of a feral former pet producing a tame monst
    that immediately dies of starvation.

    I didn't look at the earlier behavior, just forced hunger to be
    initialized separately from other edog fields.

    Fixes #1404
2025-04-07 14:11:58 -07:00
PatR
afc34c9873 mon throw-and-return cleanup
Fix up a few comments in the monster throwing code.  And change a
couple 'if (!Blind)' checks to use 'if (canseemon(magr))' instead
of that the player won't be told about a returning aklys hitting an
invisible monster ("it") on the arm.
2025-04-05 09:50:38 -07:00
PatR
500af49dd3 fix issue #1407 - mon throw-and-return crash
Issue reported by k21971:  a gnome throwing a wielded aklys at the
hero was killed when failing to catch its return.  Bookkeeping for
dead monsters got messed up, then a crash occurred.

This fixes things.  Instead of a comment stating that the thrower
might be dead, kill it off.
2025-04-05 09:44:02 -07:00
PatR
4afb9254e1 fuzzer vs yn_function()
This has been sitting around for a long time.  It prevents at least
one fuzzer exit.

Before adding this, I did trigger one yn_function() 'impossible'
while doing ordinary testing but wasn't able to reproduce that, so
am still not sure what is going on.
2025-04-03 20:07:31 -07:00
PatR
0ecd573152 escape_from_sticky_mon()
Reorganized a 'switch' statement in order to eliminate a 'goto'.
There should be no changed in behavior.
2025-04-03 15:26:05 -07:00
copperwater
b32ce258e3 Fix: buffer overflow in gamelog with an extremely long wish string
This was discovered when a game of xNetHack crashed with stack smashing
detected during dumplog creation after an ascension. I traced the
problem to a wish with a very long string the player had made much
earlier in the game ("greased very blessed holy rustproof unlit historic
thoroughly +5 very cloak of protection named it would be a shame if
something happened to me wearing this cloak"), which is further recorded
in an even longer form in the chronicle as 'wished for "X", got "Y"'.
That string does get truncated, but since the gamelog strings are
dynamically allocated, they can be longer than BUFSZ.

When show_gamelog was subsequently called, it didn't use any bounds
checking, which allowed its stack-allocated buffer to overflow. Changing
the offending sprintf to snprintf and limiting it to the buffer size
appears to fix this issue. It will truncate the string at BUFSZ-1
characters and therefore will be expressed in the dumplog as an
incomplete string, but 1) that was happening anyway because the gamelog
string already doesn't capture the entire "wished for X, got Y" message
on such a wish, and 2) this should only ever happen for very long
wishes.
2025-03-29 07:21:04 -04:00
PatR
1df8fd8b3b cutting down closed doors
Most things that can be dug or chopped can only have that done by one
of the two types of digging/chopping tools:  pick-axe or axe.  Since
closed door can be broken open via either type, mention the type of
implement in the final "you break through the door" message by adding
"with your <uwep>."
2025-03-20 16:09:15 -07:00
PatR
d7f107eaf9 still more 'nethack --dumpweights'
After updating the --dumpweights code in hack.c to insert "pair of"
for gloves and boots and "set of" for dragon scales, I've switched
it to use simple_typename() instead.

Turns out that that routine also lacked handling for 'pair|set of'.
And it was generating "coin of gold piece".  Fix those.

Roughly half of the gems are "<gem>" and the others "<gem> stone",
so the --dumpweights output is different by more than just pair/set.
2025-03-19 17:30:56 -07:00
PatR
b237337806 streamline domove_core()
Split handling for paranoid_confirm:Trap out of domove_core() into
a separate routine.  There should be no change in behavior.
2025-03-19 14:33:13 -07:00
nhmall
1f99638bbf ren nhconst.h -> weight.h
The speed related values were not used, except for NORMAL_SPEED,
which has been moved back to permonst.h
2025-03-19 17:14:07 -04:00
nhmall
e8c401acb3 follow-up: numeric values in comment fix 2025-03-19 13:38:12 -04:00
nhmall
a943c4c10b replace some weight-related magic numbers
adds a header file include/nhconst.h  (I'm open to a better name)
2025-03-19 13:29:58 -04:00
PatR
00a5d811ee monmove.c: remove a couple of trailing spaces 2025-03-19 07:48:12 -07:00
PatR
ef9734f1c1 another 'nethack --dumpweights' tweak
Don't suppress slime mold.
2025-03-19 01:39:01 -07:00
PatR
ec6632352f 'nethack --dumpweights' tweak
In the generated comments accompanying weights, show /* a novel */
rather than /* a spellbook of novel */.
2025-03-18 11:53:58 -07:00
Pasi Kallinen
a64796e64d Flip monster goal when flipping the level 2025-03-17 14:33:01 +02:00
nhmall
8c0c33aa1f another follow-up bit 2025-03-17 08:09:00 -04:00
nhmall
ed406dafe7 follow-up: store square of dist in arwep table
Also includes some additional unrelated #undef's since one was
being added.
2025-03-17 07:38:37 -04:00
Greg Kennedy
4e42ae27b4 Add "Murphy" to list of random ghost names
"Murphy's Ghost" is a recurring fixture of the long-running "Wizardry" series of classic dungeon crawler video games.
2025-03-16 21:43:49 -05:00
PatR
f7a390db11 fix #K4324 - Xp and Exp highlit after restore
Experience-level and experience-points, if enabled, could be
highlighted via 'up' or 'changed' rules in initial display after
restore.  I tried 'down' rule too but didn't produce with that.

I don't understand what was going on but was able to reproduce it
and then fix it via the trial and error method....
2025-03-16 19:37:40 -07:00
nhmall
d53698baea whitespace at end-of-line 2025-03-16 15:39:22 -04:00
nhmall
0bdf9830e6 throw-and-return weapons used by monsters
Resolves #1338
2025-03-16 15:37:49 -04:00
Pasi Kallinen
7c43654580 Lua: allow functions for some optional strings
Those places that use get_table_str_opt() to get an optional string
value can instead use a function that returns a string.
This can be used for example in quest data lua table, or some table
fields in the lua api bindings, or the dungeon definition.

For example, in quest.lua

text = "You again sense %l pleading for help.",

could be replaced with

text = function() return "You again sense %l pleading for help."; end,

which of course allows using lua to build the string.
2025-03-16 20:29:28 +02:00
nhmall
53cbccdb86 warning bit from the door fix earlier
mklev.c(97,14): warning C4389: '!=': signed/unsigned mismatch
2025-03-16 08:42:42 -04:00
nhmall
e164ce0af4 rings were missed in --dumpweights text 2025-03-16 08:41:08 -04:00
Pasi Kallinen
b2c071bc66 Fix rare door in corner of room bug
There were couple reports of doors being generated in a corner
of a room.  This happened for randomly generated irregular rooms,
because the code that was deciding if a corridor starting or
ending location was good did not handle irregular rooms at all.

This changes the corridor code so it can now generate start and
end points properly for any valid position in irregular rooms,
instead of only on the edges.  This means the corridor sometimes
meanders a bit more than before, because it tries to find
the end point away from the edge of the room rectangle.

Also added is sanity checking for the randomly generated rooms
and corridors level, testing for door placement and room connectivity.

And another fix for a rare special case where dig_corridor
created a zero-tile long corridor; the entrance door was placed,
but there was nothing behind it.

Fixes github #1269 and #1385
2025-03-16 09:46:53 +02:00
nhmall
ef6ca6c5fa follow-up for --dumpweights
Use a string compare for the sort and encode the weight
at the beginning of the string
2025-03-15 23:18:01 -04:00
nhmall
b169b79d36 dump monster and obj weights using --dumpweights 2025-03-15 19:55:49 -04:00
Pasi Kallinen
488011571a Fix vision when vault guard corridor vanishes 2025-03-15 22:20:59 +02:00
nhmall
ef4cd7608d follow-up for pull-request #1397
Fix warnings
objnam.c: In function ‘wizterrainwish’:
objnam.c:3536:54: warning: variable ‘didblock’ set but not used [-Wunused-but-set-variable]
 3536 |     boolean madeterrain = FALSE, badterrain = FALSE, didblock, is_dbridge;
      |                                                      ^~~~~~~~
2025-03-14 10:34:22 -04:00
nhmall
57825b170d pull request #1397 by copperwater
Closes #1397
2025-03-14 10:00:35 -04:00
PatR
90717ca633 more chest->tknown handling
Disarming a chest trap was setting obj->tknown = 0 even though the
hero just discovered that it isn't trapped.

Triggering a chest trap behaved similarly.  Since there are no
repeating chest traps, hero should know that the chest whose trap
just went off is no longer trapped.

chest_trap() didn't document its return value but was clearly meant
to return True if the chest was destroyed.  It didn't handle that
correctly when the chest was being carried.  However, none of the
callers actually use the return value.  [This fix tracks whether the
chest gets deleted; a better fix would be to destroy an exploding
chest even when it is being carried.]
2025-03-13 13:54:56 -07:00
PatR
31d86a8c41 trapped box->tknown
If 'autounlock' is set to test a chest for traps, skip "check for
traps?" when tknown is set; go directly to "disarm trap?" if the
chest is trapped, skip that too if it isn't.

If wand of probing hits a chest, set the tknown bit.
2025-03-12 01:28:05 -07:00
PatR
719166f9ec fix issue #1377 - Forcefight vs displacer beasts
Issue reported by elunna:  Using the 'F' prefix against a displacer
beast prevented swapping places.

This doesn't use the suggested fix.  It is quite short but there is
a large diff due to change in indentation and reformatting several
comments because of that.

Attacking a displacer beast either with or without 'F' might miss,
hit, or swap places.  It won't "harmlessly attack thin air."

Fixes #1377
2025-03-10 09:17:41 -07:00
PatR
0a180c52ef more issue #1362 - carrying Mitre of Holiness
Protect carried items as well as hero when carrying the Mitre of
Holiness.  Already handled when wearing that artifact.

This might make it be too strong.  At the time that it was given
the carrued attribute, there was no such thing as carried items
providing any protection to other carried items.
2025-03-09 14:28:50 -07:00
PatR
a3c6eec5c0 enlightenment about bones
"You have disabled loading of bones levels" (during play) and
"You disabled loading of bones levels" (end of game disclosure)
both clearly refer to the player rather than the hero.
"You have never encountered a bones level" is accurate for current
hero but not necessarily accurate for the player.  Rephrase it.

Also, if OPTIONS=!bones is set and the hero just died, extend
"You disabled loading of bones levels" during disclosure to
"You disabled loading and storing of bones levels" (even in the
case where bones wouldn't be saved anyway).
2025-03-08 13:16:27 -08:00
nhmall
d0d77ed5f4 related comments were not updated with parameters 2025-03-08 12:51:53 -05:00
copperwater
49b43f760f Fix: a number of unblock_points shouldn't unblock unconditionally
Initially diagnosed in an xnethack fuzzer crash - unblock_point
shouldn't be called when a closed door becomes non-closed, because it's
possible that there's a gas cloud on the space which means it still
blocks vision. These always need to be recalc_block_point. A number of
them were fixed, but when I went through all the xnethack ones, I found
some that were unchanged from upstream NetHack. I reproduced the sanity
check impossibles usually by breathing gas at a door as an iron golem
and then opening or destroying the door to trigger the unblock_point
call.

The use of recalc_block_point in wizterrainwish was not triggering this
bug, but the previous code there basically duplicated
recalc_block_point.
2025-03-08 07:53:57 -05:00
PatR
a6a1e1b365 nasty() tuning
Another old stash.  Slighty weakens genocide of high level monsters.
2025-03-07 12:14:22 -08:00
PatR
6a24d5ac04 report.c tweaks
The report.c bit committed today reminded me that I had an old stashed
change for that file.  There should be no change in behavior.
2025-03-07 12:07:17 -08:00
nhkeni
adeb69ba82 report.c: fix HASH_BINFILE typo 2025-03-07 13:34:53 -05:00
nhmall
ceee6aff31 pointer decl style consistency; use any_types enum 2025-03-06 07:20:16 -05:00
nhmall
78ca37290b cast style tidbit 2025-03-05 10:29:50 -05:00