summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/script.c32
-rw-r--r--src/map/script.h1
3 files changed, 34 insertions, 1 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 3015ea5..901c964 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -73,7 +73,7 @@ HPExport void plugin_init (void)
addScriptCommand("getq", "i", getq);
addScriptCommand("setq", "ii", setq);
addScriptCommand("getnpcdir", "*", getNpcDir);
- addScriptCommand("setnpcdir", "*", dummy);
+ addScriptCommand("setnpcdir", "*", setNpcDir);
addScriptCommand("rif", "is*", dummyStr);
addScriptCommand("countitemcolor", "*", dummyInt);
addScriptCommandDeprecated("getclientversion", "", getClientVersion);
diff --git a/src/map/script.c b/src/map/script.c
index ba75561..cca62c7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -323,3 +323,35 @@ BUILDIN(getNpcDir)
return true;
}
+
+BUILDIN(setNpcDir)
+{
+ int newdir;
+ struct npc_data *nd = 0;
+
+ if (script_hasdata(st, 3))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ newdir = script_getnum(st, 3);
+ }
+ else if (script_hasdata(st, 2))
+ {
+ if (!st->oid)
+ return false;
+
+ nd = (struct npc_data *) map->id2bl (st->oid);
+ newdir = script_getnum(st, 2);
+ }
+ if (!nd)
+ return false;
+
+ if (newdir < 0)
+ newdir = 0;
+ else if (newdir > 7)
+ newdir = 7;
+
+ nd->dir = newdir;
+ npc->enable (nd->name, 1);
+
+ return true;
+}
diff --git a/src/map/script.h b/src/map/script.h
index 999d65e..b9b13db 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -19,5 +19,6 @@ BUILDIN(requestLang);
BUILDIN(getq);
BUILDIN(setq);
BUILDIN(getNpcDir);
+BUILDIN(setNpcDir);
#endif // EVOL_MAP_SCRIPT