summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-09-12 13:25:42 -0300
committerJesusaves <cpntb1@ymail.com>2020-09-12 13:25:42 -0300
commit78200eab7c4020db84cab2bcdf57d4ffb86b4947 (patch)
tree3b338efab128300e35cbee355710ba3fa0e8db2e
parent5ad77e97ee8079507d0bb8aa061cba2f013c1541 (diff)
downloadevol-hercules-78200eab7c4020db84cab2bcdf57d4ffb86b4947.tar.gz
evol-hercules-78200eab7c4020db84cab2bcdf57d4ffb86b4947.tar.bz2
evol-hercules-78200eab7c4020db84cab2bcdf57d4ffb86b4947.tar.xz
evol-hercules-78200eab7c4020db84cab2bcdf57d4ffb86b4947.zip
add buildin getnpcsubtype() to get nd->subtype
fix an incompatible assignment in buildin getnpcsubtype() Patch by gumi
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script.c8
-rw-r--r--src/emap/script_buildins.c24
-rw-r--r--src/emap/script_buildins.h1
4 files changed, 34 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 5f662c6..c321823 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -217,6 +217,7 @@ HPExport void plugin_init (void)
addScriptCommand("setitemoptionbyindex", "iii*", setItemOptionByIndex);
addScriptCommand("isinstance", "i", isInstance);
addScriptCommand("readbattleparam","ii",readBattleParam);
+ addScriptCommand("getnpcsubtype", "?", getNpcSubtype);
// TMW2 Custom Script Commands
addScriptCommand("getguildinfo","i",getguildinfo);
diff --git a/src/emap/script.c b/src/emap/script.c
index 236461b..991d8b8 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -88,6 +88,14 @@ void escript_hardcoded_constants_pre(void)
{
script->constdb_comment("Evol constants");
script->set_constant("MAX_SLOTS", MAX_SLOTS, false, false);
+
+ // npc subtypes
+ script->set_constant("NPCSUBTYPE_WARP", WARP, false, false);
+ script->set_constant("NPCSUBTYPE_SHOP", SHOP, false, false);
+ script->set_constant("NPCSUBTYPE_SCRIPT", SCRIPT, false, false);
+ script->set_constant("NPCSUBTYPE_CASHSHOP", CASHSHOP, false, false);
+ script->set_constant("NPCSUBTYPE_TOMB", TOMB, false, false);
+
script->constdb_comment(NULL);
eskill_addskill_conststants();
}
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index da9ccf2..28fc0e5 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -2424,6 +2424,30 @@ BUILDIN(isInstance)
return true;
}
+BUILDIN(getNpcSubtype)
+{
+ TBL_NPC *nd = map->id2nd(st->oid);
+
+ if (script_hasdata(st, 2))
+ {
+ if (script_isstringtype(st, 2)) {
+ nd = npc->name2id(script_getstr(st, 2));
+ } else {
+ nd = map->id2nd(script_getnum(st, 2));
+ }
+ }
+
+ if (!nd)
+ {
+ ShowWarning("npc not found\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ script_pushint(st, nd->subtype);
+ return true;
+}
+
/*==========================================
* return the battle stats of a structure
* Supported values are most of UDT_* ones
diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h
index 5c0544b..8426f2a 100644
--- a/src/emap/script_buildins.h
+++ b/src/emap/script_buildins.h
@@ -102,6 +102,7 @@ BUILDIN(getItemOptionParamByIndex);
BUILDIN(setItemOptionByIndex);
BUILDIN(isInstance);
BUILDIN(readBattleParam);
+BUILDIN(getNpcSubtype);
// TMW2 Build Ins
BUILDIN(getguildinfo);