From db2c1615ba8b2a679b81eec2c93d9d68e2c5edf8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Nov 2014 17:54:02 +0300 Subject: Impliment script command setnpcdir. --- src/map/init.c | 2 +- src/map/script.c | 32 ++++++++++++++++++++++++++++++++ src/map/script.h | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src/map') 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 -- cgit v1.2.3-70-g09d2