Commit Graph

481 Commits

Author SHA1 Message Date
PatR
b9ff8068b4 extending u.usaving_grace
Issue a livelog/#chronicle message if saving-grace saves the hero.
Right now it's classified as conduct for livelog filtering, because
I didn't want to implement a new category (needs update of global.h
and also the template 'sysconf') and conduct felt like the best fit
of the existing classifications.

Report whether saving-grace is available or already used, among
the attributes of magical enlightenment or end-of-game disclosure.

And move the fixes entry for it from the fixes section to the new
features section of fixes3-7-0.txt.

It seems likely that someone will want to turn not using saving-
grace into a tracked conduct.  That seems like overkill to me, not
to mention inflating the N for "N conduct games".
2024-09-06 15:32:26 -07:00
PatR
045d60848b hero health manipulation
I've been investigating issue #1252 (while the fuzzer was running,
sanity_check complained that hero's current health was greater
than maximum health) off and on for three months and haven't found
the cause.

I've checked all the places that lower maximum HP that I've managed
to find, but not spent much time looking for places that raise
current HP.

These changes might provide some more information.  They don't rely
on sanity_check being enabled.

Issue #1252 is still open.
2024-09-06 13:35:00 -07:00
PatR
aa043f0ddf some reformatting (2 of 4) 2024-09-05 14:51:21 -07:00
PatR
cd19f84721 boulder pushing comment
Replace wondering whether something is possible with a description of
how it can happen.
2024-09-05 01:14:20 -07:00
PatR
bd10bf36ec address #K4246 - pushing shop boulder out of shop
The report is for 3.6.7:  pushing a boulder into a general store adds
it to shop's inventory, but pushing it back out lets player remove it
for free.  3.7 has already fixed this; update its comments though.
2024-09-04 03:00:57 -07:00
SHIRAKATA Kentaro
7bb1d4a827 unify moverock() to "early return" style
... to prepare further refactorings.
2024-09-03 23:46:21 -07:00
SHIRAKATA Kentaro
01910d2998 split "moverock_done" into a separate function 2024-08-17 18:13:35 -07:00
PatR
c63b493904 tweak paranoid_confirm:trap vs regions
It is possible to have a known trap be at the same location as a gas
cloud region.  When paranoid_confirm:trap is set, ask for confirmation
about entering the region before confirmation about entering the trap
since the map will be showing the region rather than the trap.

Dual confirmations will be annoying but not new.  Before this change,
it would ask about entering the trap, and if the answer was yes, it
would ask about entering the region.  The situation seems to be too
rare to warrant implementing a single combined confirmation, and the
code to accomplish that would likely be messy.
2024-08-13 13:53:41 -07:00
PatR
0eb8896301 paranoid_confirm:Trap vs vapor+gas cloud regions
Extend paranoid_confirm:trap to also ask for confirmation when
attempting to enter a gas cloud region (scroll of stinking cloud,
breath from green dragons or iron golems, steam clouds from boiling
water, vapor left by fog cloud movement, no doubt several others).

Like with traps, can be overridden for a given move by using the
'm' prefix.  Unlike traps, doesn't try to guess whether moving into
a region will be harmless.

Doesn't affect movement into cloud terrain (Plane of Air).

Update the Guidebook to describe the revised behavior of
paranoid_confirm:trap and to mention how #terrain deals with regions.

'any_visible_region()' got mixed in with this but isn't used yet.
Affects extern.h and region.c.
2024-08-11 14:59:57 -07:00
nhmall
6c0ae092c6 distinguish global variables that get written to savefile
The g? structs had a mix of variables that were written to
the savefile, and those that were not.

For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.

This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.

Details:

    gb.bases            -> svb.bases
    gb.bbubbles         -> svb.bbubbles
    gb.branches         -> svb.branches
    gc.context          -> svc.context
    gd.disco            -> svd.disco
    gd.dndest           -> svd.dndest
    gd.doors            -> svd.doors
    gd.doors_alloc      -> svd.doors_alloc
    gd.dungeon_topology -> svd.dungeon_topology
    gd.dungeons         -> svd.dungeons
    ge.exclusion_zones  -> sve.exclusion_zones
    gh.hackpid          -> svh.hackpid
    gi.inv_pos          -> svi.inv_pos
    gk.killer           -> svk.killer
    gl.lastseentyp      -> svl.lastseentyp
    gl.level            -> svl.level
    gl.level_info       -> svl.level_info
    gm.mapseenchn       -> svm.mapseenchn
    gm.moves            -> svm.moves
    gm.mvitals          -> svm.mvitals
    gn.n_dgns           -> svn.n_dgns
    gn.n_regions        -> svn.n_regions
    gn.nroom            -> svn.nroom
    go.oracle_cnt       -> svo.oracle_cnt
    gp.pl_character     -> svp.pl_character
    gp.pl_fruit         -> svp.pl_fruit
    gp.plname           -> svp.plname
    gp.program_state    -> svp.program_state
    gq.quest_status     -> svq.quest_status
    gr.rooms            -> svr.rooms
    gs.sp_levchn        -> svs.sp_levchn
    gs.spl_book         -> svs.spl_book
    gt.timer_id         -> svt.timer_id
    gt.tune             -> svt.tune
    gu.updest           -> svu.updest
    gx.xmax             -> svx.xmax
    gx.xmin             -> svx.xmin
    gy.ymax             -> svy.ymax
    gy.ymin             -> svy.ymin

Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
          gf.ftrap, gl.light_base, gt.timer_base
2024-07-13 14:57:50 -04:00
PatR
40716b7b0a fix #K4199 - dereference of null firstmatch pointer
Bumping into something (by fuzzer) with mention_walls On crashed
when trying to display output generated by do_screen_description().
I wasn't able to reproduce this but didn't spend much time trying.

Without a test case I'm only guessing that this fix solves the
problem.  If there was a monster phazing at the 'wall' location
or an object embedded there, the screen description wouldn't be
appropriate for trying to describe the terrain.  (I don't think that
the pass-walls monster csse would reach the affected code but the
embedded object case might.)

Use the background glyph calculated for the map, which yields the
intended "stone" instead of "wall" when outside a not-yet-mapped
wall, rather than the displayed glyph.
2024-07-06 17:00:30 -07:00
PatR
a33f1edd24 YMonnam(monst)
Replace several upstart(y_monnam(mon)) with new YMonnam(mon) to
produce "Your little dog" and such.

Also change one or two Monnam(mon) to YMonnam(mon) and one pline(...)
to pline_mon(mon, ...).
2024-07-04 14:27:28 -07:00
disperse
2ce432657c fix shop automatic annotation for #overview
[PR #1243.  Cherry picked with new commit log message.  PatR]

Fixes issue where room_discovered was never called for shops
unless #overview was called while inside the shop, fixes #1241.

Issue #1241 reported by mark-mcknight-oncorps.

Triggered by commit e4026d55fb
last December:  Lazy evaluation of overview info.

Closes #1243
Closes #1241
2024-05-07 10:31:40 -07:00
PatR
f5cde4cfd6 PR #1242 - paranoid_confirm:trap vs doorways
Pull request from disperse:  moving diagonally from an intact doorway
isn't allowed but if there was a known trap at the destination and
parnoid_confirm:trap was set, player would be asked whether to move
onto the trap before not being allowed to move diagonally.

There was similar misbehavior if a trap had been armed or web spun
in a doorway and you tried to move diagonally into that doorway, not
just out of one.  The pull request's one-line change fixes that too.

I modified the file manually rather than keep the PR's commit.  This
also adds a couple of unrelated reformatting bits.

Closes #1242
2024-05-06 12:08:17 -07:00
Pasi Kallinen
f1c77aa2fd Pets avoid a location hero just kicked
If hero kicks a location, pets and peacefuls will avoid moving
into that location for that turn.
2024-04-11 18:05:18 +03:00
Pasi Kallinen
62b78ba037 Hero movement affects water bubble direction 2024-04-10 21:57:05 +03:00
PatR
f545ca8f22 fix #K4138 - untrapping a monster while blind
If a tame or peaceful monster was trapped and blind hero hadn't seen
the trap yet, attempting to swap places would report that the monster
couldn't "move out of that trap".  And if the 'tips' option was True,
the game would suggest attempting #untrap.  But #untrap would report
that the hero wasn't aware of any trap at the spot, and fail.

Change the original message to "move out of that <type-of-trap>" and
if hero hasn't seen it yet, map it and vary the wording slightly
"... a|an <type-of-trap>".  If #untrap is attempted, it will now be
dealing with a known trap.
2024-04-07 16:56:02 -07:00
Pasi Kallinen
e2d3368b0e Make hero polyed into hezrou also stink 2024-04-04 11:22:20 +03:00
Pasi Kallinen
1b0ba3433c Show damage only when any damage is dealt 2024-03-31 18:51:34 +03:00
nhkeni
9c0ed8ae63 NOSTATICFN for src/* 2024-03-14 17:41:51 -04:00
nhmall
50811037f3 split some code into separate files
new .h files: hacklib.h selvar.h stairs.h

new .c files: calendar.c, getpos.c, report.c, selvar.c, stairs.c,
              strutil.c, wizcmds.c

cleanup of hacklib.c and mdlib.c

hacklib contains functions that do not have to link with the core

relocate wiz commands from cmd.c to wizcmds.c

relocate CRASHREPORT stuff to report.c

relocate getpos stuff from do_name.c to getpos.c

remove temporary struct definition from extern.h

cross-compile PRE-section split into cross-pre1.370 and cross-pre2.370

Windows sys/windows/Makefile.nmake and sys/windows/Makefile.mingw32 and
visual studio project file updates

Unix sys/unix/Makefile.src, sys/unix/Makefile.utl

populate selvar.c and selvar.h

build on MS-DOS (not cross-compile) Makefile updates
for sys/msdos/Makefile.GCC (untested)

vms updates for above (untested)
2024-03-07 11:01:04 -05:00
nhkeni
acf60063d5 Add missing prototypes for static functions to avoid warnings. 2024-02-29 10:49:53 -05:00
Pasi Kallinen
dd37c5326a Accessibility: showdamage option
Add a new boolean option showdamage, if on, outputs a message
like "[HP -2, 14 left]" - several variants have something similar,
but I chose the message based on how eSpeak said it, while keeping
it short.
2024-02-24 17:38:46 +02:00
nhmall
688ac6ffbe remove register from variable declarations 2024-02-19 16:30:07 -05:00
PatR
13ff565a67 github issue #1201 - Forcefighting webs
Issue reported by Umbire:  suggestion to always destroy adjacent webs
via 'F'<dir> if wielding Sting or Fire Brand.

Sting already did that; this adds Fire Brand.

This also augments the #untrap command when wielding either of those,
or any other blade.  And rephrases successful untrap message
"You remove {the or your} {bear trap or webbing} from Fido." to
"You extract Fido from {the or your} {bear trap or web}." since the
trap remains intact.

Forcefight and #untrap against webs ought to be reconciled to remove
[some of] their differences and/or share code.  But not by me...

Closes #1201
2024-01-21 11:58:44 -08:00
Pasi Kallinen
57747535af Add m_next2u, analogous to m_next2m and next2u 2024-01-19 21:53:25 +02:00
Pasi Kallinen
1c16ef68eb Fix spot_monsters giving a segfault in some cases 2024-01-15 20:53:24 +02:00
PatR
e4534d60e3 more Forcefighting webs
Hero attempting to cut an adjacent web can so with secondary weapon
if dual wielding and primary isn't a blade.

Mostly message handling for the 'neither weapon is a blade' situation.
2024-01-14 16:58:43 -08:00
Pasi Kallinen
3160112ece Accessibility: Show a message when monster is spotted
Adds a new boolean option, spot_monsters.  If on, every time
the hero notices a monster which was out of sight before,
a message is given.  Combine with accessiblemsg to get the
monster location:

(3north): You see a newt.

Breaks saves and bones.
2024-01-14 13:33:02 +02:00
PatR
32f3f7cf46 Forcefighting webs (when adjacent, not trapped)
ACURR(A_STR) can yield a value as high as 125.  Switch to acurrstr()-2
for a value of 1..19.

P_SKILL(skilltype) shouldn't be used unconditionally.  It yields a
different value for restricted than for unskilled and those two skill
levels only differ for training, not effectiveness.

Allow weaponless forcefight againsta webs.  The chance for success may
need to be tweaked.
2024-01-10 12:24:05 -08:00
Pasi Kallinen
9ab4d65431 Make force-fighting a web train the weapon
... and the skill matter a little bit for actually cutting the web.
2024-01-10 17:44:56 +02:00
nhmall
4e19221e55 variable 'display' causes shadow variable warnings in X11 build
display.botl      -> disp.botl
display.botlx     -> disp.botlx
display.time_botl -> disp.time_botl
2024-01-05 05:58:51 -05:00
nhmall
22e52ee905 bundle the display-related hints, that tell bot() and others
that an update is required, into a struct. Remove it from
context since there is no reason to save those.
2024-01-04 23:16:27 -05:00
Pasi Kallinen
dc8d9d6cd0 Accessibility: Add location info to messages
Adds a new boolean option, accessiblemsg.  If on, some game messages
are prefixed with direction or location information, for example:

   (west): The newt bites!
   (northwest): You find a hidden door.

I added the info to the most common messages, but several are
still missing it.
2024-01-02 18:59:25 +02:00
nhmall
294ce9b59d reinstate removal of mon guard from is_safemon()
callers were checked:
domove_attackmon_at(mtmp, x, y, displaceu) has mtmp declared nonnull;
    there are dereferences of mtmp in the first line of code in
    the function.

In domove_core():
    The 1st occurrence of is_safemon(mtmp) is guarded by if (mtmp) { }.
    The 2nd occurrence of is_safemon(mtmp) is inside an if (mtmp) { } block.
    The 3rd occurrence of is_safemon(mtmp) was just remediated by 987be7e8.

In lookaround():
    The only occurrence of is_safemon(mtmp) is inside an
        if ((mtmp = m_at(x, y)) != 0 [...] { } block.

In do_attack(mtmp), in uhitm.c:
    The parameter is declared NONNULLARG1, and the 1st line of
    code contains a dereference with mtmp->data, which would
    segfault if mtmp were NULL.
2023-12-16 12:37:49 -05:00
nhmall
987be7e8e5 a pair of domove_core() blocks
Following line 2425 of hack.c, in domove_core():
    mtmp = m_at(x, y);
mtmp can be null.

There were two if blocks following that, both of which
only make sense when mtmp is not null.

One of them was explicitly checking for mtmp being non-null,
and the other was avoiding catastrophe by relying on a
hidden check buried within an _is_safepet(mon) macro.

Place both of those blocks into an
    if (mtmp) { }
block.

99% of the diff is just indentation.
2023-12-16 11:38:55 -05:00
nhmall
c5a5b55c15 nonnull for some static functions during recent analysis 2023-12-16 10:51:59 -05:00
PatR
9d3710163e fix #K4063 - "back on ground" given at odd time
Moving over at item that's resting on ice gives a message about there
being ice present and then about the item, whether mention_decor is On
or Off.  With it On, you'll get a message about being back on solid
ground as soon as you leave the ice.  With it Off you wouldn't get
that at all if not levitating; that's the basic no-mention_decor
behavior for ice.  However, if you were levitating, you would get a
delayed "back on solid ground" message when moving over some other
object, which might occur quite a bit later.  Autopickup handling is
calling describe_decor() when the hero is levitating and some of that
wasn't appropriate for no-mention_decor.

This issue has been present since I first implemented mention_decor,
not introduced by recent back_on_ground() changes.
2023-12-13 13:15:18 -08:00
PatR
2bd967fe8a a few fewer update_inventory() calls
A couple of things I noticed while running umpteen tests for tty
perm_invent.  Remove the update_inventory() from unmul(), and limit
the one that deals with seeing inventory when recovering from blindness.

Just a drop in the bucket overall, and the screen updates nearly
instantly for update_inventory() except when debugging perm_invent so
players aren't likely to notice this.
2023-12-07 22:47:57 -08:00
Michael Meyer
986c8e7ff4 Check whether steed will slip on ice if mounted
If riding over ice, check whether the steed, rather than the hero, is
cold-resistant or floating to determine whether it should slip, since it
is the monster which would actually be in contact with the ice.
2023-12-04 14:52:58 -05:00
nhmall
d7fef5f194 avoid another magic number
Some of the hardcoded +1 scattered about are likely
invlet_gold or invlet_overflow, but I didn't hunt those down.
2023-11-30 11:15:32 -05:00
nhmall
a7242760f7 consistent cast syntax 2023-11-13 19:28:19 -05:00
Michael Meyer
392295d770 Require min body weight for step to wake zombies
A newt or something probably isn't disturbing anything buried 6 feet
below the ground.  WT_ELF/2 is the size of a dingo or goblin.
2023-11-10 10:04:07 -08:00
Michael Meyer
a1b1f3b250 Try to unify "back on solid ground" messaging
Put everything through a single function that can handle all the
complicated parts of using the correct proposition for different terrain
types, and will not just call things "solid ground" indiscriminately.
This got complicated but I'm not sure if it's possible to do it much
simpler while still using the distinct names for each type of terrain
(unless you are OK with the sentences sounding sort of wonky).
2023-11-07 16:13:55 -08:00
Michael Meyer
702f914306 pooleffects messaging vs mention_decor
With mention_decor enabled, exiting the water on the Plane of Water
would produce the series of messages "You pop into an air bubble.  You
are back on air bubble."  Suppress the second message.  The lack of
article there seems like a problem too...

Also, acknowledge flight/levitation and use ice_descr in the pooleffects
"solid land" message.  This should make it more consistent with how
mention_decor does a similar message, especially changes to how it
describes ice based on its melt timer.
2023-11-07 16:13:54 -08:00
nhmall
1538b401e9 quiet a new warning after pull request #1119
hack.c
.\hack.c(1607): warning C4018: '<': signed/unsigned mismatch
2023-11-06 07:37:34 -05:00
Michael Meyer
98d2b0ecb3 Follow up on disturbing buried zombies
Change 852f8e4 by requiring a minimum impact before a buried zombie
nearby will be disturbed: light, but still excluding things like
scrolls, if it's a violent impact (dropped while levitating, thrown, or
kicked), and fairly heavy if the hero is just placing the item on the
ground normally.

Moving the call out of flooreffects meant it no longer applied to
pushing boulders around, so have moverock disturb nearby zombies.  I
additionally had wake_nearby do the same thing.

Finally, I renamed check_buried_zombies (which doesn't really reflect
what it does) to disturb_buried_zombies.
2023-11-05 21:51:45 -08:00
Pasi Kallinen
852f8e4996 Dropping items disturbs buried zombies 2023-11-02 20:31:51 +02:00
nhmall
6cbefc7c2d Revert "granular verbose message suppression mechanics"
This reverts commit be76727265.
2023-10-29 20:39:07 -04:00
Pasi Kallinen
03ee609ca0 Saving grace stops multi-turn actions, sleeping, and fainting 2023-10-29 18:01:28 +02:00