used when hitting a monster with a lance while mounted; 1: joust hit; 0: ordinary hit; -1: joust but break lance */
| 2095 | /* used when hitting a monster with a lance while mounted; |
| 2096 | 1: joust hit; 0: ordinary hit; -1: joust but break lance */ |
| 2097 | staticfn int |
| 2098 | joust(struct monst *mon, /* target */ |
| 2099 | struct obj *obj) /* weapon */ |
| 2100 | { |
| 2101 | int skill_rating, joust_dieroll; |
| 2102 | |
| 2103 | if (Fumbling || Stunned) |
| 2104 | return 0; |
| 2105 | /* sanity check; lance must be wielded in order to joust */ |
| 2106 | if (obj != uwep && (obj != uswapwep || !u.twoweap)) |
| 2107 | return 0; |
| 2108 | /* can't joust while trapped--not enough room to maneuver; |
| 2109 | * TODO? if the steed is trapped in a pit, perhaps the hero ought to be |
| 2110 | * able to joust against a monster that's in a conjoined pit */ |
| 2111 | if (u.utrap) |
| 2112 | return 0; |
| 2113 | |
| 2114 | /* if using two weapons, use worse of lance and two-weapon skills */ |
| 2115 | skill_rating = P_SKILL(weapon_type(obj)); /* lance skill */ |
| 2116 | if (u.twoweap && P_SKILL(P_TWO_WEAPON_COMBAT) < skill_rating) |
| 2117 | skill_rating = P_SKILL(P_TWO_WEAPON_COMBAT); |
| 2118 | if (skill_rating == P_ISRESTRICTED) |
| 2119 | skill_rating = P_UNSKILLED; /* 0=>1 */ |
| 2120 | |
| 2121 | /* odds to joust are expert:80%, skilled:60%, basic:40%, unskilled:20% */ |
| 2122 | if ((joust_dieroll = rn2(5)) < skill_rating) { |
| 2123 | if (joust_dieroll == 0 && rnl(50) == (50 - 1) && !unsolid(mon->data) |
| 2124 | && !obj_resists(obj, 0, 100)) |
| 2125 | return -1; /* hit that breaks lance */ |
| 2126 | return 1; /* successful joust */ |
| 2127 | } |
| 2128 | return 0; /* no joust bonus; revert to ordinary attack */ |
| 2129 | } |
| 2130 | |
| 2131 | /* send in a demon pet for the hero; exercise wisdom */ |
| 2132 | staticfn void |
no test coverage detected