diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-29 13:51:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-29 13:51:19 +0300 |
commit | 82a8e2804bbcd75db6053d5e36236ba33833ec60 (patch) | |
tree | 8d27553a3ddfde922176203b6b51120be01ef7ab /src | |
parent | 468b795c5c5509dd3b13d413af5fdd82c0136699 (diff) | |
download | evol-hercules-82a8e2804bbcd75db6053d5e36236ba33833ec60.tar.gz evol-hercules-82a8e2804bbcd75db6053d5e36236ba33833ec60.tar.bz2 evol-hercules-82a8e2804bbcd75db6053d5e36236ba33833ec60.tar.xz evol-hercules-82a8e2804bbcd75db6053d5e36236ba33833ec60.zip |
Add script command checknpccell. It works same like checkcell, but for current npc.
Diffstat (limited to 'src')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script.c | 28 | ||||
-rw-r--r-- | src/emap/script.h | 1 |
3 files changed, 30 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 4c9ae8c..2d7e2d2 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -126,6 +126,7 @@ HPExport void plugin_init (void) addScriptCommand("successrefindex", "ii", successRefIndex); addScriptCommand("isstr", "v", isStr); addScriptCommand("setbgteam", "ii", setBgTeam); + addScriptCommand("checknpccell", "siii", checkNpcCell); do_init_langs(); diff --git a/src/emap/script.c b/src/emap/script.c index 33f5d60..d2069eb 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -1723,3 +1723,31 @@ BUILDIN(chatJoin) chat->join(sd, chatId, password); return true; } + +/// Retrieves the value of the specified flag of the specified cell. +/// +/// checknpccell("<map name>",<x>,<y>,<type>) -> <bool> +/// +/// @see cell_chk* constants in const.txt for the types +BUILDIN(checkNpcCell) +{ + int16 m = map->mapname2mapid(script_getstr(st, 2)); + int16 x = script_getnum(st, 3); + int16 y = script_getnum(st, 4); + cell_chk type = (cell_chk)script_getnum(st, 5); + + if (m == -1) + { + ShowWarning("checknpccell: Attempted to run on unexsitent map '%s', type %d, x/y %d,%d\n", script_getstr(st, 2), type, x, y); + return true; + } + + TBL_NPC *nd = map->id2nd(st->oid); + struct block_list *bl = NULL; + if (nd) + bl = &nd->bl; + + script_pushint(st, map->getcell(m, bl, x, y, type)); + + return true; +} diff --git a/src/emap/script.h b/src/emap/script.h index dc65855..97059df 100644 --- a/src/emap/script.h +++ b/src/emap/script.h @@ -58,5 +58,6 @@ BUILDIN(npcStand); BUILDIN(npcWalkTo); BUILDIN(setBgTeam); BUILDIN(chatJoin); +BUILDIN(checkNpcCell); #endif // EVOL_MAP_SCRIPT |