summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 08:55:18 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 08:55:18 +0000
commitae6c83ec9f0273d13ad57f1382528d7715189a2b (patch)
tree2a09386686dc53e703cf1a6ce4b25acd069b3017 /crawl-ref/source/dungeon.cc
parent4958b84b497fe729eaf14bc90b8d01874722c33d (diff)
downloadcrawl-ref-ae6c83ec9f0273d13ad57f1382528d7715189a2b.tar.gz
crawl-ref-ae6c83ec9f0273d13ad57f1382528d7715189a2b.zip
This change moves the logic for when a level or branch prohibits
teleport control from the C++ code into the vault .des files. This is done with the additions of two things: * Changeable, persistent per-level and per-branch flags which affect game play. * Dungeon events for the killing of monsters, picking up of objects and changing of features. The current level and branch flags are for teleport control prevention, making a level unmappable (like the Abyss or a Labyrinth), and preventing magic mapping from working (like the Abyss or a Labyrinth). Some related changes: * The new .des header KMASK allows for dungeon grid masks like no_monster_gen to be applied to specific symbols rather than the entire vault. * If the wizard mapping command (&{) is used in a place which is unmappable, it will ask if you wish to force the area to be mappable (so you can see what an entire Labyrinth or Abyss level looks like without having to hack the source). * A new wizard-mode level-map command, 'T', will teleport the player to wherever the cursor is pointing. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2146 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc96
1 files changed, 96 insertions, 0 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index af0495e0e5..e96d23fc1e 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -311,6 +311,64 @@ void level_clear_vault_memory()
dgn_map_mask.init(0);
}
+bool set_level_flags(unsigned long flags, bool silent)
+{
+ bool could_control = allow_control_teleport(true);
+ bool could_map = player_in_mappable_area();
+
+ unsigned long old_flags = env.level_flags;
+ env.level_flags |= flags;
+
+ bool can_control = allow_control_teleport(true);
+ bool can_map = player_in_mappable_area();
+
+ if (you.skills[SK_TRANSLOCATIONS] > 0
+ && could_control && !can_control && !silent)
+ {
+ mpr("You sense the appearence of a powerful magical force "
+ "which warps space.", MSGCH_WARN);
+ }
+
+ if (could_map && !can_map && !silent)
+ {
+ mpr("A powerful force appears that prevents you from "
+ "remembering where you've been.", MSGCH_WARN);
+ }
+
+ return (old_flags != env.level_flags);
+}
+
+bool unset_level_flags(unsigned long flags, bool silent)
+{
+ bool could_control = allow_control_teleport(true);
+ bool could_map = player_in_mappable_area();
+
+ unsigned long old_flags = env.level_flags;
+ env.level_flags &= ~flags;
+
+ bool can_control = allow_control_teleport(true);
+ bool can_map = player_in_mappable_area();
+
+ if (you.skills[SK_TRANSLOCATIONS] > 0
+ && !could_control && can_control && !silent)
+ {
+ // Isn't really a "recovery", but I couldn't think of where
+ // else to send it.
+ mpr("You sense the disappearence of a powerful magical force "
+ "which warped space.", MSGCH_RECOVERY);
+ }
+
+ if (!could_map && can_map && !silent)
+ {
+ // Isn't really a "recovery", but I couldn't think of where
+ // else to send it.
+ mpr("You sense the disappearence the force that prevented you "
+ "from remembering where you've been.", MSGCH_RECOVERY);
+ }
+
+ return (old_flags != env.level_flags);
+}
+
static void dgn_register_vault(const map_def &map)
{
if (map.has_tag("uniq"))
@@ -461,6 +519,27 @@ static void register_place(const vault_placement &place)
if (!place.map.has_tag("transparent"))
mask_vault(place, MMT_OPAQUE);
+
+ // Now do per-square by-symbol masking
+ for (int y = place.y + place.height - 1; y >= place.y; --y)
+ for (int x = place.x + place.width - 1; x >= place.x; --x)
+ if (place.map.in_map(coord_def(x - place.x, y - place.y)))
+ {
+ int key = place.map.map.glyph(x - place.x, y - place.y);
+ const keyed_mapspec* spec = place.map.mapspec_for_key(key);
+
+ if (spec != NULL)
+ {
+ dgn_map_mask[x][y] |= (short)spec->map_mask.flags_set;
+ dgn_map_mask[x][y] &= ~((short)spec->map_mask.flags_unset);
+ }
+ }
+
+ set_branch_flags(place.map.branch_flags.flags_set, true);
+ unset_branch_flags(place.map.branch_flags.flags_unset, true);
+
+ set_level_flags(place.map.level_flags.flags_set, true);
+ unset_level_flags(place.map.level_flags.flags_unset, true);
}
static bool ensure_vault_placed(bool vault_success)
@@ -548,6 +627,23 @@ static void reset_level()
// clear all markers
env.markers.clear();
+
+ // Set default level flags
+ if (you.level_type == LEVEL_DUNGEON)
+ env.level_flags = branches[you.where_are_you].default_level_flags;
+ else if (you.level_type == LEVEL_LABYRINTH ||
+ you.level_type == LEVEL_ABYSS)
+ {
+ env.level_flags = LFLAG_NO_TELE_CONTROL | LFLAG_NOT_MAPPABLE;
+
+ if (!(you.level_type == LEVEL_LABYRINTH
+ && you.species != SP_MINOTAUR))
+ {
+ env.level_flags |= LFLAG_NO_MAGIC_MAP;
+ }
+ }
+ else
+ env.level_flags = 0;
}
static void build_layout_skeleton(int level_number, int level_type,