summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwushin <pasekei@gmail.com>2014-11-18 00:17:01 -0600
committerBen Longbons <b.r.longbons@gmail.com>2014-11-19 13:43:08 -0800
commit3b936892f84bfd464cd846ec49053b4402fced98 (patch)
tree9aedb2fbe974b1fbc12a0ef2011293cf32032e1f
parent62636ed8dc5d6205286f9e2137093dfc9852e85a (diff)
downloadtmwa-3b936892f84bfd464cd846ec49053b4402fced98.tar.gz
tmwa-3b936892f84bfd464cd846ec49053b4402fced98.tar.bz2
tmwa-3b936892f84bfd464cd846ec49053b4402fced98.tar.xz
tmwa-3b936892f84bfd464cd846ec49053b4402fced98.zip
Script Builtin iscollision
- Checks map.gat, X, Y for collision
-rw-r--r--src/map/script-fun.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 8247a1a..781df69 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -2808,6 +2808,24 @@ void builtin_isin(ScriptState *st)
&& (str == sd->bl_m->name_));
}
+/*==========================================
+ * Check whether the coords are collision
+ *------------------------------------------
+ */
+static
+void builtin_iscollision(ScriptState *st)
+{
+ int x, y;
+ MapName mapname = stringish<MapName>(ZString(conv_str(st, &AARG(0))));
+ P<map_local> m = TRY_UNWRAP(map_mapname2mapid(mapname), return);
+
+ x = conv_num(st, &AARG(1));
+ y = conv_num(st, &AARG(2));
+
+ push_int<ScriptDataInt>(st->stack,
+ bool(map_getcell(m, x, y) & MapCell::UNWALKABLE));
+}
+
// Trigger the shop on a (hopefully) nearby shop NPC
static
void builtin_shop(ScriptState *st)
@@ -3024,6 +3042,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(getsavepoint, "i"_s, '.'),
BUILTIN(areatimer, "MxyxytE"_s, '\0'),
BUILTIN(isin, "Mxyxy"_s, 'i'),
+ BUILTIN(iscollision, "Mxy"_s, 'i'),
BUILTIN(shop, "s"_s, '\0'),
BUILTIN(isdead, ""_s, 'i'),
BUILTIN(fakenpcname, "ssi"_s, '\0'),