Commit Graph

9188 Commits

Author SHA1 Message Date
Michael Meyer
1736f3caaa Add 'pickup_stolen' option
Add pickup_stolen option to autopick items stolen from you by a nymph or
monkey, even if they don't match your normal autopickup settings.
Replace was_dropped, was_thrown with a 2-bit bitfield that can contain
values LOST_DROPPED, LOST_THROWN, and LOST_STOLEN (or 0), since they
should all be mutually exclusive anyway as they track the most recent
way the item left the hero's inventory.

[Rebase/merge conflict fixed up.  PR]
2023-12-08 15:19:54 -08:00
Michael Meyer
ecda85cc32 Don't merge stacks w/ different was_thrown/dropped
Previously, if you threw a dagger into a pile of daggers, you'd pick up
the entire pile with pickup_thrown on.  Since pickup_thrown and
dropped_nopick options are supposed to apply specifically to items
you've handled, don't merge items with different values in those fields.
2023-12-08 15:19:05 -08:00
Michael Meyer
c07d114644 Add object sanity check for was_dropped/was_thrown 2023-12-08 15:19:05 -08:00
Michael Meyer
e2e89cb93e Rename/invert 'pickup_dropped' to 'dropped_nopick' 2023-12-08 15:19:05 -08:00
Michael Meyer
d7d1c1476d Add option to exclude dropped items from autopick
This is based on a feature in UnNetHack (and I think some other variants
as well).  If the hero intentionally drops an item with 'pickup_dropped'
disabled, don't autopick it back up when walking over that square again.

Typically when the player drops an item, it's because she doesn't want
it in her inventory any more, and this option stops autopickup from
defeating that goal (especially useful for tasks like stash management
without a container).  Players have come up with workarounds to this
problem like toggling autopickup when approaching their stash pile or
adding name-based autopickup exceptions to allow them to exclude
individual items from autopickup, but this behavior should reduce the
need for those things.

I think 'pickup_dropped' is a little unfortunate because it suggests
equivalence to 'pickup_thrown' (i.e. any dropped items will be
automatically picked up regardless of autopickup exceptions).  Calling
it something like 'nopick_dropped' might be better, but as far as I can
tell options cannot start with the word 'no' because it's interpreted as
a negation of the rest of the option name.
2023-12-08 15:19:04 -08:00
PatR
275713b56e more source reformatting
Less extensive this time.  Contributed by entrez.
2023-12-08 12:15:24 -08:00
PatR
9ea2894448 fix discovered artifact panic
When known discoveries was displayed on a window of type NHW_MENU,
header lines sent to it via menu_add_heading() disappeared into the
bit bucket.  Switching back to putstr() made them show up.  But I also
changed the type to NHW_TEXT.  A menu_add_heading() in artifact.c was
overlooked, and after the window type change that started triggering
a panic when '\' or '`a' was used while any artifacts were discovered.

Not sure how other interfaces were dealing with this.
2023-12-08 11:41:53 -08:00
Pasi Kallinen
348f88c726 Walking into a shopkeeper tries to pay the bill 2023-12-08 18:31:16 +02:00
Pasi Kallinen
20b91270ba Fix wrong level flags in mazes below Medusa
The mazes between Medusa and the Castle had couple wrong default
level flags, because those levels don't go through the special
level routines.
2023-12-08 14:10:12 +02:00
PatR
a1f21b702d warning fix for #if CRASHREPORT
Thinko in the reformatting, not triggered during testing because I was
using !CRASHREPORT.  With it enabled, setting a watchpoint in gdb on
something unrelated resulted in nethack going into crashreport_init()
and never caming out.  (I imagine that it would have eventually but 10
or 15 minutes with nothing noticeable taking place was unbearable, and
the program hadn't even really started yet.)
2023-12-08 03:30:32 -08:00
nhmall
2a9ede0fd7 ill-formed macro (build fix) 2023-12-08 05:01:47 -05:00
PatR
c41cb1a7fa source reformatting
Fixup some of the inconsistently formatted code that has been
introduced recently or been building up for a while.  Done manually.
I wasn't systematic except for looking for lines ending in '&' or '|'
(which wouldn't find such things if they're followed by a comment)
so there might be lots more.  I changed a bunch of C++-style //...
comments to old style C /*...*/ so that they'll match the rest of
the core's code rather than because they shouldn't be used.
2023-12-08 00:30:10 -08:00
PatR
2bd967fe8a a few fewer update_inventory() calls
A couple of things I noticed while running umpteen tests for tty
perm_invent.  Remove the update_inventory() from unmul(), and limit
the one that deals with seeing inventory when recovering from blindness.

Just a drop in the bucket overall, and the screen updates nearly
instantly for update_inventory() except when debugging perm_invent so
players aren't likely to notice this.
2023-12-07 22:47:57 -08:00
Pasi Kallinen
d2ae6fd5d2 Split out wizmode monpolycontrol part 2023-12-08 08:32:07 +02:00
PatR
4140a0023c fix #4059 - TTY_PERM_INVENT not freeing memory
As part of the tty resize handling revision, code dealing with the
perm_invent window was moved out of tty_destroy_nhwindow() was moved
into a separate routine.  The new routine would have been called for
a window of NHW_PERMINVENT, but WIN_INVENT doesn't have that type,
just ordinary NHW_MENU, so the cleanup wasn't happening, resulting in
a memory leak.
2023-12-07 18:36:14 -08:00
PatR
5186af22c7 another MONITOR_HEAP bit
Another instance of freeing a null pointer.
2023-12-07 18:31:56 -08:00
PatR
b1f67a9842 lua memory usage
Silence a bunch of complaints from heaputil about freeing Null
pointers.  The C standard allows that but it makes the data collected
about mallocs and frees not match up when nethack has MONITOR_HEAP
enabled.
2023-12-07 11:48:05 -08:00
nhmall
f31a110d75 yet more monsym() 2023-12-07 09:59:34 -05:00
nhmall
12ca2be5b4 more fixes via monsym() 2023-12-07 09:55:37 -05:00
PatR
5c5a5cf2cc minor memory leak in mdlib opttext[]
opttext[] was given 120 elements but the MAXOPT macro used to limit
populating it was only 40.  There happen to be exactly 40 lines of
runtime info--at least for my config--and the last slot was going to
waste, so the final dupstr("") at the end of build_options() wasn't
being tracked and freed.

It's interesting the whatever other memory checker is being used
failed to find something caught by old heaputil.  Maybe the configs
running whatever it is are generating smaller options text?
2023-12-07 04:05:26 -08:00
nhmall
ee3ebcc10d fix bug in mon.c reported by paxed
Also adds a shorthand macro
    monsym(&mons[n])
for getting the default symbol, used in the bugfix.
2023-12-06 22:18:11 -05:00
nhmall
c1910026f0 include some more enum dumps 2023-12-06 21:41:49 -05:00
Alex Smith
0d508cc936 Implement the spellbook of chain lightning
Prior to this commit, there was no good way to deal with swarms of
weak, good-AC enemies using magic; trying to play a wizard as a
pure spellcaster would make bees and ants very difficult to deal
with (because they would usually dodge force bolts).

This commit adds a new spell designed to be very good against
swarms of weak enemies: "chain lightning", which does 2d6 lightning
damage to every monster around you. It has an initially short range,
but can chain from monster to monster to cover potentially large
distances (as long as none of the monsters en route are shock
resistant or tame/peaceful; the spell can't chain past shock
resistant monsters and avoids peacefuls). Monsters within one
space of the visible lightning bolts are affected. Unlike other
lightning effects, this one does only 2d6 damage, not enough to
blind affected monsters.

This commit breaks existing save and bones files (thus the
EDITLEVEL increase).
2023-12-06 20:02:35 +00:00
Pasi Kallinen
5dc94f3d83 Macro for picking random entry from array 2023-12-05 10:06:27 +02:00
Alex Smith
b98a70e3ec Dwarvish cloaks somewhat protect inventory from cold and fire
The change to Sokoban difficulty calculation introduced a balance
issue: previously the Sokoban prize was obtainable before item-
destruction attacks became common and would protect from them,
whereas now they commonly appear in Sokoban itself, before the
prize is accessible. This makes scrolls and potions much less
usable as escape items, and potions of healing less usable for
HP recovery, because they either get stashed or destroyed (and
in either case aren't usable by the character in time-critical
situations).

This commit attempts to alleviate the problem by adding a way to
protect items from cold and fire in the early game. It's a
little unreliable, and requires equipping an item that has bad
stats and generally isn't otherwise used, but which is generally
easy to find early on.

Not included in this commit, but probably necessary for a
"finished" version of the feature: some way of letting players
know the new mechanic. It shows up in enlightenment, but there
should probably be at least rumors (and maybe even a major Oracle
consultation) hinting at the mechanic. We might also want to
change the unIDed description of the dwarvish cloak as a hint,
although that would require, e.g., new database entries.
2023-12-05 04:52:02 +00:00
Alex Smith
7ca9951996 Reduce code duplication in extrinsics-protect-items code
The same checks were being repeated for every damage type; this
sends them through two centralised functions (one for checking
whether an extrinsic blocks a specific instance of item destruction
and one for the enlightenment message), so that new mechanisms of
item destruction prevention will need to change only one point in
the code.
2023-12-05 04:34:24 +00:00
nhmall
d52049a5d3 The src/options.c change was unneeded 2023-12-04 16:12:04 -05:00
nhmall
3ca4571011 more SYMBOLS follow-up
missing break
2023-12-04 15:46:24 -05:00
nhmall
4a9d68bf7f symbol parsing follow-up 2023-12-04 15:41:09 -05:00
PatR
df789bc200 fix showing discoveries
A few add_menu_heading() calls were added to the '\' and '`' commands
which use a text window rather than a menu.  For some reason they were
using create_nhwindow(NHW_MENU) but only populating it with text so
the heading lines sent as menu entries were lost.  (Might panic with
Qt; I didn't check.)
2023-12-04 12:18:03 -08:00
nhmall
40d090a2c3 Merge branch 'ice_fumbling' of https://github.com/entrez/NetHack into NetHack-3.7 2023-12-04 15:01:07 -05:00
Michael Meyer
986c8e7ff4 Check whether steed will slip on ice if mounted
If riding over ice, check whether the steed, rather than the hero, is
cold-resistant or floating to determine whether it should slip, since it
is the monster which would actually be in contact with the ice.
2023-12-04 14:52:58 -05:00
Michael Meyer
a15d517326 Refine ice fumbling effects vs mounted hero
Fumbling makes the hero fall from the saddle, but the justification was
weak if the only fumbling source is riding over ice (the messages were
things like "you drop the reins" which made more sense from magical
fumbling).  Make all fumbling from ice alone go into the ice-specific
"slip on the ice" block and add a chance to fall from your mount there.
If fumbling from another source while riding on ice, the hero will
always fall from his steed, since that's what happens on normal floor --
ice had actually been reducing this chance.
2023-12-04 14:40:16 -05:00
nhmall
418953e0e6 symbol parsing improvement
This gets rid of a FIXME and K4056 internal bug report.

Allow the comma to be quoted as follows:
     SYMBOLS=S_ice:\,
or
     SYMBOLS=S_ice:','

Disclaimer:
The use of the comma on the map could conflict with future
use of that currently unused symbol for other intended purposes.
2023-12-04 14:20:07 -05:00
Michael Meyer
05f9950c99 Fix: fumbling vs losing footing in earthquake
Fumbling was apparently meant to make it harder to keep your footing
when an earthquake created a pit under you, requiring a 1/5 roll to
stay upright, but because it was added as an additional OR it actually
just gave the hero an additional (albeit unlikely) chance to retain her
footing.  Make it actually have a negative impact on the hero's ability
to retain his footing rather than a minor boost.
2023-12-04 13:07:43 -05:00
nhmall
7f97d86b40 Merge branch 'fix-zap' of https://github.com/argrath/NetHack into NetHack-3.7 2023-12-04 11:27:58 -05:00
nhmall
d8909ec3d0 comment 1st dereference of otmp in bhitm() 2023-12-04 11:26:50 -05:00
Pasi Kallinen
d8421aa219 Save and restore hero tracks
The tracks left by hero were cleared when player saved and
restored the game, or changed levels.  Now the tracks are
saved in the dungeon level, so changing levels keeps the tracks
left by hero in that level.

Also increased the length of tracks from 50 to 100, and
simplify the tracking function.

Thing not done: fade out old tracks when returning to a level.

Breaks saves and bones.
2023-12-04 17:50:48 +02:00
SHIRAKATA Kentaro
b36d792334 remove unnecessary null-check on bhitm()
`otmp` here is always non-null, otherwise it leads segv at earlier code.
2023-12-04 22:14:37 +09:00
PatR
2713853f28 another uhandedness bit
For the accessories section of '*' and perminv_mode=InUse, show the
ring on main hand first (after amulet) and the one on off hand after
(before blindfold).  Main hand ring is more significant due to the
potential of a one-handed weapon becoming cursed, preventing it from
being removed.
2023-12-04 00:54:42 -08:00
PatR
6e785f4d8c uhandedness: include handedness in ^X feedback 2023-12-04 00:17:57 -08:00
PatR
2be47f1d93 options bit: wizweight
Persistent inventory window wasn't being updated right away if the
'wizweight' option was toggled via 'm O'.
2023-12-03 18:22:29 -08:00
PatR
ed6b78e227 fix #K4054 - spellbook weight bug
Report was that converting a novel into a blank spellbook via water
damage resulted in a spellbook of blank paper that increased weight
when put into a bag of holding.

Spellbooks weigh 50 units but novels were defined with a weight of 0;
when one was created, a non-zero weight of 1 got assigned.  Blanking
it didn't update the weight; that stayed at 1.  Putting it into a
container reset the weight to match the new type: spellbook of blank
paper, so its weight increased.

Do that when blanking rather than wait until a container might fix it
up.  If it is already in a [possibly nested] container, update that
container's weight too along with any outer ones.

This also changes the base weight of novel from 0 to 10, so it still
gets magically heavier when turned into a spellbook of blank paper.
(The alternative seems to be to destroy it instead.)

The Book of the Dead weighed only 20 units which seemed odd to be so
much less than a spellbook.  This changes that to 50 to match those.
2023-12-03 18:03:16 -08:00
nhmall
3230babae0 uhandedness follow-up
avoid (wielded in right hands)
2023-12-03 20:27:01 -05:00
Alex Smith
495a1a9b07 Tweak to Wizard spellbook knowledge
Wizards now start out recognising all level 1 spellbooks, making
it possible to write a low-level spellbook in order to start
training a spell skill of choice.
2023-12-03 16:16:19 +00:00
nhmall
713eafc8c8 reduce flashing w/options simple menu iterations 2023-12-03 01:15:04 -05:00
nhmall
7d22a2c7b9 uhandedness follow-up
boomerang trajectory
bones
2023-12-02 20:25:37 -05:00
Alex Smith
fe2d8faed9 Fix for use-after-free in supply chest generation 2023-12-03 00:50:28 +00:00
PatR
6c38bfeba2 fix #K4042 - visible but unreachable teleport trap
If a monster fled from the hero by intentionally jumping into a vault
teleporter located in a niche which was still hidden and the hero
saw it happen, the trap would be mapped but the niche would remain as
a secret corridor spot.  The hero couldn't move onto the trap until
searching or wall kicking or other map disclosing activity converted
the spot into regular corridor.

Trap doors in hidden niches did already change the secret corridor
into normal corridor to unhide the trap's spot, but only if the hero
saw it happen.  Now the terrain change occurs even if hero doesn't
see it; only mapping the trap depends on that.

While testing the fix, I noticed that a monster jumping onto a vault
teleporter was teleporting randomly rather than being sent to the
vault, unlike when triggering such a trap by accident.  The code has
changed for 3.7 but this bug was already present in earlier versions.
2023-12-02 15:05:45 -08:00
nhmall
0c03b9bea6 follow-up: Soundeffect does its own Deaf check
Simplify previous fix, as Soundeffect does its own Deaf checks,
so doesn't need to follow an if-test.
2023-12-02 14:40:18 -05:00