summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dat/clua/dungeon.lua6
-rw-r--r--crawl-ref/source/dat/clua/lm_fog.lua38
-rw-r--r--crawl-ref/source/dat/volcano.des52
-rw-r--r--crawl-ref/source/l_dgngrd.cc9
4 files changed, 76 insertions, 29 deletions
diff --git a/crawl-ref/source/dat/clua/dungeon.lua b/crawl-ref/source/dat/clua/dungeon.lua
index f6892870d1..477dd69d63 100644
--- a/crawl-ref/source/dat/clua/dungeon.lua
+++ b/crawl-ref/source/dat/clua/dungeon.lua
@@ -394,3 +394,9 @@ dgn.good_scrolls = [[
w:5 scroll of immolation /
w:5 scroll of vulnerability
]]
+
+-- Returns true if point1 is inside radius(X, point2).
+function dgn.point_in_radius(point1, point2, radius)
+ return dgn.distance(point1.x, point1.y, point2.x, point2.y) <=
+ (radius*radius)+1
+end
diff --git a/crawl-ref/source/dat/clua/lm_fog.lua b/crawl-ref/source/dat/clua/lm_fog.lua
index 97bc5750c4..91dbbc64f3 100644
--- a/crawl-ref/source/dat/clua/lm_fog.lua
+++ b/crawl-ref/source/dat/clua/lm_fog.lua
@@ -323,7 +323,7 @@ end
-- the turns parameter cannot be null. All other parameters are
-- considered optional.
-function warning_machine (trns, cantsee_mesg, see_mesg)
+function warning_machine (trns, cantsee_mesg, see_mesg, see_func)
if trns == nil or (see_mesg == nil and cantsee_mesg == nil) then
error("WarningMachine requires turns and message!")
end
@@ -331,7 +331,7 @@ function warning_machine (trns, cantsee_mesg, see_mesg)
local countdown = fm.countdown
if event_name == "decrement" and countdown <= mtable.turns then
if not mtable.warning_done then
- if mtable.see_message and you.see_cell(point.x, point.y) then
+ if mtable.see_message and mtable.see_function(point.x, point.y) then
crawl.mpr(mtable.see_message, "warning")
elseif mtable.cantsee_message then
crawl.mpr(mtable.cantsee_message, "warning")
@@ -343,13 +343,21 @@ function warning_machine (trns, cantsee_mesg, see_mesg)
end
end
pars = {marker_type = "listener"}
- pars.marker_params = {see_message = see_mesg, cantsee_message = cantsee_mesg,
- turns = trns * 10, warning_done = false}
+ if not see_func then
+ see_func = you.see_cell
+ end
+ pars.marker_params = {
+ see_message = see_mesg,
+ cantsee_message = cantsee_mesg,
+ turns = trns * 10,
+ warning_done = false,
+ see_function = see_func
+ }
pars.func = warning_func
return FunctionMachine:new(pars)
end
-function trigger_machine (cantsee_mesg, see_mesg, chan)
+function trigger_machine (cantsee_mesg, see_mesg, chan, see_func)
if see_mesg == nil and cantsee_mesg == nil then
error("Triggermachine requires a message!")
end
@@ -357,7 +365,7 @@ function trigger_machine (cantsee_mesg, see_mesg, chan)
local countdown = fm.countdown
if event_name == "trigger" then
channel = mtable.channel or ""
- if mtable.see_message ~= nil and you.see_cell(point.x, point.y) then
+ if mtable.see_message ~= nil and mtable.see_function(point.x, point.y) then
crawl.mpr(mtable.see_message, channel)
elseif mtable.cantsee_message ~= nil then
crawl.mpr(mtable.cantsee_message, channel)
@@ -365,10 +373,14 @@ function trigger_machine (cantsee_mesg, see_mesg, chan)
end
end
pars = {marker_type = "listener"}
+ if not see_func then
+ see_func = you.see_cell
+ end
pars.marker_params = {
channel = chan or nil,
see_message = see_mesg,
- cantsee_message = cantsee_mesg
+ cantsee_message = cantsee_mesg,
+ see_function = see_func
}
pars.func = trigger_func
return FunctionMachine:new(pars)
@@ -376,7 +388,7 @@ end
function tw_machine (warn_turns, warn_cantsee_message,
trig_cantsee_message, trig_channel,
- trig_see_message, warn_see_message)
+ trig_see_message, warn_see_message, see_func)
if (not warn_turns or (not warn_see_message and not warn_cantsee_message)
or (not trig_see_message and not trig_cantsee_message)) then
error("TWMachine needs warning turns, warning message and "
@@ -386,7 +398,7 @@ function tw_machine (warn_turns, warn_cantsee_message,
local countdown = fm.countdown
if event_name == "decrement" and countdown <= mtable.warning_turns then
if mtable.warning_done ~= true then
- if mtable.warning_see_message and you.see_cell(point.x, point.y) then
+ if mtable.warning_see_message and mtable.see_function(point.x, point.y) then
crawl.mpr(mtable.warning_see_message, "warning")
elseif mtable.warning_cantsee_message ~= nil then
crawl.mpr(mtable.warning_cantsee_message, "warning")
@@ -396,13 +408,16 @@ function tw_machine (warn_turns, warn_cantsee_message,
elseif event_name == "trigger" then
mtable.warning_done = false
channel = mtable.trigger_channel or ""
- if mtable.trigger_see_message and you.see_cell(point.x, point.y) then
+ if mtable.trigger_see_message and mtable.see_function(point.x, point.y) then
crawl.mpr(mtable.trigger_see_message, channel)
elseif mtable.trigger_cantsee_message ~= nil then
crawl.mpr(mtable.trigger_cantsee_message, channel)
end
end
end
+ if not see_func then
+ see_func = you.see_cell
+ end
pars = {marker_type = "listener"}
pars.marker_params = {
warning_see_message = warn_see_message,
@@ -411,7 +426,8 @@ function tw_machine (warn_turns, warn_cantsee_message,
warning_done = false,
trigger_see_message = trig_see_message,
trigger_cantsee_message = trig_cantsee_message,
- trigger_channel = trig_channel or nil
+ trigger_channel = trig_channel or nil,
+ see_function = see_func
}
pars.func = tw_func
return FunctionMachine:new(pars)
diff --git a/crawl-ref/source/dat/volcano.des b/crawl-ref/source/dat/volcano.des
index 1b248e11ed..2afccd3132 100644
--- a/crawl-ref/source/dat/volcano.des
+++ b/crawl-ref/source/dat/volcano.des
@@ -144,13 +144,19 @@ end
-- spread_rate=100 })
--end
+local function in_radius (x, y)
+ local p1 = dgn.point(x, y)
+ local p2 = dgn.point(you.pos())
+ return dgn.point_in_radius(p1, p2, 12)
+end
+
local large_warning = tw_machine(3, "The air gets thick with the scent of sulphur.",
"In the distance, the volcano erupts with a roar.",
"The volcano comes to life with a roar!")
local small_warning = tw_machine(3, nil, nil, nil, "The volcano roars to life, " ..
"belching forth lava!", "The air gets thick with " ..
- "the scent of sulphur.")
+ "the scent of sulphur.", in_radius)
function place_large_volcano(e)
e.kfeat("V = l")
@@ -161,11 +167,20 @@ end
function place_medium_volcano(e)
e.kfeat("V = l")
- e.lua_marker('V', fog_machine { cloud_type = "flame", walk_dist=15, pow_max=6,
+ e.lua_marker('V', fog_machine { cloud_type = "flame", walk_dist=0, pow_max=6,
delay = 300, size = 3000, spread_rate = 30,
listener = small_warning})
end
+function place_chained_volcano(e)
+ e.kfeat("V = l")
+ local fm = fog_machine { cloud_type = "flame", walk_dist=15, pow_max=6,
+ delay = 300, size = 3000, spread_rate = 30,
+ listener = large_warning}
+ e.lua_marker('V', lmark.synchronized_markers(fm, "do_fog"))
+end
+
+
function place_small_volcano(e)
e.kfeat("V = l")
e.lua_marker('V', fog_machine { cloud_type = "flame", walk_dist=15, pow_max=6,
@@ -401,6 +416,7 @@ WEIGHT: 0
local fog = fog_machine { cloud_type = 'flame',
size = 3, pow_min=2,
pow_max = 5, delay_min = 22, delay_max = 120,
+ listener = trigger_machine(nil, "Test", nil, in_radius)
}
lua_marker('m', lmark.synchronized_markers(fog, 'do_fog'))
}}
@@ -582,30 +598,30 @@ MAP
xxxyyy...........................................yxxx
xxxxy...............LLLllLLllLLLllllLLllLLlllL........yxxxx
xy..............LllllllllllllllllllllllllllllllLL........yxxx
- xxxy............LlllllllllllllllllllllllliiilllllliL........yxxx
+ xxxy............LlllllllllllllllVlllllllliiilllllliL........yxxx
xxy............LLllllllllVlllllllllllllliillliilliilllLLL......<x
- xy............LmmllllllllllllllllllllliillllllViilllllll.......yxx
- xxxy........LllllmmllllllllllllllllliillllllllllllllllllL.......yx
+ xy............Lmmllllllllllllllllllllliillllllliilllllll.......yxx
+ xxxy........LllllmmllllllllllllllllliillllllVlllllllllllL.......yx
xxy...........Llllllmmllllllllllllllilllllllllllllllllllll.....yxxx
xxy.........LllllllllmmllLlLLllLLlillLLLllLllllllllllllLL......yx
- xxy.....LlllllllllllllmL..................LlllllllllllllL.....yxxxx
- xy......Lllllllllllllll.ccccccccccccccccc.lllllllllllllllL.......yx
- xy.......LlllllVllllllL.c....+.111.+....c.LllllllllllllllL......yxx
+ xxy.....LllllllVllllllmL..................LlllllllllllllL.....yxxxx
+ xy......Lllllllllllllll.ccccccccccccccccc.llllllVllllllllL.......yx
+ xy.......LllllllllllllL.c....+.111.+....c.LllllllllllllllL......yxx
xxy.....Lrrllllllllllll.c.<1.c.G_G.c.1<.c.llllllllllllllLL.......yx
xy......LllrrlllllllllL.c....c..2..c....c.Lllllllllllluuu.......yxx
xxy.....Lllllrrllllllll.ccc==ccc+ccc==ccc.LllllllllluullL......yxx
- xy.....LlllllllrllllllL.c......c.c......c.lllllllluullllL.....yxx
+ xy.....LlllVlllrllllllL.c......c.c......c.lllllllluullllL.....yxx
xxy.....Llllllllrllllll.cccccc.c.c.cccccc.LllllluulllllllL.....yxx
- xy......LllllllllrrlllL.c.$f$c.c.c.cgd$.c.lllluullVllllllL......yxx
- xxy......LlllllVllrllll.c.$gec.c.c.c$e$.c.LluulllllllllllL......yxx
- xxy.......LllllllllrllL.c.3dgc.c.c.cfg3.c.uullllllllllllL.....yxxx
- xy........LlllllllllrlL.c......c.c......c.LllllllllllllL......yxx
+ xy......LllllllllrrlllL.c.$f$c.c.c.cgd$.c.lllluulllllllllL......yxx
+ xxy......Lllllllllrllll.c.$gec.c.c.c$e$.c.LluulllllllllllL......yxx
+ xxy.......LllllllllrllL.c.3dgc.c.c.cfg3.c.uullllllVlllllL.....yxxx
+ xy........LlllVlllllrlL.c......c.c......c.LllllllllllllL......yxx
xxy.....Lllllllllllllrr.cccccccc+cccccccc.llllllllllllllL......yxx
xy.....LlllllllnnnllnnL.................LLllllllllllllL.....yxxx
xxxy....LllllnnlllnnlllLllLlLllllLllLlLlzlllllllllllllL.......yxx
- xA.......nnnllllllllllLlllllllllllllllllzzllllllllllllL.......yxx
- xxxxy.....LllllllVllllllllllllllllllllllllzzlllVlllllllL.....yxx
- xy........LLllllllllllllllllllllllllllllllzzllllllllL.....yxx
+ xA.......nnnllllllllllLlllllllllllllllllzzlllllVllllllL.......yxx
+ xxxxy.....LllllllVllllllVlllllllllllllllllzzlllllllllllL.....yxx
+ xy........LLlllllllllllllllllllllllllVllllzzllllllllL.....yxx
xxxy..........LllllllllllllllllllLllllllllllzlllllLL......yxx
xxxy.........LLlllllllllllllLL...LLllllllllzzzL......yxxxx
xxxy.........LLlLLlLllllLL.......LLllLlLlLL.......yxxx
@@ -821,7 +837,7 @@ COLOUR: + = cyan
MONS: dragon
MONS: human ; robe ego:fire_resistance
MONS: toenail golem
-: place_medium_volcano(_G)
+: place_chained_volcano(_G)
: dgn.set_feature_desc_short("translucent rock wall",
: "glass window")
: dgn.set_feature_desc_long("translucent rock wall",
@@ -956,7 +972,7 @@ SUBST: " = ..'
KFEAT: ' = alarm trap
: fiery_humans(_G)
: volcano_setup(_G)
-: place_medium_volcano(_G)
+: place_chained_volcano(_G)
MAP
#########################################################
#########################################################
diff --git a/crawl-ref/source/l_dgngrd.cc b/crawl-ref/source/l_dgngrd.cc
index b8f1181fa0..7bb9a42e09 100644
--- a/crawl-ref/source/l_dgngrd.cc
+++ b/crawl-ref/source/l_dgngrd.cc
@@ -223,6 +223,14 @@ static int dgn_grid(lua_State *ls)
LUARET1(_dgn_is_wall, boolean,
feat_is_wall(static_cast<dungeon_feature_type>(luaL_checkint(ls, 1))))
+LUAFN(dgn_distance)
+{
+ COORDS(p1, 1, 2);
+ COORDS(p2, 3, 4);
+ lua_pushnumber(ls, distance(p1, p2));
+ return (1);
+}
+
LUAFN(_dgn_is_opaque)
{
COORDS(c, 1, 2);
@@ -243,6 +251,7 @@ const struct luaL_reg dgn_grid_dlib[] =
{ "is_opaque", _dgn_is_opaque },
{ "is_wall", _dgn_is_wall },
{ "max_bounds", dgn_max_bounds },
+{ "distance", dgn_distance },
{ NULL, NULL }
};