Commit Graph

12468 Commits

Author SHA1 Message Date
PatR
59beebcbcc get_rnd_text() selection distribution
While testing 'the("Capitalized Hallucinatory Monster")' I noticed that
some hallucinatory monsters showed up more often than others.  When
the random engravings, epitaphs, and bogus monsters were converted from
hard-coded arrays to data files accessed by random seek (3.6.0), they
became subject to the same distribution irregularites that rumors suffer
from.  The chance that an entry will be chosen depends upon the chance
that a random seek will hit somewhere in the line which precedes it, so
entries that follow long lines are more likely to be chosen and entries
that follow short lines are less likely.  We improved that for rumors
by having makedefs pad the shortest lines.  Distribution still isn't
uniform but is much better than it was (and could be further improved
with a longer padding length at the cost of making data files bigger so
possibly slower to access; both overall size and access speed mattered
back when floppy discs were supported but are probably irrelevant now).

Start doing the same thing for the newer files:  pad the shortest lines
to increase the chance that seek will find them.  The tradeoff is that
the data files become bigger.  Rumors, engravings, and epitaphs lines
are all at least 60 characters now; bogus monsters are at least 20.
These are the data file sizes I see (in bytes:  old, new; padding for
rumors was already in use so its size hasn't changed):
  bogusmon    4449    7211
  engrave     1326    2894
  epitaph    14159   24075
  rumors     49173   49173

The only place that padding is noticeable in-game is #wizrumorcheck.
2021-11-25 17:57:37 -08:00
PatR
3f3d1ad85c suppress warning
The compiler which suggested that 'aname' might be used without
being initialized is wrong, but this should pacify it.
2021-11-25 13:17:03 -08:00
PatR
c0228d1a74 shrinking globs vs shop bill
A shop-owned glob picked up by the hero was added to shop's bill
and if that shrank to nothing it moved from the unpaid portion to
used-up portion as intended.  But once there it retained obj->owt
of 0 and if 'sanity_check' was enabled, that triggered a warning
every move until finally paid for.  Both the 'Ix' list of used-up
items and itemized shop billing revealed a weight of 0 aum if
'wizweight' was enabled.

Keep track of the weight a glob had when it becomes unpaid, then
reset from 0 to that amount if it becomes used-up.  This overloads
the obj->oextra->omid field which is an unsigned int previously
only used for corpses.  Now for globs it is pre-bill obj->owt which
is also unsigned int.  I didn't add new oextra access functions for
it; it is only used in two places and existing omid ones suffice.
2021-11-25 00:47:45 -08:00
PatR
01b2bcff75 artifact fruit
Reported by entrez:  when fruit name is given the name of an artifact
that doesn't use "the" at the start of its name, messages about the
artifact could be altered.  Example was fruit=Excalibur causing usual
 |You are blased by Excalibur's power!
to unintentionally change to
 |You are blased by the Excalibur's power!
because of a false match during special handling for named fruit in
function the().

This fixes that, and also changes basic inventory formatting.  Former
 |f - an Excalibur
will now be
 |f - Excalibur
for a fruit that has been assigned that name.  When sort pack in On,
as it is by default, that will be listed under Comestibles rather than
under Weapons so really shouldn't fool anyone.  And
 |f - 2 Excaliburs
also breaks the illusion.

This formatting change only affects named fruits.  User assigned names
for object types or for individual objects behave the same as before.
2021-11-24 17:17:40 -08:00
PatR
341d1dff13 add a Harry Potter reference
Add three new hallucinatory monsters:  dementor, flying monkey, and
plaid unicorn.
2021-11-24 01:14:08 -08:00
PatR
f0f9701a37 attempting to polymorph into a unique monster
Noticed while testing revised "the" handling and trying to trigger
"you can't polymorph into [the] Oracle", if the character was human
it would turn into a new man or woman instead of having the unique
form be rejected.
2021-11-24 00:46:44 -08:00
PatR
b2d4b77d3a fix pull request #636 - the("Capitalized Monster")
Function the() wasn't supposed to be used for monsters because many
of the ones with capitalized names confuse it, but over time multiple
instances of the(mon_nam()) have crept into the code.  Instead of
ripping those out, modify the() to handle that situation better.

Pull request #636 by entrez dealt with this with one extra line of
code, but could end up scanning all the names in mons[] repeatedly
if the("Capitalized string") gets called a lot.  This uses a similar
one line fix but calls a whole new routine that scans through mons[]
once collecting all the relevant special case names.  As a bonus,
it does the same for hallucinatory monster names which name_to_mon()
couldn't handle.

Fixes #626
2021-11-24 00:24:56 -08:00
nhmall
dc4b98ebdc more windows keyhandling follow-up 2021-11-23 17:14:10 -05:00
nhmall
f9c66c9889 Merge branch 'pr637' into NetHack-3.7 2021-11-23 16:45:44 -05:00
nhmall
583969284f Merge branch 'fix-format-char' of https://github.com/argrath/NetHack into pr637 2021-11-23 16:45:17 -05:00
nhmall
93a4d8394b avoid zero for the windows key handling values 2021-11-23 16:43:42 -05:00
SHIRAKATA Kentaro
546377581a use %d for short
obj->otyp is short, so corresponding format string is %d.

(from Coverity Scan)
2021-11-24 06:30:00 +09:00
PatR
274290bcdf fixes entry for #635 - magical breathing w/ gills
Fixes entry for pull request by entrez.  If poly'd hero is wearing
an amulet of magical breathing, avoid gradually losing hit points
while out of water when in aquatic form.  You won't be able to put
on an amulet of magical breathing if already in aquatic form, but
you could have one carry over from being worn in some other form.

Implemented for monsters too but won't have any effect during play
for them because they never use that particular type of amulet.

Closes #635
2021-11-18 18:55:18 -08:00
Michael Meyer
90313d443d Magical breathing helps fish survive out of water
The hero in an aquatic polyform loses HP for time spent out of the
water; allow magical breathing to prevent this, just as it allows the
hero in her non-aquatic natural form to breathe underwater.

Also add a similar rule for monster fish-out-of-water HP loss, even
though currently monsters can't use amulets of magical breathing and
there's no non-breathing fish/eel -- just in case this changes at some
point.
2021-11-18 18:36:54 -08:00
PatR
d26537c4c9 fix github issue #608 - #untrap vs web
Reported by Vivit-R, the chance of freeing a monster from being
trapped in a web was very small and failure resulted in creation of
a new web at the hero's spot, eventually making it impossible to
attempt to #untrap the monster (if hero escaped the new web and moved
to another spot adjacent to trapped monster, eventually surrounding
it with webs).  [That's actually misleading.  Escaping the new web
but staying at the same spot lets the player try again; repeat as
needed....  But chance of failure still seemed way too high.]

This reduces the chance of failure from 29/30 to 6/7 and makes the
chance of spreading the web after failure be 1/3 instead of 100%.  It
also supplies missing feedback about the monster still being trapped
if the attempt to make a new web fails.

Closes #608
2021-11-18 18:30:19 -08:00
nhw_cron
937eef4b9b This is cron-daily v1-Jan-20-2020. guidebook updated: doc/Guidebook.txt 2021-11-16 16:42:37 -05:00
nhw_cron
346c4f7127 This is cron-daily v1-Jan-20-2020. files updated: Files 2021-11-16 16:42:25 -05:00
nhmall
0a97cc5c5e windows console changes - eliminate *key.dll
Incorporate the functionality of the loadable DLL's (nhraykey.dll,
nhdefkey.dll, and nh340key.dll) into the consoletty.c code and
remove the dll building
2021-11-16 15:27:33 -05:00
nhmall
6c8a03aa44 Merge branch 'pr633' into NetHack-3.7 2021-11-14 07:57:50 -05:00
nhmall
a2ac49ce03 Merge branch 'patch-1' of https://github.com/melkersona/NetHack into pr633 2021-11-14 07:57:29 -05:00
PatR
a94650159e shrink_glob nitpicking
For a glob in a container carried by the hero, shrinking away to
nothing would have indirectly updated the container's weight when
obj_extract_self() was called, then the 'old_top_owt' value would
never be different from current topcontnr->owt.  That only matters
for the shrink-but-not-gone case and could only happen for the gone
case so didn't result in anything noticeably wrong.  But fix it to
match the comment about weight not being adjusted yet.
2021-11-13 23:45:47 -08:00
nhmall
dad923feba ignore visual studio files in util 2021-11-13 12:36:40 -05:00
nhmall
876e36d18c cut and paste error 2021-11-13 10:42:25 -05:00
nhmall
f19112e6b1 update Install.windows for vs 2022 compiler
Include visual studio 2022 in the list of compilers tested for build
- nmake Makefile.msc tested
2021-11-13 10:39:00 -05:00
nhmall
8063ad94d7 vs 2022 is current version as of November 8, 2021 2021-11-13 10:32:33 -05:00
PatR
05a843826d shrink_glob while away from level
If the hero left a level that had globs on the floor or in floor
containers or being carried by monsters and stayed away for a
while, returning to the level only shrunk them by one unit of
weight.  Account for all the time away.  The complexity of this
has steadily grown; I hope its peak has been reached.
2021-11-12 23:05:55 -08:00
PatR
41ede41b8b shrink_glob feedback
When carrying a glob, possibly inside a container, give shrink
feedback more often (twice in the ~500 turn cycle to shrink from
20aum to 0aum rather than just once).
2021-11-11 16:16:13 -08:00
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