check whether blessed and/or silver damage applies for *non-weapon* hit; return value is the amount of the extra damage */
| 358 | /* check whether blessed and/or silver damage applies for *non-weapon* hit; |
| 359 | return value is the amount of the extra damage */ |
| 360 | int |
| 361 | special_dmgval( |
| 362 | struct monst *magr, /* attacker */ |
| 363 | struct monst *mdef, /* defender */ |
| 364 | long armask, /* armor mask, multiple bits accepted for |
| 365 | * W_ARMC|W_ARM|W_ARMU or |
| 366 | * W_ARMG|W_RINGL|W_RINGR only */ |
| 367 | long *silverhit_p) /* output flag mask for silver bonus */ |
| 368 | { |
| 369 | struct obj *obj; |
| 370 | boolean left_ring = (armask & W_RINGL) ? TRUE : FALSE, |
| 371 | right_ring = (armask & W_RINGR) ? TRUE : FALSE; |
| 372 | long silverhit = 0L; |
| 373 | int bonus = 0; |
| 374 | |
| 375 | obj = 0; |
| 376 | if (armask & (W_ARMC | W_ARM | W_ARMU)) { |
| 377 | if ((armask & W_ARMC) != 0L |
| 378 | && (obj = which_armor(magr, W_ARMC)) != 0) |
| 379 | armask = W_ARMC; |
| 380 | else if ((armask & W_ARM) != 0L |
| 381 | && (obj = which_armor(magr, W_ARM)) != 0) |
| 382 | armask = W_ARM; |
| 383 | else if ((armask & W_ARMU) != 0L |
| 384 | && (obj = which_armor(magr, W_ARMU)) != 0) |
| 385 | armask = W_ARMU; |
| 386 | else |
| 387 | armask = 0L; |
| 388 | } else if (armask & (W_ARMG | W_RINGL | W_RINGR)) { |
| 389 | armask = ((obj = which_armor(magr, W_ARMG)) != 0) ? W_ARMG : 0L; |
| 390 | } else { |
| 391 | obj = which_armor(magr, armask); |
| 392 | } |
| 393 | |
| 394 | if (obj) { |
| 395 | if (obj->blessed && mon_hates_blessings(mdef)) |
| 396 | bonus += rnd(4); |
| 397 | /* the only silver armor is shield of reflection (silver dragon |
| 398 | scales refer to color, not material) and the only way to hit |
| 399 | with one--aside from throwing--is to wield it and perform a |
| 400 | weapon hit, but we include a general check here */ |
| 401 | if (objects[obj->otyp].oc_material == SILVER |
| 402 | && mon_hates_silver(mdef)) { |
| 403 | bonus += rnd(20); |
| 404 | silverhit |= armask; |
| 405 | } |
| 406 | |
| 407 | /* when no gloves we check for silver rings (blessed rings ignored) */ |
| 408 | } else if ((left_ring || right_ring) && magr == &gy.youmonst) { |
| 409 | if (left_ring && uleft) { |
| 410 | if (objects[uleft->otyp].oc_material == SILVER |
| 411 | && mon_hates_silver(mdef)) { |
| 412 | bonus += rnd(20); |
| 413 | silverhit |= W_RINGL; |
| 414 | } |
| 415 | } |
| 416 | if (right_ring && uright) { |
| 417 | if (objects[uright->otyp].oc_material == SILVER |
no test coverage detected