called when someone is being hit by Magicbane */
| 1246 | |
| 1247 | /* called when someone is being hit by Magicbane */ |
| 1248 | staticfn boolean |
| 1249 | Mb_hit(struct monst *magr, /* attacker */ |
| 1250 | struct monst *mdef, /* defender */ |
| 1251 | struct obj *mb, /* Magicbane */ |
| 1252 | int *dmgptr, /* extra damage target will suffer */ |
| 1253 | int dieroll, /* d20 that has already scored a hit */ |
| 1254 | boolean vis, /* whether the action can be seen */ |
| 1255 | char *hittee) /* target's name: "you" or mon_nam(mdef) */ |
| 1256 | { |
| 1257 | struct permonst *old_mdat; |
| 1258 | const char *verb; |
| 1259 | boolean youattack = (magr == &gy.youmonst), |
| 1260 | youdefend = (mdef == &gy.youmonst), |
| 1261 | resisted = FALSE, do_stun, do_confuse, result; |
| 1262 | int attack_indx, fakeidx, scare_dieroll = MB_MAX_DIEROLL / 2; |
| 1263 | |
| 1264 | result = FALSE; /* no message given yet */ |
| 1265 | /* the most severe effects are less likely at higher enchantment */ |
| 1266 | if (mb->spe >= 3) |
| 1267 | scare_dieroll /= (1 << (mb->spe / 3)); |
| 1268 | /* if target successfully resisted the artifact damage bonus, |
| 1269 | reduce overall likelihood of the assorted special effects */ |
| 1270 | if (!gs.spec_dbon_applies) |
| 1271 | dieroll += 1; |
| 1272 | |
| 1273 | /* might stun even when attempting a more severe effect, but |
| 1274 | in that case it will only happen if the other effect fails; |
| 1275 | extra damage will apply regardless; 3.4.1: sometimes might |
| 1276 | just probe even when it hasn't been enchanted */ |
| 1277 | do_stun = (max(mb->spe, 0) < rn2(gs.spec_dbon_applies ? 11 : 7)); |
| 1278 | |
| 1279 | /* the special effects also boost physical damage; increments are |
| 1280 | generally cumulative, but since the stun effect is based on a |
| 1281 | different criterium its damage might not be included; the base |
| 1282 | damage is either 1d4 (athame) or 2d4 (athame+spec_dbon) depending |
| 1283 | on target's resistance check against AD_STUN (handled by caller) |
| 1284 | [note that a successful save against AD_STUN doesn't actually |
| 1285 | prevent the target from ending up stunned] */ |
| 1286 | attack_indx = MB_INDEX_PROBE; |
| 1287 | *dmgptr += rnd(4); /* (2..3)d4 */ |
| 1288 | if (do_stun) { |
| 1289 | attack_indx = MB_INDEX_STUN; |
| 1290 | *dmgptr += rnd(4); /* (3..4)d4 */ |
| 1291 | } |
| 1292 | if (dieroll <= scare_dieroll) { |
| 1293 | attack_indx = MB_INDEX_SCARE; |
| 1294 | *dmgptr += rnd(4); /* (3..5)d4 */ |
| 1295 | } |
| 1296 | if (dieroll <= (scare_dieroll / 2)) { |
| 1297 | attack_indx = MB_INDEX_CANCEL; |
| 1298 | *dmgptr += rnd(4); /* (4..6)d4 */ |
| 1299 | } |
| 1300 | |
| 1301 | /* give the hit message prior to inflicting the effects */ |
| 1302 | verb = mb_verb[!!Hallucination][attack_indx]; |
| 1303 | if (youattack || youdefend || vis) { |
| 1304 | result = TRUE; |
| 1305 | pline_The("magic-absorbing blade %s %s!", |
no test coverage detected