summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-07 08:31:45 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-07 08:31:45 +0000
commitfaca2fd92e2ba17f40f4a5c08d4f88dd25ae7085 (patch)
treee280b3b2841845a5c94429a9a2a7cf29053184de /crawl-ref/source
parentb58fbcfafc44bc2810863a3722bee2e6a8f7d22d (diff)
downloadcrawl-ref-faca2fd92e2ba17f40f4a5c08d4f88dd25ae7085.tar.gz
crawl-ref-faca2fd92e2ba17f40f4a5c08d4f88dd25ae7085.zip
Added support for "no_monster_gen" tag.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@586 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dungeon.cc28
-rw-r--r--crawl-ref/source/dungeon.h2
-rw-r--r--crawl-ref/source/monplace.cc12
-rw-r--r--crawl-ref/source/monplace.h7
4 files changed, 36 insertions, 13 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 99ebaf73f9..5d67bcebe2 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
-#include <algorithm>
#include "AppHdr.h"
#include "abyss.h"
@@ -155,6 +154,12 @@ static int vault_grid( int level_number, int vx, int vy, int altar_count,
static int pick_an_altar(void);
static void place_altar(void);
+//////////////////////////////////////////////////////////////////////////
+// Static data
+
+// Places where monsters should not be randomly generated.
+static dgn_region_list no_monster_zones;
+
static std::string level_name(int subdepth)
{
return place_name(
@@ -233,6 +238,8 @@ void builder(int level_number, char level_type)
int i; // generic loop variable
int x,y; // generic map loop variables
+ no_monster_zones.clear();
+
// blank level with DNGN_ROCK_WALL
make_box(0,0,GXM-1,GYM-1,DNGN_ROCK_WALL,DNGN_ROCK_WALL);
@@ -4552,7 +4559,7 @@ static void builder_monsters(int level_number, char level_type, int mon_wanted)
{
int i = 0;
int totalplaced = 0;
- int not_used=0;
+ int not_used = 0;
int x,y;
int lava_spaces, water_spaces;
int aq_creatures;
@@ -4565,7 +4572,8 @@ static void builder_monsters(int level_number, char level_type, int mon_wanted)
for (i = 0; i < mon_wanted; i++)
{
if (place_monster( not_used, RANDOM_MONSTER, level_number, BEH_SLEEP,
- MHITNOT, false, 1, 1, true ))
+ MHITNOT, false, 1, 1, true, PROX_ANYWHERE, 250, 0,
+ no_monster_zones ))
{
totalplaced++;
}
@@ -4612,7 +4620,8 @@ static void builder_monsters(int level_number, char level_type, int mon_wanted)
// note: unique_creatures 40 + used by unique demons
if (place_monster( not_used, 280 + which_unique, level_number,
- BEH_SLEEP, MHITNOT, false, 1, 1, true ))
+ BEH_SLEEP, MHITNOT, false, 1, 1, true,
+ PROX_ANYWHERE, 250, 0, no_monster_zones ))
{
totalplaced++;
}
@@ -4663,7 +4672,8 @@ static void builder_monsters(int level_number, char level_type, int mon_wanted)
{
if (place_monster( not_used, swimming_things[ random2(4) ],
level_number, BEH_SLEEP, MHITNOT,
- false, 1, 1, true ))
+ false, 1, 1, true, PROX_ANYWHERE, 250, 0,
+ no_monster_zones ))
{
totalplaced++;
}
@@ -4700,7 +4710,8 @@ static void builder_monsters(int level_number, char level_type, int mon_wanted)
{
if (place_monster( not_used, swimming_things[ random2(4) ],
level_number, BEH_SLEEP, MHITNOT,
- false, 1, 1, true ))
+ false, 1, 1, true, PROX_ANYWHERE, 250, 0,
+ no_monster_zones ))
{
totalplaced++;
}
@@ -5522,6 +5533,9 @@ static void build_vaults(int level_number, int force_vault)
}
}
+ if (place.map->has_tag("no_monster_gen"))
+ no_monster_zones.push_back( dgn_region( place.x, place.y, place.width, place.height ) );
+
// If the map takes the whole screen, our work is done.
if (gluggy == MAP_ENCOMPASS)
return;
@@ -5818,7 +5832,7 @@ static void replace_area(int sx, int sy, int ex, int ey, unsigned char replace,
}
// With apologies to Metallica.
-static bool unforbidden(const coord_def &c, const dgn_region_list &forbidden)
+bool unforbidden(const coord_def &c, const dgn_region_list &forbidden)
{
for (dgn_region_list::const_iterator i = forbidden.begin();
i != forbidden.end(); ++i)
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index 66b73d26ad..79a4d4809b 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -116,4 +116,6 @@ struct dgn_region
bool overlaps_any(const dgn_region_list &others) const;
};
+bool unforbidden(const coord_def &c, const dgn_region_list &forbidden);
+
#endif
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 569181f0af..c1572cc0f7 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -134,8 +134,9 @@ bool monster_can_submerge(int monster_class, int grid)
}
bool place_monster(int &id, int mon_type, int power, char behaviour,
- int target, bool summoned, int px, int py, bool allow_bands,
- int proximity, int extra, int dur)
+ int target, bool summoned, int px, int py, bool allow_bands,
+ int proximity, int extra, int dur,
+ const dgn_region_list &forbidden)
{
int band_size = 0;
int band_monsters[BIG_BAND]; // band monster types
@@ -286,7 +287,8 @@ bool place_monster(int &id, int mon_type, int power, char behaviour,
tries = 0;
}
}
- else if (tries > 60)
+ // Dropped number of tries from 60.
+ else if (tries > 45)
return (false);
px = 5 + random2(GXM - 10);
@@ -303,6 +305,10 @@ bool place_monster(int &id, int mon_type, int power, char behaviour,
if (!grid_compatible(grid_wanted, grd[px][py], true))
continue;
+ // Is the grid verboten?
+ if (!unforbidden( coord_def(px, py), forbidden ))
+ continue;
+
// don't generate monsters on top of teleport traps
// (how did they get there?)
int trap = trap_at_xy(px, py);
diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h
index 2bc26d5398..38c8014ba0 100644
--- a/crawl-ref/source/monplace.h
+++ b/crawl-ref/source/monplace.h
@@ -15,6 +15,7 @@
#define MONPLACE_H
#include "enum.h"
+#include "dungeon.h"
#include "FixVec.h"
// last updated 13mar2001 {gdl}
@@ -39,8 +40,7 @@
int mons_place( int mon_type, char behaviour, int target, bool summoned,
int px, int py, int level_type = LEVEL_DUNGEON,
int proximity = PROX_ANYWHERE, int extra = 250,
- int dur = 0,
- bool permit_bands = false );
+ int dur = 0, bool permit_bands = false );
// last updated 12may2000 {dlb}
/* ***********************************************************************
@@ -80,7 +80,8 @@ int summon_any_demon( char demon_class );
bool place_monster( int &id, int mon_type, int power, char behaviour,
int target, bool summoned, int px, int py, bool allow_bands,
int proximity = PROX_ANYWHERE, int extra = 250,
- int dur = 0 );
+ int dur = 0,
+ const dgn_region_list &proscribed = dgn_region_list() );
monster_type rand_dragon( dragon_class_type type );