MCPcopy Create free account
hub / github.com/NetHack/NetHack / passiveum

Function passiveum

src/mhitu.c:2434–2613  ·  view source on GitHub ↗

FIXME: * sequencing issue: a monster's attack might cause poly'd hero * to revert to normal form. The messages for passive counterattack * would look better if they came before reverting form, but we need * to know whether hero reverted in order to decide whether passive * damage applies. */

Source from the content-addressed store, hash-verified

2432 * damage applies.
2433 */
2434staticfn int
2435passiveum(
2436 struct permonst *olduasmon,
2437 struct monst *mtmp,
2438 struct attack *mattk)
2439{
2440 int i, tmp;
2441 struct attack *oldu_mattk = 0;
2442
2443 /*
2444 * mattk == mtmp's attack that hit you;
2445 * oldu_mattk == your passive counterattack (even if mtmp's attack
2446 * has already caused you to revert to normal form).
2447 */
2448 for (i = 0; !oldu_mattk; i++) {
2449 if (i >= NATTK)
2450 return M_ATTK_HIT;
2451 if (olduasmon->mattk[i].aatyp == AT_NONE
2452 || olduasmon->mattk[i].aatyp == AT_BOOM)
2453 oldu_mattk = &olduasmon->mattk[i];
2454 }
2455 if (oldu_mattk->damn)
2456 tmp = d((int) oldu_mattk->damn, (int) oldu_mattk->damd);
2457 else if (oldu_mattk->damd)
2458 tmp = d((int) olduasmon->mlevel + 1, (int) oldu_mattk->damd);
2459 else
2460 tmp = 0;
2461
2462 /* These affect the enemy even if you were "killed" (rehumanized) */
2463 switch (oldu_mattk->adtyp) {
2464 case AD_ACID:
2465 if (!rn2(2)) {
2466 pline_mon(mtmp, "%s is splashed by %s%s!", Monnam(mtmp),
2467 /* temporary? hack for sequencing issue: "your acid"
2468 looks strange coming immediately after player has
2469 been told that hero has reverted to normal form */
2470 !Upolyd ? "" : "your ", hliquid("acid"));
2471 if (resists_acid(mtmp)) {
2472 pline_mon(mtmp, "%s is not affected.", Monnam(mtmp));
2473 tmp = 0;
2474 }
2475 } else
2476 tmp = 0;
2477 if (!rn2(30))
2478 erode_armor(mtmp, ERODE_CORRODE);
2479 if (!rn2(6))
2480 acid_damage(MON_WEP(mtmp));
2481 return assess_dmg(mtmp, tmp);
2482 case AD_STON: /* cockatrice */
2483 {
2484 long protector = attk_protection((int) mattk->aatyp),
2485 wornitems = mtmp->misc_worn_check;
2486
2487 /* wielded weapon gives same protection as gloves here */
2488 if (MON_WEP(mtmp) != 0)
2489 wornitems |= W_ARMG;
2490
2491 if (!resists_ston(mtmp)

Callers 1

hitmuFunction · 0.85

Calls 15

dFunction · 0.85
rn2Function · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
hliquidFunction · 0.85
erode_armorFunction · 0.85
acid_damageFunction · 0.85
assess_dmgFunction · 0.85
attk_protectionFunction · 0.85
poly_when_stonedFunction · 0.85
mon_to_stoneFunction · 0.85
xkilledFunction · 0.85

Tested by

no test coverage detected