From 45001d37f21bc2b39c616d313d01b0039a78734e Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 29 Sep 2009 22:08:46 -0500 Subject: Make miasma and miasma resistance more consistent. It no longer depends on negative energy resistance, but on rotting resistance. --- crawl-ref/source/beam.cc | 65 ++++++++++++++++++++++++++------------------ crawl-ref/source/beam.h | 1 + crawl-ref/source/cloud.cc | 16 ++++------- crawl-ref/source/externs.h | 6 ++-- crawl-ref/source/fight.cc | 2 +- crawl-ref/source/mon-util.cc | 18 ++++-------- crawl-ref/source/mon-util.h | 1 - crawl-ref/source/monstuff.cc | 14 ++-------- crawl-ref/source/ouch.cc | 2 +- crawl-ref/source/player.cc | 63 ++++++++++++++++++++++++++++++------------ crawl-ref/source/player.h | 8 ++++-- 11 files changed, 110 insertions(+), 86 deletions(-) diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 7659330100..579f4def7b 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2359,7 +2359,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted, break; case BEAM_MIASMA: - if (mons_res_negative_energy(monster) == 3) + if (mons_res_rotting(monster)) { if (doFlavouredEffects) simple_monster_message(monster, " completely resists."); @@ -2372,15 +2372,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted, if (!doFlavouredEffects) return (hurted); - if (mons_res_poison(monster) <= 0) - poison_monster(monster, pbolt.whose_kill()); - - if (one_chance_in(3 + 2 * mons_res_negative_energy(monster))) - { - bolt beam; - beam.flavour = BEAM_SLOW; - beam.apply_enchantment_to_monster(monster); - } + miasma_monster(monster, pbolt.whose_kill()); } break; @@ -2661,8 +2653,6 @@ bool curare_hits_monster(actor *agent, monsters *monster, kill_category who, { poison_monster(monster, who, levels, false); - const bool res_poison = mons_res_poison(monster) > 0; - int hurted = 0; if (!mons_res_asphyx(monster)) @@ -2670,7 +2660,7 @@ bool curare_hits_monster(actor *agent, monsters *monster, kill_category who, hurted = roll_dice(2, 6); // Note that the hurtage is halved by poison resistance. - if (res_poison) + if (mons_res_poison(monster) > 0) hurted /= 2; if (hurted) @@ -2723,6 +2713,37 @@ bool poison_monster(monsters *monster, kill_category who, int levels, return (new_pois.degree > old_pois.degree); } +// Actually poisons, rots, and/or slows a monster with miasma (with +// message). +bool miasma_monster(monsters *monster, kill_category who) +{ + if (!monster->alive()) + return (false); + + if (mons_res_rotting(monster)) + return (false); + + bool success = poison_monster(monster, who); + + if (monster->max_hit_points > 4 && coinflip()) + { + monster->max_hit_points--; + monster->hit_points = std::min(monster->max_hit_points, + monster->hit_points); + success = true; + } + + if (one_chance_in(3)) + { + bolt beam; + beam.flavour = BEAM_SLOW; + beam.apply_enchantment_to_monster(monster); + success = true; + } + + return (success); +} + // Actually napalms a monster (with message). bool napalm_monster(monsters *monster, kill_category who, int levels, bool verbose) @@ -3364,6 +3385,8 @@ bool bolt::is_harmless(const monsters *mon) const return (mons_res_cold(mon) >= 3); case BEAM_MIASMA: + return (mons_res_rotting(mon)); + case BEAM_NEG: return (mons_res_negative_energy(mon) == 3); @@ -3406,6 +3429,8 @@ bool bolt::harmless_to_player() const return (player_res_steam(false) >= 3); case BEAM_MIASMA: + return (player_res_rotting()); + case BEAM_NEG: return (player_prot_life(false) >= 3); @@ -3993,19 +4018,7 @@ void bolt::affect_player() hurted = check_your_resists(hurted, flavour); if (flavour == BEAM_MIASMA && hurted > 0) - { - if (player_res_poison() <= 0) - { - poison_player(1); - was_affected = true; - } - - if (one_chance_in(3 + 2 * player_prot_life())) - { - potion_effect(POT_SLOWING, 5); - was_affected = true; - } - } + was_affected = miasma_player(); // Confusion effect for spore explosions if (flavour == BEAM_SPORE && hurted && you.holiness() != MH_UNDEAD) diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h index 9fa3c21f6c..dc8a36806d 100644 --- a/crawl-ref/source/beam.h +++ b/crawl-ref/source/beam.h @@ -288,6 +288,7 @@ bool curare_hits_monster(actor *agent, monsters *monster, kill_category who, int levels = 1); bool poison_monster(monsters *monster, kill_category who, int levels = 1, bool force = false, bool verbose = true); +bool miasma_monster(monsters *monster, kill_category who); bool napalm_monster(monsters *monster, kill_category who, int levels = 1, bool verbose = true); void fire_tracer( const monsters *monster, struct bolt &pbolt, diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 6f045249a2..5d503f70f4 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -511,12 +511,12 @@ int max_cloud_damage(cloud_type cl_type, int power) } case CLOUD_MIASMA: - if (player_prot_life() >= 3) + if (player_res_rotting()) return (0); dam += 11 * speed / 10; - break; + default: break; } @@ -666,10 +666,10 @@ void in_a_cloud() case CLOUD_MIASMA: mpr("You are engulfed in a dark miasma."); - if (x_chance_in_y(player_prot_life(), 3)) + if (player_res_rotting()) return; - poison_player(1); + miasma_player(); hurted += (random2avg(12, 3) * you.time_taken) / 10; // 3 @@ -677,12 +677,8 @@ void in_a_cloud() hurted = 0; ouch(hurted, cl, KILLED_BY_CLOUD, "foul pestilence"); - potion_effect(POT_SLOWING, 5); - - if (you.hp_max > 4 && coinflip()) - rot_hp(1); - break; + default: break; } @@ -712,7 +708,7 @@ bool is_damaging_cloud(cloud_type type, bool temp) case CLOUD_STEAM: return (player_res_steam(false, temp) <= 0); case CLOUD_MIASMA: - return (player_prot_life(false, temp) <= 2); + return (player_res_rotting()); default: // Smoke, never harmful. diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 51a3c46b4c..301bb6e8d6 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -386,9 +386,9 @@ public: virtual int res_cold() const = 0; virtual int res_elec() const = 0; virtual int res_poison() const = 0; + virtual int res_rotting() const = 0; virtual int res_asphyx() const = 0; virtual int res_sticky_flame() const = 0; - virtual int res_rotting() const = 0; virtual int res_holy_energy(const actor *attacker) const = 0; virtual int res_negative_energy() const = 0; virtual int res_torment() const = 0; @@ -1113,9 +1113,9 @@ public: int res_cold() const; int res_elec() const; int res_poison() const; + int res_rotting() const; int res_asphyx() const; int res_sticky_flame() const; - int res_rotting() const; int res_holy_energy(const actor *) const; int res_negative_energy() const; int res_torment() const; @@ -1474,9 +1474,9 @@ public: int res_cold() const; int res_elec() const; int res_poison() const; + int res_rotting() const; int res_asphyx() const; int res_sticky_flame() const; - int res_rotting() const; int res_holy_energy(const actor *) const; int res_negative_energy() const; int res_torment() const; diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 6497ac8fe5..ea025fe1a8 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2010,7 +2010,7 @@ static bool is_boolean_resist(beam_type flavour) switch (flavour) { case BEAM_ELECTRICITY: - case BEAM_MIASMA: + case BEAM_MIASMA: // rotting case BEAM_NAPALM: return (true); default: diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 885ed6eb37..7db6c96881 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1480,17 +1480,6 @@ int mons_res_cold(const monsters *mon) return (u); } -int mons_res_miasma(const monsters *mon) -{ - if (mons_holiness(mon) != MH_NATURAL - || mon->type == MONS_DEATH_DRAKE) - { - return (1); - } - - return (0); -} - int mons_res_negative_energy(const monsters *mon) { if (mons_holiness(mon) != MH_NATURAL @@ -3045,7 +3034,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell ) // Eventually, we'll probably want to be able to have monsters // learn which of their elemental bolts were resisted and have those - // handled here as well. -- bwr + // handled here as well. - bwr switch (monspell) { case SPELL_BRAIN_FEED: @@ -3053,7 +3042,6 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell ) break; case SPELL_BOLT_OF_DRAINING: - case SPELL_MIASMA: case SPELL_AGONY: case SPELL_SYMBOL_OF_TORMENT: { @@ -3082,6 +3070,10 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell ) break; } + case SPELL_MIASMA: + ret = (!foe || foe->res_rotting()); + break; + case SPELL_DISPEL_UNDEAD: // [ds] How is dispel undead intended to interact with vampires? ret = (!foe || foe->holiness() != MH_UNDEAD); diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index 1366f6042d..a869368efd 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -625,7 +625,6 @@ int mons_res_sticky_flame(const monsters *mon); int mons_res_rotting(const monsters *mon); int mons_res_acid(const monsters *mon); int mons_res_negative_energy(const monsters *mon); -int mons_res_miasma(const monsters *mon); // last updated 12may2000 {dlb} diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index af62b59e37..0c205d07bc 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -5423,7 +5423,7 @@ bool mons_avoids_cloud(const monsters *monster, cloud_type cl_type, { case CLOUD_MIASMA: // Even the dumbest monsters will avoid miasma if they can. - return (mons_res_miasma(monster) <= 0); + return (!mons_res_rotting(monster)); case CLOUD_FIRE: if (mons_res_fire(monster) > 1) @@ -9370,18 +9370,10 @@ static void _mons_in_cloud(monsters *monster) case CLOUD_MIASMA: simple_monster_message(monster, " is engulfed in a dark miasma!"); - if (mons_res_miasma(monster) > 0) + if (mons_res_rotting(monster)) return; - poison_monster(monster, cloud.whose); - - if (monster->max_hit_points > 4 && coinflip()) - monster->max_hit_points--; - - beam.flavour = BEAM_SLOW; - - if (one_chance_in(3)) - beam.apply_enchantment_to_monster(monster); + miasma_monster(monster, cloud.whose); hurted += (10 * random2avg(12, 3)) / speed; // 3 break; diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index b16fb08a45..91753b5ff0 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -215,7 +215,7 @@ int check_your_resists(int hurted, beam_type flavour) break; case BEAM_MIASMA: - if (x_chance_in_y(player_prot_life(), 3)) + if (player_res_rotting()) { canned_msg(MSG_YOU_RESIST); hurted = 0; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 13161c94c7..e0b9c41e48 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1712,6 +1712,17 @@ int player_res_poison(bool calc_unid, bool temp, bool items) return (rp); } +int player_res_rotting() +{ + if (you.is_undead + && (you.is_undead != US_SEMI_UNDEAD || you.hunger_state < HS_SATIATED)) + { + return (1); + } + + return (0); +} + int player_res_asphyx() { int ra = 0; @@ -5039,7 +5050,7 @@ void inc_hp(int hp_gain, bool max_too) you.redraw_hit_points = true; } -void rot_hp( int hp_loss ) +void rot_hp(int hp_loss) { you.base_hp -= hp_loss; calc_hp(); @@ -5050,7 +5061,7 @@ void rot_hp( int hp_loss ) you.redraw_hit_points = true; } -void unrot_hp( int hp_recovered ) +void unrot_hp(int hp_recovered) { if (hp_recovered >= 5000 - you.base_hp) you.base_hp = 5000; @@ -5062,12 +5073,12 @@ void unrot_hp( int hp_recovered ) you.redraw_hit_points = true; } -int player_rotted( void ) +int player_rotted() { return (5000 - you.base_hp); } -void rot_mp( int mp_loss ) +void rot_mp(int mp_loss) { you.base_magic_points -= mp_loss; calc_mp(); @@ -5502,6 +5513,30 @@ void reduce_poison_player(int amount) } } +bool miasma_player() +{ + ASSERT(!crawl_state.arena); + + if (player_res_rotting()) + return (false); + + bool success = poison_player(1); + + if (you.hp_max > 4 && coinflip()) + { + rot_hp(1); + success = true; + } + + if (one_chance_in(3)) + { + potion_effect(POT_SLOWING, 5); + success = true; + } + + return (success); +} + bool napalm_player(int amount) { ASSERT(!crawl_state.arena); @@ -5707,7 +5742,7 @@ bool rot_player(int amount) if (amount <= 0) return (false); - if (you.res_rotting() > 0) + if (player_res_rotting()) { mpr("You feel terrible."); return (false); @@ -6973,6 +7008,11 @@ int player::res_poison() const return (player_res_poison()); } +int player::res_rotting() const +{ + return (player_res_rotting()); +} + int player::res_sticky_flame() const { return (player_res_sticky_flame()); @@ -6997,17 +7037,6 @@ int player::res_negative_energy() const return (player_prot_life()); } -int player::res_rotting() const -{ - if (you.is_undead - && (you.is_undead != US_SEMI_UNDEAD || you.hunger_state < HS_SATIATED)) - { - return (1); - } - - return (0); -} - int player::res_torment() const { return (player_res_torment()); @@ -7143,7 +7172,7 @@ void player::drain_stat(int stat, int amount, actor *attacker) bool player::rot(actor *who, int amount, int immediate, bool quiet) { - if (res_rotting() > 0 || amount <= 0) + if (player_res_rotting() || amount <= 0) return (false); if (immediate > 0) diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index bb11ff8512..0cca6db53d 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -239,6 +239,7 @@ int player_res_steam(bool calc_unid = true, bool temp = true, * *********************************************************************** */ int player_res_poison(bool calc_unid = true, bool temp = true, bool items = true); +int player_res_rotting(); bool player_control_teleport(bool calc_unid = true, bool temp = true, bool items = true); @@ -394,10 +395,10 @@ void dec_mp(int mp_loss); void inc_mp(int mp_gain, bool max_too); void inc_hp(int hp_gain, bool max_too); -void rot_hp( int hp_loss ); -void unrot_hp( int hp_recovered ); +void rot_hp(int hp_loss); +void unrot_hp(int hp_recovered); int player_rotted(); -void rot_mp( int mp_loss ); +void rot_mp(int mp_loss); void inc_max_hp( int hp_gain ); void dec_max_hp( int hp_loss ); @@ -424,6 +425,7 @@ bool curare_hits_player(int death_source, int amount); bool poison_player(int amount, bool force = false); void dec_poison_player(); void reduce_poison_player(int amount); +bool miasma_player(); bool napalm_player(int amount); void dec_napalm_player(); -- cgit v1.2.3-54-g00ecf