summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-02 15:40:15 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-02 15:40:15 +0300
commit53edb4dd94fda5157944dbd0fc619f92ce4db500 (patch)
tree9ec217484965bb8094d15eb66e29b1388333f6f3
parent97b30eda6487c6a7fb7db61dc7af2b0ea006d71d (diff)
downloadevol-hercules-53edb4dd94fda5157944dbd0fc619f92ce4db500.tar.gz
evol-hercules-53edb4dd94fda5157944dbd0fc619f92ce4db500.tar.bz2
evol-hercules-53edb4dd94fda5157944dbd0fc619f92ce4db500.tar.xz
evol-hercules-53edb4dd94fda5157944dbd0fc619f92ce4db500.zip
add script function for check is unit walking.
New script function: isunitwalking([unitid])
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c28
-rw-r--r--src/map/script.h1
3 files changed, 30 insertions, 0 deletions
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