From 1a410d241918f85010c59827dfd2fa3b1952d238 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sun, 9 Feb 2020 07:00:14 +0100 Subject: Add unitiswalking() script command --- src/map/script.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src') diff --git a/src/map/script.c b/src/map/script.c index 26bd678fe..755a099ec 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21025,6 +21025,38 @@ static BUILDIN(unitwalk) return true; } +/** + * Checks if a unit is walking. + * + * Returns 1 if unit is walking, 0 if unit is not walking and -1 on error. + * + * @code{.herc} + * unitiswalking({}); + * @endcode + * + **/ +static BUILDIN(unitiswalking) +{ + int gid = script_hasdata(st, 2) ? script_getnum(st, 2) : st->rid; + struct block_list *bl = map->id2bl(gid); + + if (bl == NULL) { + ShowWarning("buildin_unitiswalking: Error in finding object for GID %d!\n", gid); + script_pushint(st, -1); + return false; + } + + if (unit->bl2ud(bl) == NULL) { + ShowWarning("buildin_unitiswalking: Error in finding unit_data for GID %d!\n", gid); + script_pushint(st, -1); + return false; + } + + script_pushint(st, unit->is_walking(bl)); + + return true; +} + /// Kills the unit /// /// unitkill ; @@ -26635,6 +26667,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(getunittitle,"i"), BUILDIN_DEF(setunittitle,"is"), BUILDIN_DEF(unitwalk,"ii?"), + BUILDIN_DEF(unitiswalking, "?"), BUILDIN_DEF(unitkill,"i"), BUILDIN_DEF(unitwarp,"isii"), BUILDIN_DEF(unitattack,"iv?"), -- cgit v1.2.3-70-g09d2