summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-26 16:35:56 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-26 16:37:09 -0700
commit13f7132bae4216fb745791bc97984f6fe091d5d1 (patch)
tree24583540cd175c5495d24dcd07b6b9757571fb5d
parent61cafb898b3e8e6c4eb1866a7f57b7ac7418755b (diff)
downloadcrawl-ref-13f7132bae4216fb745791bc97984f6fe091d5d1.tar.gz
crawl-ref-13f7132bae4216fb745791bc97984f6fe091d5d1.zip
Refactor acid resistance
-rw-r--r--crawl-ref/source/fight.cc9
-rw-r--r--crawl-ref/source/ouch.cc16
-rw-r--r--crawl-ref/source/player.cc12
-rw-r--r--crawl-ref/source/player.h1
4 files changed, 14 insertions, 24 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 85452d70ce..6a47fc045b 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -524,9 +524,8 @@ 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.
+ * FIXME: Does not (yet) handle draining (?), miasma, and other exotic attacks.
+ * XXX: which other attacks?
*
* @param defender The victim of the attack.
* @param flavour The type of attack having its damage adjusted.
@@ -553,7 +552,9 @@ int resist_adjust_damage(const actor* defender, beam_type flavour, int res,
if (res > 0)
{
- if (((is_mon || flavour == BEAM_NEG) && res >= 3) || res > 3)
+ const bool immune_at_3_res = is_mon || flavour == BEAM_NEG
+ || flavour == BEAM_ACID;
+ if (immune_at_3_res && res >= 3 || res > 3)
resistible = 0;
else
{
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 7a3de71ccc..f4bd1d2ccf 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -287,12 +287,12 @@ int check_your_resists(int hurted, beam_type flavour, string source,
break;
case BEAM_ACID:
- if (player_res_acid())
- {
- if (doEffects)
- canned_msg(MSG_YOU_RESIST);
- hurted = hurted * player_acid_resist_factor() / 100;
- }
+ mprf("pre-dam: %d", hurted);
+ hurted = resist_adjust_damage(&you, flavour, player_res_acid(),
+ hurted, true);
+ mprf("post-dam: %d", hurted);
+ if (hurted < original && doEffects)
+ canned_msg(MSG_YOU_RESIST);
break;
case BEAM_MIASMA:
@@ -408,7 +408,9 @@ void splash_with_acid(int acid_strength, int death_source, bool allow_corrosion,
dam += 2;
dam = roll_dice(dam, acid_strength);
- const int post_res_dam = dam * player_acid_resist_factor() / 100;
+ const int post_res_dam = resist_adjust_damage(&you, BEAM_ACID,
+ you.res_acid(), dam);
+ mprf("pre-dam: %d, post-dam: %d", dam, post_res_dam);
if (post_res_dam > 0)
{
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 59debfe31f..bd0038bff5 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1845,18 +1845,6 @@ int player_res_acid(bool calc_unid, bool items)
return you.res_corr(calc_unid, items) ? 1 : 0;
}
-// Returns a factor X such that post-resistance acid damage can be calculated
-// as pre_resist_damage * X / 100.
-int player_acid_resist_factor()
-{
- int rA = player_res_acid();
- if (rA >= 3)
- return 0;
- else if (rA >= 1)
- return 50;
- return 100;
-}
-
int player_res_electricity(bool calc_unid, bool temp, bool items)
{
int re = 0;
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 0c0d14b883..64bd592dff 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -877,7 +877,6 @@ int player_regen();
int player_res_cold(bool calc_unid = true, bool temp = true,
bool items = true);
int player_res_acid(bool calc_unid = true, bool items = true);
-int player_acid_resist_factor();
int player_res_torment(bool calc_unid = true, bool temp = true);
int player_kiku_res_torment();