summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-19 18:00:54 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-19 18:00:54 +0300
commitd38a0b63bd821e043435b852a7dea9ad0f89262e (patch)
treec6abb9c92424800c62b037b9a4a760a71b978832
parent7966264fdf4271c8b247d572c2eadef88dcaf4b4 (diff)
downloadevol-hercules-d38a0b63bd821e043435b852a7dea9ad0f89262e.tar.gz
evol-hercules-d38a0b63bd821e043435b852a7dea9ad0f89262e.tar.bz2
evol-hercules-d38a0b63bd821e043435b852a7dea9ad0f89262e.tar.xz
evol-hercules-d38a0b63bd821e043435b852a7dea9ad0f89262e.zip
Impliment script commands setq and getq.
-rw-r--r--src/map/init.c4
-rw-r--r--src/map/script.c45
-rw-r--r--src/map/script.h2
-rw-r--r--src/map/scriptdefines.h10
4 files changed, 58 insertions, 3 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 795a331..dbce79c 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -109,8 +109,8 @@ HPExport void plugin_init (void)
addScriptCommandDeprecated("getlang", "", getLang);
addScriptCommandDeprecated("setlang", "i", setLang);
addScriptCommand("requestlang", "v", requestLang);
- addScriptCommand("getq", "i", dummyInt);
- addScriptCommand("setq", "ii", dummy);
+ addScriptCommand("getq", "i", getq);
+ addScriptCommand("setq", "ii", setq);
addScriptCommand("getnpcdir", "*", dummyInt);
addScriptCommand("setnpcdir", "*", dummy);
addScriptCommand("rif", "is*", dummyStr);
diff --git a/src/map/script.c b/src/map/script.c
index 088f1d3..80e43c2 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -14,6 +14,7 @@
#include "../../../map/npc.h"
#include "../../../map/pc.h"
#include "../../../map/script.h"
+#include "../../../map/quest.h"
#include "map/script.h"
#include "map/scriptdefines.h"
@@ -249,3 +250,47 @@ BUILDIN(requestLang)
return true;
}
+BUILDIN(setq)
+{
+ int i;
+ getSD();
+
+ int quest_id = script_getnum(st, 2);
+ int quest_value = script_getnum(st, 3);
+
+ if (quest->check(sd, quest_id, HAVEQUEST) < 0)
+ quest->add(sd, quest_id);
+ ARR_FIND(0, sd->num_quests, i, sd->quest_log[i].quest_id == quest_id);
+ if (i == sd->num_quests)
+ {
+ ShowError("Quest with id=%d not found\n", quest_id);
+ return false;
+ }
+
+ sd->quest_log[i].count[0] = quest_value;
+ sd->save_quest = true;
+ clif->quest_update_objective(sd, &sd->quest_log[i]);
+ return true;
+}
+
+BUILDIN(getq)
+{
+ int i;
+ getSDReturn(0);
+
+ int quest_id = script_getnum(st, 2);
+ if (!quest->check(sd, quest_id, HAVEQUEST) < 0)
+ {
+ script_pushint(st, 0);
+ return true;
+ }
+ ARR_FIND(0, sd->num_quests, i, sd->quest_log[i].quest_id == quest_id);
+ if (i == sd->num_quests)
+ {
+ ShowError("Quest with id=%d not found\n", quest_id);
+ script_pushint(st, 0);
+ return false;
+ }
+ script_pushint(st, sd->quest_log[i].count[0]);
+ return true;
+}
diff --git a/src/map/script.h b/src/map/script.h
index 55104dc..79fcdc4 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -15,5 +15,7 @@ BUILDIN(closeDialog);
BUILDIN(shop);
BUILDIN(getItemLink);
BUILDIN(requestLang);
+BUILDIN(getq);
+BUILDIN(setq);
#endif // EVOL_MAP_SCRIPT
diff --git a/src/map/scriptdefines.h b/src/map/scriptdefines.h
index 56f32b6..7d2b115 100644
--- a/src/map/scriptdefines.h
+++ b/src/map/scriptdefines.h
@@ -29,6 +29,14 @@
#define getSD() \
TBL_PC *sd = script->rid2sd(st); \
if (!sd) \
- return 1
+ return true
+
+#define getSDReturn(def) \
+ TBL_PC *sd = script->rid2sd(st); \
+ if (!sd) \
+ { \
+ script_pushint(st, def); \
+ return true; \
+ }
#endif // EVOL_MAP_SCRIPTDEFINES