summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-23 17:17:36 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-23 17:20:33 +0300
commit28d7577356c78a625e2d2016068053325f5337e4 (patch)
tree4668f770d900dd825a40a5dad3b6f344cdbb4781
parent04f16152151c23446a6f358badabeda7b0ea7380 (diff)
downloadevol-hercules-28d7577356c78a625e2d2016068053325f5337e4.tar.gz
evol-hercules-28d7577356c78a625e2d2016068053325f5337e4.tar.bz2
evol-hercules-28d7577356c78a625e2d2016068053325f5337e4.tar.xz
evol-hercules-28d7577356c78a625e2d2016068053325f5337e4.zip
Impliment script command getnpcdir.
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/script.c28
-rw-r--r--src/map/script.h1
3 files changed, 30 insertions, 1 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 022428c..3015ea5 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -72,7 +72,7 @@ HPExport void plugin_init (void)
addScriptCommand("requestlang", "v", requestLang);
addScriptCommand("getq", "i", getq);
addScriptCommand("setq", "ii", setq);
- addScriptCommand("getnpcdir", "*", dummyInt);
+ addScriptCommand("getnpcdir", "*", getNpcDir);
addScriptCommand("setnpcdir", "*", dummy);
addScriptCommand("rif", "is*", dummyStr);
addScriptCommand("countitemcolor", "*", dummyInt);
diff --git a/src/map/script.c b/src/map/script.c
index a2f0f8a..ba75561 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -295,3 +295,31 @@ BUILDIN(getq)
script_pushint(st, sd->quest_log[i].count[0]);
return true;
}
+
+BUILDIN(getNpcDir)
+{
+ struct npc_data *nd = 0;
+
+ if (script_hasdata(st, 2))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ }
+ if (!nd && !st->oid)
+ {
+ script_pushint(st, -1);
+ return true;
+ }
+
+ if (!nd)
+ nd = (struct npc_data *) map->id2bl (st->oid);
+
+ if (!nd)
+ {
+ script_pushint(st, -1);
+ return true;
+ }
+
+ script_pushint(st, (int)nd->dir);
+
+ return true;
+}
diff --git a/src/map/script.h b/src/map/script.h
index fc63764..999d65e 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -18,5 +18,6 @@ BUILDIN(getItemLink);
BUILDIN(requestLang);
BUILDIN(getq);
BUILDIN(setq);
+BUILDIN(getNpcDir);
#endif // EVOL_MAP_SCRIPT