summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/map.h8
-rw-r--r--src/map/quest.c17
-rw-r--r--src/map/script.c19
3 files changed, 29 insertions, 15 deletions
diff --git a/src/map/map.h b/src/map/map.h
index cf3a4e57c..d50666d4b 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -789,6 +789,12 @@ struct questinfo_qreq {
int state;
};
+struct questinfo_itemreq {
+ int nameid;
+ int min;
+ int max;
+};
+
struct questinfo {
struct npc_data *nd;
unsigned short icon;
@@ -805,7 +811,7 @@ struct questinfo {
int min;
int max;
} job_level;
- VECTOR_DECL(struct item) items;
+ VECTOR_DECL(struct questinfo_itemreq) items;
struct s_homunculus homunculus;
int homunculus_type;
VECTOR_DECL(struct questinfo_qreq) quest_requirement;
diff --git a/src/map/quest.c b/src/map/quest.c
index 8cde4538e..02bf7638b 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -805,18 +805,17 @@ static bool quest_questinfo_validate_joblevel(struct map_session_data *sd, struc
*/
static bool quest_questinfo_validate_items(struct map_session_data *sd, struct questinfo *qi)
{
- int i, idx;
-
nullpo_retr(false, sd);
nullpo_retr(false, qi);
-
- for (i = 0; i < VECTOR_LENGTH(qi->items); i++) {
- struct item *item = &VECTOR_INDEX(qi->items, i);
- idx = pc->search_inventory(sd, item->nameid);
- if (idx == INDEX_NOT_FOUND)
- return false;
- if (sd->status.inventory[idx].amount < item->amount)
+ for (int i = 0; i < VECTOR_LENGTH(qi->items); i++) {
+ struct questinfo_itemreq *item = &VECTOR_INDEX(qi->items, i);
+ int count = 0;
+ for (int j = 0; j < MAX_INVENTORY; j++) {
+ if (sd->status.inventory[j].nameid == item->nameid)
+ count += sd->status.inventory[j].amount;
+ }
+ if (count < item->min || count > item->max)
return false;
}
diff --git a/src/map/script.c b/src/map/script.c
index 65ffc1a6d..31930c2dc 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -21114,17 +21114,26 @@ static BUILDIN(setquestinfo)
}
case QINFO_ITEM:
{
- struct item item = { 0 };
+ struct questinfo_itemreq item = { 0 };
item.nameid = script_getnum(st, 3);
- item.amount = script_getnum(st, 4);
+ item.min = script_hasdata(st, 4) ? script_getnum(st, 4) : 0;
+ item.max = script_hasdata(st, 5) ? script_getnum(st, 5) : 0;
if (itemdb->exists(item.nameid) == NULL) {
ShowWarning("buildin_setquestinfo: non existing item (%d) have been given.\n", item.nameid);
return false;
}
- if (item.amount <= 0 || item.amount > MAX_AMOUNT) {
- ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than 0 and smaller than %d.\n", item.amount, MAX_AMOUNT + 1);
+ if (item.min > item.max) {
+ ShowWarning("buildin_setquestinfo: minimal amount (%d) is bigger than the maximal amount (%d).\n", item.min, item.max);
+ return false;
+ }
+ if (item.min < 0 || item.min > MAX_AMOUNT) {
+ ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than or equal to 0 and smaller than %d.\n", item.min, MAX_AMOUNT + 1);
+ return false;
+ }
+ if (item.max < 0 || item.max > MAX_AMOUNT) {
+ ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than or equal to 0 and smaller than %d.\n", item.max, MAX_AMOUNT + 1);
return false;
}
if (VECTOR_LENGTH(qi->items) == 0)
@@ -25447,7 +25456,7 @@ static void script_parse_builtin(void)
//Quest Log System [Inkfish]
BUILDIN_DEF(questinfo, "i?"),
- BUILDIN_DEF(setquestinfo, "i??"),
+ BUILDIN_DEF(setquestinfo, "i???"),
BUILDIN_DEF(setquest, "i?"),
BUILDIN_DEF(erasequest, "i?"),
BUILDIN_DEF(completequest, "i?"),