summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/emap/data/npcd.c1
-rw-r--r--src/emap/init.c3
-rw-r--r--src/emap/script.c39
-rw-r--r--src/emap/script.h3
-rw-r--r--src/emap/struct/npcdext.h1
5 files changed, 47 insertions, 0 deletions
diff --git a/src/emap/data/npcd.c b/src/emap/data/npcd.c
index 7da1690..6e00c98 100644
--- a/src/emap/data/npcd.c
+++ b/src/emap/data/npcd.c
@@ -36,5 +36,6 @@ struct NpcdExt *npcd_create(void)
if (!data)
return NULL;
data->init = false;
+ data->language = 0;
return data;
}
diff --git a/src/emap/init.c b/src/emap/init.c
index 4119702..624a7b8 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -169,6 +169,9 @@ HPExport void plugin_init (void)
addHookPre("unit->can_move", eunit_can_move);
addHookPre("unit->walktoxy", eunit_walktoxy);
addHookPre("mail->invalid_operation", email_invalid_operation);
+ addHookPre("script->set_reg_npc_num", escript_set_reg_npc_num);
+ addHookPre("script->get_val_npc_num", escript_get_val_npcscope_num);
+ addHookPre("script->get_val_ref_num", escript_get_val_npcscope_num);
addHookPre("status->calc_pc_additional", estatus_calc_pc_additional);
addHookPost("clif->getareachar_unit", eclif_getareachar_unit_post);
diff --git a/src/emap/script.c b/src/emap/script.c
index 5b3519f..0df3847 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -35,6 +35,45 @@
#include "emap/struct/sessionext.h"
#include "emap/utils/formatutils.h"
+#define getExt() \
+ TBL_NPC *nd = map->id2nd(st->oid); \
+ if (!nd) \
+ return; \
+ struct NpcdExt *ext = npcd_get(nd); \
+ if (!ext) \
+ return
+
+#define getExtRet(r) \
+ TBL_NPC *nd = map->id2nd(st->oid); \
+ if (!nd) \
+ return r; \
+ struct NpcdExt *ext = npcd_get(nd); \
+ if (!ext) \
+ return r
+
+void escript_set_reg_npc_num(struct script_state* st, struct reg_db *n, int64 *num, const char* name, int *val)
+{
+ if (!strcmp(name, ".lang"))
+ {
+ getExt();
+ ext->language = *val;
+ hookStop();
+ }
+}
+
+int escript_get_val_npcscope_num(struct script_state* st, struct reg_db *n, struct script_data* data)
+{
+ const char *name = reference_getname(data);
+ if (!strcmp(name, ".lang"))
+ {
+ getExtRet(0);
+
+ hookStop();
+ return ext->language;
+ }
+ return 0;
+}
+
uint32 MakeDWord(uint16 word0, uint16 word1)
{
return ((uint32)(word0)) | ((uint32)(word1 << 0x10));
diff --git a/src/emap/script.h b/src/emap/script.h
index 599dbe1..dcd0bf5 100644
--- a/src/emap/script.h
+++ b/src/emap/script.h
@@ -4,6 +4,9 @@
#ifndef EVOL_MAP_SCRIPT
#define EVOL_MAP_SCRIPT
+void escript_set_reg_npc_num(struct script_state* st, struct reg_db *n, int64 *num, const char* name, int *val);
+int escript_get_val_npcscope_num(struct script_state* st, struct reg_db *n, struct script_data* data);
+
BUILDIN(l);
BUILDIN(lg);
BUILDIN(setCamNpc);
diff --git a/src/emap/struct/npcdext.h b/src/emap/struct/npcdext.h
index 2158f2c..9aa6cbf 100644
--- a/src/emap/struct/npcdext.h
+++ b/src/emap/struct/npcdext.h
@@ -7,6 +7,7 @@
struct NpcdExt
{
bool init;
+ int language;
};
#endif // EVOL_MAP_NPCDEXT