blessed objects vs vulnerable creatures

Collect creatures that don't like being hit by blessed objects in one
place.  No change in behavior.
This commit is contained in:
PatR
2022-01-21 13:19:57 -08:00
parent 182abe6b60
commit aab21eba95
5 changed files with 37 additions and 25 deletions

View File

@@ -1534,8 +1534,10 @@ extern boolean resists_magm(struct monst *);
extern boolean resists_blnd(struct monst *); extern boolean resists_blnd(struct monst *);
extern boolean can_blnd(struct monst *, struct monst *, uchar, struct obj *); extern boolean can_blnd(struct monst *, struct monst *, uchar, struct obj *);
extern boolean ranged_attk(struct permonst *); extern boolean ranged_attk(struct permonst *);
extern boolean hates_silver(struct permonst *);
extern boolean mon_hates_silver(struct monst *); extern boolean mon_hates_silver(struct monst *);
extern boolean hates_silver(struct permonst *);
extern boolean mon_hates_blessings(struct monst *);
extern boolean hates_blessings(struct permonst *);
extern boolean mon_hates_light(struct monst *); extern boolean mon_hates_light(struct monst *);
extern boolean passes_bars(struct permonst *); extern boolean passes_bars(struct permonst *);
extern boolean can_blow(struct monst *); extern boolean can_blow(struct monst *);

View File

@@ -1028,7 +1028,7 @@ hitmu(register struct monst *mtmp, register struct attack *mattk)
/* First determine the base damage done */ /* First determine the base damage done */
mhm.damage = d((int) mattk->damn, (int) mattk->damd); mhm.damage = d((int) mattk->damn, (int) mattk->damd);
if ((is_undead(mdat) || is_vampshifter(mtmp)) && midnight()) if ((is_undead(mdat) || is_vampshifter(mtmp)) && midnight())
mhm.damage += d((int) mattk->damn, (int) mattk->damd); /* extra damage */ mhm.damage += d((int) mattk->damn, (int) mattk->damd); /* extra dmg */
mhitm_adtyping(mtmp, mattk, &g.youmonst, &mhm); mhitm_adtyping(mtmp, mattk, &g.youmonst, &mhm);
if (mhm.done) if (mhm.done)
@@ -1051,10 +1051,9 @@ hitmu(register struct monst *mtmp, register struct attack *mattk)
if (mhm.damage) { if (mhm.damage) {
if (Half_physical_damage if (Half_physical_damage
/* Mitre of Holiness */ /* Mitre of Holiness, even if not currently blessed */
|| (Role_if(PM_CLERIC) && uarmh && is_quest_artifact(uarmh) || (Role_if(PM_CLERIC) && uarmh && is_quest_artifact(uarmh)
&& (is_undead(mtmp->data) || is_demon(mtmp->data) && mon_hates_blessings(mtmp)))
|| is_vampshifter(mtmp))))
mhm.damage = (mhm.damage + 1) / 2; mhm.damage = (mhm.damage + 1) / 2;
if (mhm.permdmg) { /* Death's life force drain */ if (mhm.permdmg) { /* Death's life force drain */

View File

@@ -327,30 +327,44 @@ ranged_attk(struct permonst* ptr)
/* True if specific monster is especially affected by silver weapons */ /* True if specific monster is especially affected by silver weapons */
boolean boolean
mon_hates_silver(struct monst* mon) mon_hates_silver(struct monst *mon)
{ {
return (boolean) (is_vampshifter(mon) || hates_silver(mon->data)); return (boolean) (is_vampshifter(mon) || hates_silver(mon->data));
} }
/* True if monster-type is especially affected by silver weapons */ /* True if monster-type is especially affected by silver weapons */
boolean boolean
hates_silver(register struct permonst* ptr) hates_silver(struct permonst *ptr)
{ {
return (boolean) (is_were(ptr) || ptr->mlet == S_VAMPIRE || is_demon(ptr) return (boolean) (is_were(ptr) || ptr->mlet == S_VAMPIRE || is_demon(ptr)
|| ptr == &mons[PM_SHADE] || ptr == &mons[PM_SHADE]
|| (ptr->mlet == S_IMP && ptr != &mons[PM_TENGU])); || (ptr->mlet == S_IMP && ptr != &mons[PM_TENGU]));
} }
/* True if specific monster is especially affected by blessed objects */
boolean
mon_hates_blessings(struct monst *mon)
{
return (boolean) (is_vampshifter(mon) || hates_blessings(mon->data));
}
/* True if monster-type is especially affected by blessed objects */
boolean
hates_blessings(struct permonst *ptr)
{
return (boolean) (is_undead(ptr) || is_demon(ptr));
}
/* True if specific monster is especially affected by light-emitting weapons */ /* True if specific monster is especially affected by light-emitting weapons */
boolean boolean
mon_hates_light(struct monst* mon) mon_hates_light(struct monst *mon)
{ {
return (boolean) (hates_light(mon->data)); return (boolean) hates_light(mon->data);
} }
/* True iff the type of monster pass through iron bars */ /* True iff the type of monster pass through iron bars */
boolean boolean
passes_bars(struct permonst* mptr) passes_bars(struct permonst *mptr)
{ {
return (boolean) (passes_walls(mptr) || amorphous(mptr) || unsolid(mptr) return (boolean) (passes_walls(mptr) || amorphous(mptr) || unsolid(mptr)
|| is_whirly(mptr) || verysmall(mptr) || is_whirly(mptr) || verysmall(mptr)

View File

@@ -678,7 +678,7 @@ peffect_water(struct obj *otmp)
return; return;
} }
g.potion_unkn++; g.potion_unkn++;
if (is_undead(g.youmonst.data) || is_demon(g.youmonst.data) if (mon_hates_blessings(&g.youmonst) /* undead or demon */
|| u.ualign.type == A_CHAOTIC) { || u.ualign.type == A_CHAOTIC) {
if (otmp->blessed) { if (otmp->blessed) {
pline("This burns like %s!", hliquid("acid")); pline("This burns like %s!", hliquid("acid"));
@@ -1725,7 +1725,7 @@ potionhit(struct monst *mon, struct obj *obj, int how)
} }
break; break;
case POT_WATER: case POT_WATER:
if (is_undead(mon->data) || is_demon(mon->data) if (mon_hates_blessings(mon) /* undead or demon */
|| is_were(mon->data) || is_vampshifter(mon)) { || is_were(mon->data) || is_vampshifter(mon)) {
if (obj->blessed) { if (obj->blessed) {
pline("%s %s in pain!", Monnam(mon), pline("%s %s in pain!", Monnam(mon),

View File

@@ -159,8 +159,7 @@ hitval(struct obj *otmp, struct monst *mon)
/* Put weapon vs. monster type "to hit" bonuses in below: */ /* Put weapon vs. monster type "to hit" bonuses in below: */
/* Blessed weapons used against undead or demons */ /* Blessed weapons used against undead or demons */
if (Is_weapon && otmp->blessed if (Is_weapon && otmp->blessed && mon_hates_blessings(mon))
&& (is_demon(ptr) || is_undead(ptr) || is_vampshifter(mon)))
tmp += 2; tmp += 2;
if (is_spear(otmp) && index(kebabable, ptr->mlet)) if (is_spear(otmp) && index(kebabable, ptr->mlet))
@@ -322,8 +321,7 @@ dmgval(struct obj *otmp, struct monst *mon)
|| otmp->oclass == CHAIN_CLASS) { || otmp->oclass == CHAIN_CLASS) {
int bonus = 0; int bonus = 0;
if (otmp->blessed if (otmp->blessed && mon_hates_blessings(mon))
&& (is_undead(ptr) || is_demon(ptr) || is_vampshifter(mon)))
bonus += rnd(4); bonus += rnd(4);
if (is_axe(otmp) && is_wooden(ptr)) if (is_axe(otmp) && is_wooden(ptr))
bonus += rnd(4); bonus += rnd(4);
@@ -357,15 +355,15 @@ dmgval(struct obj *otmp, struct monst *mon)
/* check whether blessed and/or silver damage applies for *non-weapon* hit; /* check whether blessed and/or silver damage applies for *non-weapon* hit;
return value is the amount of the extra damage */ return value is the amount of the extra damage */
int int
special_dmgval(struct monst *magr, special_dmgval(
struct monst *mdef, struct monst *magr, /* attacker */
long armask, /* armor mask, multiple bits accepted for struct monst *mdef, /* defender */
W_ARMC|W_ARM|W_ARMU or long armask, /* armor mask, multiple bits accepted for
W_ARMG|W_RINGL|W_RINGR only */ * W_ARMC|W_ARM|W_ARMU or
long *silverhit_p) /* output flag mask for silver bonus */ * W_ARMG|W_RINGL|W_RINGR only */
long *silverhit_p) /* output flag mask for silver bonus */
{ {
struct obj *obj; struct obj *obj;
struct permonst *ptr = mdef->data;
boolean left_ring = (armask & W_RINGL) ? TRUE : FALSE, boolean left_ring = (armask & W_RINGL) ? TRUE : FALSE,
right_ring = (armask & W_RINGR) ? TRUE : FALSE; right_ring = (armask & W_RINGR) ? TRUE : FALSE;
long silverhit = 0L; long silverhit = 0L;
@@ -391,8 +389,7 @@ special_dmgval(struct monst *magr,
} }
if (obj) { if (obj) {
if (obj->blessed if (obj->blessed && mon_hates_blessings(mdef))
&& (is_undead(ptr) || is_demon(ptr) || is_vampshifter(mdef)))
bonus += rnd(4); bonus += rnd(4);
/* the only silver armor is shield of reflection (silver dragon /* the only silver armor is shield of reflection (silver dragon
scales refer to color, not material) and the only way to hit scales refer to color, not material) and the only way to hit