Commit Graph

16059 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
Pasi Kallinen
ecb3a1a68d Change mind flayers, the Wizard, and the riders to bright magenta 2023-12-08 22:03:54 +02: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
ad833ce02d Add more tile grayscale mappings
Color I added to the warg tiles was missing from the greyscale
mapping when generating statue tiles.  Map the missing greys
to slightly darker shades.
2023-12-08 21:16:02 +02:00
nhmall
7259ae21f5 initializer fix for !VIRTUAL_TERMINAL_SEQUENCES
For windows sys/windows/consoletty.c.

Resolves #1169
2023-12-08 13:01:52 -05:00
nhmall
dbb41f4a2d const warning in sound/fmod/fmod.c
Parameter did not match those in include/sndprocs.h
2023-12-08 12:31:49 -05: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
Pasi Kallinen
3b2d3eabed Change wolf, werewolf, and warg colors
There were 6 brown 'd' monsters; move wolf and werewolf to grey,
and warg to black, as those colors had no canines.

The wolf tiles are already greyish; changed warg tile to be
slightly darker.
2023-12-07 17:47:21 +02:00
nhmall
4140491289 Merge branch 'fix-exit-crash' of https://github.com/chasonr/NetHack into NetHack-3.7 2023-12-07 10:08:07 -05:00
nhmall
fc4f0a603d Merge branch 'vesa-fixes' of https://github.com/chasonr/NetHack into NetHack-3.7 2023-12-07 10:07:24 -05: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
nhmall
e639c4bdaa A recent patch 634f4928 introduced new tty behavior,
where calling term_start_color(NO_COLOR) would have the same
effect as calling term_end_color().

That change only included a change for termcap, but not any of
the NO_TERMS configurations. (NO_TERMS is defined for an
implementation where termcap is not used).

This attempts to make sys/msdos/video.c and sys/windows/consoletty.c
honor the change.

The msdos change has not yet been tested.

No attempt was made to alter the term_start_color() implementations
within the outdated tree.
2023-12-07 09:34:05 -05:00
Ray Chason
df66ee1ad9 Avoid calling Curses after it is shut down 2023-12-07 07:07:21 -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
Pasi Kallinen
6e2fa24344 Change hezrou and vrock color to green
There are many red major demons, and hezrous and vrocks
now emit poison gas, so change the symbol color to green.

Also adjust vrock tiles to have green. The hezrou tiles
already are green.
2023-12-07 13:50:51 +02:00
PatR
634f492827 fix #K4058 - tty: perm_invent fixes
I think this fixes all problems with the boundary boz drawn around
perm_invent.  Also, if you enabled perm_invent in inuse_only mode
while there are already more items in use than would fix in the
available number of lines, it wasn't switching to two columns until
the next update_inventory().  And the new color handling wasn't
incorporate into tty_refresh_inventory() so after a corner window
clobbered some of perm_invent, it got redrawn but without color,
again until the next update_inventory().

With any luck this fixes more bugs than it introduces....
2023-12-07 03:22:44 -08:00
PatR
7c20bf4afa tty: term_start_color(NO_COLOR)
Make term_start_color() more versatile.  If it gets passed NO_COLOR
then it performs term_end_color().  Should be able to streamline
some of the color handling this way although this hasn't done so.
2023-12-07 02:52:41 -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
nhmall
11a926c4cc TTY_PERM_INVENT: menucolors colors text, not inv letter
This diff is slightly inflated because I relocated a tty function
within win/tty/wintty.c.
2023-12-06 15:41:06 -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
nhmall
45856e3b5b follow-up: bordercolor lacked have expected offset 2023-12-06 13:49:33 -05:00
nhmall
8018fe64cf remove an outdated TODO: comment in wintty.c
A comment made reference to something that is fulfilled by
the core now, but that probably wasn't the case when that
comment was originally added.
2023-12-06 13:42:28 -05:00
nhmall
54332f5598 TTY_PERM_INVENT: honor color passed by add_menu()
Features like menucolors and so forth, are now done in the
core, and passed to the window interfaces via add_menu().

TTY_PERM_INVENT was disregarding the passed color value.

That can be turned off by the option !menucolors.

If a way to turn off menucolors in TTY_PERM_INVENT (or
perhaps in any perm_invent implementation), while keeping
it on for other menus, then a new option will be required.
2023-12-06 13:30:33 -05:00
Ray Chason
1f52205ee2 Fix crashes and weirdness in VESA text mode 2023-12-06 09:05:23 -05:00
PatR
1b1c45d3ce TTY_PERM_INVENT perminv_mode=inuse
Revise the tty permanent inventory window's in-use mode to be able to
switch back and forth between one full width panel and two side-by-side
half width panels on the fly as needs dictate.

A lot of trial and error involved but I think it has reached a state
where it is reliable, and the smaller number of lines required at
present can probably be viable for actual usage.  At the moment it
requires at least 10 extra lines below the standard tty mesg+map+stat
display, 34 lines total for statuslines:2 or 35 for statuslines:3.
The top and bottom of the 10 or more extra lines get drawn as boundary
lines using wall characters, leaving 8 lines for full width or 16 half
lines when 8 isn't enough.  If more that 16 items are in use (maybe
lots of lit candles forced into separate inventory slots or a
menagerie on leashes), the excess get skipped.  However, it will use
more lines if they are available.  Prior to a few days ago it was
requiring 17 extra lines and able to show 15 items as full lines only,
unable to take advantage of more lines when available.
2023-12-06 02:19:41 -08: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
PatR
2d8ba944e1 add some flexibility to TTY_PERM_INVENT
Allow perm_invent to be enabled with 1 less line when statuslines==2
by not reserving a line for statuslines==3.  If the player changes
that from 2 to 3, the perm_invent window is torn down and repositioned
one line lower if that will fit.  If it won't fit, it won't reenable.

Temporarily(?) allow perminv_mode==InUse to be enabled with room for
only 8 lines instead of requiring 15.  It will use more than 8 if are
more rows.

8 happens to be the amount (via 1+21+3+(1+8+1)) that will fit within
35 lines which is the biggest I can make fit on may laptop without
switching to a smaller font.  Switching is a nuisance, worse than that
for the font tiny enough to fit the full perm_invent.

ToDo:  if in-use won't fit in the number of lines allotted, switch to
two columns before resorting to ignoring the excess.

Maybe:  allow fewer lines for full perm_invent too and use the '|'
command to scroll them.  Might be too clumsy to be worthwhile.
2023-12-04 13:20:25 -08: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