From 53edb4dd94fda5157944dbd0fc619f92ce4db500 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 2 May 2015 15:40:15 +0300 Subject: add script function for check is unit walking. New script function: isunitwalking([unitid]) --- src/map/init.c | 1 + src/map/script.c | 28 ++++++++++++++++++++++++++++ src/map/script.h | 1 + 3 files changed, 30 insertions(+) diff --git a/src/map/init.c b/src/map/init.c index e19224a..d14f5b0 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -110,6 +110,7 @@ HPExport void plugin_init (void) addScriptCommand("getareadropitem", "siiiiv*", getAreaDropItem); addScriptCommand("setmount", "?", setMount); addScriptCommand("clientcommand", "s", clientCommand); + addScriptCommand("isunitwalking", "?", isUnitWalking); do_init_langs(); diff --git a/src/map/script.c b/src/map/script.c index fe014dd..02e34a4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10,6 +10,7 @@ #include "../../../common/mmo.h" #include "../../../common/socket.h" #include "../../../common/strlib.h" +#include "../../../common/timer.h" #include "../../../map/chrif.h" #include "../../../map/clif.h" #include "../../../map/npc.h" @@ -1118,3 +1119,30 @@ BUILDIN(clientCommand) send_client_command(sd, command); return true; } + +BUILDIN(isUnitWalking) +{ + int id = 0; + if (script_hasdata(st, 2)) + id = script_getnum(st, 2); + else + id = st->oid; + struct block_list *bl = map->id2bl(id); + if (!bl) + { + ShowWarning("invalid unit id\n"); + script->reportsrc(st); + script_pushint(st, 0); + return false; + } + struct unit_data *ud = unit->bl2ud(bl); + if (!ud) + { + ShowWarning("invalid unit data\n"); + script->reportsrc(st); + script_pushint(st, 0); + return false; + } + script_pushint(st, ud->walktimer != INVALID_TIMER); + return true; +} diff --git a/src/map/script.h b/src/map/script.h index 24210a1..41c96ee 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -41,5 +41,6 @@ BUILDIN(areaTimer); BUILDIN(getAreaDropItem); BUILDIN(setMount); BUILDIN(clientCommand); +BUILDIN(isUnitWalking); #endif // EVOL_MAP_SCRIPT -- cgit v1.2.3-60-g2f50