fix #H1816 - polearm/grapnel/whip fixes (trunk only)

From a bug report, applying a polearm to make a
short-range ranged attack didn't scuff any engraving you were standing on,
unlike ordinary melee and throwing/shooting attacks.  Grappling hooks had
the same omission.  Fixing it led to several other minor bugs.  Attempting
to target an unseen monster's spot with polearm or grapnel would yield some
permutation of "wait, there's something there" but draw the 'I' glyph at
the wrong spot.  It used <u.ux+u.dx,u.uy+u.dy> instead of the actual target,
so put the 'I' one step in front of your most recent move (or throw or zap
or whatever last set u.dx and u.dy).  Giving ESC when prompted for target
spot failed to use up a turn even when the polearm or grappling hook had
just been auto-wielded for use.  Neither use_pole() nor use_grapple() set
`notonhead' for hmon() (called via thitmonst() in their cases; this was
academic since plain physical damage attacks don't actually care about it).
[The bad 'I' placement was a post-3.4.3 bug.]

     Applying a bullwhip to attack an adjacent monster didn't have any of
those issues but did have the possibility of targetting off the edge of
the map when standing at that edge while confused or stunned.

     Applying a polearm to target an 'I' would yield "nothing happens" if
the unseen monster wasn't there anymore, and it didn't bother to remove
that 'I' from the map.  After changing it to do so, the phrasing no longer
made any sense.  This led to a slightly bigger change than I intended:
since statues are now shown as gray monsters (does that work for tiles?)
instead of as chunks of stone, they are likely to be intentional targets
sometimes, so polearm attacks now handle them differently from other
non-monster locations.  [I hope that other attack forms don't need
similar handling.  Melee certainly doesn't, since walking onto the spot
is enough to distinguish statues from monsters.  Having the missile pass
right through a statue's location probably suffices for ranged attacks.]
This commit is contained in:
nethack.rankin
2009-02-23 01:20:32 +00:00
parent a2257ebb1a
commit e11c136bc9
3 changed files with 91 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)uhitm.c 3.5 2007/12/19 */
/* SCCS Id: @(#)uhitm.c 3.5 2009/02/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -116,8 +116,8 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
* not stay there, so the player will have suddenly forgotten
* the square's contents for no apparent reason.
if (!canspotmon(mtmp) &&
!glyph_is_invisible(levl[u.ux+u.dx][u.uy+u.dy].glyph))
map_invisible(u.ux+u.dx, u.uy+u.dy);
!glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph))
map_invisible(bhitpos.x, bhitpos.y);
*/
return FALSE;
}
@@ -131,12 +131,12 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
* the screen, so you know something is there.
*/
if (!canspotmon(mtmp) &&
!glyph_is_warning(glyph_at(u.ux+u.dx,u.uy+u.dy)) &&
!glyph_is_invisible(levl[u.ux+u.dx][u.uy+u.dy].glyph) &&
!glyph_is_warning(glyph_at(bhitpos.x,bhitpos.y)) &&
!glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph) &&
!(!Blind && mtmp->mundetected && hides_under(mtmp->data))) {
pline("Wait! There's %s there you can't see!",
something);
map_invisible(u.ux+u.dx, u.uy+u.dy);
map_invisible(bhitpos.x, bhitpos.y);
/* if it was an invisible mimic, treat it as if we stumbled
* onto a visible mimic
*/
@@ -152,7 +152,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
if (mtmp->m_ap_type && !Protection_from_shape_changers &&
!sensemon(mtmp) &&
!glyph_is_warning(glyph_at(u.ux+u.dx,u.uy+u.dy))) {
!glyph_is_warning(glyph_at(bhitpos.x,bhitpos.y))) {
/* If a hidden mimic was in a square where a player remembers
* some (probably different) unseen monster, the player is in
* luck--he attacks it even though it's hidden.
@@ -166,7 +166,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
}
if (mtmp->mundetected && !canseemon(mtmp) &&
!glyph_is_warning(glyph_at(u.ux+u.dx,u.uy+u.dy)) &&
!glyph_is_warning(glyph_at(bhitpos.x,bhitpos.y)) &&
(hides_under(mtmp->data) || mtmp->data->mlet == S_EEL)) {
mtmp->mundetected = mtmp->msleeping = 0;
newsym(mtmp->mx, mtmp->my);
@@ -360,6 +360,10 @@ register struct monst *mtmp;
/* possibly set in attack_checks;
examined in known_hitum, called via hitum or hmonas below */
override_confirmation = FALSE;
/* attack_checks() used to use <u.ux+u.dx,u.uy+u.dy> directly, now
it uses bhitpos instead; it might map an invisible monster there */
bhitpos.x = u.ux + u.dx;
bhitpos.y = u.uy + u.dy;
if (attack_checks(mtmp, uwep)) return(TRUE);
if (Upolyd) {