diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-09 03:44:28 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-09 03:44:28 +0000 |
commit | c4c40b70b10e104a1f567a5a23e6f9bc60c66a61 (patch) | |
tree | 2be6cd26101d2865aac0cff9979e29641efe16a0 /crawl-ref | |
parent | 751e25e3d06d60d6e9709a1a38641a3faeb39325 (diff) | |
download | crawl-ref-c4c40b70b10e104a1f567a5a23e6f9bc60c66a61.tar.gz crawl-ref-c4c40b70b10e104a1f567a5a23e6f9bc60c66a61.zip |
Moved some cloud related functions from misc.{cc,h} to cloud.{cc,h}
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5636 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/cloud.cc | 312 | ||||
-rw-r--r-- | crawl-ref/source/cloud.h | 9 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 292 | ||||
-rw-r--r-- | crawl-ref/source/misc.h | 13 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 1 |
7 files changed, 317 insertions, 314 deletions
diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 9743531da1..94d065fd11 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -20,10 +20,11 @@ #include "branch.h" #include "cloud.h" +#include "it_use2.h" #include "mapmark.h" -#include "misc.h" #include "ouch.h" #include "place.h" +#include "player.h" #include "stuff.h" #include "terrain.h" @@ -322,6 +323,308 @@ cloud_type random_smoke_type() return CLOUD_DEBUGGING; } +cloud_type beam2cloud(beam_type flavour) +{ + switch (flavour) + { + default: + case BEAM_NONE: + return CLOUD_NONE; + case BEAM_FIRE: + case BEAM_POTION_FIRE: + return CLOUD_FIRE; + case BEAM_POTION_STINKING_CLOUD: + return CLOUD_STINK; + case BEAM_COLD: + case BEAM_POTION_COLD: + return CLOUD_COLD; + case BEAM_POISON: + case BEAM_POTION_POISON: + return CLOUD_POISON; + case BEAM_POTION_BLACK_SMOKE: + return CLOUD_BLACK_SMOKE; + case BEAM_POTION_GREY_SMOKE: + return CLOUD_GREY_SMOKE; + case BEAM_POTION_BLUE_SMOKE: + return CLOUD_BLUE_SMOKE; + case BEAM_POTION_PURP_SMOKE: + return CLOUD_PURP_SMOKE; + case BEAM_STEAM: + case BEAM_POTION_STEAM: + return CLOUD_STEAM; + case BEAM_MIASMA: + case BEAM_POTION_MIASMA: + return CLOUD_MIASMA; + case BEAM_RANDOM: + return CLOUD_RANDOM; + } +} + +beam_type cloud2beam(cloud_type flavour) +{ + switch (flavour) + { + default: + case CLOUD_NONE: + return BEAM_NONE; + case CLOUD_FIRE: + return BEAM_FIRE; + case CLOUD_STINK: + return BEAM_POTION_STINKING_CLOUD; + case CLOUD_COLD: + return BEAM_COLD; + case CLOUD_POISON: + return BEAM_POISON; + case CLOUD_BLACK_SMOKE: + return BEAM_POTION_BLACK_SMOKE; + case CLOUD_GREY_SMOKE: + return BEAM_POTION_GREY_SMOKE; + case CLOUD_BLUE_SMOKE: + return BEAM_POTION_BLUE_SMOKE; + case CLOUD_PURP_SMOKE: + return BEAM_POTION_PURP_SMOKE; + case CLOUD_STEAM: + return BEAM_STEAM; + case CLOUD_MIASMA: + return BEAM_MIASMA; + case CLOUD_RANDOM: + return BEAM_RANDOM; + } +} + +void in_a_cloud() +{ + int cl = env.cgrid[you.x_pos][you.y_pos]; + int hurted = 0; + int resist; + + if (you.duration[DUR_CONDENSATION_SHIELD] > 0) + { + mpr("Your icy shield dissipates!", MSGCH_DURATION); + you.duration[DUR_CONDENSATION_SHIELD] = 0; + you.redraw_armour_class = 1; + } + + switch (env.cloud[cl].type) + { + case CLOUD_FIRE: + if (you.duration[DUR_FIRE_SHIELD]) + return; + + mpr("You are engulfed in roaring flames!"); + + resist = player_res_fire(); + + if (resist <= 0) + { + hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; + + if (resist < 0) + hurted += ((random2avg(14, 2) + 3) * you.time_taken) / 10; + + hurted -= random2(player_AC()); + + if (hurted < 1) + hurted = 0; + else + ouch( hurted, cl, KILLED_BY_CLOUD, "flame" ); + } + else + { + canned_msg(MSG_YOU_RESIST); + hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; + hurted /= (1 + resist * resist); + ouch( hurted, cl, KILLED_BY_CLOUD, "flame" ); + } + expose_player_to_element(BEAM_FIRE, 7); + break; + + case CLOUD_STINK: + // If you don't have to breathe, unaffected + mpr("You are engulfed in noxious fumes!"); + if (player_res_poison()) + break; + + hurted += (random2(3) * you.time_taken) / 10; + if (hurted < 1) + hurted = 0; + else + ouch( (hurted * you.time_taken) / 10, cl, KILLED_BY_CLOUD, + "noxious fumes" ); + + if (1 + random2(27) >= you.experience_level) + { + mpr("You choke on the stench!"); + confuse_player( (coinflip() ? 3 : 2) ); + } + break; + + case CLOUD_COLD: + mpr("You are engulfed in freezing vapours!"); + + resist = player_res_cold(); + + if (resist <= 0) + { + hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; + + if (resist < 0) + hurted += ((random2avg(14, 2) + 3) * you.time_taken) / 10; + + hurted -= random2(player_AC()); + if (hurted < 0) + hurted = 0; + + ouch( hurted, cl, KILLED_BY_CLOUD, "freezing vapour" ); + } + else + { + canned_msg(MSG_YOU_RESIST); + hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; + hurted /= (1 + resist * resist); + ouch( hurted, cl, KILLED_BY_CLOUD, "freezing vapour" ); + } + expose_player_to_element(BEAM_COLD, 7); + break; + + case CLOUD_POISON: + // If you don't have to breathe, unaffected + mpr("You are engulfed in poison gas!"); + if (!player_res_poison()) + { + ouch( (random2(10) * you.time_taken) / 10, cl, KILLED_BY_CLOUD, + "poison gas" ); + poison_player(1); + } + break; + + case CLOUD_GREY_SMOKE: + case CLOUD_BLUE_SMOKE: + case CLOUD_PURP_SMOKE: + case CLOUD_BLACK_SMOKE: + mpr("You are engulfed in a cloud of smoke!"); + break; + + case CLOUD_STEAM: + { + mpr("You are engulfed in a cloud of scalding steam!"); + if (player_res_steam() > 0) + { + mpr("It doesn't seem to affect you."); + return; + } + + const int base_dam = steam_cloud_damage(env.cloud[cl]); + hurted += (random2avg(base_dam, 2) * you.time_taken) / 10; + + const int res_fire = player_res_fire(); + if (res_fire < 0) + hurted += (random2(base_dam / 2 + 1) * you.time_taken) / 10; + else if (res_fire) + hurted /= 1 + (res_fire / 2); + + if (hurted < 0) + hurted = 0; + + ouch( (hurted * you.time_taken) / 10, cl, KILLED_BY_CLOUD, + "steam" ); + break; + } + + case CLOUD_MIASMA: + mpr("You are engulfed in a dark miasma."); + + if (player_prot_life() > random2(3)) + return; + + poison_player(1); + + hurted += (random2avg(12, 3) * you.time_taken) / 10; // 3 + + if (hurted < 0) + 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; + } + + return; +} // end in_a_cloud() + +bool is_damaging_cloud(cloud_type type, bool temp) +{ + switch (type) + { + // always harmful + case CLOUD_FIRE: + case CLOUD_COLD: + return (true); + + // Only harmful if the player doesn't have the necessary resistances. + // Takes into account what the player can *know* and what s/he can + // also expect to be the case a few turns later (ignores spells). + case CLOUD_STINK: + case CLOUD_POISON: + return (!player_res_poison(false, temp)); + case CLOUD_STEAM: + return (player_res_steam(false, temp) <= 0); + case CLOUD_MIASMA: + return (player_prot_life(false, temp) <= 2); + + default: + // Smoke, never harmful. + return (false); + } +} + +std::string cloud_name(cloud_type type) +{ + switch (type) + { + case CLOUD_FIRE: + return "flame"; + case CLOUD_STINK: + return "noxious fumes"; + case CLOUD_COLD: + return "freezing vapour"; + case CLOUD_POISON: + return "poison gases"; + case CLOUD_GREY_SMOKE: + return "grey smoke"; + case CLOUD_BLUE_SMOKE: + return "blue smoke"; + case CLOUD_PURP_SMOKE: + return "purple smoke"; + case CLOUD_STEAM: + return "steam"; + case CLOUD_MIASMA: + return "foul pestilence"; + case CLOUD_BLACK_SMOKE: + return "black smoke"; + case CLOUD_MIST: + return "thin mist"; + default: + return "buggy goodness"; + } +} + +//////////////////////////////////////////////////////////////////////// +// cloud_struct + +killer_type cloud_struct::beam_thrower() const +{ + return (whose == KC_YOU ? KILL_YOU_MISSILE : KILL_MON_MISSILE); +} +////////////////////////////////////////////////////////////////////////// +// Fog machine stuff + void place_fog_machine(fog_machine_type fm_type, cloud_type cl_type, int x, int y, int size, int power) { @@ -515,10 +818,3 @@ fog_machine_data fogs_lab_type(int level_number) return data; } -//////////////////////////////////////////////////////////////////////// -// cloud_struct - -killer_type cloud_struct::beam_thrower() const -{ - return (whose == KC_YOU ? KILL_YOU_MISSILE : KILL_MON_MISSILE); -} diff --git a/crawl-ref/source/cloud.h b/crawl-ref/source/cloud.h index 7a4c0239ee..ae0bd5dd79 100644 --- a/crawl-ref/source/cloud.h +++ b/crawl-ref/source/cloud.h @@ -50,6 +50,15 @@ void manage_clouds(void); bool is_opaque_cloud(unsigned char cloud_idx); int steam_cloud_damage(const cloud_struct &cloud); +cloud_type beam2cloud(beam_type flavour); +beam_type cloud2beam(cloud_type flavour); + +void in_a_cloud(void); + +std::string cloud_name(cloud_type type); + +bool is_damaging_cloud(cloud_type type, bool temp = false); + void place_fog_machine(fog_machine_type fm_type, cloud_type cl_type, int x, int y, int size, int power); diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 02f3bd766c..74083641d4 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -34,6 +34,7 @@ #include "externs.h" #include "cio.h" +#include "cloud.h" #include "command.h" #include "debug.h" #include "describe.h" @@ -41,8 +42,8 @@ #include "itemname.h" #include "mapmark.h" #include "message.h" -#include "misc.h" #include "menu.h" +#include "misc.h" #include "monstuff.h" #include "mon-util.h" #include "player.h" diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index c1115df870..90879d3d75 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1307,241 +1307,6 @@ void search_around( bool only_adjacent ) return; } -cloud_type beam2cloud(beam_type flavour) -{ - switch (flavour) - { - default: - case BEAM_NONE: - return CLOUD_NONE; - case BEAM_FIRE: - case BEAM_POTION_FIRE: - return CLOUD_FIRE; - case BEAM_POTION_STINKING_CLOUD: - return CLOUD_STINK; - case BEAM_COLD: - case BEAM_POTION_COLD: - return CLOUD_COLD; - case BEAM_POISON: - case BEAM_POTION_POISON: - return CLOUD_POISON; - case BEAM_POTION_BLACK_SMOKE: - return CLOUD_BLACK_SMOKE; - case BEAM_POTION_GREY_SMOKE: - return CLOUD_GREY_SMOKE; - case BEAM_POTION_BLUE_SMOKE: - return CLOUD_BLUE_SMOKE; - case BEAM_POTION_PURP_SMOKE: - return CLOUD_PURP_SMOKE; - case BEAM_STEAM: - case BEAM_POTION_STEAM: - return CLOUD_STEAM; - case BEAM_MIASMA: - case BEAM_POTION_MIASMA: - return CLOUD_MIASMA; - case BEAM_RANDOM: - return CLOUD_RANDOM; - } -} - -beam_type cloud2beam(cloud_type flavour) -{ - switch (flavour) - { - default: - case CLOUD_NONE: - return BEAM_NONE; - case CLOUD_FIRE: - return BEAM_FIRE; - case CLOUD_STINK: - return BEAM_POTION_STINKING_CLOUD; - case CLOUD_COLD: - return BEAM_COLD; - case CLOUD_POISON: - return BEAM_POISON; - case CLOUD_BLACK_SMOKE: - return BEAM_POTION_BLACK_SMOKE; - case CLOUD_GREY_SMOKE: - return BEAM_POTION_GREY_SMOKE; - case CLOUD_BLUE_SMOKE: - return BEAM_POTION_BLUE_SMOKE; - case CLOUD_PURP_SMOKE: - return BEAM_POTION_PURP_SMOKE; - case CLOUD_STEAM: - return BEAM_STEAM; - case CLOUD_MIASMA: - return BEAM_MIASMA; - case CLOUD_RANDOM: - return BEAM_RANDOM; - } -} - -void in_a_cloud() -{ - int cl = env.cgrid[you.x_pos][you.y_pos]; - int hurted = 0; - int resist; - - if (you.duration[DUR_CONDENSATION_SHIELD] > 0) - { - mpr("Your icy shield dissipates!", MSGCH_DURATION); - you.duration[DUR_CONDENSATION_SHIELD] = 0; - you.redraw_armour_class = 1; - } - - switch (env.cloud[cl].type) - { - case CLOUD_FIRE: - if (you.duration[DUR_FIRE_SHIELD]) - return; - - mpr("You are engulfed in roaring flames!"); - - resist = player_res_fire(); - - if (resist <= 0) - { - hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; - - if (resist < 0) - hurted += ((random2avg(14, 2) + 3) * you.time_taken) / 10; - - hurted -= random2(player_AC()); - - if (hurted < 1) - hurted = 0; - else - ouch( hurted, cl, KILLED_BY_CLOUD, "flame" ); - } - else - { - canned_msg(MSG_YOU_RESIST); - hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; - hurted /= (1 + resist * resist); - ouch( hurted, cl, KILLED_BY_CLOUD, "flame" ); - } - expose_player_to_element(BEAM_FIRE, 7); - break; - - case CLOUD_STINK: - // If you don't have to breathe, unaffected - mpr("You are engulfed in noxious fumes!"); - if (player_res_poison()) - break; - - hurted += (random2(3) * you.time_taken) / 10; - if (hurted < 1) - hurted = 0; - else - ouch( (hurted * you.time_taken) / 10, cl, KILLED_BY_CLOUD, - "noxious fumes" ); - - if (1 + random2(27) >= you.experience_level) - { - mpr("You choke on the stench!"); - confuse_player( (coinflip() ? 3 : 2) ); - } - break; - - case CLOUD_COLD: - mpr("You are engulfed in freezing vapours!"); - - resist = player_res_cold(); - - if (resist <= 0) - { - hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; - - if (resist < 0) - hurted += ((random2avg(14, 2) + 3) * you.time_taken) / 10; - - hurted -= random2(player_AC()); - if (hurted < 0) - hurted = 0; - - ouch( hurted, cl, KILLED_BY_CLOUD, "freezing vapour" ); - } - else - { - canned_msg(MSG_YOU_RESIST); - hurted += ((random2avg(23, 3) + 10) * you.time_taken) / 10; - hurted /= (1 + resist * resist); - ouch( hurted, cl, KILLED_BY_CLOUD, "freezing vapour" ); - } - expose_player_to_element(BEAM_COLD, 7); - break; - - case CLOUD_POISON: - // If you don't have to breathe, unaffected - mpr("You are engulfed in poison gas!"); - if (!player_res_poison()) - { - ouch( (random2(10) * you.time_taken) / 10, cl, KILLED_BY_CLOUD, - "poison gas" ); - poison_player(1); - } - break; - - case CLOUD_GREY_SMOKE: - case CLOUD_BLUE_SMOKE: - case CLOUD_PURP_SMOKE: - case CLOUD_BLACK_SMOKE: - mpr("You are engulfed in a cloud of smoke!"); - break; - - case CLOUD_STEAM: - { - mpr("You are engulfed in a cloud of scalding steam!"); - if (player_res_steam() > 0) - { - mpr("It doesn't seem to affect you."); - return; - } - - const int base_dam = steam_cloud_damage(env.cloud[cl]); - hurted += (random2avg(base_dam, 2) * you.time_taken) / 10; - - const int res_fire = player_res_fire(); - if (res_fire < 0) - hurted += (random2(base_dam / 2 + 1) * you.time_taken) / 10; - else if (res_fire) - hurted /= 1 + (res_fire / 2); - - if (hurted < 0) - hurted = 0; - - ouch( (hurted * you.time_taken) / 10, cl, KILLED_BY_CLOUD, - "steam" ); - break; - } - - case CLOUD_MIASMA: - mpr("You are engulfed in a dark miasma."); - - if (player_prot_life() > random2(3)) - return; - - poison_player(1); - - hurted += (random2avg(12, 3) * you.time_taken) / 10; // 3 - - if (hurted < 0) - 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; - } - - return; -} // end in_a_cloud() - void curare_hits_player(int agent, int degree) { const bool res_poison = player_res_poison(); @@ -2557,63 +2322,6 @@ bool go_berserk(bool intentional) return true; } // end go_berserk() -bool is_damaging_cloud(cloud_type type, bool temp) -{ - switch (type) - { - // always harmful - case CLOUD_FIRE: - case CLOUD_COLD: - return (true); - - // Only harmful if the player doesn't have the necessary resistances. - // Takes into account what the player can *know* and what s/he can - // also expect to be the case a few turns later (ignores spells). - case CLOUD_STINK: - case CLOUD_POISON: - return (!player_res_poison(false, temp)); - case CLOUD_STEAM: - return (player_res_steam(false, temp) <= 0); - case CLOUD_MIASMA: - return (player_prot_life(false, temp) <= 2); - - default: - // Smoke, never harmful. - return (false); - } -} - -std::string cloud_name(cloud_type type) -{ - switch (type) - { - case CLOUD_FIRE: - return "flame"; - case CLOUD_STINK: - return "noxious fumes"; - case CLOUD_COLD: - return "freezing vapour"; - case CLOUD_POISON: - return "poison gases"; - case CLOUD_GREY_SMOKE: - return "grey smoke"; - case CLOUD_BLUE_SMOKE: - return "blue smoke"; - case CLOUD_PURP_SMOKE: - return "purple smoke"; - case CLOUD_STEAM: - return "steam"; - case CLOUD_MIASMA: - return "foul pestilence"; - case CLOUD_BLACK_SMOKE: - return "black smoke"; - case CLOUD_MIST: - return "thin mist"; - default: - return "buggy goodness"; - } -} - bool mons_is_safe(const struct monsters *mon, bool want_move) { int dist = grid_distance(you.x_pos, you.y_pos, mon->x, mon->y); diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index bb030a9402..a5fc5d9083 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -40,15 +40,6 @@ void down_stairs(int old_level, dungeon_feature_type force_stair = DNGN_UNSEEN, entry_cause_type entry_cause = EC_UNKNOWN); -cloud_type beam2cloud(beam_type flavour); -beam_type cloud2beam(cloud_type flavour); - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: acr - * *********************************************************************** */ -void in_a_cloud(void); - // Created Sept 1, 2000 -- bwr /* *********************************************************************** * called from: acr misc @@ -110,10 +101,6 @@ std::string weird_smell(); std::string weird_sound(); -std::string cloud_name(cloud_type type); - -bool is_damaging_cloud(cloud_type type, bool temp = false); - void curare_hits_player(int agent, int degree); bool mons_is_safe(const monsters *mon, bool want_move = false); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 6ee128d590..ac9bae5a8a 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -35,6 +35,7 @@ #include "branch.h" #include "cio.h" +#include "cloud.h" #include "clua.h" #include "delay.h" #include "dgnevent.h" diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index d645f2b3df..894f972fbf 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -15,6 +15,7 @@ #include "branch.h" #include "command.h" #include "cio.h" +#include "cloud.h" #include "clua.h" #include "delay.h" #include "describe.h" |