From e4f58176388fa16d5f76815af0900a35d9e61627 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Sat, 10 Oct 2009 23:07:21 -0400 Subject: Patch 2873911 by Jude: add rain clouds --- crawl-ref/source/beam.cc | 2 ++ crawl-ref/source/cloud.cc | 70 ++++++++++++++++++++++++++++++++++-- crawl-ref/source/cloud.h | 2 ++ crawl-ref/source/dat/clua/lm_fog.lua | 2 +- crawl-ref/source/enum.h | 2 ++ crawl-ref/source/monstuff.cc | 43 ++++++++++++++++++++-- crawl-ref/source/player.cc | 4 +++ crawl-ref/source/spells1.cc | 6 ++++ crawl-ref/source/view.cc | 1 + 9 files changed, 126 insertions(+), 6 deletions(-) diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 08d0970c60..6cb2bdf408 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -3208,6 +3208,7 @@ void bolt::affect_place_explosion_clouds() case BEAM_POTION_GREY_SMOKE: case BEAM_POTION_BLUE_SMOKE: case BEAM_POTION_PURP_SMOKE: + case BEAM_POTION_RAIN: case BEAM_POTION_MUTAGENIC: cl_type = beam2cloud(flavour); break; @@ -6017,6 +6018,7 @@ std::string beam_type_name(beam_type type) case BEAM_POTION_GREY_SMOKE: return ("grey smoke"); case BEAM_POTION_BLUE_SMOKE: return ("blue smoke"); case BEAM_POTION_PURP_SMOKE: return ("purple smoke"); + case BEAM_POTION_RAIN: return ("rain"); case BEAM_POTION_RANDOM: return ("random potion"); case BEAM_POTION_MUTAGENIC: return ("mutagenic fog"); case BEAM_VISUAL: return ("visual effects"); diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 38a5240081..907bfbe124 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -35,6 +35,8 @@ static int _actual_spread_rate(cloud_type type, int spread_rate) case CLOUD_GREY_SMOKE: case CLOUD_BLACK_SMOKE: return 22; + case CLOUD_RAIN: + return 11; default: return 0; } @@ -157,10 +159,10 @@ void manage_clouds() int dissipate = you.time_taken; // Fire clouds dissipate faster over water, - // cold clouds dissipate faster over lava. + // rain and cold clouds dissipate faster over lava. if (cloud.type == CLOUD_FIRE && grd(cloud.pos) == DNGN_DEEP_WATER) dissipate *= 4; - else if (cloud.type == CLOUD_COLD && grd(cloud.pos) == DNGN_LAVA) + else if ((cloud.type == CLOUD_COLD || cloud.type == CLOUD_RAIN) && grd(cloud.pos) == DNGN_LAVA) dissipate *= 4; expose_items_to_element(cloud2beam(cloud.type), cloud.pos, 2); @@ -174,6 +176,34 @@ void delete_cloud( int cloud ) cloud_struct& c = env.cloud[cloud]; if (c.type != CLOUD_NONE) { + if (c.type == CLOUD_RAIN) + { + // Rain clouds can occasionally leave shallow water or deepen it: + // If we're near lava, chance of leaving water is lower; + // if we're near deep water already, chance of leaving water + // is slightly higher. + if (one_chance_in((5 + count_neighbours(c.pos, DNGN_LAVA)) - + count_neighbours(c.pos, DNGN_DEEP_WATER))) + { + dungeon_feature_type feat; + + if (grd(c.pos) == DNGN_FLOOR) + feat = DNGN_SHALLOW_WATER; + else if (grd(c.pos) == DNGN_SHALLOW_WATER && you.pos() != c.pos + && one_chance_in(3)) + // Don't drown the player! + feat = DNGN_DEEP_WATER; + else + feat = grd(c.pos); + + if (grd(c.pos) != feat) + { + if (you.pos() == c.pos) + mpr("The rain has left you waist-deep in water!"); + dungeon_terrain_changed(c.pos, feat); + } + } + } c.type = CLOUD_NONE; c.decay = 0; c.whose = KC_OTHER; @@ -404,6 +434,8 @@ cloud_type beam2cloud(beam_type flavour) return CLOUD_MIASMA; case BEAM_CHAOS: return CLOUD_CHAOS; + case BEAM_POTION_RAIN: + return CLOUD_RAIN; case BEAM_POTION_MUTAGENIC: return CLOUD_MUTAGENIC; case BEAM_RANDOM: @@ -428,6 +460,7 @@ beam_type cloud2beam(cloud_type flavour) case CLOUD_STEAM: return BEAM_STEAM; case CLOUD_MIASMA: return BEAM_MIASMA; case CLOUD_CHAOS: return BEAM_CHAOS; + case CLOUD_RAIN: return BEAM_POTION_RAIN; case CLOUD_MUTAGENIC: return BEAM_POTION_MUTAGENIC; case CLOUD_RANDOM: return BEAM_RANDOM; } @@ -681,6 +714,13 @@ void in_a_cloud() ouch(hurted, cl, KILLED_BY_CLOUD, "foul pestilence"); break; + case CLOUD_RAIN: + if (you.duration[DUR_FIRE_SHIELD]) + you.duration[DUR_FIRE_SHIELD] = 1; + + mpr("You are standing in the rain."); + break; + case CLOUD_MUTAGENIC: mpr("You are engulfed in a mutagenic fog!"); @@ -744,6 +784,7 @@ bool is_harmless_cloud(cloud_type type) case CLOUD_BLUE_SMOKE: case CLOUD_PURP_SMOKE: case CLOUD_MIST: + case CLOUD_RAIN: case CLOUD_DEBUGGING: return (true); default: @@ -751,6 +792,29 @@ bool is_harmless_cloud(cloud_type type) } } +bool in_what_cloud(cloud_type type) +{ + int cl = env.cgrid(you.pos()); + + if (env.cgrid(you.pos()) == EMPTY_CLOUD) + return (false); + + if (env.cloud[cl].type == type) + return (true); + + return (false); +} + +cloud_type in_what_cloud() +{ + int cl = env.cgrid(you.pos()); + + if (env.cgrid(you.pos()) == EMPTY_CLOUD) + return (CLOUD_NONE); + + return (env.cloud[cl].type); +} + std::string cloud_name(cloud_type type) { switch (type) @@ -779,6 +843,8 @@ std::string cloud_name(cloud_type type) return "thin mist"; case CLOUD_CHAOS: return "seething chaos"; + case CLOUD_RAIN: + return "rain"; case CLOUD_MUTAGENIC: return "mutagenic fog"; default: diff --git a/crawl-ref/source/cloud.h b/crawl-ref/source/cloud.h index 726c4be001..f9fa6d6d18 100644 --- a/crawl-ref/source/cloud.h +++ b/crawl-ref/source/cloud.h @@ -66,6 +66,8 @@ std::string cloud_name(cloud_type type); bool is_damaging_cloud(cloud_type type, bool temp = false); bool is_harmless_cloud(cloud_type type); +bool in_what_cloud (cloud_type type); +cloud_type in_what_cloud (); // fog generator void place_fog_machine(fog_machine_type fm_type, cloud_type cl_type, diff --git a/crawl-ref/source/dat/clua/lm_fog.lua b/crawl-ref/source/dat/clua/lm_fog.lua index 4f1ad793e1..876af34c5c 100644 --- a/crawl-ref/source/dat/clua/lm_fog.lua +++ b/crawl-ref/source/dat/clua/lm_fog.lua @@ -21,7 +21,7 @@ -- -- cloud_type: The name of the cloud type to use. Possible cloud types are: -- flame, noxious fumes, freezing vapour, poison gases, --- grey smoke, blue smoke, purple smoke, steam, +-- grey smoke, blue smoke, purple smoke, steam, rain, -- foul pestilence, black smoke, mutagenic fog, thin mist (the default). -- walk_dist: The distance to move over the course of one random walk. -- defaults to 0. diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 5ef53a802a..563e65015e 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -262,6 +262,7 @@ enum beam_type // beam[].flavour BEAM_POTION_MUTAGENIC, BEAM_POTION_BLUE_SMOKE, BEAM_POTION_PURP_SMOKE, // 60 + BEAM_POTION_RAIN, BEAM_POTION_RANDOM, BEAM_LAST_REAL = BEAM_POTION_RANDOM, @@ -435,6 +436,7 @@ enum cloud_type CLOUD_MIASMA, CLOUD_MIST, CLOUD_CHAOS, + CLOUD_RAIN, CLOUD_MUTAGENIC, CLOUD_RANDOM = 98, CLOUD_DEBUGGING = 99 // 99: used once as 'nonexistent cloud' {dlb} diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 0ac41d1d73..e2c6672c7c 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -5429,10 +5429,11 @@ static bool _is_player_or_mon_sanct(const monsters* monster) || is_sanctuary(monster->pos())); } -bool mons_avoids_cloud(const monsters *monster, cloud_type cl_type, +bool mons_avoids_cloud(const monsters *monster, cloud_struct cloud, bool placement) { bool extra_careful = placement; + cloud_type cl_type = cloud.type; if (placement) extra_careful = true; @@ -5517,6 +5518,28 @@ bool mons_avoids_cloud(const monsters *monster, cloud_type cl_type, return (false); break; + case CLOUD_RAIN: + // Fiery monsters dislike the rain. + if (monster->is_fiery() && extra_careful) + return (true); + + // We don't care about what's underneath the rain cloud if we can fly. + if (monster->flight_mode() != FL_NONE) + return (false); + + // These don't care about deep water. + if (monster_habitable_grid(monster, DNGN_DEEP_WATER)) + return (false); + + // This position could become deep water, and they might drown. + if (grd(cloud.pos) == DNGN_SHALLOW_WATER) + return (true); + + // Otherwise, it's safe for everyone else. + return (false); + + break; + default: break; } @@ -5551,7 +5574,7 @@ bool mons_avoids_cloud(const monsters *monster, int cloud_num, *cl_type = cloud.type; // Is the target cloud okay? - if (!mons_avoids_cloud(monster, cloud.type, placement)) + if (!mons_avoids_cloud(monster, cloud, placement)) return (false); // If we're already in a cloud that we'd want to avoid then moving @@ -5566,7 +5589,7 @@ bool mons_avoids_cloud(const monsters *monster, int cloud_num, const cloud_struct &our_cloud = env.cloud[our_cloud_num]; - return (!mons_avoids_cloud(monster, our_cloud.type, true)); + return (!mons_avoids_cloud(monster, our_cloud, true)); } //--------------------------------------------------------------- @@ -9424,6 +9447,20 @@ static void _mons_in_cloud(monsters *monster) hurted += (10 * random2avg(12, 3)) / speed; // 3 break; + case CLOUD_RAIN: + if (monster->is_fiery()) + { + if (!silenced(monster->pos())) + simple_monster_message(monster, " sizzles in the rain!"); + else + simple_monster_message(monster, " steams in the rain!"); + + hurted += ((4 * random2(3)) - random2(monster->ac)); + wake = true; + } + + break; + case CLOUD_MUTAGENIC: simple_monster_message(monster, " is engulfed in a mutagenic fog!"); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index ac567372a5..4c74fec913 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1805,6 +1805,10 @@ int player_spec_fire() if (you.duration[DUR_FIRE_SHIELD]) sf++; + // if it's raining... {due} + if (in_what_cloud(CLOUD_RAIN)) + sf--; + return sf; } diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 69181d7834..183855936b 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -1463,6 +1463,12 @@ void cast_teleport_control(int power) void cast_ring_of_flames(int power) { + // You shouldn't be able to cast this in the rain. {due} + if (in_what_cloud(CLOUD_RAIN)) + { + mpr("Your spell sizzles in the rain."); + return; + } _increase_duration(DUR_FIRE_SHIELD, 5 + (power / 10) + (random2(power) / 5), 50, "The air around you leaps into flame!"); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 8d10d1e5d3..60078af7cd 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -1682,6 +1682,7 @@ inline static void _update_cloud_grid(int cloudno) which_colour = DARKGREY; break; + case CLOUD_RAIN: case CLOUD_MIST: which_colour = ETC_MIST; break; -- cgit v1.2.3-54-g00ecf