Commit Graph

6071 Commits

Author SHA1 Message Date
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
PatR
1f9e4d2468 corpse revival nitpicks
Testing a forthcoming extension of monsters using wands of undead
turning revealed a couple of pre-existing bugs.  Previously only
noticeable if hero zaps self or breaks a wand of undead turning so
unlikely to have happened much.

"Your <mon> corpse comes alive" was given even if it was revived
as an undead.  Also, it was "your <mon> corpse" instead of "one of
your <mon> corpses" even when one from a stack was involved.  If
done by hero to self that message follows "one of your <mon>
corpses glows iridescently" so the comes alive message was ok but
verbose.  Change that to "it comes alive" or "it reanimates" when
following the glow message.
2020-04-11 12:24:02 -07:00
PatR
dc6b2f5de1 let monsters use wand of undead turning
when hero is wielding a cockatrice corpse.  Wands of undead turning
aren't generated as starting equipment but they will now be picked
up if come across while the hero is carrying any corpse, and used
in preference to any other item when carried and non-empty and hero
is wielding a petrifier's corpse.
2020-04-10 18:39:46 -07:00
PatR
05028b4c3e m_lined_up() type mismatch
m_lined_up() was declared 'boolean' but returned 0, 1, or 2.
The 1 case isn't actually used any more.  I changed it to 'int'
rather than 2 to TRUE; it could just as easily be the other way
'round.
2020-04-10 18:09:58 -07:00
nhmall
db7a3abce4 Xcode warning of possible uninitialized variables 2020-04-10 00:29:51 -04:00
PatR
2e177a7fc4 fix gibhub issue #320 and more - 'mention_decor'
Fixes #320

Avoid giving "you are back on the bottom" nearly every step when
moving around underwater.

Avoid "you are back on floor" followed by "you trip over <object>"
when fumbling in case that fumbling was due to being on ice when
taking the step to floor.  Done for all fumbling rather than just
one-turn fumbling instigated by ice.

When moving from ice or water to ground, show "you are back on floor"
before listing objects at that spot instead of after.

I think there was at least one more thing but have lost track.  At
any rate, 'mention_rate' potentially has a new set of bugs.
2020-04-08 18:33:55 -07:00
PatR
27b1a153d3 teleport message sequencing
"You materialize at another location," was delivered while the
previous location still controlled line of sight.  Very noticeable
if you started from underwater and landed on the surface in an area
which hadn't been mapped yet.
2020-04-08 15:17:02 -07:00
PatR
69b4f0afc0 null pointer crash fix
The fix to try to avoid messages about out-of-view objects taking
erosion damage made water_damage_chain() vulnerable to dereferencing
a null pointer, leading to a crash if you create a pool via wizard
mode wishing.
2020-04-08 14:53:06 -07:00
PatR
6582b90008 fix github issue #321 - 'Mine Town' vs 'Minetown'
Change achievement spelling to match T-shirt spelling:  Minetown.

Fixes #321
2020-04-08 12:52:20 -07:00
PatR
93e0c0c3e6 fix #K763 - segfault eating tin of Rider meat
Eating a tin of one of the Riders and being life-saved or declining
to die would crash when trying to revive a non-existent corpse.  An
old comment stated that since such tins were impossible it could
assume that it was dealing with a corpse, but wishing for tins of
the Riders is possible in wizard mode.

They can't be passed along to normal mode via bones because they're
changed to empty tins as bones are saved.  So there doesn't seem to
be much point in allowing wizard mode wishing to create them, but
I've left that as is.
2020-04-07 16:55:07 -07:00
PatR
c6b82c0e4f water_damage() band-aid
I got "The chain mail rusts." seemingly out of the blue, then when
moving around the corner of the building on Valk home level I saw a
spot of remembered ice be redrawn as water.  Before that I checked
for any mapped objects (via ';' 'o' 'o' ... so I didn't overlook
anything; there were only a couple of objects shown on the map and
none of them were piles) and didn't see any remembered chail mail or
anything at all on that ice spot, so I'm assuming that it was carried
by a monster.  I may be leaving out some steps in the call chain here:

melt_ice -> minliquid -> mondead -> m_detach -> relobj -> mdrop_obj
  -> flooreffects -> water_damage -> erode_obj

erode_obj() uses bhitpos for visibility check of eroding objects not
carried by the hero or by a monster, with a comment expressing doubt
about doing that.  It wouldn't have yielded the right answer for the
possible call chain here unless it got set by some monster activity.
I had been zapping a wand just before and bhitpos would have been set
to a coordinate I could see at the time, fooling erode_obj()'s check
if the value was stale.

Anyway, this only addresses objects eroded from flooreffects(),
water_damage_chain(), and fire_damage_chain().  There are lots of
other indirect calls to erode_obj().
2020-04-07 11:54:52 -07:00
Pasi Kallinen
665eacf40c Expose scaled mazes to special level lua
Adds a new level init type which directly creates a maze,
optionally setting corridor width and wall thickness,
and removing dead ends.

des.level_init({ style = "maze", corrwid = 3, wallthick = 1, deadends = false });
2020-04-07 19:20:39 +03:00
PatR
f694f3b644 add missing two-weapon feedback
When dual-wielding and you wield a different weapon, two weapon combat
was silently toggled off even when the new weapon was eligible to be
dual-wielded.  If the verbose flag is On, explicitly tell the player
when wielding something toggles off two-weapon mode.  Wielding '-' is
an exception because you already get told that you're empty handed.
2020-04-07 07:40:33 -07:00
Pasi Kallinen
297eb934a7 Fix monster booted into limbo trying to act
There's a chance that a tactics-using monster (eg. arch-lich)
teleporting next to you on a full level would get booted off
into limbo. After that, if the monster tried using an item
in the same action you'd get panic "relmon: mon not in list"

Fix this particular case by checking monster mstate.
Other cases may lurk in other places that eventually call mnexto.
2020-04-07 17:23:23 +03:00
PatR
fd3c3181f5 type mismatch in weapon_insight
can_advance() returns boolean rather than int.	Change the affected
local variables	to match rather than casting its return value.
2020-04-07 06:45:53 -07:00
PatR
1b2e3f5c90 ^X vs two-weapon
When dual-wielding and both weapons use the same skill, the weapon
feedback by ^X was inadvertently skipping the part where it would
tell the player whether either the weapons' skill or two-weapon
skill or both had already been trained enough to to be advanced.

Most of the diff is change in indentation.
2020-04-07 06:17:35 -07:00
copperwater
0befdbfd02 Re-implement gradient selections
Uncomments and makes available selection.gradient in Lua. (The backend C
code for this still existed, it just wasn't used.)

The only valid way to specify a gradient is with a table. I considered
adding non-table versions, but decided that there are too many
independent variables that can be optional. A non-table version, without
named parameters, would be confusing to read, especially since most of
the arguments are ints.

Also adds an impossible in the (possibly unreachable) case that
selection_do_gradient gets called with a bad gradient type.
2020-04-06 18:54:39 +03:00
copperwater
407f65aa8a Print out Lua error message when encountering an error
Rather than spitting out an error code number that is not particularly
useful. The string contains the line number and the nature of the error,
which is much more useful for debugging or reporting an issue.
2020-04-06 18:50:29 +03:00
PatR
995fde037c fix segfault fix
Previous fix prevented getting skill feedback about bare-handed
combat/martial arts.
2020-04-06 08:24:39 -07:00
Pasi Kallinen
c24b9f0f1a Fix one more prototype warning 2020-04-06 18:24:15 +03:00
Pasi Kallinen
7b1bc9dcbd Prevent segfault when not wielding anything 2020-04-06 18:09:47 +03:00
PatR
dc9de59f63 ^X weapon feedback
Report weapon skill in the ^X status section when dual-wielding,
The effective skill level is the lower of the weapon's skill and
two-weapon skill, separately for primary and secondary.  It's a
much bigger chunk of code than most enlightenment/^X features so
I put it in its own routine.
2020-04-06 06:25:17 -07:00
PatR
d07595db2c dual-wielding tweaks
Reject arrows and darts as candidates for wielding two weapons at
once.

Make the check for being able to two-weapon when polymorphed be more
robust.  Instead of just testing whether the monster form's second
atttack is a weapon attack and then assuming that the first one is
too, test the first three to validate that at least two of those are
AT_WEAP.  The existing code works but seemed fragile.
2020-04-06 06:12:25 -07:00
Pasi Kallinen
d087746fd7 And some more warning fixes 2020-04-06 15:41:26 +03:00
Pasi Kallinen
e215f09ddb Fix even more warnings 2020-04-06 13:34:07 +03:00
Pasi Kallinen
99519c4e5b Fix more warnings 2020-04-06 10:25:17 +03:00
PatR
b6904d8fc8 'A' tweak
Get rid of a couple of unnecessary calls to set_twoweap() to clear
u.twoweap when using 'A' to 'take off' either weapon.  setuwep() and
setuswapwep() don't do that, but they call setworn() which does.

Make the feedback when disarming with 'A' be more specific when you
are two-weaponing at the time either weapon is unwielded.
2020-04-05 15:32:00 -07:00
PatR
300d987bdf warning fix
A couple of the new prototypes used 'char' where 'CHAR_P' is needed.

Also, move them out of middle of long block of command declarations.
I started to reorder the prototypes into the order in which those
functions appear in the file but gave that up pretty quickly.
2020-04-05 14:31:01 -07:00
Pasi Kallinen
9411d24edb Fix more warnings 2020-04-05 21:53:45 +03:00
Pasi Kallinen
01e35397de Fix warnings
Add missing prototypes and rename one shadowed declaration.
2020-04-05 21:36:38 +03:00
copperwater
4b7f34f5f8 Refactor mongets to return the object it creates
The impetus for this was to avoid ugly constructions such as the one
below (none of which currently appear in vanilla NetHack):

mongets(mtmp, LONG_SWORD);
struct obj* sword = m_carrying(mtmp, LONG_SWORD);
if (sword)
  /* do thing to sword */

Most cases where mongets is used discard the returned value (which used
to be the created object's spe); the only places that do use it are the
series of statements that give various human monsters armor and prevent
them from getting too much armor. These statements included hardcoded
constants representing the base AC of the armor, which would have caused
discrepancies if armor's base AC were ever changed.

With mongets now returning a pointer to the created object, it can just
be passed into ARM_BONUS instead, which covers both the base AC and the
enchantment. (It will also cover erosion, if anyone ever decides that
armor should rarely generate as pre-eroded).

The overall algorithm is not changed by this; human monsters should
receive armor with the same probabilities as before.
2020-04-05 21:08:34 +03:00
copperwater
a9dd7a5a46 Don't interrupt tin opening if being slimed and tin is chameleon
Another SliceHack feature. It's possible for you to eat the chameleon
tin and turn into a fiery monster that burns off the slime in its
natural form, either extremely luckily at random or if you have
polymorph control.
2020-04-05 16:10:33 +03:00
copperwater
1b945bf60a Blessed teleport scrolls now give a single controlled teleport
This buffs the blessed effect of the teleport scroll by providing the
reader control over their destination even if they lack teleport
control. This seems like it makes the blessed/uncursed distinction
actually meaningful, rather than mostly pointless.
2020-04-05 16:08:22 +03:00
copperwater
f54485b913 Pets will not eat shapeshifter corpses except in extreme circumstances
Ported from SpliceHack, and generalized to all shapeshifters (Splice
only implemented it for chameleons). It's very aggravating when your
powerful but hungry pet chows down on a shapeshifter before you can stop
them and then turns into something much more useless, so this aims to
prevent that.

The extreme circumstances under which a pet will eat a shapeshifter are:
  1. The pet is starving, and prefers polymorph to starvation
  2. The pet's tameness is 1

The reasoning behind the second condition is that if you mistreat your
pet almost to the point of untaming it, it might want to take a chance
on turning into something that might get some more respect from you.
Practically, whenever this happens, this will result in the player now
owning a newly polymorphed and *still* nearly feral pet.
2020-04-05 16:01:39 +03:00
PatR
995a6bf4fe purple worms
Compiler complained about 'ptr' possibly being used unitinialized
in meatcorpse() and in this case it was right.  meatcorpse() was
cloned from meatobj() but the necessary initialization was missing.

Purple worm would devore an entire stack of corpses in one bite.
Split one off and have it eat that instead.

I'm not sure whether attempting to revive a Rider corpse can force
a monster off the level to make room.  If so, meatobj() and
meatcorpse() weren't prepared to handle that, nor was their caller.
It appears that the monster (either g.cube or purple worm) will
only eat as it moves so can't revive a Rider on a completely full
level since it won't be able to move in that situation.  I fixed
the caller to be prepared to handle a result of 3 (no further
action allowed) instead of just dealing with 2 (died), but I didn't
fix either of the meatfoo() routines to return 3 since bumping the
eating monster off the level seems to not be possible.

Don't let purple worms eat lichen corpses, regardless of whether
they'll swallow live ones.
2020-04-05 05:57:37 -07:00
copperwater
30ad8eed84 Make demon lords hostile if wielding Demonbane as well as Excalibur
This makes a lot of sense. Why would they hate one artifact sword so
much and not really care about the one that is especially designed to
kill their type personally?
2020-04-05 15:42:38 +03:00
copperwater
e13b1833cc Scroll of remove curse becomes learned when items' curses are removed
The scroll of remove curse is trivially identified by checking inventory
after reading it to see whether anything became uncursed. This leads to
annoying tactics like remembering which scroll you just read so you can
go call it "remove curse" on the discoveries list.

This simply autoidentifies it when an item that was known to be cursed
has its curse removed.
2020-04-05 15:40:21 +03:00
copperwater
da3afd39d2 Deliberate level teleporter activation ignores magic resistance
This is aimed at providing a little quality of life in the form of not
having to divest yourself of your sources of magic resistance before
using a level teleporter. The player is already able to use regular
teleport traps while Antimagic; there's no reason why it should be
different for level teleporters.

This ultimately comes from "Stevie-O's level teleporter jump patch", by
way of SliceHack. I simplified it a bit: deliberately jumping onto the
trap always takes time even if it fails to levelport you (which would
only happen with level teleporters in the End Game, which don't exist).
2020-04-05 15:34:20 +03:00
copperwater
63d3d7b688 You may survive food poisoning with a Con/100 chance
Another feature from SliceHack. Randomly averting an instadeath might
seem a little too generous, but the only time you get food poisoning is
if you're a new player who hasn't learned about tainted corpses yet or
if you just did something stupid. So, be a little nicer in those
scenarios.

If you survive, your Con silently decreases by 1. Hey, it's better than
dying.
2020-04-05 15:15:30 +03:00
copperwater
4129706a4c Potions of hallucination can give enlightenment
This is also from SliceHack, but with the odds of enlightenment toned
down a bit, to 4/9 for a blessed potion and 1/6 for an uncursed potion
(SliceHack had it at 50% blessed, 20% cursed, and strangely, 0%
uncursed). It gives a much-needed use to one of the potions that's
commonly blanked or discarded.
2020-04-05 15:06:43 +03:00
Pasi Kallinen
1ba1422eba Confused scroll of light conjures tame cancelled lights
Tame cancelled lights are actually quite interesting and useful: they
are a mobile light source that will follow you around, and because they
are cancelled they won't explode at hostile monsters.

This replaces the existing confused scroll effect of creating an area of
darkness (the cursed scroll of light still produces this effect). If you
are confused *and* the scroll is cursed, it summons black lights instead
of yellow ones.

Original change by copperwater <aosdict@gmail.com>, added with
formatting and some functional changes.
2020-04-05 13:21:54 +03:00
Pasi Kallinen
cf1c725148 Purple worm changes
Shriekers only spawn purple worms when they're appropriate difficulty.
Non-tame Purple worms eat corpses off the ground.
Baby purple worms attack shriekers.
Hero polyed into baby purple worm is warned against shriekers.

Original changes by copperwater <aosdict@gmail.com>, added with some
formatting adjustments and consolidation.
2020-04-05 12:44:25 +03:00
PatR
8119c52d84 wizard mode wishing for terrain
Changing terrain type without moving wasn't registering as moving to
different terrain.  A Passes_walls hero who has levitation blocked
while moving through solid rock can wish for furniture.  Levitation
remained blocked unless hero moved off that spot and then back on.

Doesn't affect normal play.  Changing terrain by digging already
deals with similar situation; not sure whether there are any other
situations that might need to handle it.
2020-04-04 03:29:40 -07:00
PatR
c8044a202b switch_terrain() logic bug causing status updates
When moving onto a different terrain type, the logic for whether to
block or unblock levitation and flying (for the case of moving in
or out of walls and solid stone with Passes_walls while levitating)
was correct but the XOR logic for whether to do a status update
because of such a change was incorrect.  So stepping from room floor
to furniture or to doorway and vice versa or from corridor to doorway
and vice versa was requesting a status update when there was no need
for one.

Some other code must be requesting a status update when it is needed
for this (or possibly even more often than that?) because the status
line does seem to show the current state of Lev and Fly accurately.
Otherwise this should have been noticed when switch_terrain() was
first implemented.
2020-04-04 02:41:13 -07:00
PatR
8f73f926b1 groundwork: u.twoweap manipulation
Toggle u.twoweap on or off in just one place.
2020-04-03 11:42:17 -07:00
PatR
d58e449d6c set_uinwater() bit
Assignment target is a one bit wide bitfield; callers only pass 0 or 1
but guarantee that value fits so that no compiler has reason to complain.
2020-04-03 11:39:40 -07:00
Pasi Kallinen
e34f123698 Make hezrous stink 2020-04-03 21:05:49 +03:00
Pasi Kallinen
13b8a9912f Flip poison gas clouds 2020-04-03 20:42:27 +03:00