From 3b936892f84bfd464cd846ec49053b4402fced98 Mon Sep 17 00:00:00 2001 From: wushin Date: Tue, 18 Nov 2014 00:17:01 -0600 Subject: Script Builtin iscollision - Checks map.gat, X, Y for collision --- src/map/script-fun.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') 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(ZString(conv_str(st, &AARG(0)))); + P m = TRY_UNWRAP(map_mapname2mapid(mapname), return); + + x = conv_num(st, &AARG(1)); + y = conv_num(st, &AARG(2)); + + push_int(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'), -- cgit v1.2.3-60-g2f50