Commit Graph

1623 Commits

Author SHA1 Message Date
PatR
92255708f3 stone-to-flesh vs mimics
Handle a FIXME in zap.c:  stone-to-flesh spell hitting a mimic that
is disguised as a stone object or stone furniture should bring it out
of hiding.
2025-04-24 12:47:00 -07:00
nhmall
c88b288329 yet another stale ZEROCOMP bit 2025-04-16 17:04:45 -04:00
nhmall
16fc4aacb1 another stale ZEROCOMP bit 2025-04-16 17:00:21 -04:00
nhmall
830e18f52e some cleanup of stale bits 2025-04-16 16:56:17 -04:00
nhmall
a3e12550ea savefile changes - part 1
This is the first of several savefile-related changes to
follow later. This one is groundwork for those later changes.

Remove internal compression schemes (RLECOMP and ZEROCOMP)
and discard the savefile_info struct that was primarily used to
convey which internal compression schemes had been in use.

Relocate some struct definitions into appropriate header files
for use by code to come in later changes.

Remove the two struct size-related fields from version_info and
from the nmakedefs_s. Instead, include a series of bytes near the
beginning of the savefile, representing the size of each
struct or base data type that impacts the historical savefile
content. Those are referred to as the "critical bytes".
(Related note: the "you" struct required two bytes, low and high,
due to its size).

Compare those critical bytes in a savefile against the NetHack
build that is reading the savefile. This allows mismatch detection
early in the savefile-reading process, and a clean exit, rather than
proceeding to read nonsensical values from the file. Include some
feedback on what the first mismatch was when encountering
one.

For arrays stored in the savefile, use loop-logic in the core
to write/read the array elements one at a time, rather than in
a single blob. This will be required for changes to follow later.
(impacts artiexist[], artidisco[], svd.dungeons[], svl.level_info[],
svl.level.locations[][], msrooms[] field of mapseen, svb.bases[],
svb.disco[] objects[], svm.mvitals[], svs.spl_book[], svd.doors[],
go.oracle_loc[], utrack[], wgrowtime[])

This also adds data model to the long version information.

This invalidates existing save and bones files due to the changes in
the information at the start of the file.
2025-04-15 15:35:17 -04:00
Pasi Kallinen
652f8576c0 Cursed magic whistle can teleport you to your pet 2025-04-13 12:48:21 +03: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
nhmall
0bdf9830e6 throw-and-return weapons used by monsters
Resolves #1338
2025-03-16 15:37:49 -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
b169b79d36 dump monster and obj weights using --dumpweights 2025-03-15 19:55:49 -04:00
nhmall
f1be2eaffa add --dumpmongen to view mongen_order[] array 2025-02-14 09:38:29 -05:00
nhmall
a68bc3b3fb fix tamed pet issue #1379
fixes #1379
2025-02-12 23:26:03 -05:00
nhmall
fe4cb7a626 make rank() static again 2025-02-05 20:03:06 -05:00
nhmall
c24786430f 'struct former' -> 'struct ebones'
Some variants were already using a similar approach
using a struct called 'ebones', so adopt the same naming
so NetHack-3.7, hardfought, and some variants are using
the same name.

As before there are fields in the struct that are not
currently used by NetHack-3.7, but the intent is that
hardfought save and bones files can be loaded by
NetHack-3.7 without code modification, for debugging
bug reports.

This invalidates existing save and bones files.
2025-02-04 15:16:42 -05:00
PatR
a311f4b467 fix issue #1362 - carrying Mitre of Holiness
Issue reported by elunna:  the definition of the Mitre of Holiness
specifies that carrying it should confer fire resistance but that
didn't work.

The Mitre's definition (added in 3.1.0) has always included that,
but such a capability had never been implemented.  Wearing it didn't
confer fire resistance either--its definition doesn't bother to
specify a 'defend' attribute since the 'carry' one should cover that.

This adds carrying capability for damage types fire, cold, sleep,
disintegration, electrity, poison, acid, and petrification.  Fire is
still specified by the Mitre; none of the others are currently used.

Fixes #1362
2025-02-03 11:42:36 -08:00
nhmall
d785f7a649 add two unused fields for hardfought save compatability
There are two hardfought code additions that render save and bones files incompatible
with the upstream NetHack-3.7, and that makes testing with hardfought
save and bones files more challenging than it needs to be, when
investigating and troubleshooting bug reports.

Add some unused fields to advance towards achieving save file parity with
hardfought, which is a significant source of play-testing for NetHack-3.7.

1) the elbereth field addition to u_conduct

This adds an unused placeholder field named 'hf_reserved1', at the appropriate
place in u_conduct to achieve struct field parity with the one in use on
hardfought.

2) hardfought adds a field to struct monst:
    char former_rank[25]; /* for bones' ghost rank in their former life */

Instead of adding that to every monst, this adds a new mextra struct
named 'former', which currently contains the equivalent 25-character
field called 'rank' which can hold the content that was in the
former_rank[25] field. That way, the field will only be added when it
is needed.

A pull request https://github.com/k21971/NetHack37/pull/2 has been
done on hardfought to do it the same way (untested there as of yet).

Even though NetHack-3.7 does not utilize that information presently,
this will be a further step toward allowing hardfought-generated save
and bones files to be used for troubleshooting, without modification,
on a similar architecture running stock NetHack-3.7 code.

That savefile parity won't be achieved until the after the
hardfought pull-request mentioned above (or equivalent) is merged.

As this change will not be compatible with existing save and bones
files, it will be accompanied with an EDITLEVEL increment.
2025-02-02 09:00:05 -05:00
nhmall
61f969e88b follow-up for put_saddle_on_mon()
Commit 1acc2727 helped ensure that the which_armor(mtmp, W_SADDLE)
test at the top of put_saddle_on_mon() wouldn't lead to an obj
leak.

This commit covers off the adjacent can_saddle() test in
put_saddle_on_mon(), because if that failed, it could also lead
to a memory leak of the saddle obj passed by the caller.

- have put_saddle_on_mon() create and use its own saddle obj
  if a NULL saddle obj is passed, instead of having to do that
  in the caller.
- where an existing saddle obj needs to be passed from the caller,
  ensure that the caller has done its own can_saddle(mon) check prior
  to calling put_saddle_on_mon(), so that the can_saddle() test
  in put_saddle_on_mon() won't fail.
- lastly, add an impossible() to put_saddle_on_mon() to catch
  a failure when a saddle obj is passed from the caller and either
  test has failed, just in case. That should not happen with any of
  the existing cases now, but it will provide some bullet-proofing
  for new code, new callers.
2025-01-20 14:37:46 -05:00
Pasi Kallinen
991a1dbe43 Fix exploding landmine and boulders next to lava
Same issue as with breaking a wand of digging in commit 7ce0751a
2025-01-20 19:26:12 +02:00
nhmall
a513b41748 more coordxy consistency, mklev.c 2025-01-14 11:17:41 -05:00
nhmall
2354fef2d6 be more consistent with coordxy in mkmap.c
Also closes #1365
2025-01-14 10:32:36 -05:00
nhmall
1bb0f89b82 Merge branch 'check_version' of https://github.com/argrath/NetHack into NetHack-3.7 2025-01-13 08:24:15 -05:00
nhmall
62fe9e83c6 Merge branch 'xytod' of https://github.com/argrath/NetHack into NetHack-3.7 2025-01-13 08:23:52 -05:00
SHIRAKATA Kentaro
36443c965b second argument of check_version() can take NULL
There is a code path starting at restore.c line 830.

    (void) validate(nhfp, (char *) 0, FALSE);
2025-01-13 13:57:40 +09:00
Alex Smith
97e0e934e8 Use a common funcion for all monster healing
Previously, the code for monster healing was repeated every time it
was needed; this commit sends it all through a common function, which
will make it easier to make changes to how monster healing works in
the future.

This is just a code reorganisation and won't have any gameplay
effect unless I made a mistake.
2025-01-12 18:20:13 +00:00
SHIRAKATA Kentaro
9b7bcf67ba change the type of xytod()'s return value to int
xytod()'s return value is an index, so its type should be int, not coordxy.
2025-01-12 14:37:13 +09:00
Pasi Kallinen
843b02ec1d Add vision sanity checking, fix more vision
- Add a vision sanity checking routine

- Recalc block point when digging a door for temporary clouds

- Add recalc_block_point after cvt_sdoor_to_door, because doorways
  on the Rogue level have no doors, and otherwise the sanity checking
  would complain.  This doesn't actually change how the Rogue level
  vision works, as it uses a different vision system

- Monster using a trap in a secret corridor revealed the corridor,
  but didn't unblock the vision unless you saw the location
2025-01-09 17:28:24 +02:00
Pasi Kallinen
4392f5fa4e Fix vision in some cases with boulder falling into pool
We can't just unconditionally unblock vision for a location when a boulder
falls into a pool, because the location may also have a (poison) cloud on it.
2025-01-06 19:46:38 +02:00
nhmall
37758c7e48 some tty updates
Add a note about NO_TERMS to include/wintty.h for clarity.

Rename tty_startup and tty_shutdown to term_startup() and
term_shutdown(). They are found in termcap.c for !NO_TERMS
like most of the other term_ routines, as well as having
versions for several of the NO_TERMS platforms. They aren't
part of the tty_interface called from the core. The tty
implementation does call and rely on them.

Remove some conditional #ifdef's around term_shutdown()
(formerly tty_shutdown()) and just ensure that all the
tty platforms have an implementation that they can link
with, even if it is just a stub presently.

Put the protype for nethack_exit in extern.h to reduce
maintenance to a single spot, and remove it from other
locations. A warning in the msdos cross-compile led to
this change.
2025-01-04 19:01:34 -05:00
Pasi Kallinen
1ef3167ca0 Steed #monster breath feedback
Using #monster to make the steed use the breath weapon often
failed because the steed did not want to breathe at weak or
too strong monsters.
Make #monster force the steed use the breath, and if there is
no targets available, make the steed make some noise as feedback.
2025-01-04 16:37:14 +02:00
nhmall
d3c57e1b42 fix reported crash of TTY_PERM_INVENT segfaulting
Options processing can be early, even before ttyDisplay is allocated.
If we find that TTY_PERM_INVENT initialization is happening too early,
just set a marker (iflags.perm_invent_pending) to try again a bit later.

The changes in win/share are just to be able to sucessfully
reproduce the original issue on Windows. It was easily reproduced
on Unix, just by building with TTY_PERM_INVENT in include/config.h
and setting OPTIONS=perm_invent in config file.
2025-01-02 11:46:15 -05:00
nhmall
eacfa202d9 soundlib selection in config file wasn't working
When there was more than one option #define'd
selection was not working correctly.
2024-12-30 12:54:12 -05:00
nhmall
57f86662fd try harder to have --showpaths succeed
This helps avoid a potential chicken-and-egg scenario
with the system configuration file (sysconf).

If sysconf wasn't accessible at the expected location, it
caused an immediate exit, without relaying any helpful
information. That happened even when using:
    'nethack --showpaths'

That's particularly unhelpful, because the --showpaths
output might have been useful towards understanding where
NetHack was looking for such things.

That left you without an easy recourse to identify where
the game is looking for the sysconf file. That might be
especially troublesome if you didn't build the game
yourself.
2024-12-22 19:58:52 -05:00
nhmall
f6a5236beb follow-up to #1343 fix for telepathic hero
telepathic hero can discern which particular monster just
read a scroll, even though he cannot see the monster
2024-12-20 15:30:37 -05:00
PatR
8a7f3b2b6b more issue #1303
Various bits I had in progress before Michael's commit.

Mainly forget engravings when bones are saved instead of leaving them
flagged as seen for the next hero who gets the level.
2024-12-19 18:18:11 -08:00
nhmall
f7853be3dc fix GitHub issue 1303 related to engravings
GitHub issue reported by ars3niy:
https://github.com/NetHack/NetHack/issues/1303

@ars3niy commented on Oct 27:
Stepping on a square with a dust or "graffiti" engraving while blind
produces no message because presumably you can't read them by swiping
the floor with your hands, however the engraving glyph still shows up on
the map afterwards. While this helps zen players, it looks like a bug.

@ville-v commented 3 days ago:
Searching while blind also reveals the engravings. Here is a save file
demonstrating the issue.
[...]

This adds an erevealed bit to engravings, to accompany the the eread
bit that is already there.

eread:      refers to the text of the engraving
erevealed:  refers to the engraving map symbol

Hopefully, this resolves issue 1303 without creating additional bugs.

This invalidates existing save files and bones.

Fixes #1303
2024-12-19 17:53:43 -05:00
Pasi Kallinen
fd23463941 Sparkle shield effect and accessibility
When sparkle is turned off, there are some places where
a monster resisting the effect did not give any message.

This fixes some of those.
2024-12-14 14:34:22 +02:00
PatR
b2b9b685c5 fix issue #1305 - failed #untrap from doorway
Issue reported by loggersviii:  attempting #untrap from an adjacent
doorway can move the hero diagonally out of the doorway.

A followup comment by elunna pointed out that a monster's attack that
results in knockback can produce similar result.

Fixes #1305
2024-12-13 22:48:32 -08:00
Alex Smith
3491535548 More bugfixes for the recent artifact gifting changes 2024-12-12 07:35:50 +00:00
Alex Smith
d87cadaf73 Artifact and #offer rebalance, part 1: sacrifice gifts
In 3.6, artifact gifts are often either a) entirely useless or
b) gamebreaking, neither of which is really ideal from a balance
perspective.

This commit aims to make artifact gifts more useful in the early
game by greatly increasing the chance for situational artifacts to
generate positively enchanted.  However, the most powerful
artifacts will now only be gifted if you offer a high-value corpse,
meaning that they are only likely to be accessible later in the
game.  The selection of which artifact to gift has become more
complicated in order to a) increase the chance that it fits the
character and b) reduce cheese strategies (e.g. it is no longer
possible for elves to force the gifting of Stormbringer as the
first sacrifice gift).
2024-12-12 03:14:47 +00:00
Pasi Kallinen
57abae29e8 Don't switch away from polearm if monster in range
Using 'f', if hero is wielding a polearm, and a monster is in range,
don't switch away even if we do have ammo in quiver and a launcher
in the inventory.
2024-12-08 22:19:36 +02:00
Pasi Kallinen
863d455e1d Tourists gain experience by using camera flash on monsters
This counts as seeing the monster up close, so the tourist
doesn't need to get next to the monster
2024-12-07 11:24:30 +02:00
Pasi Kallinen
e23e6ef235 Blessed scroll of destroy armor asks which armor to destroy
via xNetHack with some slight modifications.
2024-12-06 11:09:27 +02:00
PatR
1301234039 mimic feedback tuning
When a mimic in door form is hit by a wand of locking or wand of
opening or corresponding spell, bring it out of concealment like
was recently done for being zapped while in chest form.  And give
some feedback rather than just changing the mimic's form to 'm'.

Give more detailed feedback when bumping into a mimic while moving.
2024-12-02 11:37:04 -08:00
nhmall
9f33d1cf7a Merge branch 'newsym_worm' of https://github.com/entrez/NetHack into NetHack-3.7 2024-11-30 20:14:40 -05:00
Michael Meyer
92d931f190 Refresh worm segments when (un)taming
Because newsym() would be called only on the head position of the worm,
if hilite_pet was on, the segments and head of a long worm would have
mismatched highlighting in the immediate aftermath of taming or
untaming.
2024-11-30 17:30:52 -05:00
nhmall
bc88266081 NetHack's regex function prototypes into nhregex.h
There was an issue with Windows mingw build because the function
prototypes were not available. Place them into a distinct
header file nhregex.h and include it from extern.h, and
available for cppregex.cpp to include without the rest of
extern.h (which can give some problems with c++).
2024-11-30 17:08:54 -05:00
nhmall
e83e04dbb3 fix some memory leaks 2024-11-10 22:24:45 -05:00
nhmall
5cc529efc8 follow-up related to #1320
This is additional groundwork related to
https://github.com/NetHack/NetHack/issues/1320

This additional groundwork just puts some safeguards
in place to make it rather tough to end up with an
instant death from handling a cockatrice corpse in
your inventory without appropriate protection.

At this point, still no actual petrification will occur.
2024-11-09 23:49:10 -05:00
nhmall
9c554895b1 adjust wish for cockatrice corpse
Wishing is powerful, so if you cannot safely handle a cockatrice
corpse, then have a wish for one result in the corpse materializing
on the floor rather than in your inventory.

Resolves #1320
2024-11-09 14:06:43 -05:00
nhmall
9a42d70901 ranged attack in repertoire might not be used
Commit 22884522, ported (from Sporkhack, Evilhack), added the ability
for monsters to maintain awareness of player resistances that they
observed.

Since they will refrain from using a ranged attack that they deem
futile, take the specific monster's seen_resistance field into consideration
when choosing code paths based on the availability of ranged attacks.

Resolves #1307
2024-11-03 09:03:04 -05:00