From eb2a8c8519ad566e2b2dfae18d11acc8478a85fc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 28 Nov 2014 16:03:23 +0300 Subject: Add script command "getnpcclass". Format: getnpcclass ([NAME]) --- src/map/init.c | 1 + src/map/script.c | 28 ++++++++++++++++++++++++++++ src/map/script.h | 1 + 3 files changed, 30 insertions(+) diff --git a/src/map/init.c b/src/map/init.c index e22bcba..519ca02 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -78,6 +78,7 @@ HPExport void plugin_init (void) addScriptCommand("addmapmask", "si", addMapMask); addScriptCommand("removemapmask", "si", removeMapMask); addScriptCommand("getmapmask", "s", getMapMask); + addScriptCommand("getnpcclass", "*", getNpcClass); do_init_langs(); diff --git a/src/map/script.c b/src/map/script.c index 676d598..8b8cbfe 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -506,3 +506,31 @@ BUILDIN(removeMapMask) send_mapmask_brodcast(m, mapData->mask); return true; } + +BUILDIN(getNpcClass) +{ + struct npc_data *nd = 0; + + if (script_hasdata(st, 2)) + { + nd = npc->name2id (script_getstr(st, 2)); + } + if (!nd && !st->oid) + { + script_pushint(st, -1); + return false; + } + + if (!nd) + nd = (struct npc_data *) map->id2bl(st->oid); + + if (!nd) + { + script_pushint(st, -1); + return false; + } + + script_pushint(st, (int)nd->class_); + + return true; +} diff --git a/src/map/script.h b/src/map/script.h index 3210cca..36e8150 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -24,5 +24,6 @@ BUILDIN(setMapMask); BUILDIN(getMapMask); BUILDIN(addMapMask); BUILDIN(removeMapMask); +BUILDIN(getNpcClass); #endif // EVOL_MAP_SCRIPT -- cgit v1.2.3-70-g09d2