From 62312d2e84339a4fe9f0e04434bbcbbd983dc6b0 Mon Sep 17 00:00:00 2001 From: Aleos Date: Fri, 2 Oct 2020 10:05:05 -0400 Subject: [PATCH] Fixes achievements and multi level up events (#5425) * Fixes #5413. * Fixes an issue where achievements that check for specific base/job level events don't get triggered if battle_config.multi_level_up is enabled. Thanks to @saya9200! Co-authored-by: Lemongrass3110 --- src/map/atcommand.cpp | 9 ++++++--- src/map/pc.cpp | 13 ++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 01aae437bc..38748e584e 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -1559,8 +1559,10 @@ ACMD_FUNC(baselevelup) status_calc_pc(sd, SCO_FORCE); status_percent_heal(&sd->bl, 100, 100); clif_misceffect(&sd->bl, 0); - achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.base_level); - achievement_update_objective(sd, AG_GOAL_STATUS, 2, sd->status.base_level, sd->status.class_); + for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) { + achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j); + achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_); + } clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised. } else { if (sd->status.base_level == 1) { @@ -1622,7 +1624,8 @@ ACMD_FUNC(joblevelup) sd->status.job_level += (unsigned int)level; sd->status.skill_point += level; clif_misceffect(&sd->bl, 1); - achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.job_level); + for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++) + achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i); clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised. } else { if (sd->status.job_level == 1) { diff --git a/src/map/pc.cpp b/src/map/pc.cpp index ec0a859847..4051273422 100755 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -7050,6 +7050,8 @@ int pc_checkbaselevelup(struct map_session_data *sd) { if (!next || sd->status.base_exp < next || pc_is_maxbaselv(sd)) return 0; + uint32 base_level = sd->status.base_level; + do { sd->status.base_exp -= next; //Kyoki pointed out that the max overcarry exp is the exp needed for the previous level -1. [Skotlex] @@ -7093,8 +7095,10 @@ int pc_checkbaselevelup(struct map_session_data *sd) { party_send_levelup(sd); pc_baselevelchanged(sd); - achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.base_level); - achievement_update_objective(sd, AG_GOAL_STATUS, 2, sd->status.base_level, sd->status.class_); + for (; base_level <= sd->status.base_level; base_level++) { + achievement_update_objective(sd, AG_GOAL_LEVEL, 1, base_level); + achievement_update_objective(sd, AG_GOAL_STATUS, 2, base_level, sd->status.class_); + } return 1; } @@ -7117,6 +7121,8 @@ int pc_checkjoblevelup(struct map_session_data *sd) if(!next || sd->status.job_exp < next || pc_is_maxjoblv(sd)) return 0; + uint32 job_level = sd->status.job_level; + do { sd->status.job_exp -= next; //Kyoki pointed out that the max overcarry exp is the exp needed for the previous level -1. [Skotlex] @@ -7142,7 +7148,8 @@ int pc_checkjoblevelup(struct map_session_data *sd) clif_status_change(&sd->bl, EFST_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL. npc_script_event(sd, NPCE_JOBLVUP); - achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.job_level); + for (; job_level <= sd->status.job_level; job_level++) + achievement_update_objective(sd, AG_GOAL_LEVEL, 1, job_level); pc_show_questinfo(sd); return 1;