]> granicus.if.org Git - nethack/commitdiff
fix B3032 -- wand of speed monster id
authornethack.rankin <nethack.rankin>
Fri, 8 Feb 2002 04:14:03 +0000 (04:14 +0000)
committernethack.rankin <nethack.rankin>
Fri, 8 Feb 2002 04:14:03 +0000 (04:14 +0000)
     Make wands of speed or slow monster known if their effect
on monsters is observed; likewise for speed boots.  Also, avoid
giving odd "the bat is moving faster" when seeing a bat created
in gehennom and inaccurate "the monster is moving slower" when
a monster puts on speed boots.

include/extern.h
src/apply.c
src/makemon.c
src/mcastu.c
src/mhitm.c
src/mon.c
src/muse.c
src/potion.c
src/worn.c
src/zap.c

index 952161966802c152a15f57c7bec783f4c94c09df..07621933a3de5077668b3baf005956a14943b413 100644 (file)
@@ -2238,7 +2238,7 @@ E boolean FDECL(worm_known, (struct monst *));
 E void FDECL(setworn, (struct obj *,long));
 E void FDECL(setnotworn, (struct obj *));
 E void FDECL(mon_set_minvis, (struct monst *));
-E void FDECL(mon_adjust_speed, (struct monst *,int));
+E void FDECL(mon_adjust_speed, (struct monst *,int,struct obj *));
 E void FDECL(update_mon_intrinsics, (struct monst *,struct obj *,BOOLEAN_P));
 E int FDECL(find_mac, (struct monst *));
 E void FDECL(m_dowear, (struct monst *,BOOLEAN_P));
index d4b1bc38009c26b31e9381369d0b5dcccca0048f..0f6a83f71ffb8100b82970d99f4fa7af9676f053 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)apply.c    3.4     2002/01/18      */
+/*     SCCS Id: @(#)apply.c    3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -778,9 +778,8 @@ register struct obj *obj;
                } else switch (rn2(3)) {
                        default:
                                break;
-                       case 1: in_mklev = TRUE; /* don't print messages */
-                               mon_adjust_speed(mtmp, 2);
-                               in_mklev = FALSE;
+                       case 1:
+                               mon_adjust_speed(mtmp, 2, (struct obj *)0);
                                break;
                        case 2: /* no explanation; it just happens... */
                                nomovemsg = "";
index 5f8434fbb13162eaf68234c9b693c9ac267353ec..21012ec4bc916e986e7df5fcff348d563abc692a 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)makemon.c  3.4     2001/11/07      */
+/*     SCCS Id: @(#)makemon.c  3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -928,7 +928,7 @@ register int        mmflags;
                        break;
                case S_BAT:
                        if (Inhell && is_bat(ptr))
-                           mon_adjust_speed(mtmp, 2);
+                           mon_adjust_speed(mtmp, 2, (struct obj *)0);
                        break;
        }
        if ((ct = emits_light(mtmp->data)) > 0)
index 56e690f94a78830da9566ebc066ecfc401dfa3cb..921fb7aaf8146145d5c030b78587d30e2197e932 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mcastu.c   3.4     2002/01/10      */
+/*     SCCS Id: @(#)mcastu.c   3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -427,7 +427,7 @@ int spellnum;
        dmg = 0;
        break;
     case MGC_HASTE_SELF:
-       mon_adjust_speed(mtmp, 1);
+       mon_adjust_speed(mtmp, 1, (struct obj *)0);
        dmg = 0;
        break;
     case MGC_CURE_SELF:
index fbfef17deb49311aea4c4fd7df9dbfd130d7c143..0b36cead7781c4054c462b581558fd68c767f882 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mhitm.c    3.4     2000/07/29      */
+/*     SCCS Id: @(#)mhitm.c    3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -805,7 +805,7 @@ label2:                     if (mdef->mhp > 0) return 0;
                if (!magr->mcan && vis && mdef->mspeed != MSLOW) {
                    unsigned int oldspeed = mdef->mspeed;
 
-                   mon_adjust_speed(mdef, -1);
+                   mon_adjust_speed(mdef, -1, (struct obj *)0);
                    if (mdef->mspeed != oldspeed && vis)
                        pline("%s slows down.", Monnam(mdef));
                }
index 0b6e3cfc05e402aee2168846e75eb98f9d1ec698..af9253cdd3f57af3abfc54baa8c4815bf5b13ab9 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mon.c      3.4     2002/01/07      */
+/*     SCCS Id: @(#)mon.c      3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2538,7 +2538,7 @@ int damtype, dam;
     }
     if (slow) {
        if (mon->mspeed != MSLOW)
-           mon_adjust_speed(mon, -1);
+           mon_adjust_speed(mon, -1, (struct obj *)0);
     }
     if (heal) {
        if (mon->mhp < mon->mhpmax) {
index 24c45096f9629e5d986a18d8a476406c2bf061a6..97d1b03eca9a20b2d30dd393cf91b81537bfc754 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)muse.c     3.4     2002/01/07      */
+/*     SCCS Id: @(#)muse.c     3.4     2002/02/07      */
 /*     Copyright (C) 1990 by Ken Arromdee                         */
 /* NetHack may be freely redistributed.  See license for details.  */
 
@@ -1738,7 +1738,7 @@ skipmsg:
        case MUSE_WAN_SPEED_MONSTER:
                mzapmsg(mtmp, otmp, TRUE);
                otmp->spe--;
-               mon_adjust_speed(mtmp, 1);
+               mon_adjust_speed(mtmp, 1, otmp);
                return 2;
        case MUSE_POT_SPEED:
                mquaffmsg(mtmp, otmp);
@@ -1746,8 +1746,7 @@ skipmsg:
                   different methods of maintaining speed ratings:
                   player's character becomes "very fast" temporarily;
                   monster becomes "one stage faster" permanently */
-               if (oseen) makeknown(POT_SPEED);
-               mon_adjust_speed(mtmp, 1);
+               mon_adjust_speed(mtmp, 1, otmp);
                m_useup(mtmp, otmp);
                return 2;
        case MUSE_WAN_POLYMORPH:
index 7d392ba80d4071a9a1f3d2299ac66a15838fabac..cbf7b3f18c77804872108f7e7f4f4454447155a4 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)potion.c   3.4     2002/01/15      */
+/*     SCCS Id: @(#)potion.c   3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1058,7 +1058,7 @@ boolean your_fault;
                break;
        case POT_SPEED:
                angermon = FALSE;
-               mon_adjust_speed(mon, 1);
+               mon_adjust_speed(mon, 1, obj);
                break;
        case POT_BLINDNESS:
                if(haseyes(mon->data)) {
index 513161254d353222722530ee89bc84dce4fe0334..f4a448390c90406a0d7deaa4ed3add847ae06c5f 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)worn.c     3.4     2002/01/07      */
+/*     SCCS Id: @(#)worn.c     3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -141,17 +141,19 @@ struct monst *mon;
 }
 
 void
-mon_adjust_speed(mon, adjust)
+mon_adjust_speed(mon, adjust, obj)
 struct monst *mon;
 int adjust;    /* positive => increase speed, negative => decrease */
+struct obj *obj;       /* item to make known if effect can be seen */
 {
     struct obj *otmp;
-
+    boolean give_msg = !in_mklev;
     unsigned int oldspeed = mon->mspeed;
 
     switch (adjust) {
      case  2:
        mon->permspeed = MFAST;
+       give_msg = FALSE;       /* special case monster creation */
        break;
      case  1:
        if (mon->permspeed == MSLOW) mon->permspeed = 0;
@@ -165,6 +167,7 @@ int adjust; /* positive => increase speed, negative => decrease */
        break;
      case -2:
        mon->permspeed = MSLOW;
+       give_msg = FALSE;       /* (not currently used) */
        break;
     }
 
@@ -176,11 +179,21 @@ int adjust;       /* positive => increase speed, negative => decrease */
     else
        mon->mspeed = mon->permspeed;
 
-    if (!in_mklev && mon->mspeed != oldspeed && canseemon(mon)) {
-       if (adjust > 0)
-           pline("%s is suddenly moving faster.", Monnam(mon));
+    if (give_msg && mon->mspeed != oldspeed && canseemon(mon)) {
+       /* fast to slow (skipping intermediate state) or vice versa */
+       const char *howmuch = (mon->mspeed + oldspeed == MFAST + MSLOW) ?
+                               "much " : "";
+
+       if (adjust > 0 || mon->mspeed == MFAST)
+           pline("%s is suddenly moving %sfaster.", Monnam(mon), howmuch);
        else
-           pline("%s seems to be moving slower.", Monnam(mon));
+           pline("%s seems to be moving %sslower.", Monnam(mon), howmuch);
+
+       /* might discover an object if we see the speed change happen, but
+          avoid making possibly forgotten book known when casting its spell */
+       if (obj != 0 && obj->dknown &&
+               objects[obj->otyp].oc_class != SPBOOK_CLASS)
+           makeknown(obj->otyp);
     }
 }
 
@@ -205,7 +218,7 @@ boolean on;
            mon->minvis = !mon->invis_blkd;
            break;
         case FAST:
-           mon_adjust_speed(mon, 0);
+           mon_adjust_speed(mon, 0, obj);
            break;
        /* properties handled elsewhere */
         case ANTIMAGIC:
@@ -240,7 +253,7 @@ boolean on;
            mon->minvis = mon->perminvis;
            break;
         case FAST:
-           mon_adjust_speed(mon, 0);
+           mon_adjust_speed(mon, 0, obj);
            break;
         case FIRE_RES:
         case COLD_RES:
index 4d24c0daab691db64ac0fc2a96763ba5b9120295..204eeb6bd5f23f2636ae18a8487354a188b81ead 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)zap.c      3.4     2002/01/07      */
+/*     SCCS Id: @(#)zap.c      3.4     2002/02/07      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -139,7 +139,7 @@ struct obj *otmp;
        case WAN_SLOW_MONSTER:
        case SPE_SLOW_MONSTER:
                if (!resist(mtmp, otmp->oclass, 0, NOTELL)) {
-                       mon_adjust_speed(mtmp, -1);
+                       mon_adjust_speed(mtmp, -1, otmp);
                        m_dowear(mtmp, FALSE); /* might want speed boots */
                        if (u.uswallow && (mtmp == u.ustuck) &&
                            is_whirly(mtmp->data)) {
@@ -151,7 +151,7 @@ struct obj *otmp;
                break;
        case WAN_SPEED_MONSTER:
                if (!resist(mtmp, otmp->oclass, 0, NOTELL)) {
-                       mon_adjust_speed(mtmp, 1);
+                       mon_adjust_speed(mtmp, 1, otmp);
                        m_dowear(mtmp, FALSE); /* might want speed boots */
                }
                break;
@@ -609,7 +609,7 @@ register struct obj *obj;
                                       NO_MINVENT|MM_NOWAIT);
                        if (mtmp) {
                                mtmp->mhp = mtmp->mhpmax = 100;
-                               mon_adjust_speed(mtmp, 2);      /* MFAST */
+                               mon_adjust_speed(mtmp, 2, (struct obj *)0); /* MFAST */
                        }
                } else {
                    if (obj->oxlth && (obj->oattached == OATTACHED_MONST)) {