diff options
author | Adam Borowski <kilobyte@angband.pl> | 2009-10-13 09:56:41 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2009-10-13 09:57:09 +0200 |
commit | 7cb4b819399d86effcf5890498f3e89dcb8a7178 (patch) | |
tree | d591f28e24caaf7196a93dbf7f02deb727413f9f /crawl-ref/source/cloud.cc | |
parent | 072864bdfdb2befa0cb865dbe4234f7f0c8dec39 (diff) | |
parent | ffa4e38d65ac1f41a20f3820d38c4d54291c9a8f (diff) | |
download | crawl-ref-7cb4b819399d86effcf5890498f3e89dcb8a7178.tar.gz crawl-ref-7cb4b819399d86effcf5890498f3e89dcb8a7178.zip |
Merge branch 'trees'.
There's still the issue of glyph choice, and cutting them down with an
axe is not coded yet.
Diffstat (limited to 'crawl-ref/source/cloud.cc')
-rw-r--r-- | crawl-ref/source/cloud.cc | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 7591920662..4e66215059 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -23,6 +23,7 @@ REVISION("$Rev$"); #include "terrain.h" #include "view.h" #include "mutation.h" +#include "los.h" static int _actual_spread_rate(cloud_type type, int spread_rate) { @@ -132,13 +133,45 @@ static int _spread_cloud(const cloud_struct &cloud) return (extra_decay); } +static void _spread_fire(const cloud_struct &cloud) +{ + int make_flames = one_chance_in(5); + + for ( adjacent_iterator ai(cloud.pos); ai; ++ai ) + { + if (!in_bounds(*ai) + || env.cgrid(*ai) != EMPTY_CLOUD + || is_sanctuary(*ai)) + continue; + + // burning trees produce flames all around + if (!grid_is_solid(*ai) && make_flames) + _place_new_cloud( CLOUD_FIRE, *ai, cloud.decay/2+1, cloud.whose, + cloud.killer, cloud.spread_rate ); + + // forest fire doesn't spread in all directions at once, + // every neighbouring square gets a separate roll + if (grd(*ai) == DNGN_TREES && one_chance_in(20)) + { + if (see_grid(*ai)) + mpr("The forest fire spreads!"); + grd(*ai) = DNGN_FLOOR; + _place_new_cloud( cloud.type, *ai, random2(30)+25, cloud.whose, + cloud.killer, cloud.spread_rate ); + } + + } +} + static void _dissipate_cloud(int cloudidx, int dissipate) { cloud_struct &cloud = env.cloud[cloudidx]; // Apply calculated rate to the actual cloud. cloud.decay -= dissipate; - if (x_chance_in_y(cloud.spread_rate, 100)) + if (cloud.type == CLOUD_FOREST_FIRE) + _spread_fire(cloud); + else if (x_chance_in_y(cloud.spread_rate, 100)) { cloud.spread_rate -= div_rand_round(cloud.spread_rate, 10); cloud.decay -= _spread_cloud(cloud); @@ -379,8 +412,7 @@ bool is_opaque_cloud(unsigned char cloud_idx) return (false); const int ctype = env.cloud[cloud_idx].type; - return (ctype == CLOUD_BLACK_SMOKE - || ctype >= CLOUD_GREY_SMOKE && ctype <= CLOUD_STEAM); + return (ctype >= CLOUD_OPAQUE_FIRST && ctype <= CLOUD_OPAQUE_LAST); } cloud_type cloud_type_at(const coord_def &c) @@ -452,6 +484,7 @@ beam_type cloud2beam(cloud_type flavour) default: case CLOUD_NONE: return BEAM_NONE; case CLOUD_FIRE: return BEAM_FIRE; + case CLOUD_FOREST_FIRE: return BEAM_FIRE; case CLOUD_STINK: return BEAM_POTION_STINKING_CLOUD; case CLOUD_COLD: return BEAM_COLD; case CLOUD_POISON: return BEAM_POISON; @@ -489,6 +522,7 @@ int max_cloud_damage(cloud_type cl_type, int power) switch (cl_type) { case CLOUD_FIRE: + case CLOUD_FOREST_FIRE: if (you.duration[DUR_FIRE_SHIELD]) return (0); resist = player_res_fire(); @@ -575,6 +609,7 @@ void in_a_cloud() switch (env.cloud[cl].type) { case CLOUD_FIRE: + case CLOUD_FOREST_FIRE: if (you.duration[DUR_FIRE_SHIELD]) return; @@ -750,6 +785,7 @@ bool is_damaging_cloud(cloud_type type, bool temp) { // always harmful... case CLOUD_FIRE: + case CLOUD_FOREST_FIRE: // ... unless a Ring of Flames is up and it's a fire cloud. if (temp && you.duration[DUR_FIRE_SHIELD]) return (false); @@ -823,6 +859,8 @@ std::string cloud_name(cloud_type type) { case CLOUD_FIRE: return "flame"; + case CLOUD_FOREST_FIRE: + return "fire"; case CLOUD_STINK: return "noxious fumes"; case CLOUD_COLD: |