summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/cloud.cc19
-rw-r--r--crawl-ref/source/cloud.h1
-rw-r--r--crawl-ref/source/fight.cc22
-rw-r--r--crawl-ref/source/player.cc10
4 files changed, 35 insertions, 17 deletions
diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc
index bbbaca890a..6f045249a2 100644
--- a/crawl-ref/source/cloud.cc
+++ b/crawl-ref/source/cloud.cc
@@ -237,7 +237,7 @@ int steam_cloud_damage(const cloud_struct &cloud)
{
return steam_cloud_damage(cloud.decay);
}
-
+
int steam_cloud_damage(int decay)
{
decay = std::min(decay, 60);
@@ -433,6 +433,17 @@ beam_type cloud2beam(cloud_type flavour)
}
}
+// 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);
+}
+
// NOTE: Keep in sync with in_a_cloud()
int max_cloud_damage(cloud_type cl_type, int power)
{
@@ -462,7 +473,7 @@ int max_cloud_damage(cloud_type cl_type, int power)
else
{
dam += 32 * speed / 10;
- dam /= (1 + resist * resist);
+ dam /= resist_fraction(resist);
}
break;
@@ -554,7 +565,7 @@ void in_a_cloud()
{
canned_msg(MSG_YOU_RESIST);
hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10;
- hurted /= (1 + resist * resist);
+ hurted /= resist_fraction(resist);
ouch(hurted, cl, KILLED_BY_CLOUD, "flame");
}
expose_player_to_element(BEAM_FIRE, 7);
@@ -602,7 +613,7 @@ void in_a_cloud()
{
canned_msg(MSG_YOU_RESIST);
hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10;
- hurted /= (1 + resist * resist);
+ hurted /= resist_fraction(resist);
ouch(hurted, cl, KILLED_BY_CLOUD, "freezing vapour");
}
expose_player_to_element(BEAM_COLD, 7);
diff --git a/crawl-ref/source/cloud.h b/crawl-ref/source/cloud.h
index 240ef74e77..9736788dbf 100644
--- a/crawl-ref/source/cloud.h
+++ b/crawl-ref/source/cloud.h
@@ -60,6 +60,7 @@ int steam_cloud_damage(int decay);
cloud_type beam2cloud(beam_type flavour);
beam_type cloud2beam(cloud_type flavour);
+int resist_fraction(int resist, int bonus_res = 0);
int max_cloud_damage(cloud_type cl_type, int power = -1);
void in_a_cloud(void);
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 2ced048a7c..af7c6e1979 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -2045,10 +2045,6 @@ int resist_adjust_damage(actor *defender, beam_type flavour,
const bool monster = (defender->atype() == ACT_MONSTER);
- // Check if this is a resist that pretends to be boolean for damage
- // purposes. Only electricity and sticky flame (napalm) do this at
- // the moment; raw poison damage uses the normal formula.
- int res_base = (is_boolean_resist(flavour) ? 2 : 1);
const int resistible_fraction = get_resistible_fraction(flavour);
int resistible = rawdamage * resistible_fraction / 100;
@@ -2059,7 +2055,19 @@ int resist_adjust_damage(actor *defender, beam_type flavour,
if (monster && res >= 3)
resistible = 0;
else
- resistible /= res_base + res * res;
+ {
+ // Check if this is a resist that pretends to be boolean for damage
+ // purposes. Only electricity and sticky flame (napalm) do this at
+ // the moment; raw poison damage uses the normal formula.
+ const int bonus_res = (is_boolean_resist(flavour) ? 1 : 0);
+
+ // Use a new formula for players, but keep the old, more effective
+ // for monsters.
+ if (monster)
+ resistible /= 1 + bonus_res + res * res;
+ else
+ resistible /= resist_fraction(res, bonus_res);
+ }
}
else if (res < 0)
resistible = resistible * (ranged? 15 : 20) / 10;
@@ -3033,9 +3041,7 @@ bool melee_attack::apply_damage_brand()
break;
case SPWPN_ELECTROCUTION:
- if (defender->airborne())
- break;
- else if (defender->res_elec() > 0)
+ if (defender->airborne() || defender->res_elec() > 0)
break;
else if (one_chance_in(3))
{
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 9a535d5f7d..fb0059a963 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -5527,12 +5527,12 @@ void dec_napalm_player()
{
ouch(((random2avg(9, 2) + 1) * you.time_taken) / 10,
NON_MONSTER, KILLED_BY_BURNING);
- }
- if (res_fire < 0)
- {
- ouch(((random2avg(9, 2) + 1) * you.time_taken) / 10,
- NON_MONSTER, KILLED_BY_BURNING);
+ if (res_fire < 0)
+ {
+ ouch(((random2avg(9, 2) + 1) * you.time_taken) / 10,
+ NON_MONSTER, KILLED_BY_BURNING);
+ }
}
if (you.duration[DUR_CONDENSATION_SHIELD] > 0)