diff options
-rw-r--r-- | doc/script_commands.txt | 31 | ||||
-rw-r--r-- | src/map/script.c | 63 |
2 files changed, 88 insertions, 6 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 65caf5837..26ecbdd42 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8339,17 +8339,23 @@ If *questinfo is set, and the same ID is specified here, the icon will be cleare --------------------------------------- -*completequest <ID>; +*completequest <ID>{,<ID2>}; Change the state for the given quest <ID> to "complete" and remove from the users quest log. +If a second quest id of greater value is specified, all quests between the two +will be completed. + --------------------------------------- -*erasequest <ID>; +*erasequest <ID>{,<ID2>}; Remove the quest of the given <ID> from the user's quest log. +If a second quest id of greater value is specified, all quests between the two +will be erased. + --------------------------------------- *changequest <ID>,<ID2>; @@ -8361,6 +8367,8 @@ Add quest of the <ID2> to the the quest log, and the state is "active". *checkquest(<ID>{,PLAYTIME|HUNTING}) +DEPRECATED - use questprogress instead. + If no additional argument supplied, return the state of the quest: -1 = Quest not started (not in quest log) 0 = Quest has been given, but the state is "inactive" @@ -8384,6 +8392,25 @@ If parameter "HUNTING" is supplied: --------------------------------------- +*questprogress(<ID>{,PLAYTIME|HUNTING}) + +If no additional argument supplied, return the state of the quest: + 0 = Quest not started (not in quest log) + 1 = Quest has been given + 2 = Quest completed + +If parameter 'PLAYTIME' is supplied: + 0 = Quest not started (not in quest log) + 1 = The time limit has not yet been reached + 2 = The time limit has been reached + +If parameter 'HUNTING' is supplied: + 0 = Quest not started (not in quest log) + 1 = Player hasn't killed all of the target monsters + 2 = Player has killed all of the target monsters + +--------------------------------------- + *showevent <icon>{,<mark color>} Show an emotion on top of a NPC, and optionally, diff --git a/src/map/script.c b/src/map/script.c index 1b6e10930..c88e2851f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -16304,21 +16304,45 @@ BUILDIN(setquest) { BUILDIN(erasequest) { struct map_session_data *sd = script->rid2sd(st); + int quest_id; if( sd == NULL ) return false; - quest->delete(sd, script_getnum(st, 2)); + if (script_hasdata(st, 3)) { + if (script_getnum(st, 3) < script_getnum(st, 2)) { + ShowError("buildin_erasequest: The second quest id must be greater than the id of the first.\n"); + return false; + } + for (quest_id = script_getnum(st, 2); quest_id < script_getnum(st, 3); quest_id++) { + quest->delete(sd, quest_id); + } + } else { + quest->delete(sd, script_getnum(st, 2)); + } + return true; } BUILDIN(completequest) { struct map_session_data *sd = script->rid2sd(st); + int quest_id; if( sd == NULL ) return false; - quest->update_status(sd, script_getnum(st, 2), Q_COMPLETE); + if (script_hasdata(st, 3)) { + if (script_getnum(st, 3) < script_getnum(st, 2)) { + ShowError("buildin_completequest: The second quest id must be greater than the id of the first.\n"); + return false; + } + for (quest_id = script_getnum(st, 2); quest_id < script_getnum(st, 3); quest_id++) { + quest->update_status(sd, quest_id, Q_COMPLETE); + } + } else { + quest->update_status(sd, script_getnum(st, 2), Q_COMPLETE); + } + return true; } @@ -16332,6 +16356,8 @@ BUILDIN(changequest) { return true; } +// Deprecated +// Please use questprogress instead. BUILDIN(checkquest) { struct map_session_data *sd = script->rid2sd(st); enum quest_check_type type = HAVEQUEST; @@ -16347,6 +16373,33 @@ BUILDIN(checkquest) { return true; } +BUILDIN(questprogress) { + struct map_session_data *sd = script->rid2sd(st); + enum quest_check_type type = HAVEQUEST; + int quest_progress = 0; + + if (sd == NULL) + return false; + + if (script_hasdata(st, 3)) + type = (enum quest_check_type)script_getnum(st, 3); + + quest_progress = quest->check(sd, script_getnum(st, 2), type); + + // "Fix" returned quest state value to make more sense. + // 0 = Not Started, 1 = In Progress, 2 = Completed. + if (quest_progress == -1) // Not found + quest_progress = 0; + else if (quest_progress == 0 || quest_progress == 1) + quest_progress = 1; + else + quest_progress = 2; + + script_pushint(st, quest_progress); + + return true; +} + BUILDIN(showevent) { TBL_PC *sd = script->rid2sd(st); struct npc_data *nd = map->id2nd(st->oid); @@ -17327,6 +17380,7 @@ BUILDIN(setmounting) { } return true; } + /** * Retrieves quantity of arguments provided to callfunc/callsub. * getargcount() -> amount of arguments received in a function @@ -19265,9 +19319,10 @@ void script_parse_builtin(void) { //Quest Log System [Inkfish] BUILDIN_DEF(questinfo, "ii??"), BUILDIN_DEF(setquest, "i"), - BUILDIN_DEF(erasequest, "i"), - BUILDIN_DEF(completequest, "i"), + BUILDIN_DEF(erasequest, "i?"), + BUILDIN_DEF(completequest, "i?"), BUILDIN_DEF(checkquest, "i?"), + BUILDIN_DEF(questprogress, "i?"), BUILDIN_DEF(changequest, "ii"), BUILDIN_DEF(showevent, "i?"), |