summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-07 10:16:26 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-07 10:16:26 +0000
commit56e74bf761ad5b73de543c2a331c26f1b40c0b12 (patch)
treed25f36e35a64cbe082009ac952cbd44bc98ef727
parent0ed1d5f2217c5cee43cb9fe38ceff0234d9c617a (diff)
downloadcrawl-ref-56e74bf761ad5b73de543c2a331c26f1b40c0b12.tar.gz
crawl-ref-56e74bf761ad5b73de543c2a331c26f1b40c0b12.zip
Create random blood spatter in the Abyss and Pandemonium (FR 1986241).
How it works: * Pick 12 random grids on the map and make them bloody. * Recursively and with decreasing chances, allow their neighbours to get spattered as well. I think the effect is rather nice but the numbers might need to be tweaked anyway. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5533 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/abyss.cc58
-rw-r--r--crawl-ref/source/abyss.h2
-rw-r--r--crawl-ref/source/acr.cc20
-rw-r--r--crawl-ref/source/dungeon.cc2
-rw-r--r--crawl-ref/source/files.cc4
-rw-r--r--crawl-ref/source/misc.cc55
-rw-r--r--crawl-ref/source/misc.h1
7 files changed, 95 insertions, 47 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc
index 4ab9cc92ca..67c4f1dfe0 100644
--- a/crawl-ref/source/abyss.cc
+++ b/crawl-ref/source/abyss.cc
@@ -23,6 +23,7 @@
#include "makeitem.h"
#include "mapmark.h"
#include "message.h"
+#include "misc.h"
#include "monplace.h"
#include "mtransit.h"
#include "player.h"
@@ -66,8 +67,8 @@ static bool place_feature_near( const coord_def &centre,
return (false);
}
-// public for abyss generation
-void generate_abyss(void)
+// Public for abyss generation.
+void generate_abyss(bool spatter)
{
int i, j; // loop variables
int temp_rand; // probability determination {dlb}
@@ -129,7 +130,8 @@ static int _abyssal_rune_roll()
return (odds);
}
-static void generate_area(int gx1, int gy1, int gx2, int gy2)
+static void generate_area(int gx1, int gy1, int gx2, int gy2,
+ bool spatter = false)
{
// Any rune on the floor prevents the abyssal rune from being generated.
bool placed_abyssal_rune =
@@ -148,10 +150,10 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2)
FixedVector<dungeon_feature_type, 5> replaced;
- // nuke map
+ // Nuke map.
env.map.init(map_cell());
- // generate level composition vector
+ // Generate level composition vector.
for (int i = 0; i < 5; i++)
{
const int temp_rand = random2(10000);
@@ -169,7 +171,7 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2)
{
int rooms_to_do = 1 + random2(10);
- for ( int rooms_done = 0; rooms_done < rooms_to_do; ++rooms_done )
+ for (int rooms_done = 0; rooms_done < rooms_to_do; ++rooms_done)
{
const int x1 = 10 + random2(GXM - 20);
const int y1 = 10 + random2(GYM - 20);
@@ -242,7 +244,7 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2)
if (one_chance_in(7500)) // place an exit
exits_wanted++;
- // Don't place exit under items
+ // Don't place exit under items.
if (exits_wanted > 0 && igrd[i][j] == NON_ITEM)
{
grd[i][j] = DNGN_EXIT_ABYSS;
@@ -252,7 +254,7 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2)
#endif
}
- if (one_chance_in(10000)) // place an altar
+ if (one_chance_in(10000)) // Place an altar.
altars_wanted++;
// Don't place altars under items.
@@ -267,7 +269,7 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2)
|| grd[i][j] == DNGN_ALTAR_SHINING_ONE
|| grd[i][j] == DNGN_ALTAR_ELYVILON);
- // Lugonu has a flat 50% chance of corrupting the altar
+ // Lugonu has a flat 50% chance of corrupting the altar.
if (coinflip())
grd[i][j] = DNGN_ALTAR_LUGONU;
@@ -277,6 +279,8 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2)
#endif
}
}
+
+ generate_random_blood_spatter_on_level();
}
static int abyss_exit_nearness()
@@ -398,7 +402,7 @@ void area_shift(void)
if (!m.alive())
continue;
- // remove non-nearby monsters
+ // Remove non-nearby monsters.
if (grid_distance(m.x, m.y, you.x_pos, you.y_pos) > 10)
abyss_lose_monster(m);
}
@@ -406,21 +410,21 @@ void area_shift(void)
for (int i = 5; i < (GXM - 5); i++)
for (int j = 5; j < (GYM - 5); j++)
{
- // don't modify terrain by player
+ // Don't modify terrain by player.
if (grid_distance(i, j, you.x_pos, you.y_pos) <= 10)
continue;
- // nuke terrain otherwise
+ // Nuke terrain otherwise.
grd[i][j] = DNGN_UNSEEN;
- // nuke items
+ // Nuke items.
lose_item_stack( i, j );
if (mgrd[i][j] != NON_MONSTER)
abyss_lose_monster( menv[ mgrd[i][j] ] );
}
- // shift all monsters & items to new area
+ // Shift all monsters & items to new area.
for (int i = you.x_pos - 10; i < you.x_pos + 11; i++)
{
if (i < 0 || i >= GXM)
@@ -434,13 +438,13 @@ void area_shift(void)
const int ipos = 45 + i - you.x_pos;
const int jpos = 35 + j - you.y_pos;
- // move terrain
+ // Move terrain.
grd[ipos][jpos] = grd[i][j];
- // move item
+ // Move item.
move_item_stack_to_grid( i, j, ipos, jpos );
- // move monster
+ // Move monster.
mgrd[ipos][jpos] = mgrd[i][j];
if (mgrd[i][j] != NON_MONSTER)
{
@@ -449,7 +453,7 @@ void area_shift(void)
mgrd[i][j] = NON_MONSTER;
}
- // move cloud
+ // Move cloud,
if (env.cgrid[i][j] != EMPTY_CLOUD)
move_cloud( env.cgrid[i][j], ipos, jpos );
}
@@ -471,7 +475,7 @@ void area_shift(void)
you.moveto(45, 35);
generate_area(MAPGEN_BORDER, MAPGEN_BORDER,
- GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER);
+ GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, true);
xom_check_nearness();
@@ -506,7 +510,7 @@ void abyss_teleport( bool new_area )
if (!new_area)
{
- // try to find a good spot within the shift zone:
+ // Try to find a good spot within the shift zone.
for (i = 0; i < 100; i++)
{
x = 16 + random2( GXM - 32 );
@@ -536,10 +540,10 @@ void abyss_teleport( bool new_area )
mpr("New area Abyss teleport.", MSGCH_DIAGNOSTICS);
#endif
- // teleport to a new area of the abyss:
+ // Teleport to a new area of the abyss.
- init_pandemonium(); // get new monsters
- dgn_set_colours_from_monsters(); // and new colours
+ init_pandemonium(); // Get new monsters
+ dgn_set_colours_from_monsters(); // ...and new colours.
for (i = 0; i < MAX_MONSTERS; i++)
{
@@ -547,7 +551,7 @@ void abyss_teleport( bool new_area )
abyss_lose_monster(menv[i]);
}
- // Orbs and fixed artefacts are marked as "lost in the abyss"
+ // Orbs and fixed artefacts are marked as "lost in the abyss".
for (k = 0; k < MAX_ITEMS; k++)
{
if (is_valid_item( mitm[k] ))
@@ -563,7 +567,7 @@ void abyss_teleport( bool new_area )
for (i = 10; i < (GXM - 9); i++)
for (j = 10; j < (GYM - 9); j++)
{
- grd[i][j] = DNGN_UNSEEN; // so generate_area will pick it up
+ grd[i][j] = DNGN_UNSEEN; // So generate_area will pick it up.
igrd[i][j] = NON_ITEM;
mgrd[i][j] = NON_MONSTER;
env.cgrid[i][j] = EMPTY_CLOUD;
@@ -574,7 +578,7 @@ void abyss_teleport( bool new_area )
you.moveto(45, 35);
generate_area(MAPGEN_BORDER, MAPGEN_BORDER,
- GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER);
+ GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, true);
xom_check_nearness();
@@ -900,7 +904,7 @@ bool lugonu_corrupt_level(int power)
std::auto_ptr<crawl_environment> backup(new crawl_environment(env));
generate_abyss();
generate_area(MAPGEN_BORDER, MAPGEN_BORDER,
- GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER);
+ GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, false);
corrupt_choose_colours();
diff --git a/crawl-ref/source/abyss.h b/crawl-ref/source/abyss.h
index 61108bae8f..ea4e28eb84 100644
--- a/crawl-ref/source/abyss.h
+++ b/crawl-ref/source/abyss.h
@@ -19,7 +19,7 @@
/* ***********************************************************************
* called from: dungeon
* *********************************************************************** */
-void generate_abyss(void);
+void generate_abyss(bool spatter = false);
// last updated 12may2000 {dlb}
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 969fff663f..67c985e225 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -211,11 +211,11 @@ int old_main( int argc, char *argv[] )
int main( int argc, char *argv[] )
#endif
{
- _compile_time_asserts(); // just to quiet "unused static function" warning
+ _compile_time_asserts(); // just to quiet "unused static function" warning
// Load in the system environment variables
get_system_environment();
- // parse command line args -- look only for initfile & crawl_dir entries
+ // Parse command line args -- look only for initfile & crawl_dir entries.
if (!parse_args(argc, argv, true))
{
_show_commandline_options_help();
@@ -228,7 +228,7 @@ int main( int argc, char *argv[] )
// Read the init file.
init_file_error = read_init_file();
- // now parse the args again, looking for everything else.
+ // Now parse the args again, looking for everything else.
parse_args( argc, argv, false );
if (Options.sc_entries != 0 || !SysEnv.scorefile.empty())
@@ -1745,8 +1745,8 @@ static void _print_friendly_pickup_setting(bool was_changed)
}
}
-// note that in some actions, you don't want to clear afterwards.
-// e.g. list_jewellery, etc.
+// Note that in some actions, you don't want to clear afterwards.
+// e.g. list_jewellery, etc.
void process_command( command_type cmd )
{
apply_berserk_penalty = true;
@@ -3855,11 +3855,11 @@ static bool _initialise(void)
msg::initialise_mpr_streams();
- // init item array:
+ // Init item array.
for (int i = 0; i < MAX_ITEMS; i++)
init_item(i);
- // empty messaging string
+ // Empty messaging string.
info[0] = 0;
for (int i = 0; i < MAX_MONSTERS; i++)
@@ -3887,7 +3887,7 @@ static bool _initialise(void)
cio_init();
- // system initialisation stuff:
+ // System initialisation stuff.
textbackground(0);
clrscr();
@@ -3901,7 +3901,7 @@ static bool _initialise(void)
}
#endif
- // sets up a new game:
+ // Sets up a new game.
const bool newc = new_game();
if (!newc)
restore_game();
@@ -3925,7 +3925,7 @@ static bool _initialise(void)
NUM_LEVEL_AREA_TYPES, -1, you.where_are_you );
#if DEBUG_DIAGNOSTICS
- // Debug compiles display a lot of "hidden" information, so we auto-wiz
+ // Debug compiles display a lot of "hidden" information, so we auto-wiz.
you.wizard = true;
#endif
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index d6d9dabdc2..e3176ed262 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -1824,7 +1824,7 @@ static builder_rc_type _builder_by_type(int level_number, char level_type)
if (level_type == LEVEL_ABYSS)
{
- generate_abyss();
+ generate_abyss(true);
return (BUILD_SKIP);
}
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index dcf852e7d3..50354f5ab9 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1055,10 +1055,10 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode,
{
if (tmp_file_pairs[you.your_level][you.where_are_you] == false)
{
- // make sure old file is gone
+ // Make sure old file is gone.
unlink(cha_fil.c_str());
- // save the information for later deletion -- DML 6/11/99
+ // Save the information for later deletion -- DML 6/11/99
tmp_file_pairs[you.your_level][you.where_are_you] = true;
}
}
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 4224889d69..d024069bb8 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1149,14 +1149,14 @@ static void maybe_bloodify_square(int x, int y, int amount, bool spatter = false
for (int i = -1; i <= 1; i++)
for (int j = -1; j <= 1; j++)
{
- if (i == 0 && j == 0) // current square
- continue;
+ if (i == 0 && j == 0) // current square
+ continue;
- // Spattering onto walls etc. less likely.
- if (grd[x+i][y+j] < DNGN_MINMOVE && !one_chance_in(3))
- continue;
+ // Spattering onto walls etc. less likely.
+ if (grd[x+i][y+j] < DNGN_MINMOVE && !one_chance_in(3))
+ continue;
- maybe_bloodify_square(x+i, y+j, amount/15);
+ maybe_bloodify_square(x+i, y+j, amount/15);
}
}
}
@@ -1174,6 +1174,48 @@ void bleed_onto_floor(int x, int y, int montype, int damage, bool spatter)
maybe_bloodify_square(x, y, damage, spatter);
}
+static void _spatter_neighbours(int cx, int cy, int chance)
+{
+ int posx, posy;
+ for (int x = -1; x <= 1; x++)
+ for (int y = -1; y <= 1; y++)
+ {
+ posx = cx + x;
+ posy = cy + y;
+ if (!in_bounds(posx, posy))
+ continue;
+
+ if (!allow_bleeding_on_square(posx, posy))
+ continue;
+
+ if (grd[posx][posy] < DNGN_MINMOVE && !one_chance_in(3))
+ continue;
+
+ if (one_chance_in(chance))
+ {
+ env.map[posx][posy].property = FPROP_BLOODY;
+ _spatter_neighbours(posx, posy, chance+1);
+ }
+ }
+}
+
+void generate_random_blood_spatter_on_level()
+{
+ int cx, cy;
+ int startprob;
+ int max_cluster = 7 + random2(9);
+ for (int i = 0; i < max_cluster; i++)
+ {
+ cx = 10 + random2(GXM - 10);
+ cy = 10 + random2(GYM - 10);
+ startprob = 1 + random2(4);
+
+ if (allow_bleeding_on_square(cx, cy))
+ env.map[cx][cy].property = FPROP_BLOODY;
+ _spatter_neighbours(cx, cy, startprob);
+ }
+}
+
void search_around( bool only_adjacent )
{
int i;
@@ -2265,6 +2307,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
break;
PlaceInfo &place_info = you.get_place_info();
+ generate_random_blood_spatter_on_level();
// Entering voluntarily only stimulates Xom if you've never
// been there before
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index 7e56008d7c..2880e79cfb 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -85,6 +85,7 @@ void split_potions_into_decay( int obj, int amount, bool need_msg = true );
bool victim_can_bleed(int montype);
void bleed_onto_floor(int x, int y, int mon, int damage, bool spatter = false);
+void generate_random_blood_spatter_on_level();
// last updated 12may2000 {dlb}
/* ***********************************************************************