From 39bd7b8798e06d472f38351446fa5d0ff89ec377 Mon Sep 17 00:00:00 2001 From: dolorous Date: Fri, 7 Nov 2008 19:29:37 +0000 Subject: Add poison-related cleanups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7400 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 37 ++++++++++++++++++------------------- crawl-ref/source/beam.h | 6 ++++-- crawl-ref/source/externs.h | 6 +++--- crawl-ref/source/fight.cc | 17 +++++++---------- crawl-ref/source/misc.cc | 23 ----------------------- crawl-ref/source/misc.h | 2 -- crawl-ref/source/mon-util.cc | 2 +- crawl-ref/source/player.cc | 36 ++++++++++++++++++++++++++++++------ crawl-ref/source/player.h | 5 +++-- 9 files changed, 66 insertions(+), 68 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 5470dfb70a..8622b566ea 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2370,8 +2370,8 @@ static void _beam_petrifies_monster(bolt &pbolt, monsters *monster) } // Returns true if the curare killed the monster. -bool curare_hits_monster( const bolt &beam, monsters *monster, - kill_category who, int levels ) +bool curare_hits_monster(const bolt &beam, monsters *monster, + kill_category who, int levels) { const bool res_poison = mons_res_poison(monster) > 0; @@ -2397,17 +2397,14 @@ bool curare_hits_monster( const bolt &beam, monsters *monster, // Deities take notice. if (who == KC_YOU) - did_god_conduct( DID_POISON, 5 + random2(3) ); + did_god_conduct(DID_POISON, 5 + random2(3)); return (!monster->alive()); } -// Actually poisons a monster (w/ message). -bool poison_monster( monsters *monster, - kill_category from_whom, - int levels, - bool force, - bool verbose) +// Actually poisons a monster (with message). +bool poison_monster(monsters *monster, kill_category who, int levels, + bool force, bool verbose) { if (!monster->alive()) return (false); @@ -2416,21 +2413,23 @@ bool poison_monster( monsters *monster, return (false); const mon_enchant old_pois = monster->get_ench(ENCH_POISON); - monster->add_ench( mon_enchant(ENCH_POISON, levels, from_whom) ); + monster->add_ench(mon_enchant(ENCH_POISON, levels, who)); const mon_enchant new_pois = monster->get_ench(ENCH_POISON); - // Actually do the poisoning. - // Note: order important here. - if (verbose && new_pois.degree > old_pois.degree) + // Actually do the poisoning. The order is important here. + if (new_pois.degree > old_pois.degree) { - simple_monster_message( monster, - !old_pois.degree? " is poisoned." - : " looks even sicker." ); + if (verbose) + { + simple_monster_message(monster, + old_pois.degree > 0 ? " looks even sicker." + : " is poisoned."); + } } // Finally, take care of deity preferences. - if (from_whom == KC_YOU) - did_god_conduct( DID_POISON, 5 + random2(3) ); + if (who == KC_YOU) + did_god_conduct(DID_POISON, 5 + random2(3)); return (new_pois.degree > old_pois.degree); } @@ -3887,7 +3886,7 @@ static int _affect_player( bolt &beam, item_def *item, bool affect_items ) && (hurted || beam.ench_power == AUTOMATIC_HIT && x_chance_in_y(90 - 3 * player_AC(), 100))) { - poison_player( 1 + random2(3) ); + poison_player(1 + random2(3)); was_affected = true; } } diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h index 0cf97ad563..f44b638356 100644 --- a/crawl-ref/source/beam.h +++ b/crawl-ref/source/beam.h @@ -127,8 +127,10 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int who, mon_resist_type mons_ench_f2(monsters *monster, bolt &pbolt); -bool poison_monster( monsters *monster, kill_category who, - int levels = 1, bool force = false, bool verbose = true ); +bool curare_hits_monster(const bolt &beam, 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); void fire_tracer( const monsters *monster, struct bolt &pbolt, bool explode_only = false ); bool check_line_of_sight( const coord_def& source, const coord_def& target ); diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 57fb104bef..62dbc942ca 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -343,11 +343,11 @@ public: virtual mon_holy_type holiness() const = 0; virtual int res_fire() const = 0; - virtual int res_sticky_flame() const = 0; virtual int res_steam() const = 0; virtual int res_cold() const = 0; virtual int res_elec() const = 0; virtual int res_poison() const = 0; + virtual int res_sticky_flame() const = 0; virtual int res_negative_energy() const = 0; virtual int res_rotting() const = 0; virtual int res_torment() const = 0; @@ -902,11 +902,11 @@ public: mon_holy_type holiness() const; int res_fire() const; - int res_sticky_flame() const; int res_steam() const; int res_cold() const; int res_elec() const; int res_poison() const; + int res_sticky_flame() const; int res_negative_energy() const; int res_rotting() const; int res_torment() const; @@ -1252,11 +1252,11 @@ public: mon_holy_type holiness() const; int res_fire() const; - int res_sticky_flame() const; int res_steam() const; int res_cold() const; int res_elec() const; int res_poison() const; + int res_sticky_flame() const; int res_negative_energy() const; int res_rotting() const; int res_torment() const; diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index f0162a5e3a..0945828291 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -728,11 +728,8 @@ static bool _player_vampire_draws_blood(const int mons, const int damage, int food_value = 0; if (chunk_type == CE_CLEAN) food_value = 30 + random2avg(59, 2); - else if (chunk_type == CE_CONTAMINATED - || chunk_type == CE_POISONOUS) - { + else if (chunk_type == CE_CONTAMINATED || chunk_type == CE_POISONOUS) food_value = 15 + random2avg(29, 2); - } // Bats get a rather less nutrition out of it. if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) @@ -1200,7 +1197,7 @@ bool melee_attack::player_apply_aux_unarmed() attack_strength_punctuation().c_str()); if (damage_brand == SPWPN_VENOM && coinflip()) - poison_monster( def, KC_YOU ); + poison_monster(def, KC_YOU); // Normal vampiric biting attack, not if already got stabbing special. if (damage_brand == SPWPN_VAMPIRICISM && you.species == SP_VAMPIRE @@ -2207,7 +2204,7 @@ bool melee_attack::apply_damage_brand() // Weapons of venom do two levels of poisoning to the player, // but only one level to monsters. - defender->poison( attacker, 2 ); + defender->poison(attacker, 2); if (defender->atype() == ACT_PLAYER && old_poison < you.duration[DUR_POISONING] @@ -3473,9 +3470,9 @@ void melee_attack::mons_do_poison(const mon_attack_def &attk) return; if (attk.flavour == AF_POISON_NASTY - || one_chance_in( 15 + 5 * (attk.flavour == AF_POISON) ) + || one_chance_in(15 + 5 * (attk.flavour == AF_POISON ? 1 : 0)) || (damage_done > 1 - && one_chance_in( attk.flavour == AF_POISON? 4 : 3 ))) + && one_chance_in(attk.flavour == AF_POISON ? 4 : 3))) { if (needs_message) { @@ -3505,7 +3502,7 @@ void melee_attack::mons_do_poison(const mon_attack_def &attk) else if (attk.flavour == AF_POISON_STRONG) amount += roll_dice(2, 5); - defender->poison( attacker, amount ); + defender->poison(attacker, amount); } } @@ -3766,7 +3763,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk) case AF_ACID: if (attacker->id() == MONS_SPINY_WORM && defender->res_poison() <= 0) - defender->poison( attacker, 2 + random2(4) ); + defender->poison(attacker, 2 + random2(4)); splash_defender_with_acid(3); break; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index a4f7f5e80b..4eecb216f0 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -48,7 +48,6 @@ #include "food.h" #include "format.h" #include "hiscores.h" -#include "it_use2.h" #include "itemprop.h" #include "items.h" #include "lev-pand.h" @@ -1298,28 +1297,6 @@ void search_around( bool only_adjacent ) } } -void curare_hits_player(int agent, int degree) -{ - const bool res_poison = player_res_poison(); - - poison_player(degree); - - if (!player_res_asphyx()) - { - int hurted = roll_dice(2, 6); - // Note that the hurtage is halved by poison resistance. - if (res_poison) - hurted /= 2; - - if (hurted) - { - mpr("You have difficulty breathing."); - ouch(hurted, agent, KILLED_BY_CURARE, "curare-induced apnoea"); - } - potion_effect(POT_SLOWING, 2 + random2(4 + degree)); - } -} - void merfolk_start_swimming(void) { if (you.attribute[ATTR_TRANSFORMATION] != TRAN_NONE) diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index efccdec0c7..6a7a095e9c 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -69,8 +69,6 @@ std::string weird_smell(); std::string weird_sound(); -void curare_hits_player(int agent, int degree); - bool mons_is_safe(const monsters *mon, bool want_move = false); bool need_auto_exclude(const monsters *mon, bool sleepy = false); void remove_auto_exclude(const monsters *mon, bool sleepy = false); diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 6a6bc3c7df..381af53734 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -5163,7 +5163,7 @@ int monsters::skill(skill_type sk, bool) const switch (sk) { case SK_NECROMANCY: - return (holiness() == MH_UNDEAD? hit_dice / 2 : hit_dice / 3); + return (holiness() == MH_UNDEAD ? hit_dice / 2 : hit_dice / 3); default: return (0); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 2acfa1a66b..a67a2f3481 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -34,6 +34,7 @@ #include "itemname.h" #include "itemprop.h" #include "items.h" +#include "it_use2.h" #include "Kills.h" #include "macro.h" #include "message.h" @@ -5013,7 +5014,29 @@ void contaminate_player(int change, bool controlled, bool status_only) } } -bool poison_player( int amount, bool force ) +void curare_hits_player(int agent, int degree) +{ + const bool res_poison = player_res_poison(); + + poison_player(degree); + + if (!player_res_asphyx()) + { + int hurted = roll_dice(2, 6); + // Note that the hurtage is halved by poison resistance. + if (res_poison) + hurted /= 2; + + if (hurted) + { + mpr("You have difficulty breathing."); + ouch(hurted, agent, KILLED_BY_CURARE, "curare-induced apnoea"); + } + potion_effect(POT_SLOWING, 2 + random2(4 + degree)); + } +} + +bool poison_player(int amount, bool force) { if (!force && player_res_poison() || amount <= 0) return (false); @@ -5027,13 +5050,14 @@ bool poison_player( int amount, bool force ) if (you.duration[DUR_POISONING] > old_value) { mprf(MSGCH_WARN, "You are %spoisoned.", - (old_value > 0) ? "more " : "" ); + old_value > 0 ? "more " : ""); learned_something_new(TUT_YOU_POISON); } + return (true); } -void reduce_poison_player( int amount ) +void reduce_poison_player(int amount) { if (you.duration[DUR_POISONING] == 0 || amount <= 0) return; @@ -5043,10 +5067,10 @@ void reduce_poison_player( int amount ) if (you.duration[DUR_POISONING] <= 0) { you.duration[DUR_POISONING] = 0; - mpr( "You feel better.", MSGCH_RECOVERY ); + mpr("You feel better.", MSGCH_RECOVERY); } else - mpr( "You feel a little better.", MSGCH_RECOVERY ); + mpr("You feel a little better.", MSGCH_RECOVERY); } bool confuse_player( int amount, bool resistable ) @@ -6474,7 +6498,7 @@ int player::mons_species() const } } -void player::poison(actor*, int amount) +void player::poison(actor *agent, int amount) { ::poison_player(amount); } diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 4d6eb1ac9a..a6c4b5f55c 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -416,8 +416,9 @@ void contaminate_player(int change, bool controlled = false, bool status_only = false); /* @return true iff they were poisoned (false if they are immune) */ -bool poison_player( int amount, bool force = false ); -void reduce_poison_player( int amount ); +void curare_hits_player(int agent, int degree); +bool poison_player(int amount, bool force = false); +void reduce_poison_player(int amount); bool confuse_player( int amount, bool resistable = true ); void reduce_confuse_player( int amount ); -- cgit v1.2.3-54-g00ecf