diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-27 18:07:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-27 18:07:52 +0300 |
commit | 454c1448e30fe9d8cc2e6bc535921b2f7efd58e2 (patch) | |
tree | f3b7e3cf2da964ed5ffd3ebb093de5b7cc002077 | |
parent | 828bececcd905903535b1e543a5b1dc1581c250d (diff) | |
download | evol-hercules-454c1448e30fe9d8cc2e6bc535921b2f7efd58e2.tar.gz evol-hercules-454c1448e30fe9d8cc2e6bc535921b2f7efd58e2.tar.bz2 evol-hercules-454c1448e30fe9d8cc2e6bc535921b2f7efd58e2.tar.xz evol-hercules-454c1448e30fe9d8cc2e6bc535921b2f7efd58e2.zip |
Add .lang variable to npc for storing language.
Also add hooks to set/get vars.
-rw-r--r-- | src/emap/data/npcd.c | 1 | ||||
-rw-r--r-- | src/emap/init.c | 3 | ||||
-rw-r--r-- | src/emap/script.c | 39 | ||||
-rw-r--r-- | src/emap/script.h | 3 | ||||
-rw-r--r-- | src/emap/struct/npcdext.h | 1 |
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 |