return 0;
}
-DISABLE_WARNING_FORMAT_NONLITERAL
-
-/* Maybe give an intrinsic to monster from eating corpse that confers it. */
+/* give monster property prop */
void
-mon_givit(struct monst *mtmp, struct permonst *ptr)
+mon_give_prop(struct monst *mtmp, int prop)
{
- int prop = corpse_intrinsic(ptr);
- boolean vis = canseemon(mtmp);
const char *msg = NULL;
unsigned short intrinsic = 0; /* MR_* constant */
- if (ptr == &mons[PM_STALKER]) {
- /*
- * Invisible stalker isn't flagged as conferring invisibility
- * so prop is 0. For hero, eating a stalker corpse confers
- * temporary invisibility if hero is visible. When already
- * invisible, if confers permanent invisibilty and also
- * permanent see invisible. For monsters, only permanent
- * invisibility is possible; temporary invisibility and see
- * invisible aren't implemented for them.
- *
- * A monster being invisible gains no benefit against other
- * monsters, and an invisible pet when hero can't see invisible
- * is a nuisance at best, so this is probably detrimental.
- * Players will just have to live with it if they want to be
- * able to have pets gain intrinsics from eating corpses.
- */
- if (!mtmp->perminvis || mtmp->invis_blkd) {
- char mtmpbuf[BUFSZ];
-
- Strcpy(mtmpbuf, Monnam(mtmp));
- mon_set_minvis(mtmp);
- if (vis)
- pline("%s %s.", mtmpbuf,
- !canspotmon(mtmp) ? "vanishes"
- : mtmp->invis_blkd ? "seems to flicker"
- : "becomes invisible");
- }
- mtmp->mstun = 1; /* no timeout but will eventually wear off */
- return;
- }
-
- if (prop == 0)
- return; /* no intrinsic from this corpse */
-
- if (!should_givit(prop, ptr))
- return; /* failed die roll */
-
/* Pets don't have all the fields that the hero does, so they can't get all
the same intrinsics. If it happens to choose strength gain or teleport
control or whatever, ignore it. */
msg = "%s looks healthy.";
break;
default:
+ return; /* can't give it */
break;
}
if (intrinsic)
mtmp->mintrinsics |= intrinsic;
- if (vis && msg)
+ if (canseemon(mtmp) && msg) {
+ DISABLE_WARNING_FORMAT_NONLITERAL
pline(msg, Monnam(mtmp));
+ RESTORE_WARNING_FORMAT_NONLITERAL
+ }
}
-RESTORE_WARNING_FORMAT_NONLITERAL
+/* Maybe give an intrinsic to monster from eating corpse that confers it. */
+void
+mon_givit(struct monst *mtmp, struct permonst *ptr)
+{
+ int prop = corpse_intrinsic(ptr);
+ boolean vis = canseemon(mtmp);
+
+ if (ptr == &mons[PM_STALKER]) {
+ /*
+ * Invisible stalker isn't flagged as conferring invisibility
+ * so prop is 0. For hero, eating a stalker corpse confers
+ * temporary invisibility if hero is visible. When already
+ * invisible, if confers permanent invisibilty and also
+ * permanent see invisible. For monsters, only permanent
+ * invisibility is possible; temporary invisibility and see
+ * invisible aren't implemented for them.
+ *
+ * A monster being invisible gains no benefit against other
+ * monsters, and an invisible pet when hero can't see invisible
+ * is a nuisance at best, so this is probably detrimental.
+ * Players will just have to live with it if they want to be
+ * able to have pets gain intrinsics from eating corpses.
+ */
+ if (!mtmp->perminvis || mtmp->invis_blkd) {
+ char mtmpbuf[BUFSZ];
+
+ Strcpy(mtmpbuf, Monnam(mtmp));
+ mon_set_minvis(mtmp);
+ if (vis)
+ pline("%s %s.", mtmpbuf,
+ !canspotmon(mtmp) ? "vanishes"
+ : mtmp->invis_blkd ? "seems to flicker"
+ : "becomes invisible");
+ }
+ mtmp->mstun = 1; /* no timeout but will eventually wear off */
+ return;
+ }
+
+ if (prop == 0)
+ return; /* no intrinsic from this corpse */
+
+ if (!should_givit(prop, ptr))
+ return; /* failed die roll */
+
+ mon_give_prop(mtmp, prop);
+}
void
mpickgold(register struct monst* mtmp)
}
}
-/* remove a random INTRINSIC ability */
-void
+/* remove a random INTRINSIC ability from hero.
+ returns the intrinsic property which was removed,
+ or 0 if nothing was removed. */
+int
attrcurse(void)
{
+ int ret = 0;
+
switch (rnd(11)) {
case 1:
if (HFire_resistance & INTRINSIC) {
HFire_resistance &= ~INTRINSIC;
You_feel("warmer.");
+ ret = FIRE_RES;
break;
}
/*FALLTHRU*/
if (HTeleportation & INTRINSIC) {
HTeleportation &= ~INTRINSIC;
You_feel("less jumpy.");
+ ret = TELEPORT;
break;
}
/*FALLTHRU*/
if (HPoison_resistance & INTRINSIC) {
HPoison_resistance &= ~INTRINSIC;
You_feel("a little sick!");
+ ret = POISON_RES;
break;
}
/*FALLTHRU*/
if (Blind && !Blind_telepat)
see_monsters(); /* Can't sense mons anymore! */
Your("senses fail!");
+ ret = TELEPAT;
break;
}
/*FALLTHRU*/
if (HCold_resistance & INTRINSIC) {
HCold_resistance &= ~INTRINSIC;
You_feel("cooler.");
+ ret = COLD_RES;
break;
}
/*FALLTHRU*/
if (HInvis & INTRINSIC) {
HInvis &= ~INTRINSIC;
You_feel("paranoid.");
+ ret = INVIS;
break;
}
/*FALLTHRU*/
}
You("%s!", Hallucination ? "tawt you taw a puttie tat"
: "thought you saw something");
+ ret = SEE_INVIS;
break;
}
/*FALLTHRU*/
if (HFast & INTRINSIC) {
HFast &= ~INTRINSIC;
You_feel("slower.");
+ ret = FAST;
break;
}
/*FALLTHRU*/
if (HStealth & INTRINSIC) {
HStealth &= ~INTRINSIC;
You_feel("clumsy.");
+ ret = STEALTH;
break;
}
/*FALLTHRU*/
if (HProtection & INTRINSIC) {
HProtection &= ~INTRINSIC;
You_feel("vulnerable.");
+ ret = PROTECTION;
break;
}
/*FALLTHRU*/
if (HAggravate_monster & INTRINSIC) {
HAggravate_monster &= ~INTRINSIC;
You_feel("less attractive.");
+ ret = AGGRAVATE_MONSTER;
break;
}
/*FALLTHRU*/
default:
break;
}
+ return ret;
}
/*sit.c*/