summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-12 23:56:21 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-13 01:44:02 -0800
commit6321ec9aeeb988b9833cca313b366d1b648c41ba (patch)
tree951ca6ed16ae6da3906603c2c278b38d13038a1a /crawl-ref/source/dat/clua
parent3afcd8d5b4123299491280d878ef0ba8d01a8164 (diff)
downloadcrawl-ref-6321ec9aeeb988b9833cca313b366d1b648c41ba.tar.gz
crawl-ref-6321ec9aeeb988b9833cca313b366d1b648c41ba.zip
MonPropsMarker: set hash properties on monsters
A marker class which will take the monster on top of it, set any number entries in that monster's props CrawslHashTable member, and then disappear.
Diffstat (limited to 'crawl-ref/source/dat/clua')
-rw-r--r--crawl-ref/source/dat/clua/lm_mon_prop.lua50
-rw-r--r--crawl-ref/source/dat/clua/luamark.lua1
2 files changed, 51 insertions, 0 deletions
diff --git a/crawl-ref/source/dat/clua/lm_mon_prop.lua b/crawl-ref/source/dat/clua/lm_mon_prop.lua
new file mode 100644
index 0000000000..6bc3dd6de9
--- /dev/null
+++ b/crawl-ref/source/dat/clua/lm_mon_prop.lua
@@ -0,0 +1,50 @@
+------------------------------------------------------------------------------
+-- lm_mon_prop.lua:
+--
+-- This marker takes whatever monster is standing on it, sets properties in
+-- the CrawlHashTable member of that monster, then disappears.
+------------------------------------------------------------------------------
+
+MonPropsMarker = { CLASS = "MonPropsMarker" }
+MonPropsMarker.__index = MonPropsMarker
+
+function MonPropsMarker:new(props)
+ if not props then
+ error("MonPropsMarker:new() needs props")
+ end
+ if type(props) ~= "table" then
+ error("MonPropsMarker:new() needs type(props) == table")
+ end
+
+ local mp = { }
+ setmetatable(mp, self)
+ self.__index = self
+
+ mp.props = props
+
+ return mp
+end
+
+function MonPropsMarker:activate(marker)
+ local mon = dgn.mons_at(marker:pos())
+
+ if not mon then
+ crawl.mpr("No monster for MonPropsMarker:activate()")
+ dgn.remove_marker(marker)
+ return
+ end
+
+ for k, v in pairs(self.props) do
+ mon.set_prop(k, v)
+ end
+
+ dgn.remove_marker(marker)
+end
+
+function MonPropsMarker:write(marker, th)
+ error("MonPropsMarker should never be saved")
+end
+
+function MonPropsMarker:read(marker, th)
+ error("MonPropsMarker should never be in save file")
+end
diff --git a/crawl-ref/source/dat/clua/luamark.lua b/crawl-ref/source/dat/clua/luamark.lua
index bc99e10ebd..d8a07f2b71 100644
--- a/crawl-ref/source/dat/clua/luamark.lua
+++ b/crawl-ref/source/dat/clua/luamark.lua
@@ -11,6 +11,7 @@ require('clua/lm_timed.lua')
require('clua/lm_flags.lua')
require('clua/lm_fog.lua')
require('clua/lm_props.lua')
+require('clua/lm_mon_prop.lua')
require('clua/lm_monst.lua')
require('clua/lm_mslav.lua')