Permalink
Browse files

CS221: Tell apart real vampires and blood suckers

This defines is_vampiric() to allow selected non-vampire monsters to
suck blood like vampires. So far it does nothing different, since this
only includes vampire bats, which don't have a life-draining bite
anyway. Maybe it's used later.
  • Loading branch information...
1 parent fd45a79 commit 6d9c896440a45f4cb00d96230a62513676efd3e9 @tung committed Apr 29, 2012
Showing with 12 additions and 9 deletions.
  1. +3 −0 libnitrohack/include/mondata.h
  2. +1 −1 libnitrohack/src/dog.c
  3. +1 −1 libnitrohack/src/dogmove.c
  4. +5 −5 libnitrohack/src/eat.c
  5. +2 −2 libnitrohack/src/uhitm.c
@@ -81,6 +81,9 @@
#define is_were(ptr) (((ptr)->mflags2 & M2_WERE) != 0L)
#define is_vampire(ptr) ((ptr)->mlet == S_VAMPIRE || \
(ptr) == &mons[PM_VAMPIRE_BAT])
+/* feeds on blood */
+#define is_vampiric(ptr) (is_vampire(ptr) || \
+ (ptr) == &mons[PM_VAMPIRE_BAT])
#define is_elf(ptr) (((ptr)->mflags2 & M2_ELF) != 0L)
#define is_dwarf(ptr) (((ptr)->mflags2 & M2_DWARF) != 0L)
#define is_gnome(ptr) (((ptr)->mflags2 & M2_GNOME) != 0L)
View
@@ -645,7 +645,7 @@ int dogfood(struct monst *mon, struct obj *obj)
/* Vampires only "eat" very fresh corpses ... */
/* Assume meat -> blood */
- if (is_vampire(mon->data)) {
+ if (is_vampiric(mon->data)) {
return (obj->otyp == CORPSE &&
has_blood(&mons[obj->corpsenm]) && !obj->oeaten &&
peek_at_iced_corpse_age(obj) + 5 >= moves) ?
@@ -110,7 +110,7 @@ int dog_eat(struct monst *mtmp, struct obj *obj, int x, int y, boolean devour)
struct edog *edog = EDOG(mtmp);
boolean poly = FALSE, grow = FALSE, heal = FALSE;
int nutrit;
- boolean vampiric = is_vampire(mtmp->data);
+ boolean vampiric = is_vampiric(mtmp->data);
if (edog->hungrytime < moves)
edog->hungrytime = moves;
View
@@ -98,7 +98,7 @@ boolean is_edible(struct obj *obj)
/* Vampires drink the blood of meaty corpses. */
/* [ALI] (fully) drained food is not presented as an option,
but partly eaten food is (even though you can't drain it). */
- if (is_vampire(youmonst.data))
+ if (is_vampiric(youmonst.data))
return (boolean)(obj->otyp == CORPSE &&
has_blood(&mons[obj->corpsenm]) &&
(!obj->odrained || obj->oeaten > drainlevel(obj)));
@@ -349,7 +349,7 @@ static int eatfood(void) /* called each move during eating process */
do_reset_eat();
return 0;
}
- if (is_vampire(youmonst.data) != victual.piece->odrained) {
+ if (is_vampiric(youmonst.data) != victual.piece->odrained) {
/* polymorphed while eating/draining */
do_reset_eat();
return 0;
@@ -1153,7 +1153,7 @@ static int eatcorpse(struct obj *otmp)
* Thus happens before the conduct checks intentionally - should it be after?
* Blood is assumed to be meat and flesh.
*/
- if (is_vampire(youmonst.data)) {
+ if (is_vampiric(youmonst.data)) {
/* oeaten is set up by touchfood */
if (otmp->odrained ?
otmp->oeaten <= drainlevel(otmp) :
@@ -1252,7 +1252,7 @@ static int eatcorpse(struct obj *otmp)
if (!retcode) consume_oeaten(otmp, 2); /* oeaten >>= 2 */
if (retcode < 2 && otmp->odrained && otmp->oeaten < drainlevel(otmp))
otmp->oeaten = drainlevel(otmp);
- } else if (!is_vampire(youmonst.data)) {
+ } else if (!is_vampiric(youmonst.data)) {
pline("%s%s %s!",
!uniq ? "This " : !type_is_pname(&mons[mnum]) ? "The " : "",
food_xname(otmp, FALSE),
@@ -1900,7 +1900,7 @@ int doeat(struct obj *otmp) /* generic "eat" command funtion (see cmd.c) */
}
/* [ALI] Hero polymorphed in the meantime. */
- if (otmp == victual.piece && is_vampire(youmonst.data) != otmp->odrained)
+ if (otmp == victual.piece && is_vampiric(youmonst.data) != otmp->odrained)
victual.piece = NULL; /* can't resume */
/* [ALI] Blood can coagulate during the interruption
View
@@ -1613,7 +1613,7 @@ int damageum(struct monst *mdef, const struct attack *mattk)
if (!negated && !rn2(3) && !resists_drli(mdef)) {
int xtmp = dice(2,6);
if (mdef->mhp < xtmp) xtmp = mdef->mhp;
- if (maybe_polyd(is_vampire(youmonst.data),
+ if (maybe_polyd(is_vampiric(youmonst.data),
Race_if(PM_VAMPIRE)) &&
mattk->aatyp == AT_BITE &&
has_blood(pd)) {
@@ -2322,7 +2322,7 @@ int passive(struct monst *mon, boolean mhit, int malive, uchar aatyp)
const struct permonst *ptr = mon->data;
int i, tmp;
- if (mhit && aatyp == AT_BITE && is_vampire(youmonst.data)) {
+ if (mhit && aatyp == AT_BITE && is_vampiric(youmonst.data)) {
if (bite_monster(mon))
return 2; /* lifesaved */
}

0 comments on commit 6d9c896

Please sign in to comment.