summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgammafunk <gammafunk@gmail.com>2014-08-05 19:46:48 -0500
committergammafunk <gammafunk@gmail.com>2014-08-05 19:56:32 -0500
commit28e3730145ef18d613acfa864b65aaffd953440d (patch)
treee94fce2527a84f6695bb389444e8a37dbba30b81
parent57b3fc90fd53850f7dc4e0e4fb6dd3d0ed48fedb (diff)
downloadcrawl-ref-28e3730145ef18d613acfa864b65aaffd953440d.tar.gz
crawl-ref-28e3730145ef18d613acfa864b65aaffd953440d.zip
Simplify out a function
-rw-r--r--crawl-ref/source/cloud.cc12
-rw-r--r--crawl-ref/source/cloud.h1
-rw-r--r--crawl-ref/source/fight.cc7
3 files changed, 5 insertions, 15 deletions
diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc
index b99fe48f11..3c46374c55 100644
--- a/crawl-ref/source/cloud.cc
+++ b/crawl-ref/source/cloud.cc
@@ -702,18 +702,6 @@ cloud_type random_smoke_type()
}
return CLOUD_DEBUGGING;
}
-
-// Returns by how much damage gets divided due to elemental resistances.
-// Damage is reduced to, level 1 -> 1/2, level 2 -> 1/3, level 3 -> 1/5, or
-// for "boolean" attacks (which use bonus_res = 1, sticky flame/electricity)
-// to level 1 -> 1/3, level 2 -> 1/4, or level 3 -> 1/6.
-// With the old formula (1 + resist * resist) this used to be
-// 1/2, 1/5, 1/10 (normal) and 1/3, 1/6, 1/11 (boolean), respectively.
-int resist_fraction(int resist, int bonus_res)
-{
- return (3*resist + 1)/2 + bonus_res;
-}
-
int max_cloud_damage(cloud_type cl_type, int power)
{
cloud_struct cloud;
diff --git a/crawl-ref/source/cloud.h b/crawl-ref/source/cloud.h
index 8e569bcee7..9a8ad4b582 100644
--- a/crawl-ref/source/cloud.h
+++ b/crawl-ref/source/cloud.h
@@ -32,7 +32,6 @@ void manage_clouds();
bool is_opaque_cloud(int cloud_idx);
-int resist_fraction(int resist, int bonus_res = 0);
int max_cloud_damage(cloud_type cl_type, int power = -1);
int actor_apply_cloud(actor *act);
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 37667323a8..5f4f71f6cd 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -528,7 +528,10 @@ static inline int get_resistible_fraction(beam_type flavour)
*
* FIXME: Does not (yet) handle draining (?), miasma, and other exotic attacks.
* XXX: which other attacks?
- *
+ * Damage is reduced to 1/2, 1/3, or 1/5 if res has values 1, 2, and 3,
+ * respectively. For "boolean" attacks like electricity and sticky flame, the
+ * damage is instead reduced to 1/3, 1/4, and 1/6 at resist levels 1, 2, and 3
+ * respectively.
* @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.)
@@ -573,7 +576,7 @@ int resist_adjust_damage(const actor* defender, beam_type flavour, int res,
else if (flavour == BEAM_NEG)
resistible /= res * 2;
else
- resistible /= resist_fraction(res, bonus_res);
+ resistible /= (3 * res + 1) / 2 + bonus_res;
}
}
else if (res < 0)