MCPcopy Create free account
hub / github.com/NetHack/NetHack / mbhitm

Function mbhitm

src/muse.c:1596–1703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1594}
1595
1596staticfn int
1597mbhitm(struct monst *mtmp, struct obj *otmp)
1598{
1599 int tmp;
1600 boolean reveal_invis = FALSE, learnit = FALSE,
1601 hits_you = (mtmp == &gy.youmonst);
1602
1603 if (!hits_you && otmp->otyp != WAN_UNDEAD_TURNING) {
1604 mtmp->msleeping = 0;
1605 if (mtmp->m_ap_type)
1606 seemimic(mtmp);
1607 }
1608 switch (otmp->otyp) {
1609 case WAN_STRIKING:
1610 reveal_invis = TRUE;
1611 if (hits_you) {
1612 if (Antimagic) {
1613 monstseesu(M_SEEN_MAGR); /* monsters notice hero resisting */
1614 shieldeff(u.ux, u.uy);
1615 Soundeffect(se_boing, 40);
1616 pline("Boing!");
1617 learnit = TRUE;
1618 } else if (rnd(20) < 10 + u.uac &&
1619 !(gb.buzzer && !gb.buzzer->mwandexp)) {
1620 monstunseesu(M_SEEN_MAGR); /* mons see hero not resisting */
1621 pline_The("wand hits you!");
1622 tmp = d(2, 12);
1623 if (Half_spell_damage)
1624 tmp = (tmp + 1) / 2;
1625 losehp(tmp, "wand", KILLED_BY_AN);
1626 learnit = TRUE;
1627 } else {
1628 pline_The("wand misses you.");
1629 }
1630 stop_occupation();
1631 nomul(0);
1632 } else if (resists_magm(mtmp)) {
1633 shieldeff(mtmp->mx, mtmp->my);
1634 Soundeffect(se_boing, 40);
1635 pline("Boing!");
1636 learnit = TRUE;
1637 } else if (rnd(20) < 10 + find_mac(mtmp)) {
1638 tmp = d(2, 12);
1639 hit("wand", mtmp, exclam(tmp));
1640 (void) resist(mtmp, otmp->oclass, tmp, TELL);
1641 learnit = TRUE;
1642 } else {
1643 miss("wand", mtmp);
1644 }
1645 /* need to see the wand being zapped and also the spot where the
1646 target is hit; don't have to see the target itself though */
1647 if (learnit && gz.zap_oseen && (hits_you
1648 || cansee(mtmp->mx, mtmp->my)))
1649 makeknown(WAN_STRIKING);
1650 break;
1651 case WAN_TELEPORTATION:
1652 if (hits_you) {
1653 tele();

Callers

nothing calls this directly

Calls 15

seemimicFunction · 0.85
monstseesuFunction · 0.85
shieldeffFunction · 0.85
rndFunction · 0.85
monstunseesuFunction · 0.85
pline_TheFunction · 0.85
dFunction · 0.85
losehpFunction · 0.85
stop_occupationFunction · 0.85
nomulFunction · 0.85
resists_magmFunction · 0.85
find_macFunction · 0.85

Tested by

no test coverage detected