Jump to content

[Feature] [7934] support ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA


Recommended Posts

Posted

What features does the patch add?

support ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA

For which repository revision was the patch created?

master [7723]

Is there a thread in the bug report section or at lighthouse?

None I know

Who has been writing this patch?

Myself

src/game/AchievementMgr.cpp |   25 ++++++++++++++++++++++++-
src/game/BattleGround.cpp   |   10 ++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp
index 03083a6..b42687a 100644
--- a/src/game/AchievementMgr.cpp
+++ b/src/game/AchievementMgr.cpp
@@ -279,6 +279,11 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin
                    achievementCriteria->healing_done.mapid == miscvalue2)
                    SetCriteriaProgress(achievementCriteria, 0, PROGRESS_SET);
                break;
+            case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA:  // have total statistic also not expected to be reset
+                // reset only the criteria having the miscvalue1 condition
+                if (achievementCriteria->win_rated_arena.flag == miscvalue1)
+                    SetCriteriaProgress(achievementCriteria, 0, PROGRESS_SET);
+                break;
            default:                                        // reset all cases
                break;
        }
@@ -867,6 +872,23 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                    continue;
                SetCriteriaProgress(achievementCriteria, GetPlayer()->GetItemCount(achievementCriteria->own_item.itemID, true));
                break;
+            case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA:
+                // miscvalue1 constains the personal rating
+                if (!miscvalue1) // no update at login
+                    continue;
+
+                // minimum rating requirement not in dbc
+                if (achievementCriteria->ID == 3384 && miscvalue1 < 1800
+                 || achievementCriteria->ID == 3385 && miscvalue1 < 2000
+                    )
+                {
+                    // reset the progress as we have a win without the requirement.
+                    SetCriteriaProgress(achievementCriteria, 0);
+                    continue;
+                }
+
+                SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
+                break;
            case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
                // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
                if(!miscvalue1)
@@ -1113,7 +1135,6 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
            case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA:
            case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA:
            case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL:
-            case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA:
            case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING:
            case ACHIEVEMENT_CRITERIA_TYPE_REACH_TEAM_RATING:
            case ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK:
@@ -1229,6 +1250,8 @@ bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achieve
            return progress->counter >= 1;
        case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
            return progress->counter >= achievementCriteria->own_item.itemCount;
+        case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA:
+            return progress->counter >= achievementCriteria->win_rated_arena.count;
        case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
            return progress->counter >= achievementCriteria->use_item.itemCount;
        case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 6ea83c0..f801820 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -697,9 +697,19 @@ void BattleGround::EndBattleGround(uint32 winner)
        if (isArena() && isRated() && winner_arena_team && loser_arena_team)
        {
            if (team == winner)
+            {
+                // update achievement BEFORE personal rating update
+                plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, winner_arena_team->GetMember(plr->GetGUID())->personal_rating);
+
                winner_arena_team->MemberWon(plr,loser_rating);
+            }
            else
+            {
                loser_arena_team->MemberLost(plr,winner_rating);
+
+                // Arena lost => reset the win_rated_arena having the "no_loose" condition
+                plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE);
+            }
        }

        if (team == winner)

  • 1 month later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use