summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-31 20:32:05 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-31 20:32:05 +0000
commit4aaf7deee06e2d817aa084f42a8b99c784a23a0b (patch)
tree337686f9646cce93a98decbc873ab9f3634f3f6b
parent6235210791fbc6a6b61d8d7975ab425a9e90e68a (diff)
downloadcrawl-ref-4aaf7deee06e2d817aa084f42a8b99c784a23a0b.tar.gz
crawl-ref-4aaf7deee06e2d817aa084f42a8b99c784a23a0b.zip
Move Slime:6 wall change to lair.des Lua. The slimy rune is now guaranteed.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3987 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/dat/clua/dungeon.lua33
-rw-r--r--crawl-ref/source/dat/clua/lm_flags.lua7
-rw-r--r--crawl-ref/source/dat/lair.des31
-rw-r--r--crawl-ref/source/luadgn.cc17
-rw-r--r--crawl-ref/source/monstuff.cc11
5 files changed, 86 insertions, 13 deletions
diff --git a/crawl-ref/source/dat/clua/dungeon.lua b/crawl-ref/source/dat/clua/dungeon.lua
index c7b585952d..7f7f0cd688 100644
--- a/crawl-ref/source/dat/clua/dungeon.lua
+++ b/crawl-ref/source/dat/clua/dungeon.lua
@@ -3,6 +3,8 @@
-- Dungeoneering functions.
------------------------------------------------------------------------------
+dgn.GXM, dgn.GYM = dgn.max_bounds()
+
-- Wraps a map_def into a Lua environment (a table) such that
-- functions run in the environment (with setfenv) can directly
-- address the map with function calls such as name(), tags(), etc.
@@ -112,3 +114,34 @@ end
function dgn.orig_gly_points(map, glyph)
return dgn.orig_fn(map, dgn.gly_points, glyph)
end
+
+function dgn.fnum(feat)
+ if type(feat) == 'string' then
+ return dgn.feature_number(feat)
+ else
+ return feat
+ end
+end
+
+function dgn.fnum_map(map)
+ local fnmap = { }
+ for k, v in pairs(map) do
+ fnmap[dgn.fnum(k)] = dgn.fnum(v)
+ end
+ return fnmap
+end
+
+-- Replaces all features matching
+function dgn.replace_feat(rmap)
+ local cmap = dgn.fnum_map(rmap)
+
+ for x = 0, dgn.GXM - 1 do
+ for y = 0, dgn.GYM - 1 do
+ local grid = dgn.grid(x, y)
+ local repl = cmap[grid]
+ if repl then
+ dgn.terrain_changed(x, y, repl)
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/crawl-ref/source/dat/clua/lm_flags.lua b/crawl-ref/source/dat/clua/lm_flags.lua
index 0e2ab9c817..68bf42177e 100644
--- a/crawl-ref/source/dat/clua/lm_flags.lua
+++ b/crawl-ref/source/dat/clua/lm_flags.lua
@@ -81,6 +81,7 @@ function ChangeFlags:new(pars)
cf.level_flags = pars.level_flags
cf.branch_flags = pars.branch_flags
cf.msg = pars.msg
+ cf.trigger = pars.trigger
cf.props = { flag_group = pars.group }
return cf
@@ -91,6 +92,10 @@ function ChangeFlags:do_change(marker)
local did_change2 = false
local silent = self.msg and self.msg ~= ""
+ if self.trigger then
+ self.trigger(marker)
+ end
+
if self.props.flag_group and self.props.flag_group ~= "" then
local num_markers = dgn.num_matching_markers("flag_group",
self.props.group)
@@ -127,6 +132,7 @@ function ChangeFlags:write(marker, th)
file.marshall(th, self.level_flags)
file.marshall(th, self.branch_flags)
file.marshall(th, self.msg)
+ file.marshall_meta(th, self.trigger)
lmark.marshall_table(th, self.props)
end
@@ -134,6 +140,7 @@ function ChangeFlags:read(marker, th)
self.level_flags = file.unmarshall_string(th)
self.branch_flags = file.unmarshall_string(th)
self.msg = file.unmarshall_string(th)
+ self.trigger = file.unmarshall_meta(th)
self.props = lmark.unmarshall_table(th)
setmetatable(self, ChangeFlags)
diff --git a/crawl-ref/source/dat/lair.des b/crawl-ref/source/dat/lair.des
index 493186511d..9b63a34ad1 100644
--- a/crawl-ref/source/dat/lair.des
+++ b/crawl-ref/source/dat/lair.des
@@ -3,6 +3,33 @@
# branch endings for Shoals, Snake Pit, Slime Pit and Swamp.
##############################################################################
+lua {{
+
+-- Special effects for Slime:6
+function slime_wall_morph(x)
+ local stone = dgn.feature_number('stone_wall')
+ local inlos = false
+ for x = 0, dgn.GXM - 1 do
+ for y = 0, dgn.GYM - 1 do
+ if dgn.grid(x, y) == stone and you.see_grid(x, y) then
+ inlos = true
+ break
+ end
+ end
+ if inlos then break end
+ end
+ dgn.replace_feat { stone_wall= "clear_rock_wall" }
+ if inlos then
+ crawl.mpr("Suddenly all colour oozes out of the stone walls.",
+ "monster_enchant")
+ else
+ crawl.mpr("You feel a strange vibration for a moment.",
+ "monster_enchant")
+ end
+end
+
+}}
+
##############################################################################
# Lair entries
##############################################################################
@@ -755,10 +782,12 @@ ORIENT: encompass
MONS: royal jelly, acid blob, great orb of eyes / nothing
SUBST: ' : ' .:1, ' : ' x:1, ' = .x
SUBST: " : " .:3, " = .c
+NSUBST: P = O / *|
SHUFFLE: ([{
LFLAGS: no_tele_control
MARKER: X = lua:mons_dies_change_flags { \
- level_flags="!no_tele_control", mon_name="royal jelly" \
+ level_flags="!no_tele_control", mon_name="royal jelly", \
+ trigger=slime_wall_morph \
}
SUBST: X = .
MAP
diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc
index 0c5555dc27..005ad8fe8c 100644
--- a/crawl-ref/source/luadgn.cc
+++ b/crawl-ref/source/luadgn.cc
@@ -836,6 +836,13 @@ static int dgn_grid(lua_State *ls)
PLUARET(number, grd[x][y]);
}
+static int dgn_max_bounds(lua_State *ls)
+{
+ lua_pushnumber(ls, GXM);
+ lua_pushnumber(ls, GYM);
+ return (2);
+}
+
typedef
flood_find<map_def::map_feature_finder, map_def::map_bounds_check>
map_flood_finder;
@@ -1299,9 +1306,14 @@ static int dgn_terrain_changed(lua_State *ls)
type = dungeon_feature_by_name(lua_tostring(ls, 3));
const bool affect_player =
lua_isboolean(ls, 4)? lua_toboolean(ls, 4) : true;
+ const bool preserve_features =
+ lua_isboolean(ls, 5)? lua_toboolean(ls, 5) : true;
+ const bool preserve_items =
+ lua_isboolean(ls, 6)? lua_toboolean(ls, 6) : true;
dungeon_terrain_changed( coord_def( luaL_checkint(ls, 1),
luaL_checkint(ls, 2) ),
- type, affect_player );
+ type, affect_player,
+ preserve_features, preserve_items );
return (0);
}
@@ -1683,7 +1695,10 @@ static const struct luaL_reg dgn_lib[] =
{ "kitem", dgn_kitem },
{ "kmons", dgn_kmons },
{ "kmask", dgn_kmask },
+
{ "grid", dgn_grid },
+ { "max_bounds", dgn_max_bounds },
+
{ "terrain_changed", dgn_terrain_changed },
{ "points_connected", dgn_points_connected },
{ "any_point_connected", dgn_any_point_connected },
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 53f81ca337..107951b5b2 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1206,17 +1206,6 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
dgn_event(DET_MONSTER_DIED, monster->pos(), 0,
monster_index(monster), killer));
- // This is assuming the royal jelly is a unique monster. Is it?
- // FIXME: Needs check for being at bottom level of the branch.
- if (monster->type == MONS_ROYAL_JELLY
- && player_in_branch( BRANCH_SLIME_PITS ))
- {
- mpr("Suddenly, all colour oozes out of the surrounding stone!",
- MSGCH_MONSTER_ENCHANT);
-
- replace_area_wrapper(DNGN_STONE_WALL, DNGN_CLEAR_ROCK_WALL);
- }
-
const coord_def mwhere = monster->pos();
if (drop_items)
_monster_drop_ething(monster, YOU_KILL(killer) || pet_kill);