PatR [Thu, 24 Mar 2022 22:49:27 +0000 (15:49 -0700)]
eating green mold corpses
A reddit posting points out that the green mold monster definition
has the flag for conveying stoning resistance but it doesn't work.
There seem to be 3 choices:
1) implement being able to gain that resistance;
2) take the flag away;
3) mark green molds no-corpse so that the issue becomes moot.
The poster was hoping for (1) but I've gone with (2). Green molds
are too common and not at all dangerous; being able to gain stoning
resistance--even with a tiny chance--could potentially be a major
change in play balance.
PatR [Thu, 24 Mar 2022 18:15:37 +0000 (11:15 -0700)]
mazexy() again
Some maze code treats row y_maze_max and column x_maze_max as being
in play, other parts treat them as out. mazexy() was doing both; the
first loop to choose a random spot allowed them, the second loop to
try every possible spot disallowed them. Make those be consistent.
I think the extreme row and column are both expected to be solid wall
so failing to consider them might not be causing any problems.
While in there, change mazexy() to not set cc->{x,y} until it has
found a viable spot instead of potentionally making that assignment
dozens or hundreds of times. The only difference there is that 'cc'
won't have been assigned any value if panic() gets called.
PatR [Wed, 23 Mar 2022 20:20:26 +0000 (13:20 -0700)]
mkstairs() sanity check
Complain during level creation if stairs are placed on top of anything
other than the expected room/corridor/ice terrain. This won't prevent
the bug of upstairs and downstairs existing on the same spot (github
issue #702, also a newsgroup posting by a hardfought player) but might
at least warn players if/when that happens.
Michael Meyer [Tue, 22 Mar 2022 19:40:13 +0000 (15:40 -0400)]
Handle spiders, cockatrices in mbodypart
Spiders and cockatrices were using the default animal_parts, which was
noticeably inaccurate in describing certain parts of their bodies. Add
specific handling for both types of monsters: for spiders, add a
spider-specific body part list (the best I could figure out from online
sources, not being a spider anatomy expert), and for cockatrices, use
bird_parts with "scales" from snake_parts thrown in to emphasize their
unusual nature.
PatR [Tue, 22 Mar 2022 18:33:17 +0000 (11:33 -0700)]
"just picked up" tweaks
For menustyles traditional and combination, allow 'IP' to request
inventory listing of just picked up items even if not carrying any
items flagged as just picked up. The not carrying any such items
feedback was already present but couldn't be triggered.
For menustyles partial and full, the special menu entry for 'P'
when only one item applies shows the item instead of the category
"Items you just picked up". [That sort of thing probably ought to
be done for every menu entry rather than just for 'P'.] Rephrase
it from
| P - <item>
to
| P - Just picked up: <item>
in case it is player's first time seeing that category be listed.
Clear the just picked up flag for any item that is dipped or read.
Lots of other actions besides drop or put-into-container probably
ought to do that too. [Maybe even just picking an item with getobj()
could be sufficient so that it wouldn't have to be replicated all
over the place.]
PatR [Tue, 22 Mar 2022 17:48:23 +0000 (10:48 -0700)]
encumbrance checks
I polymorphed into something wimpy and became overloaded or even
overtaxed so I dropped everything. The status line still showed
overloaded or overtaxed until my next move. That didn't happen in
3.6.x or 3.4.3 but I didn't pursue trying to figure out what caused
this misbehavior.
I wanted to add an encumber_msg() call to freeinv() but that would
cause message sequencing issues. Instead, add a call to it in a
few places where items are leaving hero's inventory, particularly
for the chain of calls for dropping stuff. I've left it off in a
bunch of other potential places.
Also add a few missing (void) casts where the return value of
existing encumber_msg() calls is being ignored.
Pasi Kallinen [Tue, 22 Mar 2022 07:16:15 +0000 (09:16 +0200)]
Lua: coordinate tweaking
Make selection rndcoord return a table with x and y keys.
Allow (most) coordinate parameters accept such a table.
Fix selection and des lua tests broken by the above changes and
an earlier change, because selections tried to set terrain
at column 0, and it now causes a complaint.
PatR [Tue, 22 Mar 2022 01:21:07 +0000 (18:21 -0700)]
hide-under webmakers...
Offer the chance to explicitly hide via #monster when poly'd into a
hides-under creature. hides_under() doesn't pass the is_hider() test
so wasn't being allowed before.
If poly'd hero's monster form is both a webmaker and can hide-under,
have #monster prompt the player for which is intended. When poly'd
hero successfully spins a web, say so.
If poly'd hero deliberately tries to hide under a cockatrice corpse,
turn to stone.
PatR [Tue, 22 Mar 2022 01:11:26 +0000 (18:11 -0700)]
eating food while hiding under it
Fix the bug reported by entrez where you could end up hiding under
nothing if while poly'd into a hides-under creature and hiding under
something edible you ate whatever you were hiding under. Same thing
could happen if it was a corpse on an altar and you offered it rather
than consumed it.
While in there, fix monsters hiding under cockatrice corpses. They
won't do that unless there are multiple objects in the pile, but
there was no check for the possible case of all additional objects
also being other cockatrice corpses.
PatR [Mon, 21 Mar 2022 19:32:07 +0000 (12:32 -0700)]
max HP manipulation
Life-saving has been setting u.uhpmax to max(2 * u.ulevel, 10)
and if it took place during level drain that could make u.uhpmax
increase instead of decrease, confusing healing which gets applied
to a monster who has drained the hero with Stormbringer or the
Staff of Aesculapius. Change the setting to be max(u.ulevel, 10)
(removing the times two part) and also have level drain force it
to be set back to previous value if/when it gets increased.
Max HP loss due to strength trying to drop below 3 or to fire trap
or to being hit by Death now uses a mininum max HP of u.ulevel
rather than 1. They don't have the alternate minimum of 10; I'm
uneasy that there are still two different minimum values.
I changed adjattrib() to set the flag to request a status update
before it gave its optional message rather than after so that the
new characteristic value would be visible during the message. That
resulted in not updating status when eating royal jelly changed HP
or max HP after boosting strength. But the same missing update
would have occurred--or rather, failed to occur--without the change
in sequencing if the strength boost causes a change in encumbrance.
PatR [Sun, 20 Mar 2022 01:03:01 +0000 (18:03 -0700)]
pull request #708 - logging of first hit
Pull request from entrez: the log message "hit with a wielded weapon
for first time" for breaking the "never hit with a wielded weapon"
conduct wss being given when hitting with wielded non-weapons. Since
the conduct remained unbroken in that situation, the 'first hit'
message would be re-logged for subsequent non-weapon hits. This bug
was not present in initial livelog implementation; it was introduced
by the change to log first-hit before first-kill when those occurred
on the same attack. Verify that the wielded object is actually a
weapon or weapon-tool when deciding whether to log first-hit event.
Michael Meyer [Sat, 19 Mar 2022 19:33:13 +0000 (15:33 -0400)]
Fix: repeated 'hit with a wielded weapon' logging
The "hit with a wielded weapon for the first time" livelog line could be
produced repeatedly: it was triggered by hitting a monster with a
wielded object of any sort, but the u.uconduct.weaphit counter was only
incremented if hitting with an actual 'weapon' (a WEAPON_CLASS or
is_weptool item). As a result, if a non-weapon-using hero whipped out a
non-weapon item -- a cockatrice corpse, for example -- and started going
to town on some monsters, the livelog message would be repeated with
every hit.
PatR [Sat, 19 Mar 2022 22:49:55 +0000 (15:49 -0700)]
menuinvertmode for win32/Windows GUI
Catch up with tty, curses, X11, and Qt: menuitem_invert_test()
applies to select as well as invert and if menuinvertmode is 2 then
it also applies to unselect.
PatR [Sat, 19 Mar 2022 22:32:31 +0000 (15:32 -0700)]
menuinvertmode for Qt
Catch up with tty, curses, and X11. Items flagged as skip-invert
will not be toggled On by select-all. If menuinvertmode is 2, they
also won't be toggled Off by unselect-all.
PatR [Sat, 19 Mar 2022 22:09:20 +0000 (15:09 -0700)]
menuinvertmode on X11
Catch up with tty and curses. Menu items flagged as skip-invert will
not be toggled On by select-all and select-page. If menuinvertmode
is 2 they also won't be toggled Off by deselect-all and deselect-page.
PatR [Sat, 19 Mar 2022 19:49:43 +0000 (12:49 -0700)]
menuinvertmode on curses
Change curses' use of menuitem_invert_test() to match the recently
changed tty behavior: when menuinvertmode is 1 the test excludes
special menu items that are flagged 'skip-invert' while handling
select-all and select-page as well as invert-all and invert-page,
and when that option is 2 then it also operates on deselect-all and
deselect-page.
Pasi Kallinen [Fri, 18 Mar 2022 16:33:32 +0000 (18:33 +0200)]
Fix dmonsfree pending when hero was hit with drain-life artifact
When a monster hit hero with an artifact with drain-life attack
(Stormbringer or The Staff of Aesculapius), and hero lost a level
and hero had more max hp in the lower xp level, the math made the
attacker lose hp. This could put the monster hp in the negative,
causing "dmonsfree: 1 removed doesn't match 0 pending"
Michael Meyer [Fri, 18 Mar 2022 00:04:58 +0000 (20:04 -0400)]
Collisions while hurtling can stone participants
Hurtling into a monster is described as "bumping into" it, so it makes
sense that hurtling willy-nilly into a cockatrice (or vice-versa) could
result in petrification. Since hurtling for the hero usually involves
"floating in the opposite direction" (presumably backwards) after
throwing an item, check whether the hero is wearing any body armor which
would cover their torso rather than looking for gloves. Do the same for
monsters on the general basis that it's a bodily collision, and for the
sake of consistency.
PatR [Thu, 17 Mar 2022 18:33:29 +0000 (11:33 -0700)]
choosing 'menustyle'
When using 'O' to set the menustyle option, include a description of
each of the styles. Makes the menu entries two lines of two columns
each: first line contains the setting value and the first half of
its description; second line has blank left column and second half
of description in the right one. Value on first line and single-line
description on second would have been simpler but this seems easier
to read--the four possible values don't have any clutter between them.
PatR [Thu, 17 Mar 2022 00:03:52 +0000 (17:03 -0700)]
tty: count for group accelerators
github issue #697 from copperwater points out that using a menu for
pickup and attempting to give a count to pickup a subset of gold was
ignoring the count and picking up all gold. That was an unintended
side-effect of making '$' be a group accelerator for gold in addition
to being the 'letter' for a stack of gold (so that it can be chosen
even when not displayed on the current page, the way other groups
behave).
Picking groups via their accelerator ignored any pending count (in
tty; curses seems to apply the count). Change tty to apply a pending
count to all menu entries that get toggled on via group accelerator.
It's intended to address the gold bug but might also be used to
select one from every potion stack via '1!', for example. (Seems to
be of very limited functionality, but that was more straightforward
than singling out gold's group to behave differently.)
While in there, change how tty uses menuitem_invert_test(): call it
for set-page/set-all/unset-page/unset-all in addition to existing
invert-page/invert-all. unset-page/unset-all won't actually be
affected unless 'menuinvertmode' option is set to 2.
PatR [Wed, 16 Mar 2022 23:19:30 +0000 (16:19 -0700)]
menuinvertmode
Change the 'menuinvertmode' default from 0 to 1 so that it gets more
exercise. It can be changed back to 0 via option settings but it's
doubtful that anyone will care enough to bother.
Some pickup/take-off actions have been using it to avoid setting
their 'all' choice when bulk toggling for current-page or whole-menu
takes place; 'O' specifies it for its '?' help choice. This adds
the skipinvert flag to the 'all' choice of #wizidentify.
The comments describing it now state that menuinvertmode applies to
bulk set-on operations as well as to toggle-on/off operations but
that will only be true if/when interfaces call menuitem_invert_test()
for set as well as for invert. tty is about to start doing that.
nhkeni [Mon, 28 Feb 2022 00:57:16 +0000 (19:57 -0500)]
cmdcount_t
Add a type to force g.{command_count,last_command_count,multi} to have the
same type (because cmd.c: g.multi = g.command_count;) and some resulting
cleanup.
Pasi Kallinen [Wed, 16 Mar 2022 14:51:53 +0000 (16:51 +0200)]
Remove melting ice timeouts when terrain changes
If special level lua code creates a melting ice timeout, but
later in the code places stairs, or a trap which might change
the ice to room floor, the timer sanity checking doesn't
like that.
Michael Meyer [Tue, 15 Mar 2022 22:28:46 +0000 (18:28 -0400)]
Fix: levitating/flying monsters moving over liquid
Commit c1a6dd4 was meant to prevent flying, levitating, and clinging
monsters from considering walls of water as acceptable movement
destinations, even outside of the Plane of Water. However, it was
evaluating the monster's starting position instead of possible places to
move to, and the evaluation was 'backwards' (the equivalent of
IS_WATERWALL, instead of !IS_WATERWALL).
The result was that non-swimming monsters could only move onto any kind
of water or lava square if the position they were moving from was a
WATER square. Change this so that instead of the starting position,
each potential destination spot's status as a wall of water is evaluated
in turn, and reverse the effect of the test so that it blocks walls of
water instead of allowing them.
Pasi Kallinen [Tue, 15 Mar 2022 09:34:45 +0000 (11:34 +0200)]
Fix autowielding tools taking no time
When applying some tools (whips, polearms, grapples), or rubbing
a lamp, or when fireassist is on and you fire something without
wielded launcher, the automatic wielding should take as much time
as wielding the item normally does.
copperwater [Tue, 15 Mar 2022 00:54:23 +0000 (20:54 -0400)]
Fix selection "random" grow direction, and other code cleanup
Noticed that when I set a selection to grow in a random direction, it
instead grew in all directions, which is not what I wanted. Turns out
the -1 random dir ended up being passed straight to the code which
checks bitmasks, without any form of randomizing among directions.
So this adds code to do that, and defines W_RANDOM as -1 rather than
using a magic number. In the process I also noticed that specifying
"random" as the wall for a door in a room made it rerandomize the
direction every iteration of its loop, essentially rolling two rn2(4)s
and only proceeding if they matched. That was pointless so I cleaned it
up a bit.
Also added safety checks in the form of an impossible for des.corridor()
being called with "random" as either walldir, because this is not
implemented currently.
And lastly, I noticed that create_secret_door was entirely unused
(secret door creation is handled in create_door), so I deleted it.
The only behavior change caused by this is that the Valkyrie quest lava
pools will be a little smaller, which is the only place grow is
currently used. If it's desired to keep them the same, that should be
changed to "all".
copperwater [Mon, 14 Mar 2022 14:11:07 +0000 (10:11 -0400)]
Reduce eucalyptus leaf nutrition to 1
Eucalyptus leaves are famously inedible except by certain animals such
as koalas. I consider it very strange that a single leaf in NetHack
gives you six meatballs' worth of calories.
I considered making it 0 nutrition, but am not sure if a 0-nutrition
comestible would end up violating some assumption that all food is at
least 1 nutrition.
copperwater [Mon, 14 Mar 2022 15:14:46 +0000 (11:14 -0400)]
Implement selection addition and difference
Selection difference is something I have found myself wanting a lot when
working on levels, and have had to defer to a clunkier xor-then-and
approach. This commit implements the TODO-ed addition and subtraction
operators on two sets.
I don't see how the addition operator would be any different from
logical or, so it just calls l_selection_or rather than implement a new
function.
copperwater [Sun, 23 May 2021 00:46:03 +0000 (20:46 -0400)]
Externify trycall() and replace many docall() calls with it
trycall() is a short docall() wrapper that is a no-op if the item is
already identified or the player has called the object type already. For
some reason, many calls to docall() did those same exact checks
beforehand.
This commit eliminates that redundancy by converting those calls into
trycall(), which is now made extern rather than local to do.c. No
behavior should be changed by this commit; I've checked that none of the
affected places could take a different code path now that the
oc_name_known and oc_uname checks are removed.
PatR [Sun, 13 Mar 2022 20:58:56 +0000 (13:58 -0700)]
revise a couple of recent changes
include/.gitignore should continue to ignore old files in case
someone checks out an older version, builds, then checks out the
current version without running 'make spotless' first.
sys/unix/Makefile.utl: tiletxt.o depends on tilemap.c in addition
to tiletxt.c.
nhmall [Sun, 13 Mar 2022 15:06:45 +0000 (11:06 -0400)]
some parallel Make glitches noticed
observed: parallel build attempts of makedefs that trampled over
one another.
attempted workaround: Add a dependency as per Pat R's suggestion.
observed: Concurrent header file movement collisions were sometimes
causing file busy errors and build failures.
workaround: Eliminate tile.h header file movement from the
Makefile build so that the collisions won't occur with that
particular file. Leave the header file tile.h in win/share as it
is in the distribution and just adjust the include path in the
rule for the specific files that use it.
observed: tiletxt.c created on-the-fly from Makefile echo statements
sometimes resulted in garbled and duplicate content in it when
parallel makes were involved, and that caused a build failure.
workaround: Instead of creating a tiletxt.c on-the-fly via echo
statements in the Makefile, simplify things and use that
same #include "tilemap.c" approach but make it an actual file
in the distribution. That makes it available for other platforms
too.
Pasi Kallinen [Sun, 13 Mar 2022 12:29:32 +0000 (14:29 +0200)]
Lua: object timers
Expose object timers to lua scripts. For example:
local o = obj.new("cockatrice egg");
o:placeobj(5, 5);
o:start_timer("hatch-egg", 3);
Available methods are:
- obj.has_timer("rot-corpse")
returns true if object has attached timer, false otherwise.
- obj.peek_timer("hatch-egg")
returns an integer value, which is the turn when the timer
attached to the object would trigger. returns 0 if no such timer.
- obj.stop_timer("shrink-glob")
stops attached timer, or if no timer type is given, stops all
timers attached to the object.
- obj.start_timer("zombify-mon", 15)
starts a timer with a trigger time in that many turns in the future.
replaces any previous timer of the same type.
Valid timers are "rot-organic", "rot-corpse", "revive-mon",
"zombify-mon", "burn-obj", "hatch-egg", "fig-transform",
and "shrink-glob". Also "melt-ice" is recognized, but does nothing
to objects.
nhmall [Sun, 13 Mar 2022 02:49:32 +0000 (21:49 -0500)]
warning fix artifact.c
artifact.c: In function 'dump_artifact_info':
artifact.c:1088:37: warning: '%s' directive writing up to 255 bytes into a region of size 218 [-Wformat-overflow=]
1088 | Sprintf(buf, " %-36.36s%s", artiname(m), buf2);
| ^~ ~~~~
In file included from ../include/config.h:652,
from ../include/hack.h:10,
from artifact.c:6:
../include/global.h:255:24: note: 'sprintf' output between 39 and 294 bytes into a destination of size 256
255 | #define Sprintf (void) sprintf
artifact.c:1088:13: note: in expansion of macro 'Sprintf'
1088 | Sprintf(buf, " %-36.36s%s", artiname(m), buf2);
| ^~~~~~~
PatR [Sun, 13 Mar 2022 01:25:54 +0000 (17:25 -0800)]
artifact tracking again
Redo the recent artifact creation stuff by replacing several nearly
identical routines with one more general one. Also adds a tracking
bit for one or two more creation methods. That changed artiexist[]
from an array of structs holding 8 or less bits to one holding 9, so
bump EDITLEVEL in case the total size changed.
PatR [Sun, 13 Mar 2022 01:07:28 +0000 (17:07 -0800)]
livelog of breaking food conducts
Shorten the livelog messages for food conduct a little by changing a
bunch of "the first time" to just "first time". Will result in fewer
instances of tty condensing whitespace for a too-wide line written
into a text window. That includes stripping off indentation, which
messes up the alignment of #chronicle output.
Also, eliminate one redundant livelog printf. Breaking vegan conduct
by eating wax when poly'd can be folded into same message for eating
leather/bones/dragon hide. [The breaking vegetarian conduct for those
says "eating meat" which seems wrong but hasn't been changed.]
PatR [Fri, 11 Mar 2022 19:00:44 +0000 (11:00 -0800)]
more artifact tracking
This should have been broken up into multiple pieces but they're
all lumped together. I did ultimately throw away a fourth change.
Implement artiexist[].bones and artiexist[].rndm artifact creation
tracking bits that were added recently. Doesn't need to increment
EDITLEVEL this time.
Add a new wizard mode feature: if you use `a to show discovered
artifacts, it will prompt about whether to show the tracking bits
for all artifacts instead. If not using menustyle traditional,
you need at least one artifact to have been discovered in order to
have 'a' choice available when selecting what class of discovered
objects to show for the '`' command.
artifact_gift(), aritfact_wish(), and so forth return a value that
none of the existing callers use, so cast their calls to (void).
PatR [Thu, 10 Mar 2022 22:57:15 +0000 (14:57 -0800)]
discovered objects within class for a and u
If any artifacts are discovered and menustyle traditional is in use,
the player can type `a to get the artifact subset of discovered items.
Likewise with `u to for unique items (the invocation tools and the
real Amulet). For normal object classes, `<class> works for every
class, even when there aren't any discoveries for it (where you get
told "you haven't discovered any yet" if you pick such). But `a
and `u were only allowed if at least one thing in the corresponding
category had been discovered. Change to allow it even when none have
been. The feedback of "you haven't discovered any {unique items,
artifacts} yet" was already in place.
Doesn't apply for picking the class via menu. Menus don't have any
concept of "allowed as a response even though not listed as a choice".