summaryrefslogtreecommitdiff
path: root/src/emap/script.c
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/script.c
parent38e12363df013928b2c236afeefef5c71fac6020 (diff)
downloadplugin-828bececcd905903535b1e543a5b1dc1581c250d.tar.gz
plugin-828bececcd905903535b1e543a5b1dc1581c250d.tar.bz2
plugin-828bececcd905903535b1e543a5b1dc1581c250d.tar.xz
plugin-828bececcd905903535b1e543a5b1dc1581c250d.zip
Add script commands npcsit and npcstand.
New script commands: npcsit [npcid]; npcstand [npcid];
Diffstat (limited to 'src/emap/script.c')
-rw-r--r--src/emap/script.c92
1 files changed, 92 insertions, 0 deletions
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;
+}