potion obj hits monster mon, which might be youmonst; obj always used up */
| 1622 | |
| 1623 | /* potion obj hits monster mon, which might be youmonst; obj always used up */ |
| 1624 | void |
| 1625 | potionhit(struct monst *mon, struct obj *obj, int how) |
| 1626 | { |
| 1627 | const char *botlnam = bottlename(); |
| 1628 | boolean isyou = (mon == &gy.youmonst); |
| 1629 | int distance, tx, ty; |
| 1630 | struct obj *saddle = (struct obj *) 0; |
| 1631 | boolean hit_saddle = FALSE, your_fault = (how <= POTHIT_HERO_THROW); |
| 1632 | |
| 1633 | if (isyou) { |
| 1634 | tx = u.ux, ty = u.uy; |
| 1635 | distance = 0; |
| 1636 | pline_The("%s crashes on your %s and breaks into shards.", botlnam, |
| 1637 | body_part(HEAD)); |
| 1638 | losehp(Maybe_Half_Phys(rnd(2)), |
| 1639 | (how == POTHIT_OTHER_THROW) ? "propelled potion" /* scatter */ |
| 1640 | : "thrown potion", |
| 1641 | KILLED_BY_AN); |
| 1642 | } else { |
| 1643 | tx = mon->mx, ty = mon->my; |
| 1644 | /* sometimes it hits the saddle */ |
| 1645 | if (((mon->misc_worn_check & W_SADDLE) |
| 1646 | && (saddle = which_armor(mon, W_SADDLE))) |
| 1647 | && (!rn2(10) |
| 1648 | || (obj->otyp == POT_WATER |
| 1649 | && ((rnl(10) > 7 && obj->cursed) |
| 1650 | || (rnl(10) < 4 && obj->blessed) || !rn2(3))))) |
| 1651 | hit_saddle = TRUE; |
| 1652 | distance = distu(tx, ty); |
| 1653 | if (!cansee(tx, ty)) { |
| 1654 | Soundeffect(se_potion_crash_and_break, 60); |
| 1655 | pline("Crash!"); |
| 1656 | } else { |
| 1657 | char *mnam = mon_nam(mon); |
| 1658 | char buf[BUFSZ]; |
| 1659 | |
| 1660 | if (hit_saddle && saddle) { |
| 1661 | Sprintf(buf, "%s saddle", |
| 1662 | s_suffix(x_monnam(mon, ARTICLE_THE, (char *) 0, |
| 1663 | (SUPPRESS_IT | SUPPRESS_SADDLE), |
| 1664 | FALSE))); |
| 1665 | } else if (has_head(mon->data)) { |
| 1666 | Sprintf(buf, "%s %s", s_suffix(mnam), |
| 1667 | (gn.notonhead ? "body" : "head")); |
| 1668 | } else { |
| 1669 | Strcpy(buf, mnam); |
| 1670 | } |
| 1671 | Soundeffect(se_potion_crash_and_break, 60); |
| 1672 | pline_The("%s crashes on %s and breaks into shards.", botlnam, |
| 1673 | buf); |
| 1674 | } |
| 1675 | if (rn2(5) && mon->mhp > 1 && !hit_saddle) |
| 1676 | mon->mhp--; |
| 1677 | } |
| 1678 | |
| 1679 | /* oil doesn't instantly evaporate; Neither does a saddle hit */ |
| 1680 | if (obj->otyp != POT_OIL && !hit_saddle && cansee(tx, ty)) |
| 1681 | pline("%s.", Tobjnam(obj, "evaporate")); |
no test coverage detected