summaryrefslogtreecommitdiff
path: root/src/map/script.c
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 /src/map/script.c
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.
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c45
1 files changed, 45 insertions, 0 deletions
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;
+}