fix github issue #285 - spellcasting monster

After casting a spell, a monster got a chance to make a regular attack
despite the apparent attempt to set up a return value indicating that
it wouldn't move.

When looking over the return value situation, I noticed 'wormhitu()'
for the first time.  It gives worms additional attacks when the hero
is adjacent to some of the tail, that only works if the head is within
reach of a melee attack.  The hidden tail segment at head's location
always met that criterium so gave an extra attack that didn't make
sense; change wormhitu() to skip that segment.

Do some formatting in mcastu.c; no change in actual code there.

Fixes #285
This commit is contained in:
PatR
2020-02-02 00:55:26 -08:00
parent bfd180a5ac
commit 2ebbe61f53
5 changed files with 41 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 worm.c $NHDT-Date: 1580043421 2020/01/26 12:57:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.42 $ */
/* NetHack 3.6 worm.c $NHDT-Date: 1580633722 2020/02/02 08:55:22 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.43 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -329,8 +329,10 @@ struct monst *worm;
* Check for mon->wormno before calling this function!
*
* If the hero is near any part of the worm, the worm will try to attack.
* Returns 1 if the worm dies (poly'd hero with passive counter-attack)
* or 0 if it doesn't.
*/
void
int
wormhitu(worm)
struct monst *worm;
{
@@ -341,11 +343,15 @@ struct monst *worm;
* is out of range of the player. We might try to kludge, and bring
* the head within range for a tiny moment, but this needs a bit more
* looking at before we decide to do this.
*
* Head has already had a chance to attack, so the dummy tail segment
* sharing its location should be skipped.
*/
for (seg = wtails[wnum]; seg; seg = seg->nseg)
for (seg = wtails[wnum]; seg != wheads[wnum]; seg = seg->nseg)
if (distu(seg->wx, seg->wy) < 3)
if (mattacku(worm))
return; /* your passive ability killed the worm */
return 1; /* your passive ability killed the worm */
return 0;
}
/* cutworm()