Commit Graph

12441 Commits

Author SHA1 Message Date
Alva Melkerson
dc7dff1d7e Update NetHackW.c
Updated some comments that referred to an old file name
2021-11-11 17:35:11 -06:00
PatR
90aded3648 weight of gold
I had wizweight On when testing glob changes and noticed
|Slasher drops a gold piece (0 aum).

Coins are supposed to weigh 1/100 of a unit, and the calculation
rounds rather than simply truncates any fraction, but that still
yielded 0 for quantities of 1..49.  Force any non-zero stack of
gold to weigh at least 1 unit.

Also, add a check for attempting to weigh a quantity 0 or less
(of anything, not only for gold) just in case.
2021-11-07 13:27:44 -08:00
nhmall
e8acc185ad proceed further into dochat() when deaf 2021-11-07 09:19:03 -05:00
PatR
e37ab5f0f9 decaying glob tweaks
Don't hardcode the weight (20) of an unaugmented glob, use
objects[].oc_weight (also 20) instead.

When a glob inside a container has decayed all the way to nothing
(weight 0), take it out before updating the container's weight.
Otherwise weight() would use objects[].oc_weight instead of 0 for
that glob.
2021-11-07 02:00:46 -08:00
PatR
e2ca016484 decaying globs of {ooze,pudding,slime}
Globs never rotted away but did become tainted after a relatively
short while, which seemed like a contradiction.  Change them to never
be tainted but shrink by 1 unit of weight approximately every 25
turns.  An ordinary glob (one that hasn't combined with any others)
starts out weighing 20 units, so it takes about 500 turns to vanish.
That's roughly twice as long as a corpse takes to rot away.

Shrinking globs give feedback when in hero's invent or in a container
in hero's inventory, but rarely (when going from an exact multiple
of 20 weight units; that is, from integral number of N globs to
N-1 + 19/20, or if weight reduction triggers an encumbrance change).
When a glob goes away completely, there is feedback for those two
circumstances and also for seeing the glob vanish from the floor.

I haven't touched how much nutrition eating a glob confers.  I have
changed formatting of glob names to use "small", "medium", "large",
"very large" instead of "small", [no adjective], "large", &c.  You
still need to have at least five globs coalesced together for the
adjective to become "medium", same amount as before.

I don't think EDITLEVEL needs to be modified but have incremented it
anyway to play things safe.
2021-11-06 18:24:36 -07:00
nhmall
aa8fd3ab3c detect visual studio 2019 16.11.5 after build test 2021-11-03 10:47:01 -04:00
PatR
1f31f1ff81 tribute update: Night Watch and The Wee Free Men
Add a page citation to passage #1 of Night Watch, and add five new
passages, briging the total to 12.

Add four new passages to The Wee Free Men, bringing the total to 13.
2021-10-30 19:16:35 -07:00
nhmall
0c80ef0526 more imp 2021-10-29 13:39:27 -04:00
nhmall
710e3bae06 visual studio 2022 preview 7 2021-10-28 22:40:46 -04:00
nhmall
e0e8fced7c bad cast making sp_lev chameleon light source
Closes #625
2021-10-28 18:19:07 -04:00
nhmall
483f398570 Merge branch 'lightsource-mon-ptr' of https://github.com/entrez/NetHack into pr625 2021-10-28 18:17:52 -04:00
Michael Meyer
9e94226235 Fix: bad cast making sp_lev chameleon light source
Giving new_light_source '(genericptr_t) mtmp' leads to the light
source's id.a_monst being set to 'mtmp->nmon' rather than 'mtmp',
since that's what is stored in the initial byte of the monst struct.
When mtmp->nmon == 0x0 this can cause a segfault in do_light_sources.
2021-10-28 18:00:27 -04:00
nhmall
f539f97346 tile fix
commit b88e17d04ec2bb37e2c12842e9f4c4a9 changed the order of some
objects but neglected to update the win/share/objects.txt tiles
to match.

In fairness, the error-alerting was broken at the time but has
since been resolved.

warning: for tile 46 (numbered 46) of objects.txt,
found 'lance' while expecting 'angled poleaxe / halberd'
warning: for tile 47 (numbered 47) of objects.txt,
found 'angled poleaxe / halberd' while expecting 'long poleaxe /
bardiche'
warning: for tile 48 (numbered 48) of objects.txt,
found 'long poleaxe / bardiche' while expecting 'pole cleaver / voulge'
warning: for tile 49 (numbered 49) of objects.txt,
found 'pole cleaver / voulge' while expecting 'pole sickle / fauchard'
warning: for tile 50 (numbered 50) of objects.txt,
found 'broad pick / dwarvish mattock' while expecting 'pruning hook /
guisarme'
warning: for tile 51 (numbered 51) of objects.txt,
found 'pole sickle / fauchard' while expecting 'hooked polearm /
bill-guisarme'
warning: for tile 52 (numbered 52) of objects.txt,
found 'pruning hook / guisarme' while expecting 'pronged polearm /
lucern hammer'
warning: for tile 53 (numbered 53) of objects.txt,
found 'hooked polearm / bill-guisarme' while expecting 'beaked polearm /
bec de corbin'
warning: for tile 54 (numbered 54) of objects.txt,
found 'pronged polearm / lucern hammer' while expecting 'broad pick /
dwarvish mattock
warning: for tile 55 (numbered 55) of objects.txt,
found 'beaked polearm / bec de corbin' while expecting 'lance'
2021-10-28 16:22:26 -04:00
nhmall
b6250b412d fix error checking during tile processing
noticed following a patch last night
2021-10-28 16:08:59 -04:00
PatR
49b2ea1b89 "someone"/"something" instead of "it"
I thought there were more places that checked for "it" and substituted
"someone" or "something".  Perhaps there are and I'm just not finding
them now.  Anyway, this extends x_monnam() and adds some_mon_nam() and
Some_Monnam() to do that during monster name formatting instead of
having various bits of code try fix it up after the fact.  The fixups
could be fooled by monsters given the name "it" or "It"; x_monnam()
won't be.
2021-10-28 12:55:32 -07:00
PatR
3a0f1bb1aa refine "next boulder"
Guard against any other places besides minimal_xname() that set up a
fake object without being aware that for boulders the corpsenm field
should be 0 rather than NON_PM.  If that field is unexpectedly -1,
xname() will format it as ordinary "boulder" rather than producing
special "next boulder".  An explict value of 1 is now required for
the latter.
2021-10-28 11:10:40 -07:00
PatR
d736cbd751 fix github issue #603 - guarding prize items
Reported by Vivit-R with comments by several others.  The prize item
in one of the closets off the Sokoban treasure zoo is sometimes
missing, most likely picked up by an elf who won't be dissuaded by
the presence of engraved Elbereth or a scroll of scare monster.

This fix prevents monsters from targetting the mines' and sokoban's
prizes for pickup (or for eating).  Once the hero picks either of the
prizes up, they stop being prizes and will be ordinary monster fodder
if dropped/stolen/stashed.

One of the comments by copperwater suggested this approach as a
possible way to fix things.  I had already implemented it from scratch
before noticing that.  It handles the usual monster behavior toward
items, but there could easily be some unusual cases still susceptible
to taking the prize before the hero gets to it.  Those are the breaks.

Fixes #603
2021-10-28 01:05:18 -07:00
PatR
5b91f81533 more baalz - digging in front of the "eyes"
like the leg hackery, if the baalz level gets flipped during creation
the fixup that modifies the locations in front of the eyes to allow
digging needs to deal with that too.
2021-10-27 16:21:03 -07:00
PatR
a5d3e03b3e fixes entry for pull request #598 - baalz level
If the baalz level got transposed during creation, the fixup for
a decorative portion of the map didn't work properly.  Monsters
eligible to be created at pool locations could end up trapped in
a couple of inaccessible locations.

[To be fair, the baalz hackery predates level flipping....]

Closes #598
2021-10-27 15:52:01 -07:00
Michael Meyer
00b3b955af Fix: baalz_fixup didn't account for level rotation
Because some spots in the fly's 'legs' on the Baalzebub lair level are
specified as pools in the level file, then later converted to walls in a
post-generation fixup routine, monsters can be generated on those spots
and then left walled up and inaccessible, Cask of Amontillado style.
For the love of God, makemon-tresor!

Some code already existed to relocate these monsters after generating
the level, but it depends on misorientated 'leg segments' being fixed up
in a particular way.  That wasn't being triggered because it didn't
account for the possible rotation of the level; as a result, the
monsters in the leg segments wouldn't be relocated, and the leg segments
themselves would continue to have the wrong orientation.

Account for possible level rotation so that the monsters are relocated
properly (and the leg segments are 'fixed').
2021-10-27 15:48:26 -07:00
PatR
da859c5eb8 fix github issue #623 - soldiers and mattocks
Reported by eakaye.  Selection of equipment when creating a soldier
or watchperson can pick a polearm, but random selection among those
had a chance to choose dwarvish mattock which doesn't use polearms
skill and isn't appropriate for a human soldier or watchperson.
Not mentioned, but lance was in the same boat.

Change the selection to only pick something which uses polearms
skill, then make that moot by moving lance and dwarvish mattock out
of the midst of the polearms so that they're no longer candidates
for special case rejection.

A couple of other things which might have had a similar issue were
already ok.  Giving a polearm when creating a troll selects between
a few choices rather than among all the polearms.  And wishing for
"polearm" only considers items which use polearms skill.

While changing objects.h to reorder the two non-polearms, I removed
a bunch of tabs that were present in the scroll definitions.

EDITLEVEL is incremented due to objects[] reordering, so existing
save and bones files will be invalidated.

Fixes #623
2021-10-27 15:36:32 -07:00
PatR
6b882609ac commit message for pull request #599 - artifacts
Explicitly un-create a randomly generated artifact if it gets
rejected (too big to include as a treasure drop with a small corpse)
so that it remains eligible for creation later.  And when generating
random contents for a new container, explicitly avoid artifacts
(which were already implicitly avoided).

Closes #599
2021-10-26 12:09:36 -07:00
Michael Meyer
2abe08d0bf Formally block artifacts as random box contents
Another (latent) case of an artifact possibly being generated and
immediately deleted: part of the process of a mimic disguising itself as
an item involves generating a random object, then deleting it.  If this
item is a box or sack, it will generate with random contents, which will
be deleted along with the container. If artifacts are allowed as random
box contents, this can silently remove an artifact from being available
in the game.

This is effectively blocked already, since none of the artifacts
eligible for random generation are items from classes marked as valid
box contents (see boxiprobs[] in mkobj.c).  Nonetheless, formally
preventing artifacts from generating as box contents will guarantee this
issue won't crop up if a randomly generated artifact tool, ring, etc, is
added in the future.
2021-10-26 11:55:00 -07:00
Michael Meyer
b242fbce5a Fix: artifacts silently removed from the game
Death drops will generate a random item, which may be an artifact.
After the object is created, some rules are applied to check whether its
size matches the monster that dropped it; if it fails these checks,
the item is deleted.  aosdict recently pointed out that if the death
drop was an artifact, this would permanently remove it from the game.

Use artifact_exist(..., FALSE) in various cases where potential
artifact objects are created, then immediately removed.  This will
prevent artifacts from being removed from play by marking the artifact
as available to create again.
2021-10-26 11:54:59 -07:00
PatR
cffeecee26 fix #K3474 - "you detect it where <foo> was"
A vampire in bat form was seen via infravision or possibly telepathy,
then when it changed into fog cloud form the feedback was
|You now detect it where the vampire bat was.
The message substitutes "detect" for "see" when the new form can't
be seen and the monster name formatting yields "it" for that case.

Give a vanish message instead since that is effectively what happens.
2021-10-26 03:11:55 -07:00
PatR
b4908f6928 fix pull request #621 - potential divide by 0
The pull request by argrath changes weight_cap() to never return a
value less than 1 because try_lift() divides by that return value
and a 0 would trigger a crash.  The code involved is used when
attempting to pull a monster out of a pit via #untrap.

I'm fairly sure that weight_cap() can never produce a value that's
less than 1 already, but have put in a variation of the PR's fix.
I've also implemented a different fix that removes the division
from try_lift().  The original code seems to have gone out of its
way to avoid calculating inv_weight() twice, but doing the latter
(for the once in a hundred games where it might happen) greatly
simplifies things by removing details of carrying capacity.

Fixes #621
2021-10-25 14:51:26 -07:00
nhmall
27fcf8999f re-do the wounded legs fix 2021-10-24 21:41:49 -04:00
nhmall
a7eca53f53 wounded legs check in insight.c
close #620
2021-10-24 21:34:05 -04:00
nhmall
1d405c511d more comment accuracy 2021-10-24 18:04:57 -04:00
PatR
6edadc4884 fix github issue #614 - applying polearm at doors
Reported by G7Nation; attacking walls and such with a polearm just
gave lackluster "you miss; nobody's there" feedback.

Make applying a polearm at some non-monster locations give feedback
similar to using 'F'orcefight with melee weapons.  Was
|You miss; there is no one there to hit.
now
|You uselessly attack the closed door.

Also, extend the supported locations to include dungeon furniture.
Was
|You attack thin air. ('F')
now
|You harmlessly attack the throne. ('F')
|You uselessly attack the throne. ('a')

This doesn't address #613:  attempting to hit non-visible locations
with an applied polearm.

Closes #614
2021-10-24 10:06:30 -07:00
nhmall
0ea7e7aef4 comment accuracy
The function involved is a different one now, but the comment had not
been updated.
2021-10-24 09:31:31 -04:00
PatR
b97df3e9e4 closed door descriptions 2021-10-23 17:33:39 -07:00
nhmall
c6f5b41e51 move compiler override note above the autodetection 2021-10-23 12:30:02 -04:00
PatR
37e63f6829 breaking wielded fragile item against iron bars
Reported by entrez, wielding something fragile (potion of acid
perhaps), and using F to smash it against iron bars called breaktest()
directly, then a second time indirectly through hero_breaks() via
hit_bars().  There is a random chance to resist breaking (99% for
artifacts, 1% for other items) so breaktest() might say that something
will break on the first call and that it will not break on the second
call, or vice versa.  That could remove uwep from inventory then leave
it in limbo without destroying it, or destroy uwep without removing it
from inventory first triggering impossible "obfree: deleting worn obj".
2021-10-22 19:11:51 -07:00
nhmall
56f79dd207 Merge branch 'pr617' into NetHack-3.7 2021-10-22 15:24:37 -04:00
nhmall
df0ed882a8 use %lu in format string in timer_sanity_check()
closes #617
2021-10-22 15:23:07 -04:00
nhmall
7601e5709f Merge branch 'fix-format-char' of https://github.com/argrath/NetHack into pr617 2021-10-22 15:19:25 -04:00
nhmall
b44b5e35a8 re-enable -Wunreachable-code under clang
whitelist the valid cases showing up

If an earlier version of clang is showing more cases (particularly
if they don't make sense), the re-enabling of the warning in
sys/unix/hints/include/compiler.2020 can be made clang-version
specific instead. I had no way to test earlier versions.
2021-10-22 12:27:10 -04:00
SHIRAKATA Kentaro
bfd79f5c9d use %lu for unsigned long
`curr->tid` is unsigned long, so use `%lu`.
2021-10-23 01:07:40 +09:00
PatR
0617410ff3 feedback for monster jumping onto polymorph trap
Give feedback for "<Mon> jumps onto a polymorph trap" in more
circumstances.  It used to give the message if the monster could
be seen, and it would map the trap if the monster's location could
be seen.  That led to some confusion when an infra-visible monster
was at a spot in the dark so the trap was accurately described but
didn't get mapped.

Map the trap if either the monster's or the trap's location can be
seen.  If it isn't already known and isn't becoming known (the
infravision case), say "hidden trap" instead of "polymorph trap"
in the message.  Give the "jumps onto trap" message if either the
monster can be seen or the trap's spot can be seen.  When monster
can't be seen, it would normally be described as "It"; switch to
"Someone" (when humanoid) or "Something" (non-humanoid) instead.

Minor unrelated bit:  the use-container action was between the 2nd
and 3rd polymorph cases.  Move it, after the third one.
2021-10-21 12:07:19 -07:00
nhmall
6c114af629 Merge branch 'pr616' into NetHack-3.7 2021-10-21 13:36:50 -04:00
nhmall
090f1fb029 check for NULL Lua_State prior to lua_close()
fixes #616
2021-10-21 13:34:21 -04:00
nhmall
182d1837fa Merge branch 'guard-luaclose' of https://github.com/argrath/NetHack into pr616 2021-10-21 13:30:42 -04:00
nhmall
16443f0db9 gcc 11 warning
../win/tty/wintty.c:4043:39: warning: argument 2 of type ‘int[3]’ with mismatched bound [-Warray-parameter=]
 4043 | check_fields(boolean forcefields, int sz[3])
      |                                   ~~~~^~~~~
../win/tty/wintty.c:221:38: note: previously declared as ‘int *’
  221 | static boolean check_fields(boolean, int *);
      |                                      ^~~~~
2021-10-21 13:24:38 -04:00
SHIRAKATA Kentaro
62e6b5a336 guard lua_close()
nhl_done() can be called with L == NULL.
So lua_close() should be guarded.
2021-10-22 02:13:17 +09:00
nhmall
9b78ff740d clang 12 warning
makedefs.c:1560:5: warning: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Wstring-concatenation]
    "  ",
    ^
makedefs.c:1559:5: note: place parentheses around the string literal to silence warning
    "currently available will not suffice for proving that P != NP or        "
    ^
1 warning generated.
2021-10-21 11:53:01 -04:00
nhmall
559a9cde21 fixes37.0 updates for pr612, 613, 615
closes #612
closes #613
closes #615
2021-10-21 08:48:23 -04:00
SHIRAKATA Kentaro
1f651f8f00 initialize attknum
`attknum` is declared without initialization, and is used on
find_roll_to_hit().  This leads unexpected result.
2021-10-21 08:48:23 -04:00
SHIRAKATA Kentaro
0f36d7ac6e revert MAX_RADIUS change
On 59818fb, MAX_RADIUS was changed from 15 to 16 to intend to support
"radius 0".  But MAX_RADIUS doesn't means the range but outer bound of
the radius table, so it should not be changed, and this change led
possible out-of-bound access on view_from() and do_clear_area() in
vision.c.

This commit reverts the change and avoids the problem.
2021-10-21 08:48:23 -04:00
SHIRAKATA Kentaro
ed543d7832 fix pointer precedence 2021-10-21 17:41:13 +09:00