diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-07 17:18:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-16 22:44:20 +0300 |
commit | 625ed85b6a3d88587e8927f1f640f1fadd3dc642 (patch) | |
tree | 0eea82cd4b6d9f939d4c1f8d708d3e1b8177e715 /src/map/script.c | |
parent | 54b5a4d666eae9692ff06746c2ae68d9e1b49641 (diff) | |
download | hercules-625ed85b6a3d88587e8927f1f640f1fadd3dc642.tar.gz hercules-625ed85b6a3d88587e8927f1f640f1fadd3dc642.tar.bz2 hercules-625ed85b6a3d88587e8927f1f640f1fadd3dc642.tar.xz hercules-625ed85b6a3d88587e8927f1f640f1fadd3dc642.zip |
Extend script command getareausers.
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 69 |
1 files changed, 56 insertions, 13 deletions
diff --git a/src/map/script.c b/src/map/script.c index e59159586..fbfb88de2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10093,21 +10093,64 @@ int buildin_getareausers_sub(struct block_list *bl,va_list ap) } BUILDIN(getareausers) { - const char *str; - int16 m,x0,y0,x1,y1; + int16 m = -1, x0, y0, x1, y1; int users = 0; - str=script_getstr(st,2); - x0=script_getnum(st,3); - y0=script_getnum(st,4); - x1=script_getnum(st,5); - y1=script_getnum(st,6); - if( (m=map->mapname2mapid(str))< 0) { - script_pushint(st,-1); - return true; + int idx = 2; + struct npc_data *nd = NULL; + if (script_hasdata(st, 2) && script_isstringtype(st, 2)) { + const char *str = script_getstr(st, 2); + if ((m = map->mapname2mapid(str)) < 0) { + script_pushint(st, -1); + return true; + } + idx = 3; + } + if (m == -1) + { + TBL_PC *sd = NULL; + sd = script->rid2sd(st); + if (!sd) + { + script_pushint(st, -1); + return false; + } + m = sd->bl.m; + } + if (st->oid) + nd = map->id2nd(st->oid); + if (script_hasdata(st, idx + 3)) { + x0 = script_getnum(st, idx + 0); + y0 = script_getnum(st, idx + 1); + x1 = script_getnum(st, idx + 2); + y1 = script_getnum(st, idx + 3); + } else if (script_hasdata(st, idx)) { + if (!nd) + { + script_pushint(st, -1); + return true; + } + int sz = script_getnum(st, idx); + x0 = nd->bl.x - sz; + y0 = nd->bl.y - sz; + x1 = nd->bl.x + sz; + y1 = nd->bl.y + sz; + } else if (st->oid) { + if (!nd || nd->u.scr.xs == -1 || nd->u.scr.ys == -1) + { + script_pushint(st, -1); + return true; + } + x0 = nd->bl.x - nd->u.scr.xs; + y0 = nd->bl.y - nd->u.scr.ys; + x1 = nd->bl.x + nd->u.scr.xs; + y1 = nd->bl.y + nd->u.scr.ys; + } else { + script_pushint(st, -1); + return false; } map->foreachinarea(script->buildin_getareausers_sub, - m,x0,y0,x1,y1,BL_PC,&users); - script_pushint(st,users); + m, x0, y0, x1, y1, BL_PC, &users); + script_pushint(st, users); return true; } @@ -19382,7 +19425,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(getusers,"i"), BUILDIN_DEF(getmapguildusers,"si"), BUILDIN_DEF(getmapusers,"s"), - BUILDIN_DEF(getareausers,"siiii"), + BUILDIN_DEF(getareausers,"*"), BUILDIN_DEF(getareadropitem,"siiiiv"), BUILDIN_DEF(enablenpc,"s"), BUILDIN_DEF(disablenpc,"s"), |