Commit Graph

10549 Commits

Author SHA1 Message Date
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
PatR
a21b6534db X11 vs S_unexplored
X11 was still initializing a blank map to 'stone' instead of to
'unexplored'.  When the core started forcing 'unexplored' as part
of cls(), you could see the S_stone background show up and then be
overwritten with S_unexplored.

Also, X11 is [still] drawing unused column 0.  That was also 'stone'
but has been changed to 'nothing' so is now blank for both tiles map
and text map (regardless of S_unexplored value).  The extra useless
column doesn't look too bad normally but does if a vertical scroll
bar is added to support a clipped map.
2020-04-05 13:37:06 -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
PatR
b37b9f25ce mention_decor vs Underwater or drowning escape
Avoid redundant
|You are on solid land again.
|You are back on floor.
when walking or teleporting out of water with the mention_decor option on.
2020-04-03 10:41:30 -07:00
Pasi Kallinen
42fc34691d Check for levl typ STONE explicitly
... instead of expecting 0 to be STONE (or unused space in this case)
2020-04-03 13:10:12 +03:00
PatR
a2338e92aa groundwork: u.uinwater manipulation
Toggle u.uinwater on or off in just one place.
2020-04-03 01:04:27 -07:00
Pasi Kallinen
5f9714bf92 Remove workarounds for ancient compilers 2020-04-03 08:21:08 +03:00
PatR
8301fc06df warning fix
Fix a warning about mixing || and && without parentheses where
parentheses were present but a closing one was misplaced.

Also, isok() was redundant in 'isok() && is_pool()' because is_pool()
starts off with its own isok() check.
2020-04-02 12:48:27 -07:00
Pasi Kallinen
2f64f419ad Unify checking if monster is ok in poison gas 2020-04-02 20:53:08 +03:00
PatR
49f4a1d8d2 partial fix for S_unexplored
I've been sitting on this for a while but have decided that I'm not
likely to make any further progress.

SYMBOLS=S_stone:8,S_unexplored:9
on tty reveals that S_stone works as intended but S_unexplored does
not.  Unexplored was being drawn as spaces, and detected or sensed
monsters moving around unexplored areas left a trail of S_unexplored
characters behind them.  ^R reverted those to spaces.

This is only a partial fix that works when the map is initially drawn
or fully redrawn.  But after tty erases parts of lines (when deleting
a menu that overlaid the map or when clearing a message line that
wrapped onto the top line of the map), unexplored locations show up
as space rather than as S_unexplored.
2020-04-01 15:49:28 -07:00
PatR
689c3e67fe restore 'use_inverse' option
'use_inverse' used to be unconditionally present but conditionally
had default value True for WIN32 and False for others.  The options
changes that moved things to optlist.h made it present for WIN32 and
absent for others.  Put it back, and change the default value to be
unconditionally True.
2020-04-01 14:58:40 -07:00
PatR
616029561b moat vs water
Far-look and getpos's autodescribe feedback described the castle moat
as "water" and Juiblex's swamp similarly.  Describe them as "moat"
and as "swamp" instead.
2020-04-01 14:22:47 -07:00
Patric Mueller
acf6f5fdff Level compiler creates correct novel with supplied name
Before this commit, the name of a novel in the level files was ignored for
setting novelidx. But the name was set nevertheless, so you got a named novel
that showed quotes from a different novel.

Now, 'des.object({ id = "novel", name="Raising Steam"});' will work as
expected.
2020-04-01 22:36:30 +02:00
nhmall
3bfb5a6c35 quiet windows x86 warnings
nhlua.c(628): warning C4244: 'function': conversion from 'lua_Integer' to 'int', possible loss of data
nhlua.c(644): warning C4244: 'function': conversion from 'lua_Integer' to 'int', possible loss of data
nhlua.c(646): warning C4244: 'function': conversion from 'lua_Integer' to 'int', possible loss of data
2020-04-01 12:58:36 -04:00
Pasi Kallinen
62538f8e62 Fix iron ball being deallocated when saving
When swallowed by an air elemental, going down into a pit
placed the attached iron ball on the floor. Saving (or
using #wizmakemap) then deallocated the iron ball.

Check being swallowed before trying to go down.
2020-04-01 12:20:18 +03:00
Pasi Kallinen
f13ee3c9bc Fix birth statistics for pets after #wizmakemap 2020-03-31 20:19:33 +03:00
Pasi Kallinen
ac2b34654f Fix lua selection error
There was a rare selection bug where selection was freed by the gc
but it was still in use. Don't remove the selections from the stack
while we're handling them.
2020-03-31 19:11:49 +03:00
PatR
aff1f4c379 'submerged' status condition
Setting up the flag for the submerged condition was unnecessarily
complicated.  The display code distinguishes between being inside
water on Plane of Water and being underwater elsewhere (I'm not
sure why...) but as far as hero and player are concerned, being
submerged in water is the same on the Water level as anywhere else.
It actually is different; levitation and flying can't take the hero
above the surface because there isn't one, but that doesn't mean
that 'submerged' should be suppressed from status there.
2020-03-31 02:38:12 -07:00
PatR
bb6be709d8 tweaks for #wizlevelflip
For interactive level flip, flip cached travel destination and
interrupted digging position.

Also, ball and chain handling wasn't right if the ball was carried.
The fix for that is untested because I don't know how to judge where
the flip area starts and stops and this code is for the case where
that boundary is straddled rather than having hero and ball and chain
all inside or all outside the flip area.
2020-03-30 04:58:28 -07:00
Pasi Kallinen
3776b7d382 Fix monsters overflowing out of rooms in special levels
In a special level, creating more monsters inside room contents
than was space in the room placed monsters outside the room,
possibly inside walls of rooms created afterwards.

Prevent monster creation if inside room contents and there's no
space for the monster.
2020-03-29 11:17:40 +03:00
Pasi Kallinen
87513ad6bf Fix polymorphing monster trying to dig undiggable wall
Not sure if this can actually happen in a non-modified game, but
my fuzz testing stopped here, so deal with it.

If a polymorphing monster turns into an earth elemental or other
wall-phasing monster, it can wander into a non-diggable area, and
then turn into a tunneling monster.
This caused mdig_tunnel to issue an impossible.
2020-03-28 15:43:10 +02:00
Pasi Kallinen
b8668da3ea Fix purple worm ending up in solid wall
If you're in a vault, the vault guard enters, and your tame purple worm
swallows and kills the guard, the worm ended up inside the vault wall.
Instead return the attacker to the old location, if the defender's
position isn't good.
2020-03-28 11:40:42 +02: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
PatR
0ac3329289 reformat monflag.h
I started out fixing some strangeness near the very bottom then
ended up redoing the whole thing.
2020-03-27 17:47:07 -07:00
Pasi Kallinen
e89c193a57 Fix flipping while punished
... if either you, the ball, or the chain are outside the flip area.
Just unplace the b&c and then put it down under the hero.
This can only happen via #wizlevelflip, as normal level flipping
is done when creating the level and b&c are not on the map.
2020-03-27 17:30:23 +02:00
Pasi Kallinen
d5aa6e04e4 Fix wizmakemap and teleport region 2020-03-27 08:48:29 +02:00
PatR
dbb133ece9 teleds() vs ball&chain
I think this should fix #K672 but without a test case I can't be sure.
The ball and chain handling in teleds() was a bit convoluted and this
streamlines it a bit.

There is still the situation that one place uses 'can't drag ball if
dist > 1' and another uses 'no need to move ball if dist <= 2'.  That
seems contradictory but I want to prevent my head from spinning so
haven't tried to puzzle it out.  Instead of relying on multiple flag
variables to decide whether to call placebc(), the ball and chain (or
just chain when ball is carried) will be replaced if they were on the
map before moving the hero and aren't there after assigning hero's
new location
2020-03-26 01:31:46 -07:00