Commit Graph

13107 Commits

Author SHA1 Message Date
SHIRAKATA Kentaro
b82f5fa28f remove redundant null-check on untrap_prob()
`ttmp` should not be NULL here, otherwise this function will crash at earlier code.
2022-03-11 09:56:35 -08:00
Pasi Kallinen
ea52bacfce Unhide monster hiding under shrinking glob 2022-03-11 17:34:26 +02:00
nhmall
3fc39f273a missed band for windows Makefile.msc 2022-03-11 07:51:12 -05:00
nhmall
a16f17a029 header file ordering change
This is groundwork for some other changes.

Include integer.h ahead of global.h in config.h.
2022-03-11 07:33:28 -05:00
PatR
d4cec7d947 discovered objects within class for a and u
If any artifacts are discovered and menustyle traditional is in use,
the player can type `a to get the artifact subset of discovered items.
Likewise with `u to for unique items (the invocation tools and the
real Amulet).  For normal object classes, `<class> works for every
class, even when there aren't any discoveries for it (where you get
told "you haven't discovered any yet" if you pick such).  But `a
and `u were only allowed if at least one thing in the corresponding
category had been discovered.  Change to allow it even when none have
been.  The feedback of "you haven't discovered any {unique items,
artifacts} yet" was already in place.

Doesn't apply for picking the class via menu.  Menus don't have any
concept of "allowed as a response even though not listed as a choice".
2022-03-10 14:57:15 -08:00
nhmall
274984480c warning fix artifact.c
src/artifact.c(65): warning C4132: 'zero_artiexist': const object
should be initialized
2022-03-10 09:15:04 -05:00
nhmall
8551594ef8 Merge branch 'pr693' into NetHack-3.7 2022-03-10 09:10:05 -05:00
nhmall
3780bb7030 Merge branch 'fix-splev' of https://github.com/argrath/NetHack into pr693 2022-03-10 09:09:33 -05:00
PatR
2d977a5d48 keep track of how artifacts got created
Since the struct used for elements of artiexist[] has a lot of unused
bits, add some new ones to extend it to indicate how artifacts have
been created.  It had
| .exists (has been created) and
| .found (hero is aware that it has been created)
introduce
| .gift (divine gift),
| .wish (player wish),
| .named (naming elven weapon Sting or Orcrist)
| .viadip (made Excalibur by dipping long sword into fountain)
| .rndm (randomly created), and
| .bones (from bones file--how it got created in earlier game isn't
tracked).  The first four are implemented, fifth and sixth aren't.

Some of the feedback when receiving an artifact or spellbook has been
revised.

When artiexist[] was changed from an array of booleans to an array of
structs a couple of days ago, EDITLEVEL should have been incremented
but I overlooked that at the time.  This commit does so now.
2022-03-09 16:11:14 -08:00
SHIRAKATA Kentaro
467777539e add explicit cast on somexy() call
All other somexy() calls not using a return value have a cast.
2022-03-10 06:12:01 +09:00
nhw_cron
a0d3ab97a6 This is cron-daily v1-Feb-22-2022. 000files updated: Files 2022-03-09 12:47:00 -05:00
nhmall
fa4ad397dc some sys/windows build updates
Place built libraries for Lua and pdcurses into lib instead of the
more transient src/o subfolder.

Remove a kludge involving sys/windows/stub-pdcscrn.c.

Don't link pdcurses into NetHackW.exe (required a couple of stubs
since NetHack.exe and NetHackW.exe currently share object files
under the visual studio nmake build.

(Note: This may require a couple of follow-on minor modifications
to the mingw build. If so, the CI will flag that for us after this
commit)
2022-03-09 12:02:37 -05:00
PatR
e3490743e0 divine gift of spell knowledge
Remove the conduct-specific aspect of receiving spells as prayer boon.
Anyone now has a 25% chance of having the spell directly implanted
into their head, not just characters who have maintained illiterate
conduct.  It can now also restore a forgotten spell or refresh one
that is nearly forgotten.  It still tries to choose a spell which
isn't already known (new: or was known but has been forgotten) but if
it picks one that is known and doesn't need refreshing, a redundant
book will be given, same as the behavior in earlier versions.

The chance for receiving a blank spellbook is higher when that item
is undiscovered.  When given as a prayer reward, make it become
discovered even if hero doesn't read it so that it will be less likely
to be given again.  There's a 1% chance for that auto-discovery to
happen with other bestowed books.  Unlike blank boots, having the book
be discovered doesn't lessen their chance of being repeat gifts.

Minor bug fix:  for a spell implanted from scratch, the book remains
unknown.  That's ok; it's actually more interesting than discovering
a book you haven't seen yet.  But after acquiring and reading the book
you could get "you know <spell> quite well already" and the book would
stay undiscovered even though you were just told what spell it's for.
2022-03-09 07:06:37 -08:00
PatR
0effaf529a fix github issue #691 - non-lawful Angels \
get lawful artifacts

Reported by vultur-cadens, Angels can be given Sunsword or Demonbane
for starting equipment even when they aren't lawful so won't attempt
to use those.

This should fix it but it's a pain to test.

Closes #691
2022-03-07 15:12:12 -08:00
PatR
17469a62b9 fixes3-7-0 entry for PR #692, typos in dat/tribute
Pull request #692 from zomGreg.  One comment misspells "transcription"
and Death quote #29 coming from Reaper Man misspells "metaphor".  Fixed
by separate commits.

Closes #692
2022-03-07 14:38:26 -08:00
zomgreg
c5f435a2f2 corrected spelling of transcription 2022-03-07 14:30:36 -08:00
zomgreg
164c720378 corrected spelling of metaphor 2022-03-07 14:30:35 -08:00
PatR
809232914e more artifact tracking
Move some code that was used to decide whether to call distant_name
or doname into distant_name so that the places which were doing that
don't need to anymore and fewer places can care about whether an
artifact is being found.  There were two or three instances of
distant_name maybe being called, based on distance from hero, and
yesterday's artifact livelog change added two or three more and made
all of them override the distance limit for artifacts.

After that change to distant_name, make sure that conditional calls
to it become unconditional--just not displayed for the cases where
!flags.verbose had been excluding them.  That way distant_name can
decide whether an item is up close and arrange for xname to find it
if it as an artifact.

Also, implement an old TODO.  Wearing the Eyes of the Overworld
extends the distance that an item can be from the hero and still be
considered near anough to be seen "up close" when monsters pick it
up or drop it.  The explicit cases were using distu(x,y) <= 5, the
distance of a knight's jump.  Each quadrant around the hero is a 2x2
square with the diagonal corner chopped off.  The replacement code in
distant_name calculates a value of 6, which is functionally equivalent
since the next value of interest beyond 5 is 8.  Wearing the Eyes
(deduced by having Xray vision) extends that threshold an extra step
in addition to overriding blindness and seeing through walls:  15,
a 3x3 square in each quadrant, still with the far diagonal corner (16)
treated as out of range.
2022-03-07 13:21:17 -08:00
nhmall
cceef37c8b Windows nmake build fix 2022-03-07 07:35:35 -05:00
PatR
f65e652e2e livelog event for finding artifacts
Log artifacts found on the floor, or carried by monsters if hero sees
those monsters do something with them.  Shown to player via #chronicle
and included in dumplog.

For most cases, finding is based on having the artifact object be
formatted for display.  So walking across one won't notice it if pile
size inhibits showing items at its location, even if the artifact is
on top.  Taking stuff out of a container won't notice an artifact if a
subset of the contents chosen by class or BUCX filter doesn't include
it unless player has used ':' to look inside.  Seeing an artifact be
picked up by a monster (even if the monster itself is unseen) or being
dropped (possibly upon death) will find an artifact even if beyond the
normal range of having it be treated as seen up close.  Random treasure
drop items are excluded since they are placed directly on the floor
rather than going into a dying monster's inventory and then dropped
with its other stuff.
2022-03-07 03:33:01 -08:00
PatR
d37fa4138a found_artifact() groundwork
Lay groundwork for generating a log event when finding an artifact
on the floor or carried by a monster.  This part should not produce
any change in behavior.

Move g.artidisco[] and g.artiexist[] out of the instance_globals
struct back to local within artifact.c.  They are both initialized
at the start of a game (and only used in that file) so don't need
to be part of any bulk reinitialization if restart-instead-of-exit
ever gets implemented.

Convert artiexist[] from an array of booleans to an array of structs
containing a pair of bitfields.  artiexist[].exists is a direct
replacement for the boolean; artiexist[].found is new but not put to
any significant use yet.  If will be used to suppress the future
found-an-artifact event for cases where a more specific event (like
crowning or divine gift as #offer reward) is already produced.

Remove g.via_naming altogether and add an extra argument to oname()
calls to replace it.

Add an extra argument to artifact_exists() calls.
2022-03-07 02:06:55 -08:00
PatR
90fc7402b8 livelog event for crowning gift
There is an event for being crowned "Hand of Elebereth" and so forth
and an event for being given an artifact (any, not just the first) as
reward for #offer, but there wasn't one for the item usually given
along with being crowned.

Now there is.  It's not something that an observer (of the events
being logged) can deduce since sometimes an alternative is given
(wizard and monk) and other times nothing is given (artifact already
exists or lawful character isn't wielding non-artifact long sword).

I flagged the spellbook given to a wizard or a monk as
'divinegift | artifact | spoiler'.  'artifact' since even though it
isn't actually an artifact, it is standing in the place for one.  And
'spoiler', to hide from #chronicle, in case the hero doesn't know the
spellbook yet.
2022-03-05 15:14:18 -08:00
Pasi Kallinen
785463ba31 Can't swallow trapped monsters
Gulping can move the trapped monster to another location, while
still being marked as trapped.  I don't want to deal with this,
so just say purple worms can't swallow trapped monsters...
2022-03-05 18:30:36 +02:00
Pasi Kallinen
0dec6cad34 Illiterate and blank spellbooks from gods
Make gods avoid giving blank spellbooks as gifts, if you're
illiterate.  But if you do get a blank spellbook as a gift,
don't force-learn that non-existent spell.
2022-03-05 16:42:46 +02:00
Pasi Kallinen
71fe55eba8 Reset next_boulder when boulder was pushed 2022-03-05 16:36:26 +02:00
Pasi Kallinen
3834bb2ca0 Get out of moverock correctly, so we clear next_boulder 2022-03-05 15:46:16 +02:00
Pasi Kallinen
d2efae280a Fix monster trapped in nonexistent trap, pt 2
Monster hiding under an item on a location with a land mine,
a rolling boulder trap launches a boulder which blows up the mine,
and all the items scatter away. If the hider survived that, it
was still hiding.
2022-03-05 13:42:28 +02:00
Pasi Kallinen
4c1d1a0666 Fix monster trapped in nonexistent trap
A monster trapped in a bear trap on ice, exploding fiery monster
turned the ice into water turning the trap into object, the trapped
monster claimed to be still trapped in the nonexistent trap.
2022-03-05 11:29:06 +02:00
PatR
fa40cc9e3a ll_achieve_msg.llflag
Fix another type mismatch with the livelog code; make the flags field
in ll_achieve_msg match the one in gavelog_line.
2022-03-05 00:31:36 -08:00
Pasi Kallinen
fab1048f2f Fix segfault with uball
Drowning in a pool while punished and carrying the ball,
and the only available space to crawl back on dry land
has a magic trap, which unpunishes you.
2022-03-05 10:09:54 +02:00
PatR
74c4ee89cc EDITLEVEL increment
The change to report which item was acquired in the logged event for
Sokoban completion changed the context struct so changed the contents
of save files but neglected to update EDITLEVEL to reject old save
files.  Do so now.
2022-03-04 19:39:45 -08:00
PatR
5327412566 livelog tweaks, mostly sokoban
Demote "completed sokoban {1,2,3,4}" from major achievement to minor
at the request of hardfought.  OR on the 'dump' flag so that those
entries appear in dumplog.

Change "completed Sokoban" (for the whole branch) to "acquired the
Sokoban <prize object>" since that's what triggers the event and it
is possible to pass through the first level without completing that.
This event is still classified as a major achievement.  It has has
the 'spoiler' flag added to prevent #chronicle from showing that event
which now discloses the type of item the prize is.  (Note: suppression
of spoiler events is ignored in wizard mode.)

The "attained rank N" achievements are classified as minor for ranks
1..3 (gaining levels 3, 6, 10); OR the 'dump' flag for those.  [Rank 0
for levels 1 and 2 isn't an achievement and 4..8 for Xp levels 14, 18,
22, 26, and 30 are classified as 'major' achievements so don't need
that flag to make it into dumplog.]
2022-03-04 13:07:14 -08:00
Pasi Kallinen
7a1db1d0bd Fix couple cases of unhiding monsters
Hidden monster might be forced to move to a location where it
can't hide, perhaps because it's mostly surrounded by other monsters.

Hidden monster in a pit under items, getting hit by a rolling boulder,
the boulder will fill the pit burying the items, making the monster
unable to hide there.
2022-03-04 19:58:24 +02:00
Pasi Kallinen
7c2ffaa8c5 More trap sanity 2022-03-04 17:18:05 +02:00
Pasi Kallinen
62906e732e Trap sanity checking 2022-03-04 16:54:43 +02:00
PatR
80e7fbe8ec Guidebook tweaks (mainly DUMPLOG)
In the sysconf section, "the following options affect the score file:"
had some score options and then several non-score options.  Change to
"following four options" which reads a little strange but is precise.
Some other inserted line after those four options describing what
follows would read better but the stuff that follows is essentially
random based on the order that support for them was implemented.

Guidebook.mn:  the 'placeholders' for DUMPLOG file name substitution
had the description column line up but the proportional font for the
'%x' column looked bad.  Force fixed-width font there.  Also add some
indentation.  I wasn't sure whether '.in' should in inside .PS ... .PE
or outside.  The final result looks the same either way.

Guidebook.tex:  the new LIVELOG entry was accidentally placed after
the \elist line when it should come before that.  (Not tested.)
2022-03-04 06:51:40 -08:00
Pasi Kallinen
2cdd8f8dcb Fix checking monster moving into a trap return value
When I added a new trap return value, this was one place that
should've checked it.

This was really annoying to debug - it manifested as a temp level
file loading error, because a monster moved on to a level teleport
trap, which zeroes out (mx, my), then later in the monster movement,
a web spinner created a web at (0,0), and then hero leaving the level,
the traps were saved into the level file ... and when loaded, the code
thought a trap with x == 0 meant there were no more traps.
2022-03-04 16:42:15 +02:00
PatR
013bb8a112 mention sysconf entry LIVELOG in Guidebook
It's description is minimal since it isn't relevant to most people,
even ones playing on servers who have live-logging enabled.
2022-03-04 06:02:32 -08:00
Pasi Kallinen
ab8a18d1f0 Unhide monster when boulder rolls away 2022-03-04 10:48:38 +02:00
Pasi Kallinen
70795fa124 Prevent monster hurtling outside map 2022-03-03 22:24:17 +02:00
PatR
93928640c6 github issue #688 - end of game livelog event
Requested by k21971 (hardfought admin):  classify the gameover event
as something other than achievement so that live-logging can exclude
it in order to use the xlogfile end-of-game entry instead.

It had been classified as an achievement because that was the only
category being treated as 'major' so written to final dumplog.  Give
is a new classification 'dump' which is distinct from achievement
and intended to explicitly request that an event go into dumplog.
The gameover event is the only one in that category, at least for now.

Add a bunch of other classifications besides achievement and dump to
be treated as 'major' for dumplog.  The new list is
  wish, achieve, umonst (death of unique monster), divinegift,
  lifesave (via amulet, not explore-/wizard-mode decline to die),
  artifact, genocide, dump
and may still need further tuning.  Currently excluded are
  conduct (first violation of any conduct), killedpet, alignment
  (changed, either via helmet or conversion), minorac (minor
  achievement such as level gain or entering the mines), and spoiler
  (currently only applies to finding Mines' End luckstone which is
  also 'achieve' so will be in dumplog).

This doesn't remove the reference to unimplemented LLC_TURNS that is
mentioned in the template sysconf.

Closes #688
2022-03-03 07:47:56 -08:00
PatR
0326b77a18 raw_print() usage
Get rid of a couple of mis-formatted casts in lock_file().  raw_print()
is declared as void so casting its result to (void) was pointless.
Presumeably at one point it has used printf() or fprintf(stderr,...)
where the cast would have been useful to pacify 'lint'.
2022-03-03 05:38:34 -08:00
PatR
cf9e8da56c fix issue #689 - ?: warning
From copperwater:  a recently added use of <test> ? <if> : <else>
had a ptrdiff_t (signed) expression for <if> and a size_t (unsigned)
expression for <else> which triggered a sign-compare warning when
the two expressions are implicitly converted into the same type.

Use casts to convert both expressions to long rather that convert
the size_t half to ptrdiff_t or vice versa.  The final result gets
cast to int already.

Fixes #689
2022-03-03 05:27:05 -08:00
PatR
e6f1b5c0ce clear_bypasses() should operate on buried objects
Fix an object sanity check failure:  a buried object with its bypass
bit set.

clear_bypasses() was supposed to be clearing the bypass bit on every
object but was neglecting the buried objects list and the billed
objects list (and inventory of the mydogs list, but that is expected
to always be empty at the time when clear_bypasses() gets called).

We already had an issue with billed objects, revealed by the fuzzer
soon after sanity checking was extended to test bypass/in_use/nomerge
bits.  That one was fixed by clearing the bypass bit of specific
objects as they are being added to a shop bill.  This fix should make
that earlier one become obsolete, but isn't removing it.
2022-03-02 14:43:12 -08:00
PatR
43e2f7d0ae some livelog cleanup
The gamelog structure's type/flags field is 'long' but the
corresponding livelog event type field and the argument passed to
gamelog's logging were 'unsigned'.  They take the same values and
those values mean the same things so change them all to long.

The actual livelog logging assumed that time_t is a long number of
seconds, and was also using a boolean as an array index.  Perform
proper type conversions.

sysconf parsing used 'int' to hold strtol() value; change to long.
Also it was using raw_printf() instead of config_error_add() to
complain about any problems.  Clearly the livelog patch was not
updated to the current code base before being incorporated.
2022-03-02 13:09:42 -08:00
Pasi Kallinen
13d85abde5 Fix uninitialized variables
... as found by valgrind
2022-03-02 13:31:18 +02:00
PatR
23d09e6678 livelog: killing unique monsters revisited
Treat all kills of the Wizard and of any of the Riders as major events
for inclusion in dumplog.  For other unique monsters, that only happens
when they're killed for the first time.
2022-03-01 17:23:41 -08:00
PatR
730f73d1c8 livelog: killing unique monsters
Treat the first kill of any unique monster as a major event (for
inclusion in dumplog).  Revival and repeat kill is not major but
can still be seen during the game via the #chronicle command.

Show the minor event more often:  in addition to death #1 it was
being shown on death 5, 10, 50, 100, 150, 200, and 250.  Add 2, 3,
and 25 to that list.
2022-03-01 16:51:41 -08:00
PatR
f9192623e1 livelog: completing a sokoban level
Log a major event when the last hole or pit is plugged on a sokoban
level.

Event logging currently reports the got-sokoban-prize achievement as
completion of sokoban.  That's misleading but this doesn't change it.
2022-03-01 15:02:20 -08:00
PatR
33191ae4a2 eat.c formatting
This is just reformatting some relatively recently added code.

There's a lot of redundancy in eating conduct tracking and livelog
reporting of that, but this doesn't attempt to streamline it.  I may
try again some other time....
2022-03-01 14:11:58 -08:00