summaryrefslogtreecommitdiff
path: root/src/emap/script.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-09-27 18:07:52 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-27 18:07:52 +0300
commit454c1448e30fe9d8cc2e6bc535921b2f7efd58e2 (patch)
treef3b7e3cf2da964ed5ffd3ebb093de5b7cc002077 /src/emap/script.c
parent828bececcd905903535b1e543a5b1dc1581c250d (diff)
downloadevol-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.
Diffstat (limited to 'src/emap/script.c')
-rw-r--r--src/emap/script.c39
1 files changed, 39 insertions, 0 deletions
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));