bhitm: monster mtmp was hit by the effect of wand or spell otmp */
| 157 | |
| 158 | /* bhitm: monster mtmp was hit by the effect of wand or spell otmp */ |
| 159 | int |
| 160 | bhitm(struct monst *mtmp, struct obj *otmp) |
| 161 | { |
| 162 | int ret = 0; |
| 163 | boolean wake = TRUE; /* Most 'zaps' should wake monster */ |
| 164 | boolean reveal_invis = FALSE, learn_it = FALSE; |
| 165 | boolean dbldam = Role_if(PM_KNIGHT) && u.uhave.questart; |
| 166 | boolean skilled_spell, helpful_gesture = FALSE; |
| 167 | int dmg, otyp = otmp->otyp; /* otmp is not NULL */ |
| 168 | const char *zap_type_text = "spell"; |
| 169 | struct obj *obj; |
| 170 | boolean disguised_mimic = (mtmp->data->mlet == S_MIMIC |
| 171 | && M_AP_TYPE(mtmp) != M_AP_NOTHING); |
| 172 | /* box_or_door(): mimic appearances that have locks */ |
| 173 | #define box_or_door(monst) \ |
| 174 | ((M_AP_TYPE(monst) == M_AP_OBJECT \ |
| 175 | && ((monst)->mappearance == CHEST \ |
| 176 | || (monst)->mappearance == LARGE_BOX)) \ |
| 177 | || (M_AP_TYPE(monst) == M_AP_FURNITURE \ |
| 178 | /* is_cmap_door() tests S_symbol values, and */ \ |
| 179 | /* mon->mappearance for furniture contains one of those */ \ |
| 180 | && is_cmap_door((monst)->mappearance))) |
| 181 | |
| 182 | if (engulfing_u(mtmp)) |
| 183 | reveal_invis = FALSE; |
| 184 | |
| 185 | gn.notonhead = (mtmp->mx != gb.bhitpos.x || mtmp->my != gb.bhitpos.y); |
| 186 | skilled_spell = (otmp->oclass == SPBOOK_CLASS && otmp->blessed); |
| 187 | |
| 188 | switch (otyp) { |
| 189 | case WAN_STRIKING: |
| 190 | zap_type_text = "wand"; |
| 191 | FALLTHROUGH; |
| 192 | /*FALLTHRU*/ |
| 193 | case SPE_FORCE_BOLT: |
| 194 | reveal_invis = TRUE; |
| 195 | learn_it = cansee(gb.bhitpos.x, gb.bhitpos.y); |
| 196 | if (resists_magm(mtmp)) { /* match effect on player */ |
| 197 | if (disguised_mimic && !disguised_as_mon(mtmp)) |
| 198 | seemimic(mtmp); |
| 199 | shieldeff(mtmp->mx, mtmp->my); |
| 200 | pline("Boing!"); |
| 201 | /* 5.0: used to 'break' to avoid setting learn_it here */ |
| 202 | } else if (u.uswallow || rnd(20) < 10 + find_mac(mtmp)) { |
| 203 | if (disguised_mimic) |
| 204 | seemimic(mtmp); |
| 205 | dmg = d(2, 12); |
| 206 | if (dbldam) |
| 207 | dmg *= 2; |
| 208 | if (otyp == SPE_FORCE_BOLT) |
| 209 | dmg = spell_damage_bonus(dmg); |
| 210 | hit(zap_type_text, mtmp, exclam(dmg)); |
| 211 | (void) resist(mtmp, otmp->oclass, dmg, TELL); |
| 212 | } else { |
| 213 | if (!disguised_mimic) |
| 214 | miss(zap_type_text, mtmp); |
| 215 | learn_it = FALSE; |
| 216 | } |
no test coverage detected