Commit Graph

7291 Commits

Author SHA1 Message Date
PatR
661947ebaf some formatting bits in dogmove.c 2022-02-19 14:55:01 -08:00
PatR
e972d0b965 gamelog: hit with wielded weapon for first time
Reordering "killed for the first time" and "hit with a wielded weapon
for the first time" was done by moving the latter to hmon().  Hitting
with an applied polearm also gave the first-hit message since it
bypassed the routine that had been doing so.  But the throwing code
that handles applied polearms calls hmon() for damage, so after that
reordering, the first-hit log message became duplicated if triggered
by polearm usage.

Also, fix a quibble with the wizard mode conduct message given after
never-hit-with-wielded-weapon conduct has been broken.  The message
said "used a wielded weapon N times" when it meant "hit with a wielded
weapon N times".  "Used" is misleading if that wielded weapon happens
to be a pick-axe, so change the message to say "hit with".
2022-02-19 11:24:28 -08:00
Pasi Kallinen
70dafd658d Imps and others cussing the hero wake up nearby monsters 2022-02-19 17:18:07 +02:00
Pasi Kallinen
5e26589fa7 Make killer bee - queen bee transformation apply to hero
if they've polyformed to a killer bee and eat royal jelly.
2022-02-19 17:06:36 +02:00
Pasi Kallinen
26ea5824c1 Reading a magic marker shows the specific red ink color 2022-02-19 13:11:24 +02:00
Pasi Kallinen
c434236f1e Allow creating unhidden traps in special levels
des.trap({ type = "rust", seen = true });
2022-02-19 12:38:28 +02:00
Pasi Kallinen
a1d5464fa7 Knight quest home level has some saddled warhorses
Also, when creating a saddle in a monster inventory in special
level lua code, automatically saddle the monster, if possible.
2022-02-19 11:51:10 +02:00
PatR
45bc2dafa9 Unix command line parsing
Move a bunch of stuff out of main() into new early_options(): '-dpath'
playground directory handling, '-s ...' show scores instead of playing,
and the 'argcheck()' options:  --version, --showpaths, --dumpenums,
and --debug (not to be confused with -D).  Also introduce
| --nethackrc=filename
| --no-nethackrc
to control RC file without using NETHACKOPTIONS so that that is still
available for setting other options.  They can start with either one
or two dashes.  --no-nethackrc is just --nethackrc=/dev/null under the
hood.  '-dpath' can now be '--directory=path' or '--directory path'
but the old syntax should still work.  '-s ...' can be '--scores ...'.

Basic call sequence in unixmain relating to options is now
|main() {
|  early_options(argc, argv[]);
|  initoptions(); /* process sysconf, .nethackrc, NETHACKOPTIONS */
|  process_options(possibly_modified_argc, possibly_modified_argv[]);
|}
Options processed by early_options() that don't terminate the program
are moved to the end of argv[], with argc reduced accordingly.  Then
process_options() only sees the ones that early_options() declines to
handle.

Most early options were using plain exit() instead of nh_terminate()
so not performing any nethack-specific cleanup.  However, since they
run before the game starts, there wasn't much cleanup being overlooked.

chdirx() takes a boolean as second argument but all its callers were
passing int (with value of 1 or 0, so it still worked after being
implicitly fixed by prototype).  Change them to pass TRUE or FALSE.

argcheck() was refusing (argc,argv[]) with count of 1 but then it was
checking 0..N-1 rather than 1..N-1, so it tested whether argv[0] was
an argument instead of skipping that as the program name.  Change to
allow count of 1 with modified argv that has an option name in argv[0].
That happens to fit well with how early_options() wanted to use it.
2022-02-18 14:38:24 -08:00
Pasi Kallinen
cd14456b02 Knights get no caitiff penalty against undead 2022-02-18 21:29:31 +02:00
copperwater
d1b5b39e6d Martial arts users never deal no damage with a clumsy kick
From EvilHack, under the basis that anyone trained in martial arts (or
is in a powerful kicking polyform or wearing kicking boots) should be
immune from landing such a poor kick. This bypass used to happen only
50% of the time; now it happens all the time.

Note that this only averts the "Your clumsy kick does no damage" case:
it remains possible for a powerfully kicking player to kick clumsily and
have the monster evade or block, for example if they are fumbling or
wearing bulky armor.

Also, documentation: I added a comment explaining what the incredibly
dense and confusing logic is with i and j happening here, for the next
poor soul that has to read that code.
2022-02-18 08:12:31 +02:00
Pasi Kallinen
a9712442dd Use defines for pet hunger limits 2022-02-17 20:03:39 +02:00
Pasi Kallinen
390429545e Wield and swapweapon ext cmd fail return values 2022-02-17 11:06:35 +02:00
Pasi Kallinen
953a534cc5 Fix fire auto-swapweaponing to polearm
When you have a polearm as secondary weapon, have a fireassist on,
and press 'f' to fire, the code tries to swapweapon to the polearm.
This failed badly and got stuck in a loop if you were also wearing
a shield - as polearms are two-handed and shield prevents wielding
those.

Add a new "command failed" result, and clear the command queue
in that case. Also make swapweapon and wield actually return
the ECMD flags back to the rhack loop.
2022-02-17 09:12:07 +02:00
Pasi Kallinen
b25138e6d9 Zombies groan 2022-02-16 23:04:02 +02:00
Pasi Kallinen
122634ec9e Hallucinatory rays
When hallucinating, use nonsensical names for the rays
(wands, spells, and breath weapons), and random ray glyphs.

Original code from xNetHack by copperwater <aosdict@gmail.com>,
inspired by a YANI by Kahran042.
2022-02-16 21:09:23 +02:00
PatR
f588a707bb groundwork for nethackrc name on command line
I've implemented 'nethack -nethackrc=filename' as an alternative to
'NETHACKOPTIONS='@filename' nethack' but at the moment it doesn't
work because the command line parsing comes after the run-time config
file has already been processed.  But this part should work, or maybe
have problems spotted and fixed if it doesn't.  The RC file part of
initoptions_finish() has been rewritten so that it won't need extra
replication of
|  set_error_handling()
|  process_file()
|  reset_error_handling()
|  if (NETHACKOPTIONS) {
|    set_error_handling()
|    process_options()
|    reset_error_handling()
|  }
I've tried to test all the combinations mentioned in the comment but
am not sure that I covered everything, particulary for repeating
earlier tests after making incremental changes.
2022-02-16 00:36:26 -08:00
Pasi Kallinen
d958d032a0 Looting will fall through to force
If you have autounlock on, and don't have unlocking tool, but
are wielding a weapon usable for forcing the lock.
2022-02-16 08:49:16 +02:00
Pasi Kallinen
679f8c11c9 Fix broken fireassist
When I recently refactored the rhack loop, I also broke fireassist,
as rhack was clearing the command queue unconditionally.
2022-02-15 20:16:31 +02:00
Pasi Kallinen
e65c921ccb Use grounded macro 2022-02-15 18:44:56 +02:00
Pasi Kallinen
f2ea207936 Monster or hero placement should avoid wall of water 2022-02-13 18:06:56 +02:00
Pasi Kallinen
c1a6dd40bc Flying should not allow monsters to walk on the wall of water
Also applies to levitating monsters.
2022-02-13 17:54:13 +02:00
Pasi Kallinen
2448ead0c4 Wall of water should block monster lined-up checks
Prevents monsters from eg. throwing items through the water.
2022-02-13 17:22:00 +02:00
Pasi Kallinen
3b2e4d682d Water walking doesn't help in wall of water 2022-02-13 14:38:54 +02:00
Pasi Kallinen
7302b87dd5 Improve avoiding walls of water 2022-02-13 14:19:40 +02:00
Pasi Kallinen
d26c7dde44 Fix the "wall of water" and paranoid:swim 2022-02-13 11:00:09 +02:00
Pasi Kallinen
73dbd39d98 Use proper locomotion when avoiding water or lava 2022-02-13 10:56:40 +02:00
PatR
a1bb10e8f6 unix command line
I wanted to be able to specify -windowtype:foo on the command line so
that I didn't have to use "NETHACKOPTIONS='windowtype:foo' nethack"
and it turned out that such an option already exists, as "-wfoo".
I either never knew about that or had completely forgotten it.  Anyway,
this makes specifying windowtype be more versatile.

"-wX11" still works; now "-w X11", "-windowtype=X11", "-windowtype:X11"
work too, with "--" variations of the latter too also supported.  The
long name can be truncated to any leading substring of "windowtype",
although it has to be at least "wi" for "--"; "--w" is rejected.

Also, any errors reported while processing the command line are
treated like config file processing errors rather than just delivered
with raw_printf().  On tty at least, they used to vanish when the
screen cleared to start the game, with no chance to read them.  Here's
an example from after this change.  It sets windowtype to tty and then
overrides that with X11.

|% ./nethack --w:Qt --win tty -wX11 -windowtype
|
|
| * Unknown option: --w:Qt.
| * Window type [nothing] not recognized.  Choices are:  tty, curses, X11, Qt.
|
|2 errors on command line.
|
|
|Hit return to continue:

This should probably be better integrated with argcheck() or vice
versa but the only change to that was a couple of formatting bits.

Anything that already worked should continue to work just the same,
aside from the improvement to the error feedback.
2022-02-12 11:42:17 -08:00
SHIRAKATA Kentaro
bb5150445a Check the return value of nhl_init() on com_pager_core()
nhl_init() can return NULL.
2022-02-12 07:45:46 -08:00
Pasi Kallinen
03c715f179 Add paranoid:swim to prevent typoing into water or lava
In the name of accessibility: Prevent moving into dangerous liquids.

Now with themed rooms, water and lava are more common, and it's
unreasonable to expect blind players to check every step for those.
With paranoid:swim, just prevent normal walking into those liquids,
unless you prefix the movement with 'm', or if the liquid would not
harm you.

Doesn't completely prevent an accidental dunking - for example
if the hero is impaired or couldn't see the liquid.

This comes from xNetHack by copperwater <aosdict@gmail.com>
with some changes to the code.
2022-02-12 17:29:32 +02:00
Pasi Kallinen
bc456938d7 Should see rusting next to you if underwater
You can see to the adjacent squares, if they're water and you're
underwater - show the item rusting there in that case.
2022-02-12 11:54:50 +02:00
Pasi Kallinen
91e2d3633e Use macro for a location next to hero 2022-02-12 11:05:10 +02:00
PatR
2b4cf04281 fix gamelog 1st kill vs 1st weapon hit sequencing
If the first monster the hero kills is killed by the hero's first hit
with a wielded weapon, report the hit first and kill second instead of
the other way around.  Not as hard to manage as I feared, but bound to
be more fragile than the simpler handling that produced the odd order.

Also while testing it I knocked something into a polymorph trap and it
changed form without any feedback.  Give foo-changes-into-bar message
if the hero is moving and can see it happening.  It isn't needed with
a monster moves deliberately into a polymorph trap but probably would
be useful when that's is unintentional.

The "<hero> enters the dungeon" log message had a trailing period but
other log messages don't have sentence punctuation, so take that off.
2022-02-11 16:17:17 -08:00
PatR
27dd93df17 more curses get_count
A couple of formatting bits I made when investigating cursor
positioning misbehavior for curses menu counts.  No change in
behavior here.
2022-02-11 12:12:35 -08:00
Pasi Kallinen
2ca8ac9a80 Make the "wall of water" stop thrown or kicked items 2022-02-11 20:38:29 +02:00
Pasi Kallinen
cd797afd0e Don't show rusting of items landing in water
When a thrown item lands in a pool of water, it immediately
rusts - but don't give that message unless the hero is at the same
location and also under the water.  My reasoning: hero can't see items
under water, and by the time the item rusts, it's in the water.
2022-02-11 20:20:24 +02:00
Pasi Kallinen
8ce3e08d00 Give a sound message when thrown item lands in water or lava 2022-02-11 20:05:46 +02:00
nhmall
5faace8b9e remove unnecessary null checks from christen_monst
Closes #681
2022-02-11 09:08:31 -05:00
SHIRAKATA Kentaro
7c1dba3f0b remove redundant null-check on christen_orc()
rndorcname() returns buf2 itself, so orcname is never NULL.
2022-02-11 16:52:50 +09:00
nhmall
9b1a501c34 error on parse_condition pr #680
The  while(s[sidx]) { ... was acting as while(1), but the
loop body contained appropriate checks and returns to
function correctly.

Fixes #680
2022-02-10 18:18:25 -05:00
PatR
0f2a1ac002 number_pad menu hack
I don't try to toggle 'number_pad' very often, but when I do I almost
always type '0' instead of 'a' for Off or '1' instead of 'b' for On
on the first attempt.  The menu shows
| a -  0 (off)
| b -  1 (on)
| c -  2 (on, MSDOS compatible)
| d -  3 (on, phone-style digit layout)
| e -  4 (on, phone-style layout, MSDOS compatible)
| f - -1 (off, 'z' to move upper-left, 'y' to zap wands)

This change makes '0' through '4' be undocumented group accelerators
for 'a' through 'e' (and '5' for 'f') in the sub-menu put up by 'O'.
tty and X11 worked as-is for '0' and required what amounts to a pair
of one-line changes to handle the other digits.

It doesn't work for curses and Qt (no idea about Windows GUI) because
they insist on treating any typed digit as the start of a count even
if one or more menu entries include that digit as a group accelerator.
(They also fail to support '0' as the group accelerator for iron-ball
class in the menu for multiple-drop.)
2022-02-10 14:18:44 -08:00
PatR
3ea4b00879 memory management
MONITOR_HEAP+heaputil pointed out some unreleased memory.  The livelog
stuff wasn't being freed.  Not surpringly the data used for collecting
and formatting build-options that just got changed from strdup() to
dupstr() wasn't being freed.  And a couple of date/version bits.
2022-02-10 12:14:27 -08:00
PatR
e02834ff87 strdup vs dupstr
mdlib.c was avoiding alloc() and dupstr() because mdlib.o gets linked
with makedefs and makedefs used to need to avoid those.  But makedefs
doesn't avoid those anymore, so mdlib.c doesn't need to either.

Replace a couple of other strdup() calls in other files too.
2022-02-10 10:25:25 -08:00
PatR
a9ba536e38 livelog/chronicle start of game
Add a log entry for the start of a new game.
2022-02-10 10:17:34 -08:00
nhmall
08da5befcb comment out some now dead code
Closes #670
2022-02-10 09:16:29 -05:00
PatR
96ba3c04d1 logging experience level changes again
The livelog message for losing a level had an off-by-1 error, showing
the level the hero ended up at rather than the level that was lost.

There was a message for regaining a previously lost level when rank
title stayed the same but no such message if the title changed (the
achievement of gaining a particular title only occurs once).

Say "regained" rather than "gained" when gaining a previously lost
level.  (Blessed potions of full healing regain levels but can also
reduce u.ulevelmax so a different way to remember peak experience
level has been added.)

Report level change due to polymorphing into new man/woman/elf/&c.
I hadn't realized that that hasn't been recording achievement for new
rank when applicable and decided to leave things that way.

Report gender change when putting on an amulet of change or becoming
a new man/&c unless hero is polymorphed at the time or experience
level is also changing.
2022-02-10 05:45:07 -08:00
Pasi Kallinen
c036c59b00 Monsters should growl even if you can't hear it
Call growl even if you are deaf, because growling also
wakes up nearby monsters. Just make growl not show the message
if you can't hear or see the monster.
2022-02-10 13:41:53 +02:00
PatR
a1feac496e cursed list vs worn light again
Fix a couple of mistakes in commit
 e8341dc9d7
pointed out by vultur-cadens.  While in read.c, reformat some of the
new livelog stuff.
2022-02-09 16:38:26 -08:00
PatR
d761263e89 livelog tweaks
Log all level gains and loses.  For the existing logging of changes
in rank, mention the level number with the new title.  Classifying
level loss as "minor achievement" seems weird but I didn't see any
choice more appropriate.

Make '#chronicle' autocomplete.  That makes "#ch" ambiguous, but
better to have to type #cha to chat than to have to completely spell
out #chronicle.  (Changing it to #journal would make #j ambigious
but might still be an improvement.)
2022-02-09 14:25:32 -08:00
nhmall
478daa0002 Merge branch 'argrath' into NetHack-3.7 2022-02-09 16:09:37 -05:00
PatR
a0771c770b flush_screen() sequencing
Call display_nhwindow(WIN_MAP) after curs_on_u().  Instead of calling
it a second time, it's simplest to just update status before updating
the map.

If anything is still leaving the cursor dangling at the end of status
I think it will now dangle at the last updated position on the map.
2022-02-09 13:02:19 -08:00