diff options
author | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-07-26 11:27:59 -0700 |
---|---|---|
committer | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-07-26 11:27:59 -0700 |
commit | 93bd6f3c9f6481f10147fec7257468db2825c310 (patch) | |
tree | 680712d63f9600b17c8e9318e7fdc70a2b44f544 /crawl-ref/source/fight.cc | |
parent | 75e7cd9dc1480d4807cf43561142ec1e4129e227 (diff) | |
download | crawl-ref-93bd6f3c9f6481f10147fec7257468db2825c310.tar.gz crawl-ref-93bd6f3c9f6481f10147fec7257468db2825c310.zip |
Comment and constify get_resistible_fraction()
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r-- | crawl-ref/source/fight.cc | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index ea24c76969..85452d70ce 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -521,21 +521,30 @@ static inline int get_resistible_fraction(beam_type flavour) } } -// Adjusts damage for elemental resists, electricity and poison. -// -// FIXME: Does not (yet) handle life draining, player acid damage -// (does handle monster acid damage), miasma, and other exotic -// attacks. -// -// beam_type is just used to determine the damage flavour, it does not -// necessarily imply that the attack is a beam attack. -int resist_adjust_damage(actor *defender, beam_type flavour, - int res, int rawdamage, bool ranged) +/** + * Adjusts damage for elemental resists, electricity and poison. + * + * FIXME: Does not (yet) handle life draining, player acid damage + * (does handle monster acid damage), miasma, and other exotic + * attacks. + * + * @param defender The victim of the attack. + * @param flavour The type of attack having its damage adjusted. + * (Does not necessarily imply the attack is a beam.) + * @param res The level of resistance that the defender possesses. + * @param rawdamage The base damage, to be adjusted by resistance. + * @param ranged Whether the attack is ranged, and therefore has a + * smaller damage multiplier against victims with negative + * resistances. (????) + * @return The amount of damage done, after resists are applied. + */ +int resist_adjust_damage(const actor* defender, beam_type flavour, int res, + int rawdamage, bool ranged) { if (!res) return rawdamage; - const bool mons = (defender->is_monster()); + const bool is_mon = defender->is_monster(); const int resistible_fraction = get_resistible_fraction(flavour); @@ -544,7 +553,7 @@ int resist_adjust_damage(actor *defender, beam_type flavour, if (res > 0) { - if (((mons || flavour == BEAM_NEG) && res >= 3) || res > 3) + if (((is_mon || flavour == BEAM_NEG) && res >= 3) || res > 3) resistible = 0; else { @@ -556,7 +565,7 @@ int resist_adjust_damage(actor *defender, beam_type flavour, // Use a new formula for players, but keep the old, more // effective one for monsters. - if (mons) + if (is_mon) resistible /= 1 + bonus_res + res * res; else if (flavour == BEAM_NEG) resistible /= res * 2; |