diff options
-rw-r--r-- | src/emap/init.c | 3 | ||||
-rw-r--r-- | src/emap/script.c | 92 | ||||
-rw-r--r-- | src/emap/script.h | 3 |
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 |