Commit Graph

8898 Commits

Author SHA1 Message Date
PatR
11bfb09daa fix #4005 - paranoid_confirm:Autoall
When paranoid confirmation for menustyle:full's "Autoselect all" is
enabled, it is handling yes vs no backwards.

The initial implementation had it right, then a negation got dropped
when it was expanded to support yes|no via paranoid_confirm:Confirm.

ESC is being treated as 'n' rather than as cancel.  Fixing that will
take some more work.  This just adds the missing negation to make 'y'
and 'n' behave properly.
2023-09-17 16:43:26 -07:00
PatR
56036ed5c7 status bit: trucated gold count
Gold on status line can be truncated, so testing the display value
might miss up/down/changed highlights.  I don't think that it actually
matters since a hero cannot pick up enough gold to reach the 999999
truncation threshold.

Normal amounts still seem to highlight correctly after this.
2023-09-16 17:48:51 -07:00
nhmall
b25512f7a1 fix broken build as of 2a5f03a3
gcc-9 -g -I../include -DNOTPARMDECL -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -pedantic -Wmissing-declarations -Wformat-nonliteral -Wunreachable-code -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes -Wformat-overflow -Wmissing-parameter-type -fPIC -DCURSES_GRAPHICS -D_XOPEN_SOURCE_EXTENDED=1 -DX11_GRAPHICS -DQT_GRAPHICS -DSND_LIB_QTSOUND -DUSER_SOUNDS -DSND_SOUNDEFFECTS_AUTOMAP -DDLB -DHACKDIR=\"/home/vsts/nh/install/games/lib/nethackdir\" -DDEFAULT_WINDOW_SYS=\"tty\" -DSYSCF -DSYSCF_FILE=\"/home/vsts/nh/install/games/lib/nethackdir/sysconf\" -DSECURE -DTIMED_DELAY -DDUMPLOG -DCONFIG_ERROR_SECURE=FALSE -DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\" -DCURSES_UNICODE -DUSE_XPM  -c -o decl.o decl.c
decl.c:223:15: error: incompatible types when initializing type ‘enum statusfields’ using type ‘void *’
  223 |             , UNDEFINED_PTR, UNDEFINED_PTR
      |               ^~~~~~~~~~~~~
decl.c:219:44: warning: missing braces around initializer [-Wmissing-braces]
  219 | const struct instance_globals_b g_init_b = {
      |                                            ^
decl.c:219:44: warning: missing braces around initializer [-Wmissing-braces]
decl.c:219:44: warning: missing braces around initializer [-Wmissing-braces]
decl.c:219:44: warning: missing braces around initializer [-Wmissing-braces]
decl.c:219:44: warning: missing braces around initializer [-Wmissing-braces]
decl.c:219:44: warning: missing braces around initializer [-Wmissing-braces]
make[1]: *** [Makefile:1837: decl.o] Error 1
2023-09-16 20:02:11 -04:00
PatR
2a5f03a3b4 status hilites: Hp and Pw percentages
The hitpoints and power/energy status values (and corresponding
maxima) shown on the screen are capped at 9999 to control status line
width.  The actual values can be bigger than that.  Highlights based
on percentages were doing their calculations on the potentially
truncated values rather than on the actual ones.

Add another field to the blstat[] structure, populate it for BL_HP,
BL_HPMAX, BL_ENE, and BL_EXEMAX and switch to it for their percentage
calculations.

Doesn't seem to break highlighting of 'normal' range values but hasn't
been tested for extreme ones.
2023-09-16 12:42:26 -07:00
PatR
e451966266 botl.c cleanup
Mainly miscellaneous source formatting, plus some expanded comments
and #undef of macros when done with them.
2023-09-16 10:15:05 -07:00
PatR
450efa0dc4 status hilites fix
The options menu for status hilites wouldn't work as intended if the
entries in the initblstats[] array were changed to not be in BL_xyz
order.  (No effect on current behavior since they are in that order.)
2023-09-15 12:35:42 -07:00
PatR
6636db94e7 corridor engravings in black and white
The default engraving-in-corridor character is the same as the default
corridor symbol (and also default lit corridor one), distinguished by
color.  Show it differently (in inverse vidoe, like lava vs water and
sink vs fountain) if color is Off.

It might be better to change the engraving-in-room symbol to be the
same as the room one so that they'll be more consistent with corridors;
color is probably sufficient without resorting to back-tick.  But this
update hasn't done that.
2023-09-12 01:34:47 -07:00
PatR
9016d65df4 another wall of lava fix
Use inverse video for wall of lava if color is disabled, same as is
done for ordinary lava.  The two won't have any visible distinction
from each other but at least wall of lava won't look like water.
2023-09-10 14:25:41 -07:00
PatR
0a7cdeae3c viewing geno'd monsters at "genocide what?" prompt
At either of the genocide prompts,
|What type of monster do you want to genocide?
or
|What class of monsters do you want to genocide?
answering "?<return>" will show the list of monster types that have
already been genocided, then re-prompt.
2023-09-09 16:56:24 -07:00
PatR
1a64ee1c28 github PR #259 - paranoid_confirmation:trap
Fairly old pull request from copperwater:  add new paranoid_confirm
setting 'trap'.

The old commit suffered from bit rot and merging needed too much
fixing up despite there not being many bands of change in the commit's
diffs.  I ultimately redid it from scratch, although the two biggest
chunks of code started with copy+paste of the pull request's commit.

It operates like paranoid:pray.  Setting paranoid:trap adds a new
"Really step into <trap>?" y/n prompt when attempting to move
into/onto a known trap, even if an object covers it on the map.
Setting both 'paranoid:Confirm trap' turns that into a yes/no prompt.
(Adding 'Confirm' affects other paranoid confirmations; in addition
to requiring yes<return> rather than just y to accept, it also forces
no<return> to reject.)

However, moving into a known trap that is considered to be harmless
behaves as if no trap was present.  Some of the trap classification
might be out of date; several types of traps have undergone changes
since implementation of the original pull request, notably anti-magic
field.  When the hero is hallucinating, all known traps are considered
harmful since the map no longer reliably describes them.

Preceding a movement command with the 'm' prefix also behaves as if
no trap was present, bypassing confirmation for that move, similar to
how paranoid:swim currently behaves.  Being stunned or confused also
behaves as if no trap was present, taking priority over hallucination.

This updates the documentation.

Supersedes #259
Closes #259
2023-09-08 15:55:31 -07:00
nhkeni
33d85bfe08 CRASHREPORT cleanup
make deprecation warning suppression unconditional
formatting/whitespace
2023-09-07 20:55:07 -04:00
Michael Meyer
9d7378ec57 Fix: undoing monsters' permablindness by accident
Monsters can become permanently blind (in very narrow circumstances -- I
think limited only to a very short-range camera flash), in which case
they have both mon->mblinded and mon->mcansee set to 0.  Such
permanently blinded monsters can counterintuitively regain their sight
by being blinded a second time from a different source: for example, by
being hit with a cream pie.  That second blinding will increase
mon->mblinded (which functions as a blindness timeout) by some amount,
and when it runs out the monster will regain its sight.  Try to make
sure that doesn't happen by skipping any blinding attacks if the monster
has already been permanently blinded.
2023-09-07 05:59:50 -07:00
Michael Meyer
1dab134fce Fix: rising from the grave as a zombie
When the hero is killed by a zombie, she is supposed to arise from the
grave as a zombie of a type matching her race.  Commit 580c5a6 broke
this inadvertently -- done_in_by was passing gy.youmonst.data to
zombie_form() and relying on the old behavior where it attempted to
include the hero's race in is_elf, is_orc, etc if the permonst matched
the hero's role.  Because this no longer works, zombie_form was only
returning PM_HUMAN_ZOMBIE when passed the role permonst of an
unpolymorphed hero.  Use gu.urace.zombienum instead.  This would have to
be a little more sophisticated (falling back to zombie_form() if Upolyd)
if a polymorphed hero with unchanging could die via done_in_by but
that's not currently possible as far as I can tell.
2023-09-07 05:35:51 -07:00
nhkeni
ee2510eb2f blind attempt to fix Windows build 2023-09-06 13:55:06 -04:00
nhkeni
385d860bef Merge branch 'keni-crashweb3' into NetHack-3.7 2023-09-06 12:39:17 -04:00
nhkeni
8c095b009a Add CRASHREPORT, show contact form on panic/impossible
When calling panic() or impossible(), create the option
of opening a browser window with most of the fields
already populated.  Code for MacOS and linux is included;
other ports are affected by argument change to early_init
which are done but not tested.

To enable, define CRASHREPORT in config.h and set
CRASHREPORTURL in sysconf to (for the moment at least)
http[s]://www.nethack.org/common/contactcr.html

Adds --grep-defined option to makedefs for Makefiles.

Adds "bid" (binary identifier), an MD4 of the main nethack
binary.  This is ONLY for helping (in the future) contact.html
to set the "NetHack from" field automatically for our own
binaries.  This can be faked, but the user can lie so nothing
lost.  There's nothing magic about MD4; other ports can use
anything that prodcues a long apparently random string we can
match against.

- new option --bidshow for us to get the MD4 of a
  released binary so I can add it to the website.
  Only available in wizard mode and not in nethack.6.
- typo macos -> macosx in hints file

No support for packaging builds as I'm not sure what that
would look like.

Adds a javascript helper for MacOS.
Adds a lua helper for linux (and builds and installs
 nhlua).
2023-09-06 12:27:13 -04:00
Pasi Kallinen
50084750c4 Ring of hunger prevents choking on food
... but you will not be prompted to stop eating,
and you will vomit enough to be hungry afterwards.
2023-09-03 18:27:00 +03:00
PatR
67513c96bb options help
Update the 'optmenu' data file to describe the simple options menu
(new paragraph containing just a one sentence) as well as the full
options menu (still several paragraphs).  Visible by choosing '?' in
the full options menu or the 'how to set options' choice in the main
help menu.

Add a line to the simple options menu about how to get the full
options menu.  Only shown if you type '?' to toggle on "show help";
taken away again if you use '?' to toggle back to "hide help".
2023-08-31 14:58:51 -07:00
PatR
bc93ee5d04 pet petrified by eating Medusa's corpse
From a reddit thread:  a tame mind flayer ate Medusa's corpse and was
turned to stone.  Pets won't eat cockatrice corpses unless stoning
resistant but would eat Medusa's corpse if merely poison resistant.
Mind flayers aren't normally poison resistant but could be if wearing
green dragon scales/mail.

Augment the touch_petrifies() test when classifying food for pets.
2023-08-30 13:38:08 -07:00
Michael Meyer
8fa53d6ac5 Adjust seenres when observed attack succeeds
If a monster sees an elemental attack succeed from some other creature
or environmental danger, it will be willing to try those attacks again.
2023-08-29 12:05:48 +03:00
PatR
82d83dc83d \#wizkill vs dmonsfree
When testing the high priest livelog/#chronicle feedback I used #wizkill
on the Sanctum level to kill Moloch's high priestess and immediately
level teleported to the Astral level to target the other high priests.
I got impossible "dmonsfree: 0 removed doesn't match 1 pending" there.
2023-08-29 00:45:11 -07:00
PatR
05a99064b6 fix #K3997 - livelog feedback for high priests
If you killed a second high priest (either two on Astral or first in
the Sanctum and another on Astral) the livelog/#chronicle message
would report "killed high priest of Foo (2nd time)" even though the
first was the high priest of Bar, or even just "killed high priest
(2nd time)" if second kill happened when not adjacent.

High priests pass the 'unique monster' test (even though they aren't
actually unique--there will be four of them) so get logged for killing
such.  Always report "killed high priest of Foo" and only do so if the
specific high priest[ess] monster hasn't been revived and re-killed.

Logging deaths of unique monsters normally reports the 1st, 2nd, 3rd,
5th, 10th, and various later instances.  If you were to kill Moloch's
high priest and all three on Astral, the last one wouldn't be logged
because 4th instance gets skipped.  This forces each one to be treated
as the 1st (provided that the mrevived flag is clear), so for logging
purposes it will now behave as if there are 4 distinct high priests.
2023-08-29 00:02:19 -07:00
Michael Meyer
38cda5ad52 Adjust seenres on visible gear removal
If a monster sees you remove some piece of gear that grants a
resistance, it will remove that resistance from its list of remembered
resistances and be willing to try attacking you with that adtyp again.
This avoids the situation where you put on a ring of cold, get hit with
one cold attack, and then can remove it because all the monsters nearby
will permanently remember you as being cold resistant (but even after
this change a wily hero could still step into a niche and do it without
any monsters seeing, so trick them into thinking she's still cold
resistant...).  The hero could still be resistant if there were multiple
sources to begin with, of course, but the monsters will test it and
learn that again if necessary.

It's a little weird that the monsters can recognize the intrinsic
granted by the item being removed, but they display knowledge of
unidentified (by the hero) objects in many other circumstances too, so I
hope it's forgivable in the pursuit of having them act more cleverly
about resuming previously-resisted attacks like this.  Another approach
that avoids the gear recognition, blanking seenres on any gear change,
can result in odd situations like orcs treating their own cloaks as
potential sources of many different resistances, which also seems silly.
2023-08-26 14:13:03 +03:00
Michael Meyer
9a5b6e8e77 Fix: name confusion after MB cancels shapeshifter
The cancellation effect of Magicbane can cause shapeshifters to change
to their base forms.  Since the name of the monster being attacked is
cached earlier, the name used for subsequent messages from Mb_hit would
be outdated after this happened.  For example, as encountered in a
recent game: "The magic-absorbing blade cancels the vampire bat! The
vampire bat turns into a vampire lord! The vampire bat is confused."
Insert the new name into hittee[] if cancellation caused the targeted
monster to change form.
2023-08-25 12:03:32 -07:00
PatR
6ad9eef25d update a couple of comments
Fix a couple of typos and rephrase 'livelog_mon_nam()' description.
2023-08-25 11:43:00 -07:00
Pasi Kallinen
b5a43a60f2 Asmodeus' cold magic attack when hero is resistant
Asmodeus kept using the cold magic attack when hero was cold resistant.
The distance magic attack already considered hero resistances, so
use the same logic for the close-up magic attack.
2023-08-25 10:58:11 +03:00
Pasi Kallinen
e407af4477 Allow defining random-teleport exclusion zones in lua
Adds a new lua command

  des.exclusion({ type = "teleport", region = { x1,y1, x2,y2 } });

which allows defining "exclusion zones" in the level, areas where
random teleports (or falling into the level) will never place the hero.
Does not prevent targeted teleportation into the area.

Breaks saves and bones.
2023-08-24 18:38:39 +03:00
Pasi Kallinen
0794a64b9d Fix lua object added to container error
The reference count of the deleted object was changed,
instead of the object that it was merged into.
2023-08-24 09:22:57 +03:00
PatR
78607a37a5 more obufs - two-handed weapon in "hands"
Pointed out by entrez:  prevent doname() from consuming two obuf[]
buffers when it constructs the plural of "hand" while formatting a
wielded two-handed weapon.

Since only one such item should be able to occur in any list of
objects, it is not likely to be the cause of any message oddities
that might happen when a cached value is in a formatting buffer gets
re-used too soon.  However, not releasing a second buffer right away
prevents an attempt to release the first one from succeeding because
it won't be the last one allocated anymore, so some buffer churn was
happening.
2023-08-16 18:16:11 -07:00
nhmall
d421e2512e tab to spaces 2023-08-16 10:07:01 -04:00
PatR
341b1ad289 sortloot details
The sortloot classification routine had some inappropriate casts to
'coordxy' for things had nothing to do with map coordinates.  I was
going to change the relevant fields to 'short' but that seems iffy
for 'indx' so I changed them all to 'int'.
2023-08-15 15:48:41 -07:00
Michael Meyer
3ce3128e09 Release obufs used by sortloot
Some further application of e43ec0c logic, which was intended to fix odd
messages produced by obufs clobbered by inventory updates (like "the
ogre lord yanks Cleaver from your corpses!").  That issue was still
lurking around because sortloot(), via sortloot_cmp(), was continuing to
call for obufs via loot_xname() without releasing them immediately.  It
was going through the entire inventory doing that, much like
display_pickinv() was prior to Pat's fix in e43ec0ce, so could cause
the contents of obufs to still be clobbered by perm_invent updates.
This changes sortloot_cmp() to releases the obufs it calls for as soon
as possible so that won't happen any more.
2023-08-15 14:33:17 -07:00
nhmall
b5dcb58d52 two minor comment typos 2023-08-15 14:12:52 -04:00
nhkeni
9ba47555c9 Merge remote-tracking branch 'origin/keni-versioncopy' into NetHack-3.7 2023-08-15 09:33:59 -04:00
PatR
1e47b4e824 third typo on same line as previous two... 2023-08-12 16:11:50 -07:00
PatR
fe919f91b3 couple of comment typos
The second one has two on the same line.
2023-08-12 15:04:10 -07:00
PatR
7ea091048c count_level_features() bit
The relatively recent code to recalculate the number of fountains and
sinks on a level was including column 0.  levl[*][0] is not used for
the map.
2023-08-12 15:01:02 -07:00
Pasi Kallinen
491cc9933f Unhide a water monster using a polymorph trap 2023-08-08 16:49:03 +03:00
PatR
9f16eaa0a5 fix 'up' and 'down' status highlighting for HP
If there was a status_hilite rule for hitpoints:up, it got used for
both up and down changes.  If there was one for hitpoints:down, it got
ignored even if there was no 'up' rule.  The flag for which direction
the value changed was always positive even when the value went down.

I'm reasonably sure that at some point HP up/down worked correctly.
This problem was present in 3.6.4; I didn't go back any farther.
2023-08-05 12:50:47 -07:00
PatR
70791271dd update PR #1071 - highlighting critical HP
If status field 'hitpoints' has rules for both 'criticalhp' and 'up'
or 'down' or 'changed', make critical-hp take precedence.  Otherwise
critical-hp might never be seen because of the value changing every
move (if hero has regeneration attribute).  Normally up/down/changed
take precedence over other types of highlighting.

Something is messed up with up/down/changed HP though.  I'm seeing
the 'up' highlight when it goes either up or down and not seeing the
'down' highlight at all.  'up' and 'down' for gold work as expected.
2023-08-04 22:33:29 -07:00
PatR
651a5b210f fix github issue #1085 - strength of orc captain
Issue reported by Umbire:  Uruk-Hai have strength 18/100 and can grow
into orc captains, but orc captains' strength was limited to 18/50.

Cap strength at 18/100 for hero poly'd into an orc captain, same as
when poly'd into an Uruk-hai.  Since poly'd heroes don't grow into
larger forms, the only way to notice is to polymorph into an Uruk-Hai
at some point and into an orc captain at some other point.

Fixes #1085
2023-08-04 15:12:33 -07:00
nhkeni
1663ecf85d Add --version:copy, deprecate --version:paste. 2023-08-03 21:51:25 -04:00
PatR
9d9042e94b fix #K3968 - objfree: obj not worn
New feature to sometimes hit twice for skilled martial-arts/bare-handed
was unconditionally using uswapwep for the second hit.  If it was a
breakable object, hitting could break it and produce impossible "objfree:
obj not free".

Only use uswapwep for u.twoweap; use Null for second bare-handed hit.
2023-08-01 10:28:21 -07:00
PatR
af387db16d bare-handed combat warning fix 2023-07-31 10:26:37 -07:00
nhmall
7cec01748e Revert "warning after commit 60c19568"
This reverts commit d32208562e.
2023-07-31 10:16:35 -04:00
nhmall
d32208562e warning after commit 60c19568
uhitm.c:843:63: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Wbitwise-conditional-parentheses]
                   | (hmd->twohits == 0 || hmd->twohits == 2) ? W_RINGL : 0L);
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
uhitm.c:843:63: note: place parentheses around the '|' expression to silence this warning
                   | (hmd->twohits == 0 || hmd->twohits == 2) ? W_RINGL : 0L);
                                                              ^
                                                             )
uhitm.c:843:63: note: place parentheses around the '?:' expression to evaluate it first
                   | (hmd->twohits == 0 || hmd->twohits == 2) ? W_RINGL : 0L);
2023-07-31 10:10:19 -04:00
PatR
60c1956850 revamp 'special' combat
This is a re-creation of a project that was lost years ago while not
quite finished.  The old version included some instrumentation to
measure how many hits it takes to kill things during actual play; that
wasn't ready for prime time and this hasn't attempted to redo it.

Changes:
1) improves martial arts and bare-handed combat:  they now have a
   chance to hit twice when skill is better than 'basic'; 20% chance
   for second hit at skilled, 40% at expert, 60% at master, and 80% at
   grandmaster; when attacking more than once, strength bonus is
   handled as in #2;
2) nerfs two-weapon combat a bit:  hitting twice uses only 3/4 strength
   bonus on each hit, but when both attacks hit that's 3/2 bonus from
   strength which is still more than you get for one hit at a time;
3) beefs up two-handed weapons:  hitting via melee with a two-handed
   weapon uses 3/2 of stength bonus to reflect the increased influence
   of strength; isn't done for applied polearms though.

The reduction in strength bonus for two-weapon has far less impact
than it might sound, due to rounding up with the low values involved.
| full   3/4
|  +1 -> +1
|  +2 -> +2
|  +3 -> +2
|  +4 -> +3
|  +5 -> +4
|  +6 -> +5
The small reduction also doesn't matter if/when current hit happens to
deal a killing blow anyway.

Rings of increase damage apply at full value to every hit, same as
before.

When hitting bare-handed (#1 without gloves), a silver ring on either
hand continues to give a damage bonus against silver haters when you
make an ordinary single attack.  However if you attack twice, a silver
ring only applies on the first hit when it is worn on the right hand
and only applies on the second hit when worn on the left hand.  (Two
hits with a silver ring on each hand will give silver bonus for both.)

We might conceivably need to add support for a count prefix of 1 to
let player explicitly avoid a second bare-handed/martial-arts hit
attempt (similar to how throw and fire accept a count to limit missile
volley amount).

Kicking has been ignored.
2023-07-30 14:08:30 -07:00
PatR
eb5bb2b989 weapon.c formatting bit
Fix some overly-wide lines.  I didn't look through the file for other
stuff that might need reformatting.
2023-07-27 13:11:22 -07:00
PatR
06d7b0561c double klick (not what you think...)
When testing water-vault chests, I kept getting
|Klick!  Klick!
when zapping them with a wand of opening.  This had me scratching my
head for a while, but it seems to have been caused by partially adding
a sound effect.  pline("Klick!") became duplicated and presumeably one
of the two was intended to be edited into a sound-effect call but got
overlooked.

Sound_effect(se_klick,) doesn't make any sound though.
2023-07-22 17:54:12 -07:00
PatR
d99b549bb0 more PR #1051 - water-vault escape item
When generating an "escape item" inside one of the chests in the
"water-surrounded vault" theme room, make sure that the chest is not
locked if the item is made of glass or crystal.  Otherwise kicking the
chest to get access to its contents might destroy the item.

I imagine that this could be done more cleanly, but after quite a bit
of thrashing about I have something which seems to work.  To test, I
temporarily modified object shuffling to force wand of digging to be
made out of crystal and gave the water-vault a very high generation
frequency.
2023-07-21 15:00:54 -07:00