diff --git a/include/extern.h b/include/extern.h index 879fcc7dd..84d61a8e1 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1782,6 +1782,7 @@ extern void mimic_hit_msg(struct monst *, short); extern void adj_erinys(unsigned); extern void see_monster_closeup(struct monst *) NONNULLARG1; extern void see_nearby_monsters(void); +extern void shieldeff_mon(struct monst *) NONNULLARG1; /* ### mondata.c ### */ diff --git a/src/mhitm.c b/src/mhitm.c index c92cb7d40..a65ed98d7 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1137,7 +1137,7 @@ mon_poly(struct monst *magr, struct monst *mdef, int dmg) if (resists_magm(mdef)) { /* Magic resistance */ if (gv.vis) - shieldeff(mdef->mx, mdef->my); + shieldeff_mon(mdef); } else if (resist(mdef, WAND_CLASS, 0, TELL)) { /* general resistance to magic... */ ; diff --git a/src/mon.c b/src/mon.c index 4767920d7..cf77dd8c6 100644 --- a/src/mon.c +++ b/src/mon.c @@ -5838,4 +5838,15 @@ see_nearby_monsters(void) } } +/* monster resists something. + make a shield effect at monster's location and give a message */ +void +shieldeff_mon(struct monst *mtmp) +{ + shieldeff(mtmp->mx, mtmp->my); + /* does not depend on seeing the monster; the shield effect is visible */ + if (cansee(mtmp->mx, mtmp->my)) + pline_xy(mtmp->mx, mtmp->my, "%s resists!", Monnam(mtmp)); +} + /*mon.c*/ diff --git a/src/trap.c b/src/trap.c index 64e185d32..d1be7d9b5 100644 --- a/src/trap.c +++ b/src/trap.c @@ -2444,7 +2444,7 @@ trapeffect_poly_trap( boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed); if (resists_magm(mtmp)) { - shieldeff(mtmp->mx, mtmp->my); + shieldeff_mon(mtmp); } else if (!resist(mtmp, WAND_CLASS, 0, NOTELL)) { (void) newcham(mtmp, (struct permonst *) 0, NC_SHOW_MSG); if (in_sight) diff --git a/src/zap.c b/src/zap.c index 00120647a..23fdac1be 100644 --- a/src/zap.c +++ b/src/zap.c @@ -265,7 +265,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) } else if (resists_magm(mtmp)) { /* magic resistance protects from polymorph traps, so make it guard against involuntary polymorph attacks too... */ - shieldeff(mtmp->mx, mtmp->my); + shieldeff_mon(mtmp); } else if (!resist(mtmp, otmp->oclass, 0, NOTELL)) { boolean polyspot = (otyp != POT_POLYMORPH), give_msg = (!Hallucination @@ -510,7 +510,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) if (otyp == SPE_DRAIN_LIFE) dmg = spell_damage_bonus(dmg); if (resists_drli(mtmp)) { - shieldeff(mtmp->mx, mtmp->my); + shieldeff_mon(mtmp); } else if (!resist(mtmp, otmp->oclass, dmg, NOTELL) && !DEADMONSTER(mtmp)) { mtmp->mhp -= dmg; @@ -6068,10 +6068,8 @@ resist(struct monst *mtmp, char oclass, int damage, int tell) resisted = rn2(100 + alev - dlev) < mtmp->data->mr; if (resisted) { - if (tell) { - shieldeff(mtmp->mx, mtmp->my); - pline("%s resists!", Monnam(mtmp)); - } + if (tell) + shieldeff_mon(mtmp); damage = (damage + 1) / 2; }