From 4fd0078136544a8230f7581e87b57ecd53478414 Mon Sep 17 00:00:00 2001 From: dolorous Date: Wed, 12 Nov 2008 17:27:03 +0000 Subject: Add more player duration cleanups, and fix ouch() napalm death sources. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7439 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 28 +-------- crawl-ref/source/beam.cc | 34 +++++----- crawl-ref/source/ouch.cc | 7 ++- crawl-ref/source/player.cc | 148 ++++++++++++++++++++++++++------------------ crawl-ref/source/player.h | 10 ++- crawl-ref/source/spells1.cc | 10 ++- crawl-ref/source/spells1.h | 2 +- 7 files changed, 120 insertions(+), 119 deletions(-) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index c0790a49c0..182ba873ca 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2918,31 +2918,7 @@ static void _decrement_durations() dec_disease_player(); - if (you.duration[DUR_POISONING] > 0) - { - if (x_chance_in_y(you.duration[DUR_POISONING], 5)) - { - if (you.duration[DUR_POISONING] > 10 && random2(you.duration[DUR_POISONING]) >= 8) - { - ouch(random2(10) + 5, NON_MONSTER, KILLED_BY_POISON); - mpr("You feel extremely sick.", MSGCH_DANGER); - } - else if (you.duration[DUR_POISONING] > 5 && coinflip()) - { - ouch((coinflip() ? 3 : 2), NON_MONSTER, KILLED_BY_POISON); - mpr("You feel very sick.", MSGCH_WARN); - } - else - { - // "the poison running through your veins."); - ouch(1, NON_MONSTER, KILLED_BY_POISON); - mpr("You feel sick."); - } - - if ((you.hp == 1 && one_chance_in(3)) || one_chance_in(8)) - reduce_poison_player(1); - } - } + dec_poison_player(); if (you.duration[DUR_DEATHS_DOOR]) { @@ -3172,7 +3148,7 @@ static void _world_reacts() if (you.hunger <= 100) { - mpr( "You have starved to death.", MSGCH_FOOD ); + mpr("You have starved to death.", MSGCH_FOOD); ouch(INSTANT_DEATH, NON_MONSTER, KILLED_BY_STARVATION); } } diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 24f554c6a4..a49f943d84 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2371,7 +2371,6 @@ 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) { @@ -2379,9 +2378,11 @@ bool curare_hits_monster(const bolt &beam, monsters *monster, const bool res_poison = mons_res_poison(monster) > 0; + int hurted = 0; + if (!mons_res_asphyx(monster)) { - int hurted = roll_dice(2, 6); + hurted = roll_dice(2, 6); // Note that the hurtage is halved by poison resistance. if (res_poison) @@ -2401,7 +2402,7 @@ bool curare_hits_monster(const bolt &beam, monsters *monster, if (who == KC_YOU) did_god_conduct(DID_POISON, 5 + random2(3)); - return (!monster->alive()); + return (hurted > 0); } // Actually poisons a monster (with message). @@ -4452,11 +4453,12 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) napalm_monster(mon, _whose_kill(beam), levels); } + bool wake_mimic = true; + // Handle missile effects. - if (item) + if (item && item->base_type == OBJ_MISSILES) { - if (item->base_type == OBJ_MISSILES - && item->special == SPMSL_POISONED) + if (item->special == SPMSL_POISONED) { int num_levels = 0; // ench_power == AUTOMATIC_HIT if this is a poisoned needle. @@ -4484,23 +4486,21 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) { if (num_success == 2) num_levels++; - poison_monster( mon, _whose_kill(beam), num_levels ); + poison_monster(mon, _whose_kill(beam), num_levels); } } - } - - bool wake_mimic = true; - if (item && item->base_type == OBJ_MISSILES - && item->special == SPMSL_CURARE) - { - if (beam.ench_power == AUTOMATIC_HIT - && curare_hits_monster( beam, mon, _whose_kill(beam), 2 )) + else if (item->special == SPMSL_CURARE) { - wake_mimic = false; + if (beam.ench_power == AUTOMATIC_HIT + && curare_hits_monster(beam, mon, _whose_kill(beam), 2) + && !mon->alive()) + { + wake_mimic = false; + } } } - if (wake_mimic && mons_is_mimic( mon->type )) + if (wake_mimic && mons_is_mimic(mon->type)) mimic_alert(mon); else if (hit_woke_orc) beogh_follower_convert(mon, true); diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index f38eca7e9b..078d80be82 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -795,10 +795,13 @@ static void _yred_mirrors_injury(int dam, int death_source) if (dam <= 0 || invalid_monster_index(death_source)) return; - simple_god_message(" mirrors your injury!"); - monsters *mon = &menv[death_source]; + if (!mon->alive()) + return; + + simple_god_message(" mirrors your injury!"); + #ifndef USE_TILE flash_monster_colour(mon, RED, 200); #endif diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 775a2cc810..f796518b40 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5016,15 +5016,50 @@ void contaminate_player(int change, bool controlled, bool status_only) } } -void curare_hits_player(int agent, int degree) +bool confuse_player(int amount, bool resistable) { - const bool res_poison = player_res_poison(); + if (amount <= 0) + return (false); + + if (resistable && wearing_amulet(AMU_CLARITY)) + { + mpr("You feel momentarily confused."); + return (false); + } + + const int old_value = you.duration[DUR_CONF]; + you.duration[DUR_CONF] += amount; + + if (you.duration[DUR_CONF] > 40) + you.duration[DUR_CONF] = 40; + + if (you.duration[DUR_CONF] > old_value) + { + you.check_awaken(500); + + mprf(MSGCH_WARN, "You are %sconfused.", + old_value > 0 ? "more " : ""); + + learned_something_new(TUT_YOU_ENCHANTED); + xom_is_stimulated(you.duration[DUR_CONF] - old_value); + } + + return (true); +} + +bool curare_hits_player(int agent, int degree) +{ poison_player(degree); + const bool res_poison = player_res_poison() > 0; + + int hurted = 0; + if (!player_res_asphyx()) { - int hurted = roll_dice(2, 6); + hurted = roll_dice(2, 6); + // Note that the hurtage is halved by poison resistance. if (res_poison) hurted /= 2; @@ -5037,11 +5072,13 @@ void curare_hits_player(int agent, int degree) potion_effect(POT_SLOWING, 2 + random2(4 + degree)); } + + return (hurted > 0); } bool poison_player(int amount, bool force) { - if (!force && player_res_poison() || amount <= 0) + if (!force && player_res_poison() > 0 || amount <= 0) return (false); const int old_value = you.duration[DUR_POISONING]; @@ -5061,25 +5098,60 @@ bool poison_player(int amount, bool force) return (true); } +void dec_poison_player() +{ + if (you.duration[DUR_POISONING] > 0) + { + if (x_chance_in_y(you.duration[DUR_POISONING], 5)) + { + int hurted = 1; + msg_channel_type channel = MSGCH_PLAIN; + const char *adj = ""; + + if (you.duration[DUR_POISONING] > 10 + && random2(you.duration[DUR_POISONING]) >= 8) + { + hurted = random2(10) + 5; + channel = MSGCH_DANGER; + adj = "extremely "; + } + else if (you.duration[DUR_POISONING] > 5 && coinflip()) + { + hurted = coinflip() ? 3 : 2; + channel = MSGCH_WARN; + adj = "very "; + } + + ouch(hurted, NON_MONSTER, KILLED_BY_POISON); + mprf(channel, "You feel %ssick.", adj); + + if ((you.hp == 1 && one_chance_in(3)) || one_chance_in(8)) + reduce_poison_player(1); + } + } +} + void reduce_poison_player(int amount) { - if (you.duration[DUR_POISONING] == 0 || amount <= 0) + if (amount <= 0) return; + const int old_value = you.duration[DUR_POISONING]; you.duration[DUR_POISONING] -= amount; - if (you.duration[DUR_POISONING] <= 0) - { + if (you.duration[DUR_POISONING] < 0) you.duration[DUR_POISONING] = 0; - mpr("You feel better.", MSGCH_RECOVERY); + + if (you.duration[DUR_POISONING] < old_value) + { + mprf(MSGCH_RECOVERY, "You feel %sbetter.", + you.duration[DUR_POISONING] > 0 ? "a little " : ""); } - else - mpr("You feel a little better.", MSGCH_RECOVERY); } bool napalm_player(int amount) { - if (player_res_sticky_flame() || amount <= 0) + if (player_res_sticky_flame() > 0 || amount <= 0) return (false); const int old_value = you.duration[DUR_LIQUID_FLAMES]; @@ -5115,14 +5187,14 @@ void dec_napalm_player() if (res_fire <= 0) { - ouch(((random2avg(9, 2) + 1) * you.time_taken) / 10, 0, - KILLED_BY_BURNING); + 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, 0, - KILLED_BY_BURNING); + ouch(((random2avg(9, 2) + 1) * you.time_taken) / 10, + NON_MONSTER, KILLED_BY_BURNING); } if (you.duration[DUR_CONDENSATION_SHIELD] > 0) @@ -5132,52 +5204,6 @@ void dec_napalm_player() you.duration[DUR_LIQUID_FLAMES] = 0; } -bool confuse_player(int amount, bool resistable) -{ - if (amount <= 0) - return (false); - - if (resistable && wearing_amulet(AMU_CLARITY)) - { - mpr("You feel momentarily confused."); - return (false); - } - - const int old_value = you.duration[DUR_CONF]; - you.duration[DUR_CONF] += amount; - - if (you.duration[DUR_CONF] > 40) - you.duration[DUR_CONF] = 40; - - if (you.duration[DUR_CONF] > old_value) - { - you.check_awaken(500); - - mprf(MSGCH_WARN, "You are %sconfused.", - (old_value > 0) ? "more " : "" ); - - learned_something_new(TUT_YOU_ENCHANTED); - - xom_is_stimulated(you.duration[DUR_CONF] - old_value); - } - - return (true); -} - -void reduce_confuse_player(int amount) -{ - if (you.duration[DUR_CONF] == 0 || amount <= 0) - return; - - you.duration[DUR_CONF] -= amount; - - if (you.duration[DUR_CONF] <= 0) - { - you.duration[DUR_CONF] = 0; - mpr("You feel less confused."); - } -} - bool slow_player(int amount) { if (amount <= 0) diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 1637c6a849..199d2e3066 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -415,24 +415,22 @@ void set_mp(int new_amount, bool max_too); void contaminate_player(int change, bool controlled = false, bool status_only = false); -/* @return true iff they were poisoned (false if they are immune) */ -void curare_hits_player(int agent, int degree); +bool confuse_player(int amount, bool resistable = true); + +bool curare_hits_player(int agent, int degree); bool poison_player(int amount, bool force = false); +void dec_poison_player(); void reduce_poison_player(int amount); bool napalm_player(int amount); void dec_napalm_player(); -bool confuse_player(int amount, bool resistable = true); -void reduce_confuse_player(int amount); - bool slow_player(int amount); void dec_slow_player(); void haste_player(int amount); void dec_haste_player(); -/* return true iff they were diseased */ bool disease_player(int amount); void dec_disease_player(); diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index b26296c2de..fe99b952c9 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -1013,14 +1013,12 @@ bool cast_revivification(int pow) return (success); } -void cast_cure_poison(int mabil) +void cast_cure_poison(int pow) { - if (!you.duration[DUR_POISONING]) - canned_msg(MSG_NOTHING_HAPPENS); + if (you.duration[DUR_POISONING] > 0) + reduce_poison_player(2 + random2(pow) + random2(3)); else - reduce_poison_player( 2 + random2(mabil) + random2(3) ); - - return; + canned_msg(MSG_NOTHING_HAPPENS); } void purification(void) diff --git a/crawl-ref/source/spells1.h b/crawl-ref/source/spells1.h index cad0bbaef2..8b32ca2264 100644 --- a/crawl-ref/source/spells1.h +++ b/crawl-ref/source/spells1.h @@ -44,7 +44,7 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink = false); int cast_big_c(int pow, cloud_type cty, kill_category whose, bolt &beam); void cast_confusing_touch(int power); -void cast_cure_poison(int mabil); +void cast_cure_poison(int pow); int allowed_deaths_door_hp(void); void cast_deaths_door(int pow); void setup_fire_storm(const actor *source, int pow, bolt &beam); -- cgit v1.2.3-54-g00ecf