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.
This commit is contained in:
nethack.rankin
2002-02-08 04:14:03 +00:00
parent 80a0fbd62b
commit f750e2df4e
10 changed files with 43 additions and 32 deletions

View 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));

View 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 = "";

View 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)

View 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:

View 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));
}

View File

@@ -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) {

View 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:

View 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)) {

View 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:

View File

@@ -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)) {