Commit Graph

6118 Commits

Author SHA1 Message Date
PatR
ca4e729216 detection bugs when vault guard is at <0,0>
Monster detection skipped dead monsters during fmon traversal but
found semi-dead guard parked at <0,0> waiting to remove temporary
vault corridor.  If that happened to be the only monster found then
the feedback was incorrect (a blank map showing no found monsters
instead of a strange feeling).  Object detection found semi-dead
guard's inventory and might report incorrectly too although the
chance of that being the only objects found on the level is a lot
less than it being the only monster.
2020-04-20 16:11:47 -07:00
PatR
5ec96751ba fix issue #325 - wishing for "garlic" doesn't work
Wishing allowed "royal jelly" to match "lump of royal jelly" as a
special case, but not "wolfsbane" to match "sprig of wolfsbane" or
"tricks" to match "bag of tricks".  Handle that sort of match in a
more general way.

While in there, add a minor glob bit:  instead of giving a random
corpse (because monster is flagged as no-corpse) if someone wishes
for "gray ooze corpse" give "glob of gray ooze".

Fixes #325
2020-04-20 14:57:17 -07:00
PatR
63b1bf54e8 fix wishing crash
After 05403182eb (I think, possibly the
change to objnam.c which followed that one) from a couple of days ago,
wishing for a monster name dereferenced a Null pointer and crashed.
2020-04-20 13:28:43 -07:00
Pasi Kallinen
2d67aaebb8 Clear saved lua_State from dungeons
These will be recreated if necessary in makerooms
2020-04-20 16:48:56 +03:00
Pasi Kallinen
776ebd809e No trying themed rooms if lua init failed 2020-04-20 16:34:22 +03:00
PatR
5fa12f4bc4 yet more S_unexplored
Revert part of one of the earlier S_unexplored changes (erasing
the map window on tty) and deal with the issue differently.
2020-04-19 16:15:16 -07:00
PatR
579939010d lua.adoc typo
"not-cursed" was misspelled.
2020-04-19 15:42:32 -07:00
nhmall
d8a409c34f windows build fix
src\cmd.c(505) : error C4703: potentially uninitialized local pointer variable 'efp' used
NMAKE : fatal error U1077
2020-04-19 13:40:20 -04:00
PatR
2337252acf fix issue #326 - can't wish for were-foo corpse
"were{rat,jackal,wolf}" each occur twice in mons[], once for the
beast form and second time among '@' for the human form.  Wishing
for werecreature corpse or tin always matches the first entry so
yields the beast form, but all their beast forms are flagged as
no-corpse so the wish would fallback to a corpse with random monster
type.  Wishing for werecreature figurine worked but always produced
one that created its beast form if/when activated.

This fix allows specifying "human werecreature" to match the second
entry.  It's optional for corpse and tin; the wish code will now
switch to that implicitly if it gets a no-corpse were-form for
those.  It has to be specified explicitly to get a figurine that
will activate as the human form.  It works for ^G too.

Fixes #326
2020-04-19 05:28:18 -07:00
PatR
05403182eb wishing fix
name_to_mon() has a bunch of alternate monster names, such as
"gray-elf" to match "grey-elf" and "ki rin" to match "ki-rin".  Those
worked as intended when they occurred at the end of a wish, but only
worked in the middle if their length was the same or one character
less than the canonical name in mons[].mname.

djinni figurine     -> h - a figurine of a djinni
genie figurine      -> i - a figurine of a djinni
figurine of mumak   -> j - a figurine of a mumak
mumak figurine      -> k - a figurine of a mumak
figurine of mumakil -> l - a figurine of a mumak
mumakil figurine    -> nothing fitting that description exists

(The one-less case worked because its following space ended up being
implicitly removed when skipping ahead by the length of mons[].mname;
subsequent explicit removal didn't find a space so was a no-op.)
2020-04-19 04:58:18 -07:00
PatR
37ef5a2561 objects[] infrastructure
The bases[] array allows finding the index of the first object in
a particular class.  Extend it so that bases[class + 1] - 1 is a
reliable way to find the last object in any class.  The array had
to be extended by one so that the last class has a [class+1] entry
available, and object initialization now makes sure that classes
within objects[] are in ascending order so that [class+1] always
holds a higher index than [class].
2020-04-19 04:18:22 -07:00
PatR
8c744de8cd || vs &&
Add some parentheses.
2020-04-19 03:20:01 -07:00
PatR
51180274df fix issue #331 - steam clouds vs moats
Water locations on Medusa's level didn't show steam clouds.  It
wasn't because the location was a moat rather than a pool, it was
because the moat location was unlit (and in line of sight) and
tested pool locations were lit.  Poison gas clouds explicitly
override the lit/unlit issue but other region types weren't.

Fixes #331
2020-04-18 15:28:53 -07:00
Pasi Kallinen
9784b5adef Fix heap use after free
In a lua script, if object was created inside a container, it
might've merged with another object.

Also prevent stacking, lighting, and burying contained objects.
2020-04-18 22:13:52 +03:00
Pasi Kallinen
9b74ea0b22 Shaped and themed rooms
Allows creating shaped or themed rooms for the Dungeons of Doom
via lua script.

Invalidates bones and saves.

Makefiles updated for unix/linux by adding themerms.lua, but other
OSes need to have that added.
2020-04-18 19:55:09 +03:00
Pasi Kallinen
2d43c6d62a Fix segfault on teleport while punished due to flooreffects
... deleting the ball & chain, but keeping a boulder in the pit.

Noticed a segfault when fuzzing, teleport while punished caused
a segfault via fill_pit -> flooreffects -> bury_objs -> unpunish,
and then the next line in teleds tried to look up uchain.

Guard against that particular case.

Fix the case of boulder being in a pit, triggered by you being in
a pit and a giant throwing a boulder on top of you.
2020-04-18 18:58:39 +03:00
Pasi Kallinen
9cdcf7b219 Also explode the other bag of holding 2020-04-18 11:31:16 +03:00
PatR
cf9e0d9434 map updating change to fix tty 2020-04-17 16:45:41 -07:00
PatR
274321d4ec adopt pull request #328 - steam clouds
This adds a superset of the code from github pull request #328
to create a short-lived cloud of steam when fire hits a pool or
fountain.  The original code required C99; this doesn't.  It also
allowed vapor clouds on the Plane of Water where they don't work
sanely becaure regions don't understand air bubble movement and/or
vice versa.  This inhibits the clouds there [the same ought to be
done for scrolls of stinking cloud].  It also left as-is the code
that reported when fountains got used up even though conceptually
the steam should interfere with being able to see that.  This adds
a glyph-check hack to augment cansee() so that fountains that boil
away entirely are hidden at the time.

Regions that block line of slight should be calling block_point()
when created and unblock_point() when removed but a naive attempt
to introduce that didn't work as expected so I'm giving up on.

Fixes #328
2020-04-17 14:56:47 -07:00
PatR
263ee3015f tty: S_unexplored
Screen erasure leaves the map set to spaces.  If S_unexplored is
something other than <space>, tty wasn't drawing with S_unexplored
after a menu or long message line got erased following temporary
overwrite of part of the map.

This seems to work but is not the correct way to do things.
clear_screen(), cl_eos(), and cl_end() should all be taught to
flag the map as needing to be refreshed after they erase part of it.
tty_clear_nhwindow(WIN_BASE) is also lacking since it erases the
message line, full map, and status lines but leaves their internal
windows with stale data about what is shown instead of marking them
blank.
2020-04-17 01:06:37 -07:00
Pasi Kallinen
7c44e06ab1 Dehardcode the monk minetown food shop conversion
Instead of trying to figure out in core whether to change a minetown
food shop to health food shop for monks, just figure it out in the
minetown level creation script.
2020-04-16 21:01:37 +03:00
PatR
10a89a529c mimic in health food store
Make a mimic that picks special VEGETARIAN_CLASS look like food
instead of a random object.  Also, at least a couple of Minetown
variants are classified as mazes so  had a 50% chance of not even
making that choice and look like a statue instead.  Override maze
when 'in_town()' yields True.
2020-04-16 01:09:01 -07:00
PatR
c09733f2e4 health food store
When a food shop gets converted into a health food shop (minetown
when playing as a monk), the shop type and underlying room type
weren't changed to match.
2020-04-16 01:00:31 -07:00
Pasi Kallinen
43d331c4eb Nerf unicorn horn
Unicorn horns are just too good. Nerf it in similar way several
other variants have done: don't let it restore attribute loss.

This makes potion of restore ability more valuable, and the
int loss from the (nerfed) mind flayers matter more.
2020-04-15 22:45:47 +03:00
PatR
a768507ebd getpos help
This started with fixing a warning suggesting parentheses when
mixing || and &&, then started sprawling.  The getpos help for x/X
was misleading.  It said that using x or X would move cursor to the
next unexplored location but it actually moves the cursor to next
explored location that's adjacent to an unexplored one.
2020-04-15 01:43:47 -07:00
Pasi Kallinen
fe8f18c5d7 Mimic in a health food store could cause a panic
Health food stores use a special "vegetarian class" of items,
which mkobj doesn't understand. Just make the mimic use a random
item class in that case.
2020-04-15 11:10:26 +03:00
Pasi Kallinen
02f222bc0c Add vault guards to undisplaceable monsters 2020-04-15 08:59:35 +03:00
copperwater
a9eb81e0c7 Change logic for immobilized displacement, fixing a bug
The bug was that you could easily displace peaceful sleeping monsters.
The source of this was that there was no check for sleeping in the
attack() function that checks for immobilization.

As well as adding the sleeping check, this logic is modified so that it
makes more sense: if a monster is immobilized at all (sleeping, frozen,
or mcanmove = 0) it always "doesn't seem to move!" You can't randomly
displace it anyway 1/6 of the time.

Sessile monsters who are otherwise not immobilized don't move 5/6 of the
time, but can be displaced with the other 1/6.
2020-04-15 08:46:47 +03:00
copperwater
6134c6f165 Pet displacement improvements
Pets can no longer be displaced out of a trap, because that was
inconsistent with peaceful monsters refusing to be displaced out of a
trap. The untaming-via-displacement-out-of-trap code is removed.

Pets also now have a better survival instinct: they follow the code for
peaceful displacement into a bad position, and refuse to swap places.
This means it's no longer possible to accidentally kill a pet by
levitating/walking over water and displacing it.
2020-04-15 08:46:47 +03:00
copperwater
92b9db7630 Shopkeepers are immune to peaceful displacement as well 2020-04-15 08:46:47 +03:00
copperwater
5a1bbb4d16 Fix: rn2(0) when trying to displace peaceful out of trap
A side effect of making is_safepet() count peacefuls. Now checks
directly for a trapped, peaceful monster and says "they can't move out
of the trap"; this is inconsistent with pet behavior, and pet behavior
should probably be changed to be in line with it (ie they can't be
displaced out of a trap at all.)

Also refactor the code here a bit: a bunch of different if statements
have the exact same resetting code and steed resetting code in them.
Change this to a boolean flag and put the resetting code in one place
checked by that flag.
2020-04-15 08:46:47 +03:00
copperwater
21351fc13c More peaceful monsters that can't be displaced: priests, Oracle
Shouldn't be able to displace priests since that could theoretically
eventually force them out of their temple, which would probably cause
problems. The Oracle doesn't usually move anyway, but seems like she
should "not want to swap places" in any circumstance.
2020-04-15 08:46:47 +03:00
copperwater
2ee09b9210 Player can now displace peaceful monsters
Changes domove() code to allow displacing peaceful monsters.
Specifically, is_safepet() now returns true if the monster is peaceful.
Peacefuls are slightly pickier than pets about whether they consent to
being displaced: they will not displace if a goodpos() check fails for
the displaced space, or if there is a trap on the displaced space, or if
they are your quest leader. is_safepet should probably be renamed to
something else.

In the process of doing this, some other changes were made: the code now
checks whether the player and monster should be swapping places at all
first (previously it ran some code for displacing pets out of traps
first, which was a little weird if the displacement didn't actually
happen.)

In the original commit for this, I needed to guard the spoteffects()
call made in domove with a clause testing whether the player actually
moved; it was previously possible to fail to displace a monster and then
re-trigger a trap on the space you were still standing on. However, the
devteam has apparently put in an if (u.umoved) clause in the same place
and serving the same purpose.
2020-04-15 08:46:47 +03:00
Pasi Kallinen
7efe7b05df Fix "x" and "a" when choosing map location
Recent(ish) change to split unexplored glyphs from solid wall glyphs
resulted in getloc commands to choose unexplored and interesting
locations not work correctly.

Fixes #323
2020-04-15 07:15:41 +03:00
copperwater
18d19c902b Allow specifying a montype on figurines in lua files
This was already allowed for the other montype-compatible objects like
statues, corpses, eggs and tins. I don't see a reason why figurines
shouldn't be part of this group; perhaps it was an oversight.
2020-04-15 06:47:58 +03:00
PatR
2fbf9573d5 unclutter mattacku a bit
Move demon summoning and were creature summoning out of mattacku()
to a separate routine.  Should be no change in behavior.

Also, redo several comments that came after what they applied to
rather than before, and reorder the file-scope prototypes to be in
the same order as the corresponding functions.
2020-04-14 18:13:32 -07:00
Pasi Kallinen
bddb80f13c Make hostile monsters with launcher and ammo keep away
If a hostile monster is wielding a ranged weapon, and is carrying
appropriate ammo for it, make the monster try to stay away,
outside the melee range.
2020-04-14 15:19:30 +03:00
PatR
caac70c5ec rest/search refinement
When rest and search refuse to operate because a hostile monster is
adjacent, include a reminder of how to force them to operate.  Every
time if 'cmdassist' is On, or just once until after some subsequent
try actually does something.

This new rest and search behavior probably needs to be optional and
default to the old behavior.  It isn't uncommon to deliberately rest
while adjacent to a hostile monster if also adjacent to a peaceful
one and trying to wait for Stun or Confusion to time out, or maybe
search while next to such a monster hoping to find a secret door to
run away through.  A count prefix won't work and needing an extra
keystroke each time is going to be an annoyance.
2020-04-13 14:58:12 -07:00
PatR
124d39f4c5 fix #K797 - wrong message when stealing as nymph
When polymorphed into a nymph and melee hit steals items from the
target, the same-gender charm message vs opposite-gender seduce
message is being chosen by hero's base gender rather than nymphs
always being female.  The seduce message used dynamic pronouns for
the target monster but the charm message used hardcoded She and her
for female nymph attacking female target.  I'm not sure why hero's
base gender is used so left that alone; this changes charm message
to use dynamic pronouns that correctly match the target monster.
2020-04-13 12:58:54 -07:00
Pasi Kallinen
71754910db Scatter bag of holding contents instead of deleting them
Losing all of your items in one go is really frustrating.
If you blow up your bag of holding, make the contents scatter around
instead of outright deleting them. This will destroy fragile objects.
2020-04-13 21:49:29 +03:00
Pasi Kallinen
d78dcdcb9b Allow matching any wall map terrain in lua scripts
When matching a terrain, allow using a "w" placeholder that matches
any solid wall:

For example:
   local s = selection.match([[w.w]]);
would match all floor locations with a wall to the left and right of it.
The walls can be solid stone, horizontal, vertical, etc.

This applies to selection.match(), selection.filter_mapchar(), and
des.replace_terrain()
2020-04-13 20:00:34 +03:00
Pasi Kallinen
9513b73169 Trapped container creates occasionally an actual gas cloud 2020-04-13 13:08:39 +03:00
Pasi Kallinen
6b9c9bb170 In-game doc the extended commands accepting 'm' prefix 2020-04-13 11:10:59 +03:00
Pasi Kallinen
ecc1ceb581 Allow random mimics to mimic more furniture
In addition to stairs, allow altar, grave, throne, and sink.
2020-04-12 22:08:06 +03:00
Pasi Kallinen
ac94c44b0b Prevent searching or waiting next to a hostile
Generally speaking there's no reason to wait or search next to
a hostile monster, so let's just prevent those actions. You can
still do those commands by prefixing them with the 'm' prefix.
2020-04-12 17:32:29 +03:00
Pasi Kallinen
47fb7e5ee5 Fix double free 2020-04-12 16:55:00 +03:00
Pasi Kallinen
6d1df04eda Remove incorrect comment 2020-04-12 15:45:13 +03:00
nhmall
d47792ca64 Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7 2020-04-11 17:55:09 -04:00
nhmall
b0237e6d3f prototype for optfn_palette 2020-04-11 17:54:24 -04:00
PatR
d83f1c178b refinement of monster use of undead turning
Instead of just picking up wands of undead turning when one or more
corpses are in hero's inventory, have monsters also pick those up if
hero has a cockatrice corpse in a carried container.  And instead of
only zapping such wands (as defensive measure) when hero is wielding
a cockatrice corpse, also zap them (as offensive measure) if hero is
carrying any corpse in open inventory.
2020-04-11 12:34:32 -07:00