summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-11-01 20:03:07 +1000
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-11-01 16:20:46 +0530
commit9f6de9fef21ca311f82a0aa5cc7f5067e4e62af9 (patch)
treed5cb8fb28f29b43665766e63d47109cab3f732ea /crawl-ref/source/dat/clua
parentcc61ee4e8a90f192732d03c58984bfccf7200e4b (diff)
downloadcrawl-ref-9f6de9fef21ca311f82a0aa5cc7f5067e4e62af9.tar.gz
crawl-ref-9f6de9fef21ca311f82a0aa5cc7f5067e4e62af9.zip
Lua distance bindings, Volcano tweaks, FogMachine message tweaks.
New binding for coord.cc's distance functions (dgn.distance(x1, y1, x2, y2)), lua function "point_in_radius", accepts two dgn.point functions and a radius and returns true if point1 is in radius around point2. Extensive tweaks to FogMachine warning messages: most now accept a "see function" as the final parameter, which should take two parameters: an x and a y. The function should return true if the player can "see" this point. Finally, tweaks to Volcanoes: utilise see_function and dgn.point_in_radius to provide better warning for lake. Utilise greensnark's new slave/master system for chaining FogMachines together in Bunker and Village. Signed-off-by: Darshan Shaligram <dshaligram@users.sourceforge.net>
Diffstat (limited to 'crawl-ref/source/dat/clua')
-rw-r--r--crawl-ref/source/dat/clua/dungeon.lua6
-rw-r--r--crawl-ref/source/dat/clua/lm_fog.lua38
2 files changed, 33 insertions, 11 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)