diff options
author | Vsevolod Kozlov <zaba@thorium.homeunix.org> | 2009-11-08 16:20:49 +0300 |
---|---|---|
committer | Vsevolod Kozlov <zaba@thorium.homeunix.org> | 2009-11-08 16:20:49 +0300 |
commit | ce42ec3ebfa796ba601e46d27c7c4f5e01489970 (patch) | |
tree | f70efd5578acc84ef1f71b3eb975d0dbaa30f54a | |
parent | 5562dfc2a3dd500be1a98a02703eb37496b5fb8e (diff) | |
download | crawl-ref-ce42ec3ebfa796ba601e46d27c7c4f5e01489970.tar.gz crawl-ref-ce42ec3ebfa796ba601e46d27c7c4f5e01489970.zip |
Replace uses of player_AC with player::armour_class.
-rw-r--r-- | crawl-ref/source/beam.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/cloud.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/ghost.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 369 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/traps.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/wiz-fsim.cc | 2 |
8 files changed, 193 insertions, 200 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index e8b4cdceb8..3218c0ba30 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -4041,7 +4041,7 @@ void bolt::affect_player() std::vector<std::string> messages; apply_dmg_funcs(&you, hurted, messages); - int armour_damage_reduction = random2( 1 + player_AC() ); + int armour_damage_reduction = random2( 1 + you.armour_class() ); if (flavour == BEAM_ELECTRICITY) armour_damage_reduction /= 2; hurted -= armour_damage_reduction; @@ -4049,8 +4049,8 @@ void bolt::affect_player() // shrapnel has triple AC reduction if (flavour == BEAM_FRAG && !player_light_armour()) { - hurted -= random2( 1 + player_AC() ); - hurted -= random2( 1 + player_AC() ); + hurted -= random2( 1 + you.armour_class() ); + hurted -= random2( 1 + you.armour_class() ); } #if DEBUG_DIAGNOSTICS @@ -4111,7 +4111,7 @@ void bolt::affect_player() } else if (item->special == SPMSL_CURARE) { - if (x_chance_in_y(90 - 3 * player_AC(), 100)) + if (x_chance_in_y(90 - 3 * you.armour_class(), 100)) { curare_hits_player(actor_to_death_source(agent()), 1 + random2(3)); diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 96ae7d8916..65e6ae3c80 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -626,7 +626,7 @@ void in_a_cloud() if (resist < 0) hurted += ((random2avg(14, 2) + 3) * you.time_taken) / 10; - hurted -= random2(player_AC()); + hurted -= random2(you.armour_class()); if (hurted < 0) hurted = 0; @@ -680,7 +680,7 @@ void in_a_cloud() if (resist < 0) hurted += ((random2avg(14, 2) + 3) * you.time_taken) / 10; - hurted -= random2(player_AC()); + hurted -= random2(you.armour_class()); if (hurted < 0) hurted = 0; diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc index 2d8430d042..4bb2f6f1e8 100644 --- a/crawl-ref/source/ghost.cc +++ b/crawl-ref/source/ghost.cc @@ -333,7 +333,7 @@ void ghost_demon::init_player_ghost() name = you.your_name; max_hp = ((you.hp_max >= MAX_GHOST_HP) ? MAX_GHOST_HP : you.hp_max); ev = player_evasion(); - ac = player_AC(); + ac = you.armour_class(); if (ev > MAX_GHOST_EVASION) ev = MAX_GHOST_EVASION; diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 605a20edfd..b38ecd0c80 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -484,7 +484,7 @@ static void _print_stats_ac(int x, int y) textcolor( RED ); else textcolor( HUD_VALUE_COLOUR ); - cprintf( "%2d ", player_AC() ); + cprintf( "%2d ", you.armour_class() ); // SH: (two lines lower) cgotoxy(x+4, y+2, GOTO_STAT); @@ -1685,7 +1685,7 @@ static std::vector<formatted_string> _get_overview_stats() snprintf(buf, sizeof buf, "Gold %d", you.gold); cols1.add_formatted(0, buf, false); - snprintf(buf, sizeof buf, "AC %2d" , player_AC()); + snprintf(buf, sizeof buf, "AC %2d" , you.armour_class()); cols1.add_formatted(1, buf, false); snprintf(buf, sizeof buf, "EV %2d" , player_evasion()); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 07ba1e784a..cb352bfd18 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1976,192 +1976,6 @@ static int _player_armour_racial_bonus(const item_def& item) return racial_bonus; } -int player_AC(void) -{ - int AC = 0; - - for (int eq = EQ_CLOAK; eq <= EQ_BODY_ARMOUR; ++eq) - { - if (eq == EQ_SHIELD) - continue; - - if (!player_wearing_slot(eq)) - continue; - - const item_def& item = you.inv[you.equip[eq]]; - const int ac_value = property(item, PARM_AC ) * 100; - int racial_bonus = _player_armour_racial_bonus(item); - - AC += ac_value * (30 + 2 * you.skills[SK_ARMOUR] + racial_bonus) / 30; - - AC += item.plus * 100; - - // The deformed don't fit into body armour very well. - // (This includes nagas and centaurs.) - if (eq == EQ_BODY_ARMOUR && player_mutation_level(MUT_DEFORMED)) - AC -= ac_value / 2; - } - - AC += player_equip( EQ_RINGS_PLUS, RING_PROTECTION ) * 100; - - if (player_equip_ego_type( EQ_WEAPON, SPWPN_PROTECTION )) - AC += 500; - - if (player_equip_ego_type( EQ_SHIELD, SPARM_PROTECTION )) - AC += 300; - - AC += scan_artefacts(ARTP_AC) * 100; - - if (you.duration[DUR_ICY_ARMOUR]) - AC += 400 + 100 * you.skills[SK_ICE_MAGIC] / 3; // max 13 - - if (you.duration[DUR_STONEMAIL]) - AC += 500 + 100 * you.skills[SK_EARTH_MAGIC] / 2; // max 18 - - if (you.duration[DUR_STONESKIN]) - AC += 200 + 100 * you.skills[SK_EARTH_MAGIC] / 5; // max 7 - - if (you.mutation[MUT_ICEMAIL]) - AC += (100 * ICEMAIL_MAX) - - (you.duration[DUR_ICEMAIL_DEPLETED] * 100 - * ICEMAIL_MAX / ICEMAIL_TIME); - - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_NONE - || you.attribute[ATTR_TRANSFORMATION] == TRAN_LICH - || you.attribute[ATTR_TRANSFORMATION] == TRAN_BLADE_HANDS) - { - // Being a lich doesn't preclude the benefits of hide/scales -- bwr - // - // Note: Even though necromutation is a high level spell, it does - // allow the character full armour (so the bonus is low). -- bwr - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_LICH) - AC += (300 + 100 * you.skills[SK_NECROMANCY] / 6); // max 7 - - //jmf: only give: - if (player_genus(GENPC_DRACONIAN)) - { - if (you.experience_level < 8) - AC += 200; - else if (you.species == SP_GREY_DRACONIAN) - AC += 100 + 100 * (you.experience_level - 4) / 2; // max 12 - else - AC += 100 + (100 * you.experience_level / 4); // max 7 - } - else - { - switch (you.species) - { - case SP_NAGA: - AC += 100 * you.experience_level / 3; // max 9 - break; - - default: - break; - } - } - - // Scales -- some evil uses of the fact that boolean "true" == 1... - // I'll spell things out with some comments -- bwr - - // mutations: - // these give: +1, +2, +3 - AC += 100 * player_mutation_level(MUT_TOUGH_SKIN); - AC += 100 * player_mutation_level(MUT_GREY_SCALES); - AC += 100 * player_mutation_level(MUT_SHAGGY_FUR); - AC += 100 * player_mutation_level(MUT_BLUE_SCALES); - AC += 100 * player_mutation_level(MUT_SPECKLED_SCALES); - AC += 100 * player_mutation_level(MUT_IRIDESCENT_SCALES); - AC += 100 * player_mutation_level(MUT_PATTERNED_SCALES); - - // these give: +1, +3, +5 - if (player_mutation_level(MUT_GREEN_SCALES) > 0) - AC += (player_mutation_level(MUT_GREEN_SCALES) * 200) - 100; - if (player_mutation_level(MUT_NACREOUS_SCALES) > 0) - AC += (player_mutation_level(MUT_NACREOUS_SCALES) * 200) - 100; - if (player_mutation_level(MUT_BLACK2_SCALES) > 0) - AC += (player_mutation_level(MUT_BLACK2_SCALES) * 200) - 100; - if (player_mutation_level(MUT_WHITE_SCALES) > 0) - AC += (player_mutation_level(MUT_WHITE_SCALES) * 200) - 100; - - // these give: +2, +4, +6 - AC += player_mutation_level(MUT_GREY2_SCALES) * 200; - AC += player_mutation_level(MUT_YELLOW_SCALES) * 200; - AC += player_mutation_level(MUT_PURPLE_SCALES) * 200; - - // black gives: +3, +6, +9 - AC += player_mutation_level(MUT_BLACK_SCALES) * 300; - - // boney plates give: +2, +3, +4 - if (player_mutation_level(MUT_BONEY_PLATES) > 0) - AC += 100 * (player_mutation_level(MUT_BONEY_PLATES) + 1); - - // red gives +1, +2, +4 - AC += 100 * (player_mutation_level(MUT_RED_SCALES) - + (player_mutation_level(MUT_RED_SCALES) == 3)); - - // indigo gives: +2, +3, +5 - if (player_mutation_level(MUT_INDIGO_SCALES) > 0) - { - AC += 100 * (1 + player_mutation_level(MUT_INDIGO_SCALES) - + (player_mutation_level(MUT_INDIGO_SCALES) == 3)); - } - - // brown gives: +2, +4, +5 - AC += 100 * ((player_mutation_level(MUT_BROWN_SCALES) * 2) - - (player_mutation_level(MUT_BROWN_SCALES) == 3)); - - // orange gives: +1, +3, +4 - AC += 100 * (player_mutation_level(MUT_ORANGE_SCALES) - + (player_mutation_level(MUT_ORANGE_SCALES) > 1)); - - // knobbly red gives: +2, +5, +7 - AC += 100 * ((player_mutation_level(MUT_RED2_SCALES) * 2) - + (player_mutation_level(MUT_RED2_SCALES) > 1)); - - // metallic gives +3, +7, +10 - AC += 100 * (player_mutation_level(MUT_METALLIC_SCALES) * 3 - + (player_mutation_level(MUT_METALLIC_SCALES) > 1)); - } - else - { - // transformations: - switch (you.attribute[ATTR_TRANSFORMATION]) - { - case TRAN_NONE: - case TRAN_BLADE_HANDS: - case TRAN_LICH: // can wear normal body armour (small bonus) - break; - - case TRAN_SPIDER: // low level (small bonus), also gets EV - AC += (200 + 100 * you.skills[SK_POISON_MAGIC] / 6); // max 6 - break; - - case TRAN_ICE_BEAST: - AC += (500 + 100 * (you.skills[SK_ICE_MAGIC] + 1) / 4); // max 12 - - if (you.duration[DUR_ICY_ARMOUR]) - AC += (100 + 100 * you.skills[SK_ICE_MAGIC] / 4); // max +7 - break; - - case TRAN_DRAGON: - AC += (700 + 100 * you.skills[SK_FIRE_MAGIC] / 3); // max 16 - break; - - case TRAN_STATUE: // main ability is armour (high bonus) - AC += (1700 + 100 * you.skills[SK_EARTH_MAGIC] / 2); // max 30 - - if (you.duration[DUR_STONESKIN] || you.duration[DUR_STONEMAIL]) - AC += (100 + 100 * you.skills[SK_EARTH_MAGIC] / 4); // max +7 - break; - - default: - break; - } - } - - return (AC / 100); -} - bool is_light_armour( const item_def &item ) { if (get_equip_race(item) == ISFLAG_ELVEN) @@ -6343,7 +6157,188 @@ int player::skill(skill_type sk, bool bump) const int player::armour_class() const { - return (player_AC()); + int AC = 0; + + for (int eq = EQ_CLOAK; eq <= EQ_BODY_ARMOUR; ++eq) + { + if (eq == EQ_SHIELD) + continue; + + if (!player_wearing_slot(eq)) + continue; + + const item_def& item = inv[equip[eq]]; + const int ac_value = property(item, PARM_AC ) * 100; + int racial_bonus = _player_armour_racial_bonus(item); + + AC += ac_value * (30 + 2 * skills[SK_ARMOUR] + racial_bonus) / 30; + + AC += item.plus * 100; + + // The deformed don't fit into body armour very well. + // (This includes nagas and centaurs.) + if (eq == EQ_BODY_ARMOUR && player_mutation_level(MUT_DEFORMED)) + AC -= ac_value / 2; + } + + AC += player_equip( EQ_RINGS_PLUS, RING_PROTECTION ) * 100; + + if (player_equip_ego_type( EQ_WEAPON, SPWPN_PROTECTION )) + AC += 500; + + if (player_equip_ego_type( EQ_SHIELD, SPARM_PROTECTION )) + AC += 300; + + AC += scan_artefacts(ARTP_AC) * 100; + + if (duration[DUR_ICY_ARMOUR]) + AC += 400 + 100 * skills[SK_ICE_MAGIC] / 3; // max 13 + + if (duration[DUR_STONEMAIL]) + AC += 500 + 100 * skills[SK_EARTH_MAGIC] / 2; // max 18 + + if (duration[DUR_STONESKIN]) + AC += 200 + 100 * skills[SK_EARTH_MAGIC] / 5; // max 7 + + if (mutation[MUT_ICEMAIL]) + AC += (100 * ICEMAIL_MAX) + - (duration[DUR_ICEMAIL_DEPLETED] * 100 + * ICEMAIL_MAX / ICEMAIL_TIME); + + if (attribute[ATTR_TRANSFORMATION] == TRAN_NONE + || attribute[ATTR_TRANSFORMATION] == TRAN_LICH + || attribute[ATTR_TRANSFORMATION] == TRAN_BLADE_HANDS) + { + // Being a lich doesn't preclude the benefits of hide/scales -- bwr + // + // Note: Even though necromutation is a high level spell, it does + // allow the character full armour (so the bonus is low). -- bwr + if (attribute[ATTR_TRANSFORMATION] == TRAN_LICH) + AC += (300 + 100 * skills[SK_NECROMANCY] / 6); // max 7 + + //jmf: only give: + if (player_genus(GENPC_DRACONIAN)) + { + if (experience_level < 8) + AC += 200; + else if (species == SP_GREY_DRACONIAN) + AC += 100 + 100 * (experience_level - 4) / 2; // max 12 + else + AC += 100 + (100 * experience_level / 4); // max 7 + } + else + { + switch (species) + { + case SP_NAGA: + AC += 100 * experience_level / 3; // max 9 + break; + + default: + break; + } + } + + // Scales -- some evil uses of the fact that boolean "true" == 1... + // I'll spell things out with some comments -- bwr + + // mutations: + // these give: +1, +2, +3 + AC += 100 * player_mutation_level(MUT_TOUGH_SKIN); + AC += 100 * player_mutation_level(MUT_GREY_SCALES); + AC += 100 * player_mutation_level(MUT_SHAGGY_FUR); + AC += 100 * player_mutation_level(MUT_BLUE_SCALES); + AC += 100 * player_mutation_level(MUT_SPECKLED_SCALES); + AC += 100 * player_mutation_level(MUT_IRIDESCENT_SCALES); + AC += 100 * player_mutation_level(MUT_PATTERNED_SCALES); + + // these give: +1, +3, +5 + if (player_mutation_level(MUT_GREEN_SCALES) > 0) + AC += (player_mutation_level(MUT_GREEN_SCALES) * 200) - 100; + if (player_mutation_level(MUT_NACREOUS_SCALES) > 0) + AC += (player_mutation_level(MUT_NACREOUS_SCALES) * 200) - 100; + if (player_mutation_level(MUT_BLACK2_SCALES) > 0) + AC += (player_mutation_level(MUT_BLACK2_SCALES) * 200) - 100; + if (player_mutation_level(MUT_WHITE_SCALES) > 0) + AC += (player_mutation_level(MUT_WHITE_SCALES) * 200) - 100; + + // these give: +2, +4, +6 + AC += player_mutation_level(MUT_GREY2_SCALES) * 200; + AC += player_mutation_level(MUT_YELLOW_SCALES) * 200; + AC += player_mutation_level(MUT_PURPLE_SCALES) * 200; + + // black gives: +3, +6, +9 + AC += player_mutation_level(MUT_BLACK_SCALES) * 300; + + // boney plates give: +2, +3, +4 + if (player_mutation_level(MUT_BONEY_PLATES) > 0) + AC += 100 * (player_mutation_level(MUT_BONEY_PLATES) + 1); + + // red gives +1, +2, +4 + AC += 100 * (player_mutation_level(MUT_RED_SCALES) + + (player_mutation_level(MUT_RED_SCALES) == 3)); + + // indigo gives: +2, +3, +5 + if (player_mutation_level(MUT_INDIGO_SCALES) > 0) + { + AC += 100 * (1 + player_mutation_level(MUT_INDIGO_SCALES) + + (player_mutation_level(MUT_INDIGO_SCALES) == 3)); + } + + // brown gives: +2, +4, +5 + AC += 100 * ((player_mutation_level(MUT_BROWN_SCALES) * 2) + - (player_mutation_level(MUT_BROWN_SCALES) == 3)); + + // orange gives: +1, +3, +4 + AC += 100 * (player_mutation_level(MUT_ORANGE_SCALES) + + (player_mutation_level(MUT_ORANGE_SCALES) > 1)); + + // knobbly red gives: +2, +5, +7 + AC += 100 * ((player_mutation_level(MUT_RED2_SCALES) * 2) + + (player_mutation_level(MUT_RED2_SCALES) > 1)); + + // metallic gives +3, +7, +10 + AC += 100 * (player_mutation_level(MUT_METALLIC_SCALES) * 3 + + (player_mutation_level(MUT_METALLIC_SCALES) > 1)); + } + else + { + // transformations: + switch (attribute[ATTR_TRANSFORMATION]) + { + case TRAN_NONE: + case TRAN_BLADE_HANDS: + case TRAN_LICH: // can wear normal body armour (small bonus) + break; + + case TRAN_SPIDER: // low level (small bonus), also gets EV + AC += (200 + 100 * skills[SK_POISON_MAGIC] / 6); // max 6 + break; + + case TRAN_ICE_BEAST: + AC += (500 + 100 * (skills[SK_ICE_MAGIC] + 1) / 4); // max 12 + + if (duration[DUR_ICY_ARMOUR]) + AC += (100 + 100 * skills[SK_ICE_MAGIC] / 4); // max +7 + break; + + case TRAN_DRAGON: + AC += (700 + 100 * skills[SK_FIRE_MAGIC] / 3); // max 16 + break; + + case TRAN_STATUE: // main ability is armour (high bonus) + AC += (1700 + 100 * skills[SK_EARTH_MAGIC] / 2); // max 30 + + if (duration[DUR_STONESKIN] || duration[DUR_STONEMAIL]) + AC += (100 + 100 * skills[SK_EARTH_MAGIC] / 4); // max +7 + break; + + default: + break; + } + } + + return (AC / 100); } int player::melee_evasion(const actor *act) const diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index e7cca6269b..0bcb1822f5 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -578,8 +578,6 @@ int carrying_capacity(burden_state_type bs = BS_OVERLOADED); int check_stealth(void); -int player_AC(void); - int player_energy(void); int player_evasion(void); diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index ed54548df7..35cdabc2dd 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -442,7 +442,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) { mpr("A huge blade swings out and slices into you!"); const int damage = (you.your_level * 2) + random2avg(29, 2) - - random2(1 + player_AC()); + - random2(1 + you.armour_class()); ouch(damage, NON_MONSTER, KILLED_BY_TRAP, "blade"); bleed_onto_floor(you.pos(), MONS_PLAYER, damage, true); } diff --git a/crawl-ref/source/wiz-fsim.cc b/crawl-ref/source/wiz-fsim.cc index fd58cc30b8..846a441f75 100644 --- a/crawl-ref/source/wiz-fsim.cc +++ b/crawl-ref/source/wiz-fsim.cc @@ -94,7 +94,7 @@ static void _fsim_defence_item(FILE *out, long cum, int hits, int max, // AC | EV | Arm | Dod | Acc | Av.Dam | Av.HitDam | Eff.Dam | Max.Dam | Av.Time fprintf(out, "%2d %2d %2d %2d %3ld%% %5.2f %5.2f %5.2f %3d" " %2d\n", - player_AC(), + you.armour_class(), player_evasion(), you.skills[SK_DODGING], you.skills[SK_ARMOUR], |