Commit Graph

13342 Commits

Author SHA1 Message Date
PatR
e45ccca3ff pull request #744 - specifying items in lua files
Pull request #744 from vultur-cadens:  the object specification
supported by des.object() was ambiguous for items whose name in
objects[] doesn't include the object class name.  For instance ring
and spellbook of protection are just named "protection" (unlike
"cloak of protection" which has its full name).

Fixes #744

The commit message for pull request #743 misidentified it as #744,
so didn't get marked closed properly.  Do that now...

Closes #743
2022-04-24 00:35:53 -07:00
vultur-cadens
3571934c59 Allow specifying object classes in the object name given to des.object()
and actually do so in the lua files.

Before this, it was not possible to specify (for example) "scroll of
teleportation" in des.object() because there is actually no object
defined in objects.h named "scroll of teleportation", so
find_objtype() failed to find it.  Instead, one had to request
"teleportation", but that is ambiguous, and find_objtype() would find
the first defined item with that name instead (ring of teleportation).

In cases of ambiguity, I referred to the des files from 3.6.6 (before
the lua conversion).
2022-04-24 00:35:25 -07:00
PatR
9054f97b41 followup to PR #744
Pull some pointer assignments in wc_set_window_colors() out of
if-else-endif so that it is more obvious that they can't be Null.
2022-04-24 00:26:50 -07:00
PatR
3f6e371a4e pull request #744 - remove unneeded Null checks
Pull request #744 from argrath.

Closes #744
2022-04-24 00:15:31 -07:00
SHIRAKATA Kentaro
4a79d4195a remove unnecessary null-check on wc_set_window_colors()
mungspaces() returns its argument itself, so `newop` is assigned to `buf`, and always non-null.
`tfg` and `tbg` is assigned to (some addition of) `newop`, so these are also always non-null.
2022-04-24 00:08:52 -07:00
PatR
6bc52ebb77 fix to #adjust for '!fixinv' config
If you have 'fixinv' set to Off and and an inventory of three items,
they'll always be a and b and c.  #adjust had you pick 'from' slot
among [abc] and the prompt for 'to' was supposed to show the letter
you picked plus 'd' for 'move to last'.  But it was only showing
the 'from' letter itself as likely candidate, omitting the last+1
choice.  (Anything after the last letter in use could be picked and
yield the right result, only the list of likely candidate slots in
the prompt wrong.)

Fixed more by trial and error than by understanding why the old code
didn't do what was intended.
2022-04-23 14:52:36 -07:00
PatR
c2ac36f0c9 inventory item-action: add '-' for uswapwep
There's no 'w-' or 'Q-' for alternate weapon, but context-sensitive
inventory is starting from the object rather than the command so can
finesse that.  'A' does allow alternate weapon to be directly unset
(aka reset to bare/gloved hands) but is not friendly to being passed
queued input.

This adds an extra internal command which only handles unset uswapwep,
even though that is something which is awfully specialized to get it's
own command.  Users don't see this command so that shouldn't matter.
2022-04-23 11:58:52 -07:00
PatR
dce05d487a item-action 'Q-' for for uquiver
For context-sensitve inventory, if player picks the item occupying
the quiver slot, offer '-' as a choice.  Like for wielded weapon,
picking that will clear the slot.  Also, don't include the 'Q' for
quivering it choice since it is already quivered.

Unlike nethack4, we don't currently have a way to explicitly clear
uswapwep.  The sequence #swap, #wield '-', #swap won't work if
primary weapon is cursed and isn't safe to use if alternate one is.
It would be simple enough to just directly call setuswapwep(NULL)
and untwoweapon() in the item-action routine instead of queuing up
some command to do it but that feels a bit unclean.  Adding yet
another internal command for it would work too but this one wouldn't
be for variant user-interaction of an existing command.
2022-04-23 03:03:50 -07:00
PatR
40d0caa157 'f'ire revamp
The fire command could claim that time passed when it hadn't (fill
quiver with ammo, which takes no time, then queue commands to switch
to matching launcher, which should also take no time while queueing,
only during subsequent execution).

If quiver is empty or has ammo in it, give wielded thrown-and-return
weapon (aklys) priority over filling quiver or switching to ammo's
launcher.  Don't do that if quiver has non-ammo in it, otherwise
players running Valks who wield Mjollnir with super strength but
want to throw quivered daggers would complain.

When player is being asked what to fill the quiver with, use the
\#quiver command to do that.  Using it honors a count to split a
stack, handles switching uwep or uswapwep to uquiver, and gives
feedback.  This is actually a fairly substantial change.

For 'fireassist', when switching to a launcher that isn't already
uswapwep pick one known to be blessed or uncursed over one having
unknown BUC status.  But use the latter as last resort.
2022-04-23 02:12:21 -07:00
PatR
e8374b36a1 fix github issue #742 - suit of no digestion
Reported by vultur-cadens:  slow digestion from wearing white dragon
scales/mail blocked per-turn hunger and didn't cause any hunger,
unlike ring of slow digestion which blocks per-turn hunger but still
causes some hunger as a worn ring itself.  If no rings or amulet
were worn, wearing the suit prevented the hero from ever burning any
nutrition.

Change to treat wearing the suit to be quite a bit like wearing a
ring, unless hero is also wearing an actual ring of slow digestion
(then the hunger cost of the suit is 'free').

Wearing a ring of slow digestion and another ring consumes two units
of nutrition every 20 turns, no matter what suit.  Wearing white
dragon scales/mail and two non-slow digestion rings now consumes three
units of nutrition every 20 turns.  Using the suit to effectively get
an extra ring finger isn't free.

Fixes #742
2022-04-22 06:11:12 -07:00
PatR
e584f718a8 fix github issue #729 - edibility_prompts()
Issue #729 by argrath points out that one of the checks in
edibility_prompts() couldn't work.

For the next-meal effect after reading a blessed scroll of food
detection, the check whether a corpse was tainted but not dangerous
because the hero had sickness resistance could never be evaluated.
An earlier condition would cause the routine to return before
reaching that check.

Move it sooner, even though doing so violates the "order by most
to least dangerous" guideline.  It was either that or eliminate it
altogether.

edibility_prompts() had a lot of repetitive code that has now been
condensed.

Simplify acid blob corpse handling--for all of eating, not just for
edibility_prompts()--by treating that as "never rots" so that the
'rotted' variable always stays 0.  Now checks for that variable
being greater than some threshold don't need to include "and not an
acid blob corpse" as an exception.  A side-effect of this change is
that not only do they never become tainted, they'll no longer yield
the "you feel sick" outcome when they're old but not old enough to
exceed the tainted threshold.

Bug fix:  edibility testing stopped warning about green slimes.
That worked in 3.6.x, but 3.7 changed the 'cadaver' variable to
exclude them so the check for eating a glob of green slime could no
longer be reached.

Fixes #729
2022-04-21 16:40:43 -07:00
PatR
98eebb97d2 corpse gender
Reported by entrez.  Don't make 50% of neuter monsters be flagged as
female.  It doesn't matter for live monsters but gets inherited by
their corpses, where female and non-female corpses stack separately.
2022-04-21 03:31:32 -07:00
PatR
bbbf5f6bcc duplicate status highlight rules
Noticed earlier when testing the status_hilite_menu_fld() changes:
if you enter a duplicate rule (with different highlighting), it didn't
replace the previous one and the old rule continued to be used.

This still doesn't do replacement, but by adding the new rule at the
end of the list of rules for the specified field instead of inserting
it at the beginning, the new rule gets used.
2022-04-21 02:39:54 -07:00
PatR
844fcbc16c item-actions for 'I'
Support context-sensitive inventory item-actions from the class
inventory display ('I' command) as well as from regular inventory.
2022-04-20 23:27:45 -07:00
PatR
fea939899d wishing fix (obj->dknown)
A change made 5 or 6 weeks ago that was meant to enhance tracking of
artifact creation had an unintended side-effect of making every object
obtained via wishing have its dknown flag be set.  That made them
behave differenly from items picked up off the floor, so revert to the
old behavior.
2022-04-20 23:08:29 -07:00
PatR
0f1674a262 redo status_hilite_menu_fld() [pull request #740]
Pull request #740 by argrath removes some redundant code.  Instead
of adopting that, this rewrites the section of code in question.

The menu involved allows the user to select both "delete hilites"
and "add new hilite" but if both are selected it would only do
deletion.  It also falsely claimed to have done something if delete
was chosen but no highlights were selected to be deleted.  And it
only added one new highlight for the specified field when adding.
This supports both add and delete on the same menu invocation, for
addition it keeps adding until no new highlight is specified, and
has caller do the highlight updating if any changes are made.

Supersedes #740
2022-04-20 22:22:36 -07:00
PatR
a9a9d19038 item-action 'I' - use #adjust to split a stack
More context-sensitive inventory support.  While examining inventory,
if you pick an item other than gold and it has a quantity of more
than 1, "I - Adjust inventory by splitting this stack" will be one
of the menu choices.

Breaking doorganize() into two parts was much easier than expected,
but the new internal command added to be an alternate for the first
part had more niggling details than anticipated.

Message history only shows the first digit with "Split off how many?"
if the player enters more than that.
2022-04-20 13:38:09 -07:00
PatR
627fa5efad another item-action: 'i' to #adjust inventory
Add context-sensitive inventory item-action 'i' to run the #adjust
command.  Groundwork for item-action 'I' to use #adjust to split a
stack is included but non-functional.

Also reorders some of the enums and switch cases to be alphabetical
by their menu selection letter, dip moves from 'd' (which is drop)
to 'a' and offer/sacrifice moves from last to 'O'.
2022-04-20 00:55:19 -07:00
PatR
eb6e6312e6 fixes entry for PR #738 - "the the entrails"
Add pull request #738 by entrez.

Fixes #738
2022-04-20 00:12:45 -07:00
Michael Meyer
a384f0353b Fix: "in the the purple worm's entrails"
The message printed if the hero threw gold while swallowed by an animal
used "the <mon_nam>'s entrails", which produced a doubled 'the'.  It
could also use the wrong possessive form, since it doesn't take
advantage of any of the special case handling in s_suffix.  I think the
only way that could ever be a problem with the current cast of engulfers
is if the hero was swallowed by a purple worm while hallucinating, but I
changed it to use s_suffix anyway.
2022-04-20 00:09:02 -07:00
PatR
3d3851ba53 pull request #739 - redundancy in adj_pit_checks
Add github pull request #739 by argrath.

Closes #739
2022-04-20 00:01:35 -07:00
SHIRAKATA Kentaro
949c30dffa remove redundant condition on adj_pit_checks()
supporting is never null, as outer if statement checks it.
2022-04-20 00:00:46 -07:00
PatR
d6ab241b8c part of pull request #737 - pets approach \
hero when hero is [impatiently waiting...] on stairs

My attempts to cherry-pick this failed, so this was done manually.
It is a reimplementation of
NullCGT:feature/monster-item-use:dc2cef0562542fece1732dd2d4c4f0775308faff

] Pets approach the player if they are standing on the stairs.
]
] One of the most frequent complaints I have seen is that pets refuse
] to follow their owners down the stairs. While this can be resolved by
] waiting, most players, especially new ones, are not willing to spend
] multiple dozens of turns waiting for their pets to approach closely
] enough to follow them. This simple commit makes pets react to a player
] standing on stairs as if the player is holding a tripe ration. Simple,
] non-disruptive, and should solve many headaches.
2022-04-19 18:21:26 -07:00
PatR
49b046f2e5 disallow assigning type name to Amulet of Yendor
Something I noticed when testing the item-action handling for name and
call; applies to the C/#name command too.  You were allowed to call the
real Amulet something and allowed to call fake ones something [else].
If you did that, xname/doname didn't show it but the discoveries list
did, giving away information when the player had access to more than
one unID'd Amulet of Yendor.  Rather than messing about with discovery
handling, make real and fake Amulet be ineligible from being given a
type name.  (They can still be given individual names.)
2022-04-19 14:19:48 -07:00
PatR
5489b3ebd9 command queue handling in getobj, yn_function
Mostly attempting to clean up potential error handling but I don't
have any error cases to test with.  Doesn't seem to break anything
when there aren't any errors....
2022-04-19 13:53:40 -07:00
PatR
2356690054 mon_leaving_level followup 2022-04-19 12:30:23 -07:00
PatR
be3d9bcd1a item-action refinements for name/call and read
Switch the verb from "name" to "call" for type-naming.  Format menu
choices for name or call of unique items more carefully.

Read actions got some extra details so move them out of the main
item-action routine to avoid cluttering it up.

Avoid "r - Study the spellbook" for novels.  It's changed for known
Book of the Dead too, but I'm not sure "r - Examine the tome" conveys
"read" sufficiently.  ("Read" and "peruse" seem too mundane for it;
perhaps it should revert to "study" even though the hero isn't
attempting to learn a spell from it.)

Change "r - cast the spell on this scroll" to "r - read this scroll
to activate its magic".  Leave off the last phrase if it's a known
scroll of blank paper or scroll of mail.
2022-04-19 12:26:54 -07:00
Pasi Kallinen
af7db2f8f1 Fix panic on thrown potion of acid when swallowed
When you're swallowed and throw a missile that kills the swallower,
the thrown missile is picked up by the swallower before death.
This caused a panic when you threw a potion, which was first picked up
by the swallower, which upon death dropped the potion on the floor,
but then throw code was trying to destroy the potion ...
2022-04-19 15:00:00 +03:00
PatR
9f0e511b00 item-action name/call
Add opportunity to name an individual object or call the type of an
object to the context-sensitive inventory item-actions.
2022-04-19 04:33:01 -07:00
PatR
6880d37b33 mon_leaving_level
From 6 year old email:  m_detach (monster death or removal from play)
and relmon (monster migrating to another level) both take a monster
off the map but they weren't consistent with each other.  Change them
to use a common routine for that.

I'm not sure whether the inconsistencies resulted in any bugs.  The
email was concerned about handling for monsters that emit light, but
those aren't actually common to the two removal methods and turned
out to be ok.
2022-04-18 12:01:17 -07:00
Pasi Kallinen
262e178243 Unify mhitm magic attack negation checks 2022-04-18 19:14:40 +03:00
Pasi Kallinen
d7eb95cbf0 Minor code dedup in sp_lev 2022-04-18 13:38:01 +03:00
PatR
54189e795b more queued commands
This attempts to make item-actions, #herecmd, and #therecmd be more
robust.  When rhack() or yn_function() take queued input off cmdq
and get something unexpected, discard the rest of the queue.

It also fixes the two crash cases that entrez reported.  There are
bound to be others though.

I think a lot of actions that can be executed by queued input are
going to need nomul(0) calls to handle repeat counts that should be
ended early if something unexpected happens or something expected
fails to happen.  But that clears cmdq so may be tricky to decide
where to use.
2022-04-17 13:36:38 -07:00
PatR
ec4749914a drink_ok() tweak
Fix a comment typo and change the 'if obj/!obj' logic to be like what
was recently added to eat_ok()/offer_ok()/tin_ok().
2022-04-17 01:39:34 -07:00
PatR
52cfe40d33 eating, drinking via #herecmdmenu
Fix eat floor food and drink from dungeon feature via #herecmdmenu.
That uses queued commands, but those two actions were changed to
skip the floor when queued input was present because asking about
floor items interfered with context-sensitive inventory item-actions.

I was misled by a comment that says it couldn't insert an m-prefix;
that was for treating the 'm' key as typed text rather than as a
command.  There's no problem with inserting a #reqmenu command which
is what 'm' is these days.  So item actions can force 'm' to skip the
floor and go directly to inventory, also the #eat and #quaff commands
don't have to alter their behavior when queued input is pending so
the #herecmdmenu usage for them gets fixed.
2022-04-16 15:32:41 -07:00
PatR
f04f974c11 Qt extended command entry
For Qt with 'popup_dialog' off, if I typed "#quit" then the prompt
"Really quit?" was displayed in the message window as expected.
But if I typed "#" and then clicked on [quit], sometimes the prompt
wasn't visible even though the program was waiting for me to answer
it.  I've noticed this a time or two in the past and just pretended
that it hadn't happened; since I usually enter extended commands by
typing their name, it didn't stand out much.  Testing #repeat with
extended commands brought it back to mind.

I don't understand what's going on, but this one-line patch seems
to solve it.  (With a multi-line message window, clear_nhwindow()
doesn't erase anything, but for Qt it does update the most recent
entry.)
2022-04-16 14:53:43 -07:00
PatR
d4acb9385e & (whatdoes) enhancement?
Using '&#' or '?f#' showed "#  perform an extended command (##)".
The "(##)" part looks rather silly and is not helpful.  Expand the
text a little and omit command name for that particular command:
"#  enter and perform an extended command".
2022-04-16 14:28:27 -07:00
PatR
18755668b1 \#repeat bit
The comment preceding new 'savech_extcmd()' said that the core didn't
care whether it was given the full command name or just enough leading
substring to be unambiguous.  Then it tested the string against
"repeat" which contradicts that comment.  Didn't seem to be an actual
problem because "#repeat" is not flagged for auto-completion, but fix
the code to match the intent of the comment and reword the comment to
match the code.
2022-04-16 12:38:10 -07:00
nhmall
adbee93dea cron job updates 2022-04-16 11:08:34 -04:00
nhmall
5762631f96 resolve build error on windows with vs2022
win/tty/getline.c(305) :
warning C4701: potentially uninitialized local variable 'ecmatches' used
win/tty/getline.c(305) :
error C4703: potentially uninitialized local pointer variable
'ecmatches' used
2022-04-16 08:32:13 -04:00
PatR
31affa0722 ^A/#repeat vs extended commands
Fix '#repeat' for tty; both it and ^A can repeat an extended command.

Fix both for curses; they can repeat an extended command instead of
just repeating the initial '#' to start getting an extended command.

X11 (tested), Qt (tested), and probably Windows GUI (not tested)
behave the same as before:  ^A (or #repeat) after an extended command
just repeats the # to run the dialog to get an extended command.

I hope this introduces fewer bugs than it fixes but I don't think I'd
bet on that....
2022-04-16 01:52:12 -07:00
PatR
4485515872 context-sensitive inventory item-action quaff
Picking a potion from inventory and then picking 'quaff this potion'
from the context menu needed handling similar to eat/offer/tin:  skip
floor candidates.  If you were on a fountain or sink, picked a potion
from inventory and then the quaff option for it, you weren't prompted
to drink from the fountain but you were prompted for what potion to
drink instead of using the one that had already been picked to
initiate drinkig.
2022-04-15 12:09:17 -07:00
PatR
12a63216a7 ^A fix
If you used ^A to repeat a command which had taken no time, the
repeat execution would take time.  This fixes that.  Also, give some
feedback when trying to repeat an invalid command.

Internals bit: don't use 'X == cmd_from_func(do_repeat)' to decide
whether key X is the key for #repeat.  Both X and Y might be bound to
that action and cmd_from_func() could return Y rather than X.

There is another ^A bug that I haven't figured out how to fix:
 t ESC   start to throw but don't finish
 ^A      nothing seems to happen
 ^A      "You don't have that object."
The first ^A repeats 't', doesn't display a prompt for what to throw,
but does request input for it.  The second ^A fulfills that input and
doesn't match any inventory item.  Either 't' shouldn't have been put
into the do-again buffer or do-again handling should have ceased when
it was taken out and there was no further remembered input, so that
normal prompting would resume.  My tentative attempts for both those
approaches didn't work.
2022-04-15 11:45:50 -07:00
PatR
ad46090732 fix github issue #734 - ^A crash
Issue #734 reported as "parse function" by Meklon2007:  the change
yesterday intended to make ^A work for commands that were preceded
by a prefix was triggering a crash if used after a keystroke that's
not assigned to any command.

'M^A' or '~^A' would segfault by derefencing a null pointer when
checking whether 'M' or '~' was a prefix.  This prevents the check
attempt from doing that, but a better fix would be to not put the
invalid command keystroke into the do-again buffer in the first
place.

Fixes #734
2022-04-15 10:07:19 -07:00
Pasi Kallinen
cb02ce88c5 Revisit the Valkyrie goal level hack
Instead of hardcoding the lava terrain change in core, if the stairs
are created in a fixed location, force the terrain to room floor first.
Move the surrounding lava changing to room floor to the Val-goal lua
file.
2022-04-15 18:52:49 +03:00
PatR
a15b587b81 fix a comment
At one point temp_resist() was boolean and when it was changed to
long the comment preceding it wasn't updated.
2022-04-15 00:45:35 -07:00
PatR
da35dfe48e fix #K3577 - F+dir followed by ^A moved dir
Reported by luxidream via the web contact form and also as github
issue #732: using the repeat command after F+direction would take a
step in direction if there was no target to fight.

The direction was being repeated without the F prefix.  It wasn't
specific to F; m+dir misbehaved too.  This fix seems to work but it
should be replaced with something more robust.

Fixes #732
2022-04-14 18:59:23 -07:00
PatR
554ebc0f4c temporary? fix for github issue #730 - stairs \
placed on lava spot on Valkyrie goal level

Reported by k2, arriving at the final level of the Valkyrie quest
can issue a recently added impossible
| mkstairs: placing stairs up on molten lava at <68,13>
The report said it was easy to reproduce, but it took me multiple
tries (so not hard to do, but not a sure thing on any given attempt).

The stairs on that level are placed at specific coordinates that
are outside the pre-mapped area, so there's no guarantee that their
spot will be suitable for stairs.  The underlying terrian changes
from lava to stair, but only after the warning about molten lava.

This hack solves that particular level but is not a general solution
for this type of thing.  When about to make stairs on a lava spot,
change that spot to normal floor first.  Plus 50:50 chance to change
each adjacent lava spot to floor too so that there's decent chance
for some elbow room upon arrival.

Also, turn the no-flip attribute off for that level so that 'fixed'
location of the stairs can occur in four different places.

Fixes #730
2022-04-14 10:50:23 -07:00
Pasi Kallinen
43856fe023 Fix uninitialized var in dip 2022-04-14 18:59:03 +03:00
PatR
9c2a5cbcb8 fix github issue #731 - accessing freed memory \
after charging causes a ring to explode

Reported by gebulmer:  if charging exploded a ring, the ring's memory
got freed but the stale pointer was passed to cap_spe() which accessed
it again.  Fix by setting the object pointer to Null after using up
the ring.  This was a post-3.6 bug.

Fixes #731
2022-04-13 13:34:14 -07:00