summaryrefslogtreecommitdiff
path: root/src/emap
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-09-25 23:35:33 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-25 23:35:33 +0300
commit828bececcd905903535b1e543a5b1dc1581c250d (patch)
treefc0dec6a7f67e5e143dbf32b87e3f754f475fb0b /src/emap
parent38e12363df013928b2c236afeefef5c71fac6020 (diff)
downloadevol-hercules-828bececcd905903535b1e543a5b1dc1581c250d.tar.gz
evol-hercules-828bececcd905903535b1e543a5b1dc1581c250d.tar.bz2
evol-hercules-828bececcd905903535b1e543a5b1dc1581c250d.tar.xz
evol-hercules-828bececcd905903535b1e543a5b1dc1581c250d.zip
Add script commands npcsit and npcstand.
New script commands: npcsit [npcid]; npcstand [npcid];
Diffstat (limited to 'src/emap')
-rw-r--r--src/emap/init.c3
-rw-r--r--src/emap/script.c92
-rw-r--r--src/emap/script.h3
3 files changed, 98 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index b99ab25..4119702 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -94,6 +94,9 @@ HPExport void plugin_init (void)
addScriptCommand("getq", "i", getq);
addScriptCommand("setq", "ii", setq);
addScriptCommand("setnpcdir", "*", setNpcDir);
+ addScriptCommand("npcsit", "*", npcSit);
+ addScriptCommand("npcstand", "*", npcStand);
+ addScriptCommand("npcwalkto", "ii", npcWalkTo);
addScriptCommand("rif", "is*", rif);
addScriptCommand("countitemcolor", "v*", countItemColor);
addScriptCommand("misceffect", "i*", miscEffect);
diff --git a/src/emap/script.c b/src/emap/script.c
index 18df0b5..5b3519f 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -1372,3 +1372,95 @@ BUILDIN(isStr)
script_pushint(st, 2);
return true;
}
+
+BUILDIN(npcSit)
+{
+ TBL_NPC *nd = NULL;
+
+ if (script_hasdata(st, 2))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ }
+ else
+ {
+ if (!st->oid)
+ {
+ ShowWarning("npc not attached\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ nd = (TBL_NPC *) map->id2bl (st->oid);
+ }
+ if (!nd)
+ {
+ ShowWarning("npc not found\n");
+ script->reportsrc(st);
+ return false;
+ }
+ nd->vd->dead_sit = 2;
+ clif->sitting(&nd->bl);
+ return true;
+}
+
+BUILDIN(npcStand)
+{
+ TBL_NPC *nd = NULL;
+
+ if (script_hasdata(st, 2))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ }
+ else
+ {
+ if (!st->oid)
+ {
+ ShowWarning("npc not attached\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ nd = (TBL_NPC *) map->id2bl (st->oid);
+ }
+ if (!nd)
+ {
+ ShowWarning("npc not found\n");
+ script->reportsrc(st);
+ return false;
+ }
+ nd->vd->dead_sit = 0;
+ clif->standing(&nd->bl);
+ return true;
+}
+
+BUILDIN(npcWalkTo)
+{
+ struct npc_data *nd = (struct npc_data *)map->id2bl(st->oid);
+ int x = 0, y = 0;
+
+ x = script_getnum(st, 2);
+ y = script_getnum(st, 3);
+
+ if (nd)
+ {
+ unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
+ if (!nd->status.hp)
+ {
+ status_calc_npc(nd, SCO_FIRST);
+ }
+ else
+ {
+ status_calc_npc(nd, SCO_NONE);
+ }
+ nd->vd->dead_sit = 0;
+ unit->walktoxy(&nd->bl,x,y,0);
+ }
+ else
+ {
+ ShowWarning("npc not found\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/emap/script.h b/src/emap/script.h
index 17518a4..599dbe1 100644
--- a/src/emap/script.h
+++ b/src/emap/script.h
@@ -48,5 +48,8 @@ BUILDIN(failedRefIndex);
BUILDIN(downRefIndex);
BUILDIN(successRefIndex);
BUILDIN(isStr);
+BUILDIN(npcSit);
+BUILDIN(npcStand);
+BUILDIN(npcWalkTo);
#endif // EVOL_MAP_SCRIPT