Commit Graph

205 Commits

Author SHA1 Message Date
Pasi Kallinen
4729062846 Make Death revive faster
Death will revive faster than the other riders.
Make all the riders revive after 67 turns, instead of 500.
There was practically a zero chance a rider would revive at 500,
so keep it somewhat sensible.
2020-12-13 12:28:45 +02:00
Pasi Kallinen
d79b5388ce Remove dealloc_obj b&c sanity checking 2020-12-01 22:18:48 +02:00
PatR
2db51cf8bd fix #K3016 - kicking a bag of gold in a shop
Kicking a container that had gold in it took the gold amount
away from hero's credit or added to hero's debt, then didn't
give a refund if the container and its gold landed within the
shop.  Throwing behaved likewise, just less verbosely.

The problem is caused by addtobill() treating gold specially
and then subfrombill() not being able to perform a reverse
operation.  Actually, it may be possible for subfrombill() to
do that, but verifying all its uses is too much work.  This
moves the gold handling for drop+selling into its own routine
and adds calls to that for the throwing and kicking refunds.
The other calls to subfrombill() outside of shk.c appear to be
ok as-is.  (The calls inside that file are the ones that still
need evaluation if the gold handling is to move to there.)

bill_dummy_object() now uses the same o_id assignment for its
dummy object as split_object() does for its new partial stack.
I don't know whether the old code led to any price glitches.
2020-11-25 14:33:14 -08:00
Pasi Kallinen
229930e505 Fixes and sanity checks for monster undetected and trapped states
Adds sanity checks for mtrapped and mundetected states.

Fixes cases where those were left in wrong state.

1. Trapped monster (eg. a nymph) teleported out of a trap
2. Monster was hiding under ball or chain, which then got removed
3. While restoring a level, a zombie corpse revived while monster
   was hiding under it
4. A general case where the only object was deleted off floor and
   a monster was hiding under it

Monsters hiding under ball or chain will now get revealed when
the b or c are moved.
2020-11-24 19:37:43 +02:00
Pasi Kallinen
6ec55a3624 Rework stairs structure
Use a linked list to store stair and ladder information, instead
of having fixed up/down stairs/ladders and a single "special" (branch)
stair.

Breaks saves and bones.

Adds information to migrating objects and monsters for the dungeon
and level where they are migrating from.
2020-11-13 20:27:17 +02:00
Pasi Kallinen
aeb0ea65e3 Mild Zombie Apocalypse
When a zombie (or lich) kills a monster in melee without a weapon,
the monster can rise few turns later as a zombie.

The only creatures that can be zombified are ones that actually have
a zombie counterpart monster. A zombie cannot turn a jackal into
a zombie, for instance. But it could turn a shopkeeper into a human
zombie, or a dwarf king into a dwarf zombie.

Zombies will fight with monsters that can be turned into zombies.

Originally this was a SliceHack feature, but this is based on xNetHack
version of it, with some modifications.
2020-10-23 19:47:10 +03:00
nhmall
48fa4fa5dd more warning bits 2020-10-10 16:28:17 -04:00
nhmall
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
nhmall
6357505948 makemon and mkobj follow-up initialization bit 2020-07-31 10:00:14 -04:00
nhmall
8b2750ab60 lower the code upkeep for mextra and oextra pointer additions 2020-07-31 09:42:17 -04:00
PatR
c64049306d candy bar wrappers
Adopt the suggestion that candy bar stacks which get split should
keep the same wrapper text for both halves of the stack.  The patch
stuck with using obj->o_id to manage the wrapper which prior to the
patch wasn't a factor in merging and splitting.  Switch to obj->spe
instead, comparable to tin varities, so mergability is already
taken care of.

End of game disclosure tacks on T-shirt text to formatted items.
Do the same for candy bar wrappers.
2020-07-30 19:25:57 -07:00
PatR
fae75f5930 troll corpse revival
Prevent corpses left by cancelled trolls from reviving.  Their
revival is an innate ability but is clearly a magical one, so make
that be subject to cancellation magic.

Change existing corpses that are scheduled to revive to rot instead
if they get cancelled as objects.  Rider corpses are excluded.

Uncancel an ice troll whose corpse is put into an ice box.

Commit e9f53ab7f6 at the end of May
to fix corpses taken out of ice boxes by monsters changed removing
corpses from ice boxes by anybody to always give them rot-away
timers, even for trolls.  Make an exception for ice troll corpses:
give those revive timers instead.
2020-07-26 11:13:43 -07:00
PatR
7d7b98f0ae mhpmax of life-drained monsters
The report about problems after stone-to-flesh on a petrified
long worm included stethoscope feedback of 0(-1) hit points, after
life-draining.  I was unable to reproduce a maximum hp of -1 and hope
that it was a side-effect of the [already fixed] stale mon->wormno
value used when resurrecting the long worm.  Anyway, this changes
life-draining to never take mon->hpmax below mon->m_lev + 1 (the +1
is needed to cope with m_lev==0 monsters).  The same limit is also
applied to monster life-saving but more to avoid replicating the
arbitrary minimum of 10 (four instances) then because it might be
less than m_lev+1 somehow.

Sanity checking now tests whether a monster's max HP is less than
its level + 1 so if there are ways other than life-drain attacks for
it to drop that low, the fuzzer will choke.  The new check also tests
whether a monster's current HP is greater than max HP.

Polymophred hero killing a golem or vortex by vampire bite reported
"<Mon> dies."  Give an alternate message since those aren't alive.
2020-06-27 18:15:19 -07:00
PatR
bb566e8a04 fix stone-to-flesh on petrified long worm
montraits() didn't have any handling for long worm tails, makemon()
didn't have any provision for creating a long worm without a tail,
replmon() uses place_wegs() to put tail segments on the map when
replacing a dummy new monster with the mtraits one but place_wsegs()
wasn't updating the head segment since it isn't put on the map.

That turned out to be key because there is always an extra segment
co-located with the monster and when its coordinates were wrong,
worm_known() gave bad results for visibility checking.  The
statue-goes-away message was the one for not being able to see the
monster that it just animated into, even though 'w' appeared at the
spot.  It took quite a while to track down what was going on there.

Sanity checking for worms has been updated and could conceivably
start triggering complaints about things that it used ignore.
2020-06-03 03:00:13 -07:00
PatR
e9f53ab7f6 fix #K1139 - corpse removed from ice box by monst
Rot and revive timers are turned off when a corpse gets put inside
an ice box.  They get turned back on when taken out of the ice box
by the hero but were being left off if taken out by a monster.
That resulted in corpses of arbitrary type behaving like lizard
corpses and never rotting away.

This fixes that.  It also changes troll corpse behavior.  Once put
in an ice box, a troll corpse will not get a new revive timer when
taken out, just an ordinary rot timer.
2020-05-30 13:33:16 -07:00
PatR
e63fed627c obj->oextra->{omid,olong}
Change obj->oextra->omid from a usually-Null pointer field in
oextra to a simple 'unsigned' that doesn't need any allocation
beyond obj->oextra itself.  Value 0 means that it is not in use;
it is used to hold a monst.m_id and those are always non-zero.

Delete unused obj->oextra->olong.  'olong' used to be the last
field in struct obj, put there to force alignment of anything
which followed it back when obj structures were over-allocated to
append extra information.  It had a comment about being used for
temporary gold but whatever that was, temporary gold was gone long
before obj->oextra got introduced.

Bump EDITLEVEL since this invalidates existing 3.7 save files.

Remove a bunch of tabs from obj.h and save.c.
2020-04-24 09:29:52 -07:00
PatR
28fb6fc67b crystal ball enhancements
Allow crystal ball to search for furniture (stairs and ladders,
altar, throne, sink, fountain) as well as for a class or objects
or of monsters or all traps.  Giving any of '<','>','_','\','#',
or '{' will find all of those rather than just the individual type
specified.  Because of the default character conflict, '_' can no
longer be used to find chains; looking for altars is more useful.

The chance of getting the cursed effect due to failing a saving
throw against intelligence when the ball isn't actually cursed has
been reduced.  If it is the hero's own quest artifact, it will
happen if rnd(8) is greater than Int, so Int of 8 or more will
never yield that effect.  Otherwise if it is blessed, rnd(16) is
used so 16 or better Int means it can't act like it is cursed.
When uncursed and not hero's quest artifact, the old rnd(20) > Int
test is still used.

Crystal balls now start with 3..7 charges rather than 1..5, and
blessed charging sets the amount to 7 charges rather than 6 and
also blesses the ball.  Recharing with uncursed scroll of charging
is slightly better (adds 1..2 charges instead of always just 1,
caps the amount at 7 rather than 5) and uncurses the ball.  Cursed
scroll strips off all charges even if the ball is blessed and also
curses the ball so is harsher than before.

Crystal balls now cancel to -1 instead of 0, like wands, and using
one effect will destroy it, like zapping cancelled wands.

Also a minor tweak to the initial charges for can of grease (5..25
instead of 1..25) and horn of plenty and bag of tricks (both now
3..20 instead of 1..20).
2020-04-22 01:14:09 -07:00
PatR
3eed500886 fix #K669 - 'nasty' monster summoning
Report complained about multiple Archons causing his character to
be swarmed by monsters on the Plane of Fire.  I don't think that
the behavior has changed significantly from how it worked in 3.4.3.
Nobody can summon an Archon directly because they're excluded from
the nasties[] list.  But whenever summoning picks a genocided
'nasty', the result gets replaced by random monster of appropriate
difficulty for the level (which could be an Archon for a high level
character in the endgame).  [Note that that won't pick an Archon
in Gehennom or at arch-lich outside of there because the random
monster creation honors the only-in-hell and never-in-hell flags;
picking from the nasties[] list doesn't.]

This prevents that for any creature (except arch-lich or the Wizard)
casting the summon nasties spell.  If a replacement creature is a
spellcaster it now has to have lower difficulty than the summoner.
If not, it will be discarded even though its difficulty is classified
as appropriate.  So to summon an Archon, the summoner has to have
higher difficulty than an Archon; arch-lich and the Wizard are the
only ones meeting that criterium.  When summoner is an arch-lich,
it can't summon another arch-lich (since that wouldn't have lower
difficulty than the summoner) and can summon (via replacement for
genocided type, and only if outside of Gehennom) at most one Archon.
When summoner is the Wizard, he could summon an arch-lich (when in
Gehennom; demoted to master lich elsewhere--see below) or an Archon
(outside Gehennom only), but at most one per summoning.

For post-Wizard harassment, which effectively has infinite
difficulty level, it could still happen.  However, each instance of
harassment is only allowed to create at most one Archon or arch-lich
now, so chain summoning should be lessoned.  Also if it tries to
pick an arch-lich when outside of Gehennom it will switch to master
lich instead (which won't be allowed to summon an Archon or an arch-
lich or even another master lich).

(The monmove.c bit is unrelated, just some comment formatting that
I had laying around that got mixed in.)
2020-03-27 19:05:52 -07:00
Pasi Kallinen
408321b4f7 Use TAINT_AGE for old corpses instead of hardcoded value 2020-03-16 11:28:09 +02:00
PatR
3409546876 more random novels
Give statues 'real' spellbooks only.

Provide mkobj() a way to accomplish that instead of resorting to
mksobj(rnd_class()).
2020-01-12 22:02:36 -08:00
PatR
caaf1b375a randonly occurring Discworld novels
Give 'novel' a 1 in 1000 chance of being created in place of each
random spellbook (except for hero's initial inventory and NPC
priests' monster inventory and divine reward for prayer--those all
force regular spellbooks; statue contents aren't among the
exceptions--those books can now be novels).  Shop inventory (where
first book or scroll shop created is guaranteed one novel) hasn't
been touched.  If there is any other special spellbook handling
somewhere, I've overlooked it.
2020-01-12 11:00:38 -08:00
Pasi Kallinen
7e07cef197 Lua struct obj improvements
If the core frees the obj struct referred by lua, don't free it,
just mark it as OBJ_LUAFREE - lua will free it in gc once all
the references to it are gone.
2020-01-01 13:25:59 +02:00
Pasi Kallinen
6d8d3a9557 Add lua object references
Whenever a lua script references a core struct obj, increment a counter
in the obj struct. Core code will not free the obj, if there are any
lua references pointing to it, just makes it free-floating.
When lua script ends, the lua gc will free the free-floating objects.

Also exposes u.inventory to lua.

Breaks save and bones compat.
2019-12-26 19:15:24 +02:00
nhmall
75d22a2dbf separate MAIL functionality from MAIL-related structure inclusion
With 3.7+ aspirations of improving savefile interoperability between 32-bit
and 64-bit builds, as well as between platforms, it is better to not have
the underlying struct/array content be conditional.

This splits off some of the MAIL code into MAIL_STRUCTURES code. In theory,
since MAIL_STRUCTURES is unconditionally included, the macro could
just go away and leave that code unconditional, but this commit doesn't
go that far.
2019-11-09 16:19:05 -05:00
nhmall
8df0a63938 Merge branch 'NetHack-3.6' 2019-10-20 09:51:35 -04:00
PatR
bf7e955645 mimicking slime molds
Mimic-as-slime_mold needs to keep track of the fruit index the same
way that mimic-as-corpse keeps track of corpse's monster type.  The
mimic description was changing (for '/' and ';' feedback) whenever
the player assiged a new fruit name.

That wasn't noticeable when applying a stethoscope because
mimic-as-slime_mold always yielded "that fruit is really a mimic".
Change it to report the fruit's type instead of generic "fruit".
2019-10-19 17:38:27 -07:00
nhmall
3dd7325ff1 Merge branch 'NetHack-3.6' 2019-10-19 12:30:38 -04:00
nhmall
c099e0a1ff grammar fix for "That walking shoes is really a small mimic" 2019-10-19 12:05:33 -04:00
nhmall
3ccc6e5308 Merge branch 'NetHack-3.6' 2019-10-17 20:52:10 -04:00
PatR
1fc8d7528c fix #H9298 - corpse mismatch
Corpses for dying monsters were being created with the wrong type,
caused by incorrect block nesting for 'if (ptr)' from commit
ad302fb8a9 (Oct 10).
2019-10-12 02:31:47 -07:00
PatR
ad302fb8a9 mksobj failure
If mksobj() was told to initialize the object it's creating and the
object class was something it didn't understand, it would issue a
warning and return Null.  But an unknown object class is a severe
internal error and very few callers were prepared to deal with a
Null result, so change mksobj() to panic instead.  Also eliminate the
few attempts to deal with Null result that are present in mkobj.c;
I didn't go looking elsewhere.
2019-10-10 17:43:31 -07:00
nhmall
72fcfadf23 Merge branch 'NetHack-3.6' 2019-10-08 20:27:39 -04:00
PatR
3c6303b34e fix #H9266 - redundant obj init
Sword given to angels used obj->spe = max(obj->spe, rn2(4)) [except
using a temporary to sanely work with max() macro].  But the obj was
explicitly created as no-init, so obj->spe was always 0 and the max()
was pointless.  Shield given to angels was manipulating bless/curse
state directly instead of using the functions intended for that, a
no-no and also pointless to be clearing 'cursed' for a no-init item.

Mace for priests had useless handling for object creation failure.

Object creation failure could only happen if the mksobj() call had a
valid entry in objects[] (or out of bounds access that didn't crash)
for an object class that it doesn't know how to handle.  That can't
happen unless somebody screws up big time.  If it ever did happen,
it would have produced a memory leak.
2019-10-08 14:23:27 -07:00
PatR
ba3004d6e2 W_WEAPON -> W_WEAPONS
Report #H9243 misinterpreted W_WEAPON as W_WEP and attributed a
hypothetical ball and chain sanity checking problem to that.
Rename the former to W_WEAPONS to emphasize that it includes
alternate/secondary weapon and quivered stack as well as wielded
weapon.
2019-10-08 13:26:39 -07:00
nhmall
0d34f43830 remove STATIC_DCL, STATIC_OVL, STATIC_VAR, STATIC_PTR from core 2019-07-14 17:24:58 -04:00
nhmall
28879d296d Merge branch 'NetHack-3.6' 2019-06-26 23:52:56 -04:00
PatR
fa4f9bb8ae coalescing partly eaten globs
Another one which has been around for a while.  When merging two
globs, the result is partly eaten if either (or both) of them was
partly eaten, not just when the one that's going to stick around as
the combined glob already was.
2019-06-26 15:37:17 -07:00
nhmall
bfc4445537 Merge branch 'NetHack-3.6' 2019-06-05 08:08:32 -04:00
PatR
43afa91ff8 fix #H8850 - bless/curse state in perm_invent
Changing an inventory item's bknown flag wasn't followed by a call to
update_inventory() in many circumstances, so information which should
have appeared wasn't showing up until some other event triggered an
update.
2019-06-04 10:50:24 -07:00
nhmall
6dd7dfa66c Merge branch 'NetHack-3.6' 2019-06-02 16:19:53 -04:00
PatR
4e119f4f00 place_object(obj,0,0) debugging
Got a hit (on Plane of Water) pretty quickly.
2019-06-02 05:02:08 -07:00
nhmall
8e972874b2 Merge branch 'NetHack-3.6' 2019-05-18 16:30:43 -04:00
nhmall
670fc9ca34 further improve additional glob interaction scenarios within a shop
Scenarios:
1. shop_owned glob merging into shop_owned glob
2. player_owned glob merging into shop_owned glob
3. shop_owned glob merging into player_owned glob
4. player_owned glob merging into player_owned glob
2019-05-18 16:24:48 -04:00
PatR
255d969da2 obj sanity checking specific to globs
Verify that objects with the globby bit set are actually glob objects,
that their quantity is 1, and that their weight at least superficially
makes sense.
2019-05-17 13:28:41 -07:00
nhmall
c5fbae0a4c Merge branch 'NetHack-3.6' 2019-05-17 12:06:58 -04:00
nhmall
2aee73642d fix some billing and pricing issues when globs coalesce
payment issue caused by glob coalescing
glob pricing did not consider coalesced weight
2019-05-17 12:04:01 -04:00
nhmall
53f208c48b glob floor merge message
Make it more obvious that globs that just merged on the
floor may be at an adjacent location.
2019-05-17 11:44:39 -04:00
nhmall
02826c4ebc Merge branch 'NetHack-3.6' 2019-05-10 22:54:38 -04:00
PatR
0ef58589f1 place_object vs multiple boulders
When place_object() puts a non-boulder underneath a boulder, make it
put the non-boulder under all the boulders there rather than just under
the topmost one.  Otherwise the map display will show the non-boulder
rather than the 2nd boulder if the top boulder gets moved away by some
means other than pushing.  (Pushing explicitly brings lower boulder to
top of pile in order to try to push it next.)

Reproduce by:  wish for boulder--it will drop.  Drop something else--
the something-else will end up under the boulder.  Repeat.  The second
boulder will be on top but the second something-else will be next in
the pile, above the first boulder.  Now polymorph into a giant and pick
up the first boulder, then move away from that spot.  Map will show
second something-else instead of the remaining boulder.

This fairly simple fix should work reliably on new games since boulders
will end up being consecutive on the top of piles.  For old games,
boulders after the topmost could be anywhere and still yield a display
glitch, but since that's all the problem is (I hope...), we ought to
be able to live with that until old games eventually go away.

[A map display glitch doesn't explain a corrupted 'uball' so this fix
doesn't solve that.]
2019-05-10 15:21:59 -07:00
nhmall
145bb3f172 Merge branch 'NetHack-3.6' 2019-05-10 15:01:59 -04:00