diff options
author | KirieZ <guilherme.menaldo@outlook.com> | 2017-02-27 00:36:17 -0300 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2017-07-11 12:46:15 +0200 |
commit | af099be50ad275c55bfb07831213f4540ae265d7 (patch) | |
tree | 156e787285e2a16e5214cce417c91af43438f74f | |
parent | eef92522dcf835f42a922a580be8f855cfea1aa6 (diff) | |
download | hercules-af099be50ad275c55bfb07831213f4540ae265d7.tar.gz hercules-af099be50ad275c55bfb07831213f4540ae265d7.tar.bz2 hercules-af099be50ad275c55bfb07831213f4540ae265d7.tar.xz hercules-af099be50ad275c55bfb07831213f4540ae265d7.zip |
Added time limit parameter to setquest
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | doc/script_commands.txt | 4 | ||||
-rw-r--r-- | src/map/quest.c | 21 | ||||
-rw-r--r-- | src/map/quest.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 10 |
4 files changed, 22 insertions, 15 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index d72d1d4b7..310af13cc 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -9152,9 +9152,11 @@ Example --------------------------------------- -*setquest(<ID>) +*setquest(<ID>{, <Time Limit>}) Place quest of <ID> in the users quest log, the state of which is "active". +If Time Limit is given, this quest will have its expire time set to <Time Limit>, an UNIX epoch time, +ignoring quest_db setting. If questinfo() is set, and the same ID is specified here, the icon will be cleared when the quest is set. diff --git a/src/map/quest.c b/src/map/quest.c index ed8e5bd33..4e3362adb 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -103,22 +103,23 @@ int quest_pc_login(struct map_session_data *sd) * * New quest will be added as Q_ACTIVE. * - * @param sd Player's data - * @param quest_id ID of the quest to add. + * @param sd Player's data + * @param quest_id ID of the quest to add. + * @param time_limit Custom time, in UNIX epoch, for this quest * @return 0 in case of success, nonzero otherwise */ -int quest_add(struct map_session_data *sd, int quest_id) +int quest_add(struct map_session_data *sd, int quest_id, unsigned int time_limit) { int n; struct quest_db *qi = quest->db(quest_id); nullpo_retr(-1, sd); - if( qi == &quest->dummy ) { + if (qi == &quest->dummy) { ShowError("quest_add: quest %d not found in DB.\n", quest_id); return -1; } - if( quest->check(sd, quest_id, HAVEQUEST) >= 0 ) { + if (quest->check(sd, quest_id, HAVEQUEST) >= 0) { ShowError("quest_add: Character %d already has quest %d.\n", sd->status.char_id, quest_id); return -1; } @@ -130,7 +131,7 @@ int quest_add(struct map_session_data *sd, int quest_id) sd->avail_quests++; RECREATE(sd->quest_log, struct quest, sd->num_quests); - if( sd->avail_quests != sd->num_quests ) { + if (sd->avail_quests != sd->num_quests) { // The character has some completed quests, make room before them so that they will stay at the end of the array memmove(&sd->quest_log[n+1], &sd->quest_log[n], sizeof(struct quest)*(sd->num_quests-sd->avail_quests)); } @@ -138,7 +139,9 @@ int quest_add(struct map_session_data *sd, int quest_id) memset(&sd->quest_log[n], 0, sizeof(struct quest)); sd->quest_log[n].quest_id = qi->id; - if( qi->time ) + if (time_limit != 0) + sd->quest_log[n].time = time_limit; + else if (qi->time != 0) sd->quest_log[n].time = (unsigned int)(time(NULL) + qi->time); sd->quest_log[n].state = Q_ACTIVE; @@ -147,8 +150,8 @@ int quest_add(struct map_session_data *sd, int quest_id) clif->quest_add(sd, &sd->quest_log[n]); clif->quest_update_objective(sd, &sd->quest_log[n]); - if( map->save_settings&64 ) - chrif->save(sd,0); + if ((map->save_settings & 64) != 0) + chrif->save(sd, 0); return 0; } diff --git a/src/map/quest.h b/src/map/quest.h index 8837a1fb6..dda7c2c0a 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -69,7 +69,7 @@ struct quest_interface { /* */ struct quest_db *(*db) (int quest_id); int (*pc_login) (struct map_session_data *sd); - int (*add) (struct map_session_data *sd, int quest_id); + int (*add) (struct map_session_data *sd, int quest_id, unsigned int time_limit); int (*change) (struct map_session_data *sd, int qid1, int qid2); int (*delete) (struct map_session_data *sd, int quest_id); int (*update_objective_sub) (struct block_list *bl, va_list ap); diff --git a/src/map/script.c b/src/map/script.c index d85438903..85480d3bd 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -20336,19 +20336,21 @@ BUILDIN(setquest) { unsigned short i; int quest_id; + unsigned int time_limit; struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; quest_id = script_getnum(st, 2); + time_limit = script_hasdata(st, 3) ? script_getnum(st, 3) : 0; - quest->add(sd, quest_id); + quest->add(sd, quest_id, time_limit); // If questinfo is set, remove quest bubble once quest is set. - for(i = 0; i < map->list[sd->bl.m].qi_count; i++) { + for (i = 0; i < map->list[sd->bl.m].qi_count; i++) { struct questinfo *qi = &map->list[sd->bl.m].qi_data[i]; - if( qi->quest_id == quest_id ) { + if (qi->quest_id == quest_id) { #if PACKETVER >= 20120410 clif->quest_show_event(sd, &qi->nd->bl, 9999, 0); #else @@ -23918,7 +23920,7 @@ void script_parse_builtin(void) { //Quest Log System [Inkfish] BUILDIN_DEF(questinfo, "ii??"), - BUILDIN_DEF(setquest, "i"), + BUILDIN_DEF(setquest, "i?"), BUILDIN_DEF(erasequest, "i?"), BUILDIN_DEF(completequest, "i?"), BUILDIN_DEF(questprogress, "i?"), |