select a monster's next attack, possibly substituting for its usual one */
| 307 | |
| 308 | /* select a monster's next attack, possibly substituting for its usual one */ |
| 309 | struct attack * |
| 310 | getmattk( |
| 311 | struct monst *magr, struct monst *mdef, |
| 312 | int indx, int prev_result[], |
| 313 | struct attack *alt_attk_buf) |
| 314 | { |
| 315 | struct permonst *mptr = magr->data; |
| 316 | struct attack *attk = &mptr->mattk[indx]; |
| 317 | struct obj *weap = (magr == &gy.youmonst) ? uwep : MON_WEP(magr); |
| 318 | boolean udefend = mdef == &gy.youmonst; |
| 319 | |
| 320 | /* honor SEDUCE=0 */ |
| 321 | if (!SYSOPT_SEDUCE) { |
| 322 | extern const struct attack c_sa_no[NATTK]; |
| 323 | |
| 324 | /* if the first attack is for SSEX damage, all six attacks will be |
| 325 | substituted (expected succubus/incubus handling); if it isn't |
| 326 | but another one is, only that other one will be substituted */ |
| 327 | if (mptr->mattk[0].adtyp == AD_SSEX) { |
| 328 | *alt_attk_buf = c_sa_no[indx]; |
| 329 | attk = alt_attk_buf; |
| 330 | } else if (attk->adtyp == AD_SSEX) { |
| 331 | *alt_attk_buf = *attk; |
| 332 | attk = alt_attk_buf; |
| 333 | attk->adtyp = AD_DRLI; |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | /* prevent a monster with two consecutive disease or hunger attacks |
| 338 | from hitting with both of them on the same turn; if the first has |
| 339 | already hit, switch to a stun attack for the second */ |
| 340 | if (indx > 0 && prev_result[indx - 1] > M_ATTK_MISS |
| 341 | && (attk->adtyp == AD_DISE || attk->adtyp == AD_PEST |
| 342 | || attk->adtyp == AD_FAMN) |
| 343 | && attk->adtyp == mptr->mattk[indx - 1].adtyp) { |
| 344 | *alt_attk_buf = *attk; |
| 345 | attk = alt_attk_buf; |
| 346 | attk->adtyp = AD_STUN; |
| 347 | |
| 348 | /* make drain-energy damage be somewhat in proportion to energy */ |
| 349 | } else if (attk->adtyp == AD_DREN && udefend) { |
| 350 | int ulev = max(u.ulevel, 6); |
| 351 | |
| 352 | *alt_attk_buf = *attk; |
| 353 | attk = alt_attk_buf; |
| 354 | /* 3.6.0 used 4d6 but since energy drain came out of max energy |
| 355 | once current energy was gone, that tended to have a severe |
| 356 | effect on low energy characters; it's now 2d6 with adjustments */ |
| 357 | if (u.uen <= 5 * ulev && attk->damn > 1) { |
| 358 | attk->damn -= 1; /* low energy: 2d6 -> 1d6 */ |
| 359 | if (u.uenmax <= 2 * ulev && attk->damd > 3) |
| 360 | attk->damd -= 3; /* very low energy: 1d6 -> 1d3 */ |
| 361 | } else if (u.uen > 12 * ulev) { |
| 362 | attk->damn += 1; /* high energy: 2d6 -> 3d6 */ |
| 363 | if (u.uenmax > 20 * ulev) |
| 364 | attk->damd += 3; /* very high energy: 3d6 -> 3d9 */ |
| 365 | /* note: 3d9 is slightly higher than previous 4d6 */ |
| 366 | } |
no test coverage detected