calculate current armor class */
| 2470 | |
| 2471 | /* calculate current armor class */ |
| 2472 | void |
| 2473 | find_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 | |
| 2527 | void |
| 2528 | glibr(void) |
no test coverage detected