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

Function find_ac

src/do_wear.c:2472–2525  ·  view source on GitHub ↗

calculate current armor class */

Source from the content-addressed store, hash-verified

2470
2471/* calculate current armor class */
2472void
2473find_ac(void)
2474{
2475 int uac = mons[u.umonnum].ac; /* base armor class for current form */
2476
2477 /* armor class from worn gear */
2478 if (uarm)
2479 uac -= ARM_BONUS(uarm);
2480 if (uarmc)
2481 uac -= ARM_BONUS(uarmc);
2482 if (uarmh)
2483 uac -= ARM_BONUS(uarmh);
2484 if (uarmf)
2485 uac -= ARM_BONUS(uarmf);
2486 if (uarms)
2487 uac -= ARM_BONUS(uarms);
2488 if (uarmg)
2489 uac -= ARM_BONUS(uarmg);
2490 if (uarmu)
2491 uac -= ARM_BONUS(uarmu);
2492 if (uleft && uleft->otyp == RIN_PROTECTION)
2493 uac -= uleft->spe;
2494 if (uright && uright->otyp == RIN_PROTECTION)
2495 uac -= uright->spe;
2496 if (uamul && uamul->otyp == AMULET_OF_GUARDING)
2497 uac -= 2; /* fixed amount; main benefit is to MC */
2498
2499 /* armor class from other sources */
2500 if (HProtection & INTRINSIC)
2501 uac -= u.ublessed;
2502 uac -= u.uspellprot;
2503
2504 /* put a cap on armor class [5.0: was +127,-128, now reduced to +/- 99 */
2505 if (abs(uac) > AC_MAX)
2506 uac = sgn(uac) * AC_MAX;
2507
2508 if (uac != u.uac) {
2509 u.uac = uac;
2510 disp.botl = TRUE;
2511#if 0
2512 /* these could conceivably be achieved out of order (by being near
2513 threshold and putting on +N dragon scale mail from bones, for
2514 instance), but if that happens, that's the order it happened;
2515 also, testing for these in the usual order would result in more
2516 record_achievement() attempts and rejects for duplication */
2517 if (u.uac <= -20)
2518 record_achievement(ACH_AC_20);
2519 else if (u.uac <= -10)
2520 record_achievement(ACH_AC_10);
2521 else if (u.uac <= 0)
2522 record_achievement(ACH_AC_00);
2523#endif
2524 }
2525}
2526
2527void
2528glibr(void)

Callers 12

allmain.cFile · 0.85
Amulet_onFunction · 0.85
Amulet_offFunction · 0.85
Ring_onFunction · 0.85
Ring_off_or_goneFunction · 0.85
nh_timeoutFunction · 0.85
polymanFunction · 0.85
polymonFunction · 0.85
cancel_monstFunction · 0.85
cast_protectionFunction · 0.85
basics_enlightenmentFunction · 0.85

Calls 2

sgnFunction · 0.85
record_achievementFunction · 0.85

Tested by

no test coverage detected