Commit Graph

7506 Commits

Author SHA1 Message Date
Pasi Kallinen
eb9c7d77d4 Improve therecmdmenu
Turning on herecmd_menu and clicking with mouse is now actually
somewhat playable.
2022-04-06 21:23:27 +03:00
PatR
8aa48ecd91 'O' vs msg_window option
Change 'O's sub-menu for selecting new msg_window option setting to
work similar to the one for menustyle:  show a description of what
the values mean with a two-line, two-column menu entry.  Also make
its current value be pre-selected.

msg_window is a bit more complicated than menustyle because only
some interfaces support it and curses only supports two of the four
choices.  It currently has one hard-coded reference to "^P" (in the
tty-specific 'combination' choice).  Changing that is feasible but
seems like more trouble than it'd be worth.
2022-04-05 13:35:23 -07:00
Pasi Kallinen
e260c9ded5 Fix mouse travel and look
Looks like I broke mouse travel and clicklook a while back, and
no-one noticed...
2022-04-05 15:03:20 +03:00
PatR
47cef18a9b life-saved, while helpless
Implement the suggestion by entrez to avoid "while helpless" in the
reason for the second death if hero gets killed, life-saved, and
killed again at the same time.  Life saving sets 'multi' to -1 which
prevents the hero from moving again until next turn and is intended
to make the sequencing of "you survived that attempt on your life"
work if you're being interrupted during some multi-turn activity.

It used to behave differently when the first death occurred while
engaged in some voluntary multi-turn activity.  I've removed that
because I couldn't figure out why; it might need to be put back.
2022-04-04 10:20:28 -07:00
Pasi Kallinen
16d813b44a Give a message when stinking cloud is created on top of hero 2022-04-03 20:43:04 +03:00
Pasi Kallinen
92c21b588b Ask to kick a locked door open, if hero has no unlocking tool 2022-04-03 13:58:50 +03:00
PatR
4721ae7154 menuitem_invert_test() comment clarification 2022-04-03 01:32:59 -07:00
Pasi Kallinen
565a3cf0a9 Reverse the unique requirement 2022-04-03 08:55:09 +03:00
Pasi Kallinen
38a6cee1ab Don't pacify unique monsters when untrapping them from web 2022-04-02 19:38:50 +03:00
Pasi Kallinen
6977aef436 Fix stuck travel for good
My fixes to the travel stuck oscillation did not fix all of them,
and I've even seen a 3-step loop - which my fixes cannot detect.
I guess there could be arbitrary-sized loops too.

To definitely fix this, keep track of all the map locations travel
has moved the hero through, and if it tries to go on a location already
used, stop travel and give the unsure -message.
2022-04-02 18:27:53 +03:00
PatR
eea362249c wishing for artifacts
Use 'fuzzymatch(,," -",)' when checking whether the name specified
in a player's wish text matches an artifact name so that extra or
omitted spaces and dashes are ignored.  Wishing for "firebrand" will
yield "Fire Brand" and "demon bane" will yield "Demonbane".
2022-04-02 00:28:48 -07:00
PatR
b1f8c3d5c1 wishing for flint
Allow wishes for quantity up to 20 to be granted when asking for
flint.  Like rocks, flints are mainly useful as sling ammo.

Also, remove the hardcoded assumption that globs weigh 20 when wish
handling computes glob weight based on user-specified count and/or
relative size.
2022-04-01 10:53:19 -07:00
PatR
62bc0c846c glob rot - replace misspelled dissipates with \
dissolves

"The glob of <type> dissippates completely" was misspelled.  Instead
of just fixing the spelling, switch to a different term since
dissipate is also being used for gas clouds and globs aren't gaseous.
2022-04-01 10:47:25 -07:00
vultur-cadens
3de34c83fe fix "pertrified" typo 2022-04-01 10:02:49 -07:00
PatR
575b76afc3 sengr_at() schizophrenia
sengr_at() is used as a boolean, declared as int, and returns FALSE
if there is no engraving present.  Change the declaration to boolean.

Also, using fuzzymatch() without any list of ignorable characters
just to get case-insensitve matching didn't make sense so switch to
strcmpi().
2022-04-01 05:22:20 -07:00
PatR
f0c7394968 git issue #717 - avoid putting monsters on scare \
monster and Elbereth unless there's no other choice.

Suggested by NetSysFire, don't create new monsters on top of scrolls
of scare monster.  Not mentioned in the suggestion:  unless they are
a type of monster that isn't affected by such scrolls.  This extends
it to teleport destination too.

Avoid placing a monster on a scroll of scare monster or on engraved
Elbereth if there are other locations available.  Only performed for
callers of goodpos() who explicitly request it, which at the moment
are makemon(), rloc(), and enexto().

Also, propagate 'mmflags_nht' to a bunch of places that were left
using long or unsigned for makemon() and goodpos() flags.  I didn't
attempt to be systematic about that though.

Implements #717
2022-04-01 05:09:58 -07:00
Pasi Kallinen
f45e79e1a0 Fix medusa levels
My recent commit broke medusa-3 and medusa-4, so fix those.

Make des.stair and des.ladder also accept hash-coordinate:
  des.stair("up", {8, 10});
2022-04-01 08:53:15 +03:00
Pasi Kallinen
476e47b2cd Use correct findtravelpath param value 2022-03-31 17:50:00 +03:00
PatR
a230034af7 github issue #715 - losing stoning resistance \
while wielding a cockatrice corpse without gloves

Reported by vultur-cadens:  if safely wielding a cockatrice corpse
without gloves due to temporary stoning resistance or wearing yellow
dragon scales/mail, having the resistance be lost to timeout or to
taking off the dragon armor should have turned the hero to stone but
didn't.

Extend the handling for taking off gloves to cover these other two
cases too.  The feedback for these deaths is usually too verbose to
fit on the tombstone but does show up in logfile.

Fixes #715
2022-03-31 04:48:26 -07:00
PatR
8fbb6dc93b github issue #716 - teleporting onto pits
Implement the suggestion by NetSysFire that a levitating of flying
hero won't treat pits and holes as off limits when testing potential
destinations during teleport.

Closes #716
2022-03-30 14:41:53 -07:00
PatR
b0067493c9 fix #K3564 - obj sanity failure: N globs for N>1
Using #name and picking an item on the floor to be assigned a type
name allowed any of the four types of globs to be named.  After
that, wishing for those by the assigned name bypassed the code that
forced the quantity to stay at 1.  Asking for "3 foo" could then
produce "3 small globs of gray ooze" which fails obj_sanity() and
issues an impossible warning (which the fuzzer escalates to panic).

The "getobj refactor" patch changed the return value of call_ok().
When it gets used to check whether an object on the floor could have
a type name assigned (rather than as a getobj() callback), the test
that should have rejected the naming attempt accepted it instead.

Update the wishing code to handle globs differently:  you can still
specify the relative size via small, medium, large, or very large,
but now you can specify a count either instead or in addition.  A
count of more than 1 is used to multiply the created glob's weight,
although it's less likely to be honored as-is when the size is bigger
than small.  Quantity is always forced to 1, at a different place in
readobjnam() than previously.
2022-03-30 14:11:29 -07:00
Pasi Kallinen
2bbcfb5540 Prevent random stairs overwriting other terrain
When creating stairs in a random location in a special level lua file,
there was a chance it overwrote eg. other stairs. Make randomly placed
stairs pick locations with room, corridor, or ice terrain.

Fixes github issue #702
2022-03-29 18:02:30 +03:00
PatR
2bbcd86eb2 slime mold comment 2022-03-28 13:51:50 -07:00
PatR
0b42404ad6 enlightenment about temp resist and item resist
For timed acid resistance and timed stoning resistance, report
"You {are,were} temporarily {acid,petrification} resistant."

For items being protected by worn equipment, add "by your {armor,&c}"
similar to the existing feeback about you being protected "because
<some-reason>".  Wizard mode only.
2022-03-28 10:38:04 -07:00
PatR
e96d4ea9ef adjust temporary acid/stoning resistance
When eating a meal that is affected by acid resistance or stoning
resistance and protected by temporary resistance, increase the timeout
so that the resistance doesn't expire until after the meal finishes.
That avoids getting the "you no longer feel safe from {acid,stoning}"
during the meal and not being affected by the dangerous food despite
that message.  Useful because the protection is checked at the start
of the meal and not rechecked during; extending the duration hides
the latter.
2022-03-28 10:17:01 -07:00
PatR
6a2ff5743a items destroyed by exploding chest
From a report by a beta tester 8 years ago:  kicking a chest gave
"THUD!  The chest explodes!" but the chest remained intact.  The
explosion was destroying all floor items at the hero's spot rather
than at the chest's spot.  Fixing that results in the chest being
destroyed because it's one of the items at its own spot.

While fixing that I noticed that delobj() was only protecting the
Amulet and the invocation items from destruction, not Rider corpses.
You could destroy one or more of those by getting a trapped chest's
explosion while using a key at its spot rather than by kicking it
from adjacent.  (Getting the exploding chest result is not easy,
particuarly with positive luck.  I eventually resorted to forcing
it with a debugger.)
2022-03-27 17:55:52 -07:00
Pasi Kallinen
c763e26aa7 Second fix to stuck travel
There were at least two cases of travel oscillation that occurred,
even after my previous fix. To fix those, the guessing routine
would also have to consider distance to original target location.
I opted not to make that part more complex - as there was
no guarantee those changes would catch all of the oscillation cases.

Instead, when we're guessing where to move, and we would actually move
back to where we came from, stop travel, and give a message.

This should fix (and fuzzing seems to confirm) all of the travel
oscillation bugs for good, and it shouldn't affect actual good travel.
(Other than the player getting a YAFM in the occasional case of trying
to travel to a location with no travel path)
2022-03-27 10:58:12 +03:00
Pasi Kallinen
1d78d3c3f2 Fix travel getting stuck oscillating between two locations
There's been occasional reports (perhaps once or twice a year)
of travel getting stuck moving repeatedly between two locations
next to each other, but it has never been reproduced before.

This special level lua code fragment is a minimal test case
which triggers it:

--- special level lua fragment, indented
  des.map([[
  --##---
  ###----
  #-+----
  ####--L
  ]]);
  des.door("open", 2,2)
--- end of special level lua fragment

The open door is required.

Magic map the level. Start from somewhere NW of the door, and try
to travel to the lava pool. Hero will get stuck oscillating between NW
of the door and two steps west of the door.

Here are the maps of the travel[][] array values from findtravelpath()
in those two steps in the above map:

-------------  -------------
|  . . 2 3  |  |  . . 1 2  |
|  1 1 2 .  |  |  1 @ 1 .  |
|  @ . . .  |  |  1 . 2 .  |
|  1 1 2 .  |  |  2 . 3 4  |
-------------  -------------

There are two possible closest locations to the lava pool,
the one marked with "3" on the left map, and "4" on the right map.
Based on that alone, both would be valid places to path to.

But, in the left case, hero could not see the bottom location, so
the code won't even consider pathing to it, so it will start moving
towards the "3".

When hero moves to the second position, in the right map, now the "4"
could be seen. Now there are two possible closest locations we could
choose from. The code that scans the possible locations goes from top-left
to bottom-right, first going down (y-axis). So, the code sees the
"2" on the right. distmin() to there is 2. Good, we pick that location
to path to. Next, going down, the code considers the "4" ... which is
also equally close to the lava pool. and distmin does not consider terrain,
so ignores the door, so it has the same distmin value of "2", so the
code picks this location.

But: this was just a guess, because there's no known valid path to the
lava pool. The code loops back up to rebuild the travel[][] array
with a new starting location as the "4" from the right map, pathing
back to hero.

This is that travel array map:
-------------
|  . . . .  |
|  4 @ 3 .  |
|  3 . 2 .  |
|  3 2 1 x  |
-------------

The way travelstepx and travelstepy arrays are built means that the first
location that considers the hero's location is the "3" SW of hero, so
hero will move there next. Repeat from beginning. If there was no door,
the travelsteps would reach hero's location first from SE.

(I left the travel[][] array rebuild and travelstepx/travelstrepy build
off from the other movement position, as it's not relevant)

The fix: When considering which of the two possible closest places to the
lava pool to path to, use the one with the lowest value in the travel array.
That value is the real number of moves it takes for the hero to walk there,
so the code will consistently path to the upper location, as it is "2",
instead of considering the "4" below it.

Also some minor code reorg, so it considers couldsee first instead of
later in two separate places.
2022-03-26 23:58:30 +02:00
PatR
071d79dce2 stoning resistance revisited
It turns out that there were a bunch more monsters with the corpse-
conveys-stoning-resistance flag than just green mold.  Instead of
stripping it off, give them (including green mold) a chance to confer
timed resistance against stoning and also against acid.

All of these can convey either of those two resistances.  Like other
intrinsics obtained via eating, at most one can be obtained from any
given corpse.
  green mold, acid blob, spotted jelly, ochre jelly, black naga,
  yellow dragon, Chromatic Dragon
These can confer temporary stoning resistance but not acid resistance:
  lizard, chickatrice, cockatrice, gargoyle, winged gargoyle,
  xorn, Medusa
There aren't any that confer just acid resistance without a chance for
stoning resistance.

The effect lasts for 3d6 turns, or is extended by 3d6 more if randomly
chosen and applied when already in effect.

Having temporary acid resistance time out during another meal when
eating a corpse that ends up conferring acid resistance seems strange.
The protection against acid is granted at the start of the meal and
continues to the end (in regards to eating, not external attacks) even
when the intrinisic is lost in between.  I'm not sure whether that
needs some form of fixing, and if so, what that fixing should be.
2022-03-26 11:23:06 -07:00
PatR
dcdffe6c4f livelog message for breaking vegetarianism
Fix a minor 'fixme':  if hero breaks vegetarian conduct by eating
something made of bone, leather, or dragon-hide while polymorphed
into a shape which can eat such things, change the message from
"ate meat for first time" to "ate meat by-products for first time".

It took me a while to arrive at a sequence of actions which would
successfully test this.  You need to break foodless and vegan
conducts first, then break vegetarian with leather/bone separately
or it won't trigger a livelog event for that.  Wish for and eat a
candy bar to break vegan conduct, polymorph into a gelatinous cube,
wish for and eat leather armor, then use the #chronicle command.
2022-03-25 13:21:07 -07:00
nhmall
af24a46e32 Merge branch 'fix-trap' of https://github.com/argrath/NetHack into pr712 2022-03-25 08:21:49 -04:00
SHIRAKATA Kentaro
367ea0e6d6 add initializer on use_tinning_kit()
If poly_when_stoned() is true, an uninitialized buffer kbuf[] is passed to instapetrify().
Although instapetrify() doesn't access it in that situation for now,
it should be initialized anyway for readability.
2022-03-25 15:47:51 +09:00
PatR
f86ab67d20 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.
2022-03-24 11:15:37 -07:00
Pasi Kallinen
60bf399f91 Don't stop travel when going past a closed door 2022-03-24 19:33:37 +02:00
PatR
27b1c38c50 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.
2022-03-23 13:20:26 -07:00
PatR
74df2111a8 mkmaze() tweak
This shouldn't have any effect on behavior, just make mazexy() be
a little easier to comprehend.
2022-03-23 12:43:30 -07:00
SHIRAKATA Kentaro
291d872f62 move null-check on savelev()
Move null-check of ttmp before its first use.
2022-03-24 04:16:16 +09:00
Pasi Kallinen
27ea4b7e52 nit: Indented function end brace 2022-03-23 12:08:46 +02:00
Michael Meyer
4d82094e8b 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.
2022-03-22 14:30:21 -07:00
PatR
56c2e63492 "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.]
2022-03-22 11:33:17 -07:00
PatR
385a9a7fde 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.
2022-03-22 10:48:23 -07:00
Pasi Kallinen
ade53925a6 Lua: error when supplied coordinate is not table 2022-03-22 11:06:28 +02:00
Pasi Kallinen
6eadff01b8 Lua: selection get and rndcoord changes 2022-03-22 10:45:20 +02:00
Pasi Kallinen
27898340b9 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.
2022-03-22 09:16:19 +02:00
PatR
6fb0c8a82e cancelled #herecmd using time
I managed to execute #herecmd by mistake and when I typed ESC to get
out of its menu, monsters took their next turn.  #therecmd behaved
similarly.
2022-03-21 18:33:34 -07:00
PatR
b150594d68 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.
2022-03-21 18:21:07 -07:00
PatR
88a61f1c40 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.
2022-03-21 18:11:26 -07:00
PatR
d53c1a7a67 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.
2022-03-21 12:32:07 -07:00
Michael Meyer
fb512bac4f 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.
2022-03-19 18:10:11 -07:00
nhkeni
7840ef9554 un-streq followup 2022-03-19 20:49:00 -04:00