reconcile toss_up() with hmon_hitmon()

Throwing silver or blessed non-weapons upward and having them fall
back onto susceptible hero's head wasn't adding the extra bonus damage
that a weapon would get in that situation.

Make hitting vulnerable monsters with blessed just-about-anything get
the 1d4 bonus that blessed weapons get for that.  Doesn't apply to
things that have their own special handing, like potions or eggs.
This commit is contained in:
PatR
2022-01-21 13:37:33 -08:00
parent aab21eba95
commit afc2e1592d
2 changed files with 26 additions and 11 deletions
+22 -9
View File
@@ -1097,7 +1097,8 @@ static boolean
toss_up(struct obj *obj, boolean hitsroof) toss_up(struct obj *obj, boolean hitsroof)
{ {
const char *action; const char *action;
boolean petrifier = ((obj->otyp == EGG || obj->otyp == CORPSE) int otyp = obj->otyp;
boolean petrifier = ((otyp == EGG || otyp == CORPSE)
&& touch_petrifies(&mons[obj->corpsenm])); && touch_petrifies(&mons[obj->corpsenm]));
/* note: obj->quan == 1 */ /* note: obj->quan == 1 */
@@ -1122,7 +1123,6 @@ toss_up(struct obj *obj, boolean hitsroof)
if (obj->oclass == POTION_CLASS) { if (obj->oclass == POTION_CLASS) {
potionhit(&g.youmonst, obj, POTHIT_HERO_THROW); potionhit(&g.youmonst, obj, POTHIT_HERO_THROW);
} else if (breaktest(obj)) { } else if (breaktest(obj)) {
int otyp = obj->otyp;
int blindinc; int blindinc;
/* need to check for blindness result prior to destroying obj */ /* need to check for blindness result prior to destroying obj */
@@ -1167,7 +1167,10 @@ toss_up(struct obj *obj, boolean hitsroof)
hitfloor(obj, FALSE); hitfloor(obj, FALSE);
g.thrownobj = 0; g.thrownobj = 0;
} else { /* neither potion nor other breaking object */ } else { /* neither potion nor other breaking object */
boolean less_damage = uarmh && is_metallic(uarmh), artimsg = FALSE; boolean is_silver = (objects[otyp].oc_material == SILVER),
less_damage = (uarmh && is_metallic(uarmh)
&& (!is_silver || !Hate_silver)),
artimsg = FALSE;
int dmg = dmgval(obj, &g.youmonst); int dmg = dmgval(obj, &g.youmonst);
if (obj->oartifact) if (obj->oartifact)
@@ -1176,14 +1179,22 @@ toss_up(struct obj *obj, boolean hitsroof)
rn1(18, 2)); rn1(18, 2));
if (!dmg) { /* probably wasn't a weapon; base damage on weight */ if (!dmg) { /* probably wasn't a weapon; base damage on weight */
dmg = (int) obj->owt / 100; dmg = ((int) obj->owt + 99) / 100;
if (dmg < 1) dmg = (dmg <= 1) ? 1 : rnd(dmg);
dmg = 1; if (dmg > 6)
else if (dmg > 6)
dmg = 6; dmg = 6;
if (g.youmonst.data == &mons[PM_SHADE] /* since obj is a non-weapon, bonuses for silver and blessed
&& objects[obj->otyp].oc_material != SILVER) haven't been applied (otherwise '!dmg' test will fail when
they're applicable here); we don't have to worry about
dmgval()'s artifact light against gremlin or axe against
woody creature since both involve weapons; hero-as-shade is
hypothetical because hero can't polymorph into that form */
if (g.youmonst.data == &mons[PM_SHADE] && !is_silver)
dmg = 0; dmg = 0;
if (obj->blessed && mon_hates_blessings(&g.youmonst))
dmg += rnd(4);
if (is_silver && Hate_silver)
dmg += rnd(20);
} }
if (dmg > 1 && less_damage) if (dmg > 1 && less_damage)
dmg = 1; dmg = 1;
@@ -1216,6 +1227,8 @@ toss_up(struct obj *obj, boolean hitsroof)
done(STONING); done(STONING);
return obj ? TRUE : FALSE; return obj ? TRUE : FALSE;
} }
if (is_silver && Hate_silver)
pline_The("silver sears you!");
hitfloor(obj, TRUE); hitfloor(obj, TRUE);
g.thrownobj = 0; g.thrownobj = 0;
losehp(dmg, "falling object", KILLED_BY_AN); losehp(dmg, "falling object", KILLED_BY_AN);
+4 -2
View File
@@ -1166,13 +1166,15 @@ hmon_hitmon(struct monst *mon,
until after hit message */ until after hit message */
dryit = (rn2(obj->spe + 1) > 0); dryit = (rn2(obj->spe + 1) > 0);
} }
/* things like silver wands can arrive here so /* things like silver wands can arrive here so we
so we need another silver check */ need another silver check; blessed check too */
if (objects[obj->otyp].oc_material == SILVER if (objects[obj->otyp].oc_material == SILVER
&& mon_hates_silver(mon)) { && mon_hates_silver(mon)) {
tmp += rnd(20); tmp += rnd(20);
silvermsg = silverobj = TRUE; silvermsg = silverobj = TRUE;
} }
if (obj->blessed && mon_hates_blessings(mon))
tmp += rnd(4);
} }
} }
} }