From: nethack.rankin Date: Fri, 8 Feb 2002 04:14:03 +0000 (+0000) Subject: fix B3032 -- wand of speed monster id X-Git-Tag: MOVE2GIT~3228 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f750e2df4e733f09e3cca6ae2ef040b7f7c620a2;p=nethack fix B3032 -- wand of speed monster id 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. --- diff --git a/include/extern.h b/include/extern.h index 952161966..07621933a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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)); diff --git a/src/apply.c b/src/apply.c index d4b1bc380..0f6a83f71 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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 = ""; diff --git a/src/makemon.c b/src/makemon.c index 5f8434fbb..21012ec4b 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -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) diff --git a/src/mcastu.c b/src/mcastu.c index 56e690f94..921fb7aaf 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -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: diff --git a/src/mhitm.c b/src/mhitm.c index fbfef17de..0b36cead7 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -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)); } diff --git a/src/mon.c b/src/mon.c index 0b6e3cfc0..af9253cdd 100644 --- 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) { diff --git a/src/muse.c b/src/muse.c index 24c45096f..97d1b03ec 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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: diff --git a/src/potion.c b/src/potion.c index 7d392ba80..cbf7b3f18 100644 --- a/src/potion.c +++ b/src/potion.c @@ -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)) { diff --git a/src/worn.c b/src/worn.c index 513161254..f4a448390 100644 --- a/src/worn.c +++ b/src/worn.c @@ -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: diff --git a/src/zap.c b/src/zap.c index 4d24c0daa..204eeb6bd 100644 --- 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)) {