hit target monster; returns TRUE if it still lives */
| 755 | |
| 756 | /* hit target monster; returns TRUE if it still lives */ |
| 757 | staticfn boolean |
| 758 | hitum(struct monst *mon, struct attack *uattk) |
| 759 | { |
| 760 | boolean malive, wep_was_destroyed = FALSE; |
| 761 | struct obj *wepbefore = uwep, |
| 762 | *secondwep = u.twoweap ? uswapwep : (struct obj *) 0; |
| 763 | int tmp, dieroll, mhit, armorpenalty, attknum = 0, |
| 764 | x = u.ux + u.dx, y = u.uy + u.dy, oldumort = u.umortality; |
| 765 | |
| 766 | /* Cleaver attacks three spots, 'mon' and one on either side of 'mon'; |
| 767 | it can't be part of dual-wielding but we guard against that anyway; |
| 768 | cleave return value reflects status of primary target ('mon') */ |
| 769 | if (u_wield_art(ART_CLEAVER) && !u.twoweap |
| 770 | && !u.uswallow && !u.ustuck && !NODIAG(u.umonnum)) |
| 771 | return hitum_cleave(mon, uattk); |
| 772 | |
| 773 | /* 0: single hit, 1: first of two hits; affects strength bonus and |
| 774 | silver rings; known_hitum() -> hmon() -> hmon_hitmon() will copy |
| 775 | gt.twohits into struct _hitmon_data hmd.twohits */ |
| 776 | gt.twohits = (uwep ? u.twoweap : double_punch()) ? 1 : 0; |
| 777 | |
| 778 | tmp = find_roll_to_hit(mon, uattk->aatyp, uwep, &attknum, &armorpenalty); |
| 779 | mon_maybe_unparalyze(mon); |
| 780 | dieroll = rnd(20); |
| 781 | mhit = (tmp > dieroll || u.uswallow); |
| 782 | if (tmp > dieroll) |
| 783 | exercise(A_DEX, TRUE); |
| 784 | |
| 785 | /* gb.bhitpos is set up by caller */ |
| 786 | malive = known_hitum(mon, uwep, &mhit, tmp, armorpenalty, uattk, dieroll); |
| 787 | if (wepbefore && !uwep) |
| 788 | wep_was_destroyed = TRUE; |
| 789 | (void) passive(mon, uwep, mhit, malive, AT_WEAP, wep_was_destroyed); |
| 790 | |
| 791 | /* second attack for two-weapon combat or skilled unarmed combat; |
| 792 | won't occur if Stormbringer overrode confirmation (assumes |
| 793 | Stormbringer is primary weapon), or if hero became paralyzed by |
| 794 | passive counter-attack, or if hero was killed by passive |
| 795 | counter-attack and got life-saved, or if monster was killed or |
| 796 | knocked to different location */ |
| 797 | if (gt.twohits && !(go.override_confirmation |
| 798 | || gm.multi < 0 || u.umortality > oldumort |
| 799 | || !malive || m_at(x, y) != mon)) { |
| 800 | gt.twohits = 2; /* second of 2 hits */ |
| 801 | tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum, |
| 802 | &armorpenalty); |
| 803 | mon_maybe_unparalyze(mon); |
| 804 | dieroll = rnd(20); |
| 805 | mhit = (tmp > dieroll || u.uswallow); |
| 806 | malive = known_hitum(mon, secondwep, &mhit, tmp, armorpenalty, uattk, |
| 807 | dieroll); |
| 808 | /* second passive counter-attack only occurs if second attack hits */ |
| 809 | if (mhit) |
| 810 | (void) passive(mon, secondwep, mhit, malive, AT_WEAP, |
| 811 | secondwep && !uswapwep); |
| 812 | } |
| 813 | gt.twohits = 0; |
| 814 | return malive; |
no test coverage detected