* hitval returns an integer representing the "to hit" bonuses * of "otmp" against the monster. */
| 146 | * of "otmp" against the monster. |
| 147 | */ |
| 148 | int |
| 149 | hitval(struct obj *otmp, struct monst *mon) |
| 150 | { |
| 151 | int tmp = 0; |
| 152 | struct permonst *ptr = mon->data; |
| 153 | boolean Is_weapon = (otmp->oclass == WEAPON_CLASS || is_weptool(otmp)); |
| 154 | |
| 155 | if (Is_weapon) |
| 156 | tmp += otmp->spe; |
| 157 | |
| 158 | /* Put weapon-specific "to hit" bonuses in below: */ |
| 159 | tmp += objects[otmp->otyp].oc_hitbon; |
| 160 | |
| 161 | /* Put weapon vs. monster type "to hit" bonuses in below: */ |
| 162 | |
| 163 | /* Blessed weapons used against undead or demons */ |
| 164 | if (Is_weapon && otmp->blessed && mon_hates_blessings(mon)) |
| 165 | tmp += 2; |
| 166 | |
| 167 | if (is_spear(otmp) && strchr(kebabable, ptr->mlet)) |
| 168 | tmp += 2; |
| 169 | |
| 170 | /* trident is highly effective against swimmers */ |
| 171 | if (otmp->otyp == TRIDENT && is_swimmer(ptr)) { |
| 172 | if (is_pool(mon->mx, mon->my)) |
| 173 | tmp += 4; |
| 174 | else if (ptr->mlet == S_EEL || ptr->mlet == S_SNAKE) |
| 175 | tmp += 2; |
| 176 | } |
| 177 | |
| 178 | /* Picks used against xorns and earth elementals */ |
| 179 | if (is_pick(otmp) && (passes_walls(ptr) && thick_skinned(ptr))) |
| 180 | tmp += 2; |
| 181 | |
| 182 | /* Check specially named weapon "to hit" bonuses */ |
| 183 | if (otmp->oartifact) |
| 184 | tmp += spec_abon(otmp, mon); |
| 185 | |
| 186 | return tmp; |
| 187 | } |
| 188 | |
| 189 | /* Historical note: The original versions of Hack used a range of damage |
| 190 | * which was similar to, but not identical to, the damage used in Advanced |
no test coverage detected