AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AchievementMgr Class Reference

#include "AchievementMgr.h"

Public Member Functions

 AchievementMgr (Player *player)
 
 ~AchievementMgr ()
 
void Reset ()
 
void LoadFromDB (PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult)
 
void SaveToDB (CharacterDatabaseTransaction trans)
 
void ResetAchievementCriteria (AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete=false)
 
void UpdateAchievementCriteria (AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
 
void CompletedAchievement (AchievementEntry const *entry)
 
void CheckAllAchievementCriteria ()
 
void SendAllAchievementData () const
 
void SendRespondInspectAchievements (Player *player) const
 
bool HasAchieved (uint32 achievementId) const
 
PlayerGetPlayer () const
 
void UpdateTimedAchievements (uint32 timeDiff)
 
void StartTimedAchievement (AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost=0)
 
void RemoveTimedAchievement (AchievementCriteriaTimedTypes type, uint32 entry)
 
void RemoveCriteriaProgress (AchievementCriteriaEntry const *entry)
 
CriteriaProgressGetCriteriaProgress (AchievementCriteriaEntry const *entry)
 
CompletedAchievementMap const & GetCompletedAchievements ()
 

Static Public Member Functions

static void DeleteFromDB (ObjectGuid::LowType lowguid)
 

Private Types

enum  ProgressType {
  PROGRESS_SET ,
  PROGRESS_ACCUMULATE ,
  PROGRESS_HIGHEST ,
  PROGRESS_RESET
}
 
typedef std::map< uint32, uint32TimedAchievementMap
 

Private Member Functions

void SendAchievementEarned (AchievementEntry const *achievement) const
 
void SendCriteriaUpdate (AchievementCriteriaEntry const *entry, CriteriaProgress const *progress, uint32 timeElapsed, bool timedCompleted) const
 
void SetCriteriaProgress (AchievementCriteriaEntry const *entry, uint32 changeValue, ProgressType ptype=PROGRESS_SET)
 
void CompletedCriteriaFor (AchievementEntry const *achievement)
 
bool IsCompletedCriteria (AchievementCriteriaEntry const *achievementCriteria, AchievementEntry const *achievement)
 
bool IsCompletedAchievement (AchievementEntry const *entry)
 
bool CanUpdateCriteria (AchievementCriteriaEntry const *criteria, AchievementEntry const *achievement)
 
void BuildAllDataPacket (WorldPacket *data) const
 

Private Attributes

Player_player
 
CriteriaProgressMap _criteriaProgress
 
CompletedAchievementMap _completedAchievements
 
TimedAchievementMap _timedAchievements
 

Detailed Description

Member Typedef Documentation

◆ TimedAchievementMap

Member Enumeration Documentation

◆ ProgressType

Enumerator
PROGRESS_SET 
PROGRESS_ACCUMULATE 
PROGRESS_HIGHEST 
PROGRESS_RESET 
@ PROGRESS_SET
Definition: AchievementMgr.h:306
@ PROGRESS_HIGHEST
Definition: AchievementMgr.h:306
@ PROGRESS_ACCUMULATE
Definition: AchievementMgr.h:306
@ PROGRESS_RESET
Definition: AchievementMgr.h:306

Constructor & Destructor Documentation

◆ AchievementMgr()

AchievementMgr::AchievementMgr ( Player player)
482{
483 _player = player;
484}
Player * _player
Definition: AchievementMgr.h:316

References _player.

◆ ~AchievementMgr()

AchievementMgr::~AchievementMgr ( )
487{
488}

Member Function Documentation

◆ BuildAllDataPacket()

void AchievementMgr::BuildAllDataPacket ( WorldPacket data) const
private

used by SMSG_RESPOND_INSPECT_ACHIEVEMENT and SMSG_ALL_ACHIEVEMENT_DATA

Todo:
: This should be 1 if it is a failed timed criteria
2358{
2359 for (CompletedAchievementMap::const_iterator iter = _completedAchievements.begin(); iter != _completedAchievements.end(); ++iter)
2360 {
2361 // Skip hidden achievements
2362 AchievementEntry const* achievement = sAchievementStore.LookupEntry(iter->first);
2363 if (!achievement || achievement->flags & ACHIEVEMENT_FLAG_HIDDEN)
2364 continue;
2365
2366 *data << uint32(iter->first);
2367 data->AppendPackedTime(iter->second.date);
2368 }
2369
2370 *data << int32(-1);
2371 time_t now = GameTime::GetGameTime().count();
2372
2373 for (CriteriaProgressMap::const_iterator iter = _criteriaProgress.begin(); iter != _criteriaProgress.end(); ++iter)
2374 {
2375 *data << uint32(iter->first);
2376 data->appendPackGUID(iter->second.counter);
2377 *data << GetPlayer()->GetPackGUID();
2378 *data << uint32(0);
2379 data->AppendPackedTime(iter->second.date);
2380 *data << uint32(now - iter->second.date);
2381
2382 if (sAchievementMgr->IsAverageCriteria(sAchievementCriteriaStore.LookupEntry(iter->first)))
2383 *data << uint32(now - GetPlayer()->GetCreationTime().count()); // for average achievements
2384 else
2385 *data << uint32(now - iter->second.date);
2386 }
2387
2388 *data << int32(-1);
2389}
std::int32_t int32
Definition: Define.h:104
std::uint32_t uint32
Definition: Define.h:108
#define sAchievementMgr
Definition: AchievementMgr.h:423
DBCStorage< AchievementCriteriaEntry > sAchievementCriteriaStore(AchievementCriteriafmt)
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
@ ACHIEVEMENT_FLAG_HIDDEN
Definition: DBCEnums.h:80
Seconds GetGameTime()
Definition: GameTime.cpp:38
Player * GetPlayer() const
Definition: AchievementMgr.h:296
CompletedAchievementMap _completedAchievements
Definition: AchievementMgr.h:318
CriteriaProgressMap _criteriaProgress
Definition: AchievementMgr.h:317
PackedGuid const & GetPackGUID() const
Definition: Object.h:108
Definition: DBCStructure.h:40
uint32 flags
Definition: DBCStructure.h:52
void appendPackGUID(uint64 guid)
Definition: ByteBuffer.h:503
void AppendPackedTime(time_t time)
Definition: ByteBuffer.cpp:137

References _completedAchievements, _criteriaProgress, ACHIEVEMENT_FLAG_HIDDEN, ByteBuffer::AppendPackedTime(), ByteBuffer::appendPackGUID(), AchievementEntry::flags, GameTime::GetGameTime(), Object::GetPackGUID(), GetPlayer(), sAchievementCriteriaStore, sAchievementMgr, and sAchievementStore.

Referenced by SendAllAchievementData(), and SendRespondInspectAchievements().

◆ CanUpdateCriteria()

bool AchievementMgr::CanUpdateCriteria ( AchievementCriteriaEntry const *  criteria,
AchievementEntry const *  achievement 
)
private
2397{
2399 return false;
2400
2401 if (achievement->mapID != -1 && GetPlayer()->GetMapId() != uint32(achievement->mapID))
2402 return false;
2403
2404 if ((achievement->requiredFaction == ACHIEVEMENT_FACTION_HORDE && GetPlayer()->GetTeamId(true) != TEAM_HORDE) ||
2405 (achievement->requiredFaction == ACHIEVEMENT_FACTION_ALLIANCE && GetPlayer()->GetTeamId(true) != TEAM_ALLIANCE))
2406 return false;
2407
2408 for (uint32 i = 0; i < MAX_CRITERIA_REQUIREMENTS; ++i)
2409 {
2410 if (!criteria->additionalRequirements[i].additionalRequirement_type)
2411 continue;
2412
2413 switch (criteria->additionalRequirements[i].additionalRequirement_type)
2414 {
2416 if (GetPlayer()->GetMapId() != criteria->additionalRequirements[i].additionalRequirement_value)
2417 return false;
2418 break;
2420 if (GetPlayer()->GetGroup())
2421 return false;
2422 break;
2423 default:
2424 break;
2425 }
2426 }
2427
2428 // don't update already completed criteria
2429 if (IsCompletedCriteria(criteria, achievement))
2430 return false;
2431
2432 return true;
2433}
@ DISABLE_TYPE_ACHIEVEMENT_CRITERIA
Definition: DisableMgr.h:33
@ ACHIEVEMENT_FACTION_HORDE
Definition: DBCEnums.h:72
@ ACHIEVEMENT_FACTION_ALLIANCE
Definition: DBCEnums.h:73
@ ACHIEVEMENT_CRITERIA_CONDITION_NOT_IN_GROUP
Definition: DBCEnums.h:101
@ ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP
Definition: DBCEnums.h:98
#define MAX_CRITERIA_REQUIREMENTS
Definition: DBCEnums.h:91
TeamId GetTeamId(PvPTeamId teamId)
Definition: SharedDefines.h:3462
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:306
bool IsCompletedCriteria(AchievementCriteriaEntry const *achievementCriteria, AchievementEntry const *achievement)
Definition: AchievementMgr.cpp:1796

References ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, ACHIEVEMENT_CRITERIA_CONDITION_NOT_IN_GROUP, ACHIEVEMENT_FACTION_ALLIANCE, ACHIEVEMENT_FACTION_HORDE, AchievementCriteriaEntry::additionalRequirement_type, AchievementCriteriaEntry::additionalRequirement_value, AchievementCriteriaEntry::additionalRequirements, DISABLE_TYPE_ACHIEVEMENT_CRITERIA, GetPlayer(), GetTeamId(), AchievementCriteriaEntry::ID, IsCompletedCriteria(), DisableMgr::IsDisabledFor(), AchievementEntry::mapID, MAX_CRITERIA_REQUIREMENTS, AchievementEntry::requiredFaction, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by UpdateAchievementCriteria().

◆ CheckAllAchievementCriteria()

void AchievementMgr::CheckAllAchievementCriteria ( )

called at player login. The player might have fulfilled some achievements when the achievement system wasn't working yet.

774{
775 // suppress sending packets
776 for (uint32 i = 0; i < ACHIEVEMENT_CRITERIA_TYPE_TOTAL; ++i)
778}
AchievementCriteriaTypes
Definition: DBCEnums.h:129
@ ACHIEVEMENT_CRITERIA_TYPE_TOTAL
Definition: DBCEnums.h:232
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition: AchievementMgr.cpp:795

References ACHIEVEMENT_CRITERIA_TYPE_TOTAL, and UpdateAchievementCriteria().

Referenced by Player::CheckAllAchievementCriteria(), and Reset().

◆ CompletedAchievement()

void AchievementMgr::CompletedAchievement ( AchievementEntry const *  entry)

Currently there's only one achievement that deals with gender-specific titles. Since no common attributes were found, (not even in titleRewardFlags field) we explicitly check by ID. Maybe in the future we could move the achievement_reward condition fields to the condition system.

2228{
2229 // disable for gamemasters with GM-mode enabled
2230 if (_player->IsGameMaster())
2231 {
2232 LOG_INFO("achievement", "Not available in GM mode.");
2233 ChatHandler(_player->GetSession()).PSendSysMessage("Not available in GM mode");
2234 return;
2235 }
2236
2237 if (!sScriptMgr->OnBeforeAchievementComplete(GetPlayer(), achievement))
2238 {
2239 return;
2240 }
2241
2242 if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || HasAchieved(achievement->ID))
2243 return;
2244
2245 LOG_DEBUG("achievement", "AchievementMgr::CompletedAchievement({})", achievement->ID);
2246
2247 SendAchievementEarned(achievement);
2248 CompletedAchievementData& ca = _completedAchievements[achievement->ID];
2249 ca.date = GameTime::GetGameTime().count();
2250 ca.changed = true;
2251
2252 sScriptMgr->OnAchievementComplete(GetPlayer(), achievement);
2253
2254 // pussywizard: set all progress counters to 0, so progress will be deleted from db during save
2255 {
2256 bool allRefsCompleted = true;
2257 uint32 achiCheckId = achievement->refAchievement ? achievement->refAchievement : achievement->ID;
2258
2259 if (AchievementEntryList const* achRefList = sAchievementMgr->GetAchievementByReferencedId(achiCheckId))
2260 for (AchievementEntryList::const_iterator itr = achRefList->begin(); itr != achRefList->end(); ++itr)
2261 if (!IsCompletedAchievement(*itr))
2262 {
2263 allRefsCompleted = false;
2264 break;
2265 }
2266
2267 if (allRefsCompleted)
2268 if (AchievementCriteriaEntryList const* cList = sAchievementMgr->GetAchievementCriteriaByAchievement(achiCheckId))
2269 for (AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
2270 if (CriteriaProgress* progress = GetCriteriaProgress(*itr))
2271 {
2272 progress->changed = true;
2273 progress->counter = 0;
2274 }
2275 }
2276
2278 sAchievementMgr->SetRealmCompleted(achievement);
2279
2282
2283 // reward items and titles if any
2284 AchievementReward const* reward = sAchievementMgr->GetAchievementReward(achievement);
2285
2286 // no rewards
2287 if (!reward)
2288 return;
2289
2290 // titles
2295 if (uint32 titleId = reward->titleId[achievement->ID == 1793 ? GetPlayer()->getGender() : uint8(GetPlayer()->GetTeamId())])
2296 if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId))
2297 GetPlayer()->SetTitle(titleEntry);
2298
2299 // mail
2300 if (reward->sender)
2301 {
2302 MailDraft draft(reward->mailTemplate);
2303
2304 if (!reward->mailTemplate)
2305 {
2306 std::string subject = reward->subject;
2307 std::string text = reward->text;
2308
2310 if (localeConstant != LOCALE_enUS)
2311 {
2312 if(AchievementRewardLocale const* loc = sAchievementMgr->GetAchievementRewardLocale(achievement))
2313 {
2314 ObjectMgr::GetLocaleString(loc->Subject, localeConstant, subject);
2315 ObjectMgr::GetLocaleString(loc->Text, localeConstant, text);
2316 }
2317 }
2318
2319 draft = MailDraft(subject, text);
2320 }
2321
2322 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2323
2324 Item* item = reward->itemId ? Item::CreateItem(reward->itemId, 1, GetPlayer()) : nullptr;
2325 if (item)
2326 {
2327 // save new item before send
2328 item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
2329
2330 // item
2331 draft.AddItem(item);
2332 }
2333
2334 draft.SendMailTo(trans, GetPlayer(), MailSender(MAIL_CREATURE, reward->sender));
2335 CharacterDatabase.CommitTransaction(trans);
2336 }
2337}
LocaleConstant
Definition: Common.h:67
@ LOCALE_enUS
Definition: Common.h:68
std::uint8_t uint8
Definition: Define.h:110
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
std::list< AchievementCriteriaEntry const * > AchievementCriteriaEntryList
Definition: AchievementMgr.h:30
std::list< AchievementEntry const * > AchievementEntryList
Definition: AchievementMgr.h:31
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
@ MAIL_CREATURE
Definition: Mail.h:40
#define sScriptMgr
Definition: ScriptMgr.h:698
@ ACHIEVEMENT_FLAG_COUNTER
Definition: DBCEnums.h:79
@ ACHIEVEMENT_FLAG_REALM_FIRST_REACH
Definition: DBCEnums.h:87
@ ACHIEVEMENT_FLAG_REALM_FIRST_KILL
Definition: DBCEnums.h:88
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT
Definition: DBCEnums.h:134
@ ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS
Definition: DBCEnums.h:229
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:276
Definition: AchievementMgr.h:37
Definition: AchievementMgr.h:247
std::string subject
Definition: AchievementMgr.h:251
std::string text
Definition: AchievementMgr.h:252
uint32 titleId[2]
Definition: AchievementMgr.h:248
uint32 sender
Definition: AchievementMgr.h:250
uint32 mailTemplate
Definition: AchievementMgr.h:253
uint32 itemId
Definition: AchievementMgr.h:249
Definition: AchievementMgr.h:259
Definition: AchievementMgr.h:267
time_t date
Definition: AchievementMgr.h:268
bool changed
Definition: AchievementMgr.h:269
CriteriaProgress * GetCriteriaProgress(AchievementCriteriaEntry const *entry)
Definition: AchievementMgr.cpp:2062
bool HasAchieved(uint32 achievementId) const
Definition: AchievementMgr.cpp:2391
bool IsCompletedAchievement(AchievementEntry const *entry)
Definition: AchievementMgr.cpp:2000
void SendAchievementEarned(AchievementEntry const *achievement) const
Definition: AchievementMgr.cpp:674
Definition: Chat.h:38
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
Definition: Item.h:214
static Item * CreateItem(uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
Definition: Item.cpp:1088
virtual void SaveToDB(CharacterDatabaseTransaction trans)
Definition: Item.cpp:337
WorldSession * GetSession() const
Definition: Player.h:1961
bool IsGameMaster() const
Definition: Player.h:1148
void SetTitle(CharTitlesEntry const *title, bool lost=false)
Definition: Player.cpp:13251
static std::string_view GetLocaleString(std::vector< std::string > const &data, size_t locale)
Definition: ObjectMgr.h:1416
Definition: Mail.h:84
Definition: Mail.h:120
AccountTypes GetSecurity() const
Definition: WorldSession.h:361
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:500
Definition: DBCStructure.h:632

References _completedAchievements, _player, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS, ACHIEVEMENT_FLAG_COUNTER, ACHIEVEMENT_FLAG_REALM_FIRST_KILL, ACHIEVEMENT_FLAG_REALM_FIRST_REACH, MailDraft::AddItem(), CompletedAchievementData::changed, CharacterDatabase, Item::CreateItem(), CompletedAchievementData::date, AchievementEntry::flags, GetCriteriaProgress(), GameTime::GetGameTime(), ObjectMgr::GetLocaleString(), GetPlayer(), WorldSession::GetSecurity(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), GetTeamId(), HasAchieved(), AchievementEntry::ID, IsCompletedAchievement(), Player::IsGameMaster(), AccountMgr::IsPlayerAccount(), AchievementReward::itemId, LOCALE_enUS, LOG_DEBUG, LOG_INFO, MAIL_CREATURE, AchievementReward::mailTemplate, AchievementEntry::points, ChatHandler::PSendSysMessage(), AchievementEntry::refAchievement, sAchievementMgr, Item::SaveToDB(), sCharTitlesStore, SendAchievementEarned(), AchievementReward::sender, MailDraft::SendMailTo(), Player::SetTitle(), sScriptMgr, AchievementReward::subject, AchievementReward::text, AchievementReward::titleId, and UpdateAchievementCriteria().

Referenced by Player::CompletedAchievement(), CompletedCriteriaFor(), and UpdateAchievementCriteria().

◆ CompletedCriteriaFor()

void AchievementMgr::CompletedCriteriaFor ( AchievementEntry const *  achievement)
private
1987{
1988 // counter can never complete
1989 if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER)
1990 return;
1991
1992 // already completed and stored
1993 if (HasAchieved(achievement->ID))
1994 return;
1995
1996 if (IsCompletedAchievement(achievement))
1997 CompletedAchievement(achievement);
1998}
void CompletedAchievement(AchievementEntry const *entry)
Definition: AchievementMgr.cpp:2227

References ACHIEVEMENT_FLAG_COUNTER, CompletedAchievement(), AchievementEntry::flags, HasAchieved(), AchievementEntry::ID, and IsCompletedAchievement().

Referenced by UpdateAchievementCriteria().

◆ DeleteFromDB()

void AchievementMgr::DeleteFromDB ( ObjectGuid::LowType  lowguid)
static
542{
543 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
544
546 stmt->SetData(0, lowguid);
547 trans->Append(stmt);
548
549 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS);
550 stmt->SetData(0, lowguid);
551 trans->Append(stmt);
552
553 CharacterDatabase.CommitTransaction(trans);
554}
@ CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS
Definition: CharacterDatabase.h:364
@ CHAR_DEL_CHAR_ACHIEVEMENT
Definition: CharacterDatabase.h:363
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78

References CHAR_DEL_CHAR_ACHIEVEMENT, CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS, CharacterDatabase, and PreparedStatementBase::SetData().

Referenced by reset_commandscript::HandleResetAchievementsCommand(), and Reset().

◆ GetCompletedAchievements()

CompletedAchievementMap const & AchievementMgr::GetCompletedAchievements ( )
2436{
2438}

References _completedAchievements.

◆ GetCriteriaProgress()

CriteriaProgress * AchievementMgr::GetCriteriaProgress ( AchievementCriteriaEntry const *  entry)
2063{
2064 CriteriaProgressMap::iterator iter = _criteriaProgress.find(entry->ID);
2065
2066 if (iter == _criteriaProgress.end())
2067 return nullptr;
2068
2069 return &(iter->second);
2070}

References _criteriaProgress, and AchievementCriteriaEntry::ID.

Referenced by CompletedAchievement(), IsCompletedAchievement(), IsCompletedCriteria(), SetCriteriaProgress(), and UpdateAchievementCriteria().

◆ GetPlayer()

◆ HasAchieved()

bool AchievementMgr::HasAchieved ( uint32  achievementId) const

◆ IsCompletedAchievement()

bool AchievementMgr::IsCompletedAchievement ( AchievementEntry const *  entry)
private
2001{
2002 // counter can never complete
2003 if (entry->flags & ACHIEVEMENT_FLAG_COUNTER)
2004 return false;
2005
2006 // for achievement with referenced achievement criterias get from referenced and counter from self
2007 uint32 achievmentForTestId = entry->refAchievement ? entry->refAchievement : entry->ID;
2008 uint32 achievmentForTestCount = entry->count;
2009
2010 AchievementCriteriaEntryList const* cList = sAchievementMgr->GetAchievementCriteriaByAchievement(achievmentForTestId);
2011 if (!cList)
2012 return false;
2013 uint32 count = 0;
2014
2015 // For SUMM achievements, we have to count the progress of each criteria of the achievement.
2016 // Oddly, the target count is NOT countained in the achievement, but in each individual criteria
2017 if (entry->flags & ACHIEVEMENT_FLAG_SUMM)
2018 {
2019 for (AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
2020 {
2021 AchievementCriteriaEntry const* criteria = *itr;
2022
2023 CriteriaProgress const* progress = GetCriteriaProgress(criteria);
2024 if (!progress)
2025 continue;
2026
2027 count += progress->counter;
2028
2029 // for counters, field4 contains the main count requirement
2030 if (count >= criteria->raw.count)
2031 return true;
2032 }
2033 return false;
2034 }
2035
2036 // Default case - need complete all or
2037 bool completed_all = true;
2038 for (AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
2039 {
2040 AchievementCriteriaEntry const* criteria = *itr;
2041
2042 bool completed = IsCompletedCriteria(criteria, entry);
2043
2044 // found an uncompleted criteria, but DONT return false yet - there might be a completed criteria with ACHIEVEMENT_CRITERIA_COMPLETE_FLAG_ALL
2045 if (completed)
2046 ++count;
2047 else
2048 completed_all = false;
2049
2050 // completed as have req. count of completed criterias
2051 if (achievmentForTestCount > 0 && achievmentForTestCount <= count)
2052 return true;
2053 }
2054
2055 // all criterias completed requirement
2056 if (completed_all && achievmentForTestCount == 0)
2057 return true;
2058
2059 return false;
2060}
@ ACHIEVEMENT_FLAG_SUMM
Definition: DBCEnums.h:82
uint32 counter
Definition: AchievementMgr.h:38
Definition: DBCStructure.h:70
uint32 count
Definition: DBCStructure.h:223
struct AchievementCriteriaEntry::@301::@365 raw

References ACHIEVEMENT_FLAG_COUNTER, ACHIEVEMENT_FLAG_SUMM, AchievementEntry::count, AchievementCriteriaEntry::count, CriteriaProgress::counter, AchievementEntry::flags, GetCriteriaProgress(), AchievementEntry::ID, IsCompletedCriteria(), AchievementCriteriaEntry::raw, AchievementEntry::refAchievement, and sAchievementMgr.

Referenced by CompletedAchievement(), CompletedCriteriaFor(), IsCompletedCriteria(), and UpdateAchievementCriteria().

◆ IsCompletedCriteria()

bool AchievementMgr::IsCompletedCriteria ( AchievementCriteriaEntry const *  achievementCriteria,
AchievementEntry const *  achievement 
)
private
1797{
1798 // counter can never complete
1799 if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER)
1800 return false;
1801
1803 {
1804 // someone on this realm has already completed that achievement
1805 if (sAchievementMgr->IsRealmCompleted(achievement))
1806 return false;
1807 }
1808
1809 // pussywizard: progress will be deleted after getting the achievement (optimization)
1810 // finished achievement should indicate criteria completed, since not finding progress would start some timed achievements and probably other things
1811 if (HasAchieved(achievement->ID))
1812 {
1813 bool completed = true;
1814
1815 // completed only after all referenced achievements are also completed
1816 if (AchievementEntryList const* achRefList = sAchievementMgr->GetAchievementByReferencedId(achievement->ID))
1817 for (AchievementEntryList::const_iterator itr = achRefList->begin(); itr != achRefList->end(); ++itr)
1818 if (!IsCompletedAchievement(*itr))
1819 {
1820 completed = false;
1821 break;
1822 }
1823
1824 if (completed)
1825 return true;
1826 }
1827
1828 CriteriaProgress const* progress = GetCriteriaProgress(achievementCriteria);
1829 if (!progress)
1830 return false;
1831
1832 if (!sScriptMgr->IsCompletedCriteria(this, achievementCriteria, achievement, progress))
1833 return false;
1834
1835 switch (achievementCriteria->requiredType)
1836 {
1838 return progress->counter >= achievementCriteria->win_bg.winCount;
1840 return progress->counter >= achievementCriteria->kill_creature.creatureCount;
1842 return progress->counter >= achievementCriteria->reach_level.level;
1844 return progress->counter >= achievementCriteria->reach_skill_level.skillLevel;
1846 return progress->counter >= 1;
1848 return progress->counter >= achievementCriteria->complete_quest_count.totalQuestCount;
1850 return progress->counter >= achievementCriteria->complete_daily_quest_daily.numberOfDays;
1852 return progress->counter >= achievementCriteria->complete_quests_in_zone.questCount;
1855 return progress->counter >= achievementCriteria->healing_done.count;
1857 return progress->counter >= achievementCriteria->complete_daily_quest.questCount;
1859 return progress->counter >= achievementCriteria->fall_without_dying.fallHeight;
1861 return progress->counter >= 1;
1864 return progress->counter >= achievementCriteria->be_spell_target.spellCount;
1867 return progress->counter >= achievementCriteria->cast_spell.castCount;
1869 return progress->counter >= achievementCriteria->bg_objective.completeCount;
1871 return progress->counter >= achievementCriteria->honorable_kill_at_area.killCount;
1873 return progress->counter >= 1;
1876 return progress->counter >= achievementCriteria->honorable_kill.killCount;
1878 return progress->counter >= achievementCriteria->own_item.itemCount;
1880 return progress->counter >= achievementCriteria->win_rated_arena.count;
1882 return progress->counter >= achievementCriteria->highest_personal_rating.PersonalRating;
1884 return progress->counter >= (achievementCriteria->learn_skill_level.skillLevel * 75);
1886 return progress->counter >= achievementCriteria->use_item.itemCount;
1888 return progress->counter >= achievementCriteria->loot_item.itemCount;
1890 return progress->counter >= 1;
1892 return progress->counter >= achievementCriteria->buy_bank_slot.numberOfSlots;
1894 return progress->counter >= achievementCriteria->gain_reputation.reputationAmount;
1896 return progress->counter >= achievementCriteria->gain_exalted_reputation.numberOfExaltedFactions;
1898 return progress->counter >= achievementCriteria->visit_barber.numberOfVisits;
1900 return progress->counter >= achievementCriteria->equip_epic_item.count;
1903 return progress->counter >= achievementCriteria->roll_greed_on_loot.count;
1905 return progress->counter >= achievementCriteria->hk_class.count;
1907 return progress->counter >= achievementCriteria->hk_race.count;
1909 return progress->counter >= achievementCriteria->do_emote.count;
1911 return progress->counter >= achievementCriteria->equip_item.count;
1913 return progress->counter >= achievementCriteria->quest_reward_money.goldInCopper;
1915 return progress->counter >= achievementCriteria->loot_money.goldInCopper;
1917 return progress->counter >= achievementCriteria->use_gameobject.useCount;
1919 return progress->counter >= achievementCriteria->special_pvp_kill.killCount;
1921 return progress->counter >= achievementCriteria->fish_in_gameobject.lootCount;
1923 return progress->counter >= achievementCriteria->learn_skillline_spell.spellCount;
1925 return progress->counter >= achievementCriteria->win_duel.duelCount;
1927 return progress->counter >= achievementCriteria->loot_type.lootTypeCount;
1929 return progress->counter >= achievementCriteria->learn_skill_line.spellCount;
1931 return progress->counter >= 9000;
1933 return progress->counter >= achievementCriteria->use_lfg.dungeonsComplete;
1935 return progress->counter >= achievementCriteria->get_killing_blow.killCount;
1937 return true;
1939 return achievementCriteria->win_arena.count && progress->counter >= achievementCriteria->win_arena.count;
1941 return true;
1942 // handle all statistic-only criteria here
1980 default:
1981 break;
1982 }
1983 return false;
1984}
@ ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION
Definition: DBCEnums.h:198
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE
Definition: DBCEnums.h:224
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2
Definition: DBCEnums.h:189
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE
Definition: DBCEnums.h:137
@ ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM
Definition: DBCEnums.h:163
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY
Definition: DBCEnums.h:136
@ ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN
Definition: DBCEnums.h:223
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED
Definition: DBCEnums.h:202
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL
Definition: DBCEnums.h:133
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL
Definition: DBCEnums.h:186
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT
Definition: DBCEnums.h:135
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET
Definition: DBCEnums.h:150
@ ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM
Definition: DBCEnums.h:179
@ ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA
Definition: DBCEnums.h:155
@ ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT
Definition: DBCEnums.h:191
@ ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING
Definition: DBCEnums.h:147
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL
Definition: DBCEnums.h:151
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM
Definition: DBCEnums.h:164
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR
Definition: DBCEnums.h:214
@ ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP
Definition: DBCEnums.h:170
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST
Definition: DBCEnums.h:139
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS
Definition: DBCEnums.h:197
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND
Definition: DBCEnums.h:140
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH
Definition: DBCEnums.h:210
@ ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK
Definition: DBCEnums.h:166
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID
Definition: DBCEnums.h:144
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT
Definition: DBCEnums.h:173
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER
Definition: DBCEnums.h:185
@ ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT
Definition: DBCEnums.h:188
@ ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE
Definition: DBCEnums.h:176
@ ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS
Definition: DBCEnums.h:200
@ ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM
Definition: DBCEnums.h:158
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION
Definition: DBCEnums.h:169
@ ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS
Definition: DBCEnums.h:231
@ ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED
Definition: DBCEnums.h:222
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP
Definition: DBCEnums.h:141
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL
Definition: DBCEnums.h:156
@ ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT
Definition: DBCEnums.h:167
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS
Definition: DBCEnums.h:193
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED
Definition: DBCEnums.h:209
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL
Definition: DBCEnums.h:132
@ ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL
Definition: DBCEnums.h:227
@ ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE
Definition: DBCEnums.h:177
@ ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE
Definition: DBCEnums.h:196
@ ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM
Definition: DBCEnums.h:148
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION
Definition: DBCEnums.h:203
@ ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD
Definition: DBCEnums.h:183
@ ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER
Definition: DBCEnums.h:146
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER
Definition: DBCEnums.h:213
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM
Definition: DBCEnums.h:206
@ ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL
Definition: DBCEnums.h:157
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION
Definition: DBCEnums.h:168
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2
Definition: DBCEnums.h:225
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE
Definition: DBCEnums.h:226
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS
Definition: DBCEnums.h:181
@ ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE
Definition: DBCEnums.h:138
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_DISENCHANT
Definition: DBCEnums.h:230
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST
Definition: DBCEnums.h:149
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
Definition: DBCEnums.h:159
@ ACHIEVEMENT_CRITERIA_TYPE_HK_RACE
Definition: DBCEnums.h:175
@ ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS
Definition: DBCEnums.h:205
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH
Definition: DBCEnums.h:142
@ ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA
Definition: DBCEnums.h:165
@ ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS
Definition: DBCEnums.h:180
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL
Definition: DBCEnums.h:162
@ ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE
Definition: DBCEnums.h:145
@ ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM
Definition: DBCEnums.h:171
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID
Definition: DBCEnums.h:199
@ ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE
Definition: DBCEnums.h:130
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD
Definition: DBCEnums.h:201
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON
Definition: DBCEnums.h:143
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL
Definition: DBCEnums.h:194
@ ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS
Definition: DBCEnums.h:228
@ ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA
Definition: DBCEnums.h:153
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING
Definition: DBCEnums.h:160
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_BG
Definition: DBCEnums.h:131
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION
Definition: DBCEnums.h:204
@ ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL
Definition: DBCEnums.h:190
@ ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE
Definition: DBCEnums.h:152
@ ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS
Definition: DBCEnums.h:178
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY
Definition: DBCEnums.h:187
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA
Definition: DBCEnums.h:154
@ ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS
Definition: DBCEnums.h:182
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT
Definition: DBCEnums.h:172
@ ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM
Definition: DBCEnums.h:207
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING
Definition: DBCEnums.h:161
@ ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS
Definition: DBCEnums.h:174
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED
Definition: DBCEnums.h:208
@ ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN
Definition: DBCEnums.h:192
@ ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL
Definition: DBCEnums.h:195

References ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID, ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_TYPE_DEATH, ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP, ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON, ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS, ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA, ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN, ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS, ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING, ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS, ACHIEVEMENT_CRITERIA_TYPE_HK_RACE, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL, ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK, ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA, ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED, ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_ROLL_DISENCHANT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, ACHIEVEMENT_FLAG_COUNTER, ACHIEVEMENT_FLAG_REALM_FIRST_KILL, ACHIEVEMENT_FLAG_REALM_FIRST_REACH, AchievementCriteriaEntry::be_spell_target, AchievementCriteriaEntry::bg_objective, AchievementCriteriaEntry::buy_bank_slot, AchievementCriteriaEntry::cast_spell, AchievementCriteriaEntry::castCount, AchievementCriteriaEntry::complete_daily_quest, AchievementCriteriaEntry::complete_daily_quest_daily, AchievementCriteriaEntry::complete_quest_count, AchievementCriteriaEntry::complete_quests_in_zone, AchievementCriteriaEntry::completeCount, AchievementCriteriaEntry::count, CriteriaProgress::counter, AchievementCriteriaEntry::creatureCount, AchievementCriteriaEntry::do_emote, AchievementCriteriaEntry::duelCount, AchievementCriteriaEntry::dungeonsComplete, AchievementCriteriaEntry::equip_epic_item, AchievementCriteriaEntry::equip_item, AchievementCriteriaEntry::fall_without_dying, AchievementCriteriaEntry::fallHeight, AchievementCriteriaEntry::fish_in_gameobject, AchievementEntry::flags, AchievementCriteriaEntry::gain_exalted_reputation, AchievementCriteriaEntry::gain_reputation, AchievementCriteriaEntry::get_killing_blow, GetCriteriaProgress(), AchievementCriteriaEntry::goldInCopper, HasAchieved(), AchievementCriteriaEntry::healing_done, AchievementCriteriaEntry::highest_personal_rating, AchievementCriteriaEntry::hk_class, AchievementCriteriaEntry::hk_race, AchievementCriteriaEntry::honorable_kill, AchievementCriteriaEntry::honorable_kill_at_area, AchievementEntry::ID, IsCompletedAchievement(), AchievementCriteriaEntry::itemCount, AchievementCriteriaEntry::kill_creature, AchievementCriteriaEntry::killCount, AchievementCriteriaEntry::learn_skill_level, AchievementCriteriaEntry::learn_skill_line, AchievementCriteriaEntry::learn_skillline_spell, AchievementCriteriaEntry::level, AchievementCriteriaEntry::loot_item, AchievementCriteriaEntry::loot_money, AchievementCriteriaEntry::loot_type, AchievementCriteriaEntry::lootCount, AchievementCriteriaEntry::lootTypeCount, AchievementCriteriaEntry::numberOfDays, AchievementCriteriaEntry::numberOfExaltedFactions, AchievementCriteriaEntry::numberOfSlots, AchievementCriteriaEntry::numberOfVisits, AchievementCriteriaEntry::own_item, AchievementCriteriaEntry::PersonalRating, AchievementCriteriaEntry::quest_reward_money, AchievementCriteriaEntry::questCount, AchievementCriteriaEntry::reach_level, AchievementCriteriaEntry::reach_skill_level, AchievementCriteriaEntry::reputationAmount, AchievementCriteriaEntry::requiredType, AchievementCriteriaEntry::roll_greed_on_loot, sAchievementMgr, AchievementCriteriaEntry::skillLevel, AchievementCriteriaEntry::special_pvp_kill, AchievementCriteriaEntry::spellCount, sScriptMgr, AchievementCriteriaEntry::totalQuestCount, AchievementCriteriaEntry::use_gameobject, AchievementCriteriaEntry::use_item, AchievementCriteriaEntry::use_lfg, AchievementCriteriaEntry::useCount, AchievementCriteriaEntry::visit_barber, AchievementCriteriaEntry::win_arena, AchievementCriteriaEntry::win_bg, AchievementCriteriaEntry::win_duel, AchievementCriteriaEntry::win_rated_arena, and AchievementCriteriaEntry::winCount.

Referenced by CanUpdateCriteria(), IsCompletedAchievement(), ResetAchievementCriteria(), SetCriteriaProgress(), StartTimedAchievement(), and UpdateAchievementCriteria().

◆ LoadFromDB()

void AchievementMgr::LoadFromDB ( PreparedQueryResult  achievementResult,
PreparedQueryResult  criteriaResult 
)
613{
614 if (achievementResult)
615 {
616 do
617 {
618 Field* fields = achievementResult->Fetch();
619 uint32 achievementid = fields[0].Get<uint16>();
620
621 // must not happen: cleanup at server startup in sAchievementMgr->LoadCompletedAchievements()
622 AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementid);
623 if (!achievement)
624 continue;
625
627 ca.date = time_t(fields[1].Get<uint32>());
628 ca.changed = false;
629
630 // title achievement rewards are retroactive
631 if (AchievementReward const* reward = sAchievementMgr->GetAchievementReward(achievement))
632 if (uint32 titleId = reward->titleId[Player::TeamIdForRace(GetPlayer()->getRace())])
633 if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId))
634 if (!GetPlayer()->HasTitle(titleEntry))
635 GetPlayer()->SetTitle(titleEntry);
636 } while (achievementResult->NextRow());
637 }
638
639 if (criteriaResult)
640 {
641 do
642 {
643 Field* fields = criteriaResult->Fetch();
644 uint32 id = fields[0].Get<uint16>();
645 uint32 counter = fields[1].Get<uint32>();
646 time_t date = time_t(fields[2].Get<uint32>());
647
648 AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(id);
649 if (!criteria)
650 {
651 // we will remove not existed criteria for all characters
652 LOG_ERROR("achievement", "Non-existing achievement criteria {} data removed from table `character_achievement_progress`.", id);
653
655
656 stmt->SetData(0, uint16(id));
657
658 CharacterDatabase.Execute(stmt);
659
660 continue;
661 }
662
663 if (criteria->timeLimit && time_t(date + criteria->timeLimit) < GameTime::GetGameTime().count())
664 continue;
665
666 CriteriaProgress& progress = _criteriaProgress[id];
667 progress.counter = counter;
668 progress.date = date;
669 progress.changed = false;
670 } while (criteriaResult->NextRow());
671 }
672}
std::uint16_t uint16
Definition: Define.h:109
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
@ CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA
Definition: CharacterDatabase.h:297
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
time_t date
Definition: AchievementMgr.h:39
bool changed
Definition: AchievementMgr.h:40
static TeamId TeamIdForRace(uint8 race)
Definition: Player.cpp:5745
uint32 timeLimit
Definition: DBCStructure.h:514

References _completedAchievements, _criteriaProgress, CriteriaProgress::changed, CompletedAchievementData::changed, CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA, CharacterDatabase, CriteriaProgress::counter, CriteriaProgress::date, CompletedAchievementData::date, Field::Get(), GameTime::GetGameTime(), GetPlayer(), LOG_ERROR, sAchievementCriteriaStore, sAchievementMgr, sAchievementStore, sCharTitlesStore, PreparedStatementBase::SetData(), Player::SetTitle(), Player::TeamIdForRace(), and AchievementCriteriaEntry::timeLimit.

Referenced by Player::LoadFromDB().

◆ RemoveCriteriaProgress()

void AchievementMgr::RemoveCriteriaProgress ( AchievementCriteriaEntry const *  entry)
2149{
2150 CriteriaProgressMap::iterator criteriaProgress = _criteriaProgress.find(entry->ID);
2151 if (criteriaProgress == _criteriaProgress.end())
2152 return;
2153
2155 data << uint32(entry->ID);
2156 _player->SendDirectMessage(&data);
2157
2158 _criteriaProgress.erase(criteriaProgress);
2159}
@ SMSG_CRITERIA_DELETED
Definition: Opcodes.h:1212
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5607
Definition: WorldPacket.h:27

References _criteriaProgress, _player, AchievementCriteriaEntry::ID, Player::SendDirectMessage(), and SMSG_CRITERIA_DELETED.

Referenced by RemoveTimedAchievement(), ResetAchievementCriteria(), and UpdateTimedAchievements().

◆ RemoveTimedAchievement()

void AchievementMgr::RemoveTimedAchievement ( AchievementCriteriaTimedTypes  type,
uint32  entry 
)
2207{
2208 AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr->GetTimedAchievementCriteriaByType(type);
2209 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i != achievementCriteriaList.end(); ++i)
2210 {
2211 if ((*i)->timerStartEvent != entry)
2212 continue;
2213
2214 TimedAchievementMap::iterator timedIter = _timedAchievements.find((*i)->ID);
2215 // We don't have timer for this achievement
2216 if (timedIter == _timedAchievements.end())
2217 continue;
2218
2219 // remove progress
2221
2222 // Remove the timer
2223 _timedAchievements.erase(timedIter);
2224 }
2225}
TimedAchievementMap _timedAchievements
Definition: AchievementMgr.h:320
void RemoveCriteriaProgress(AchievementCriteriaEntry const *entry)
Definition: AchievementMgr.cpp:2148

References _timedAchievements, RemoveCriteriaProgress(), and sAchievementMgr.

Referenced by Player::RemoveTimedAchievement().

◆ Reset()

void AchievementMgr::Reset ( )
491{
492 for (CompletedAchievementMap::const_iterator iter = _completedAchievements.begin(); iter != _completedAchievements.end(); ++iter)
493 {
495 data << uint32(iter->first);
497 }
498
499 for (CriteriaProgressMap::const_iterator iter = _criteriaProgress.begin(); iter != _criteriaProgress.end(); ++iter)
500 {
502 data << uint32(iter->first);
504 }
505
507 _criteriaProgress.clear();
509
510 // re-fill data
512}
@ SMSG_ACHIEVEMENT_DELETED
Definition: Opcodes.h:1213
void CheckAllAchievementCriteria()
Definition: AchievementMgr.cpp:773
static void DeleteFromDB(ObjectGuid::LowType lowguid)
Definition: AchievementMgr.cpp:541
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
LowType GetCounter() const
Definition: ObjectGuid.h:147

References _completedAchievements, _criteriaProgress, _player, CheckAllAchievementCriteria(), DeleteFromDB(), ObjectGuid::GetCounter(), Object::GetGUID(), Player::SendDirectMessage(), SMSG_ACHIEVEMENT_DELETED, and SMSG_CRITERIA_DELETED.

Referenced by Player::ResetAchievements().

◆ ResetAchievementCriteria()

void AchievementMgr::ResetAchievementCriteria ( AchievementCriteriaCondition  condition,
uint32  value,
bool  evenIfCriteriaComplete = false 
)
515{
516 // disable for gamemasters with GM-mode enabled
517 if (_player->IsGameMaster())
518 return;
519
520 LOG_DEBUG("achievement", "AchievementMgr::ResetAchievementCriteria({}, {}, {})", condition, value, evenIfCriteriaComplete);
521
522 AchievementCriteriaEntryList const* achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByCondition(condition, value);
523 if (!achievementCriteriaList)
524 return;
525
526 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList->begin(); i != achievementCriteriaList->end(); ++i)
527 {
528 AchievementCriteriaEntry const* achievementCriteria = (*i);
529 AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement);
530 if (!achievement)
531 continue;
532
533 // don't update already completed criteria if not forced or achievement already complete
534 if ((IsCompletedCriteria(achievementCriteria, achievement) && !evenIfCriteriaComplete) || HasAchieved(achievement->ID))
535 continue;
536
537 RemoveCriteriaProgress(achievementCriteria);
538 }
539}
uint32 ID
Definition: DBCStructure.h:41
uint32 referredAchievement
Definition: DBCStructure.h:72

References _player, HasAchieved(), AchievementEntry::ID, IsCompletedCriteria(), Player::IsGameMaster(), LOG_DEBUG, AchievementCriteriaEntry::referredAchievement, RemoveCriteriaProgress(), sAchievementMgr, and sAchievementStore.

Referenced by Player::ResetAchievementCriteria().

◆ SaveToDB()

void AchievementMgr::SaveToDB ( CharacterDatabaseTransaction  trans)
557{
558 if (!_completedAchievements.empty())
559 {
560 for (CompletedAchievementMap::iterator iter = _completedAchievements.begin(); iter != _completedAchievements.end(); ++iter)
561 {
562 if (!iter->second.changed)
563 continue;
564
566 stmt->SetData(0, iter->first);
567 stmt->SetData(1, GetPlayer()->GetGUID().GetCounter());
568 trans->Append(stmt);
569
570 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT);
571 stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
572 stmt->SetData(1, iter->first);
573 stmt->SetData(2, uint32(iter->second.date));
574 trans->Append(stmt);
575
576 iter->second.changed = false;
577
578 sScriptMgr->OnAchievementSave(trans, GetPlayer(), iter->first, iter->second);
579 }
580 }
581
582 if (!_criteriaProgress.empty())
583 {
584 for (CriteriaProgressMap::iterator iter = _criteriaProgress.begin(); iter != _criteriaProgress.end(); ++iter)
585 {
586 if (!iter->second.changed)
587 continue;
588
590 stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
591 stmt->SetData(1, iter->first);
592 trans->Append(stmt);
593
594 // pussywizard: insert only for (counter != 0) is very important! this is how criteria of completed achievements gets deleted from db (by setting counter to 0); if conflicted during merge - contact me
595 if (iter->second.counter)
596 {
597 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS);
598 stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
599 stmt->SetData(1, iter->first);
600 stmt->SetData(2, iter->second.counter);
601 stmt->SetData(3, uint32(iter->second.date));
602 trans->Append(stmt);
603 }
604
605 iter->second.changed = false;
606
607 sScriptMgr->OnCriteriaSave(trans, GetPlayer(), iter->first, iter->second);
608 }
609 }
610}
@ CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA
Definition: CharacterDatabase.h:366
@ CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS
Definition: CharacterDatabase.h:367
@ CHAR_INS_CHAR_ACHIEVEMENT
Definition: CharacterDatabase.h:365
@ CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT
Definition: CharacterDatabase.h:391

References _completedAchievements, _criteriaProgress, CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT, CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA, CHAR_INS_CHAR_ACHIEVEMENT, CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS, CharacterDatabase, GetPlayer(), PreparedStatementBase::SetData(), and sScriptMgr.

Referenced by Player::SaveToDB().

◆ SendAchievementEarned()

void AchievementMgr::SendAchievementEarned ( AchievementEntry const *  achievement) const
private
675{
676 if (GetPlayer()->GetSession()->PlayerLoading())
677 return;
678
679 // Don't send for achievements with ACHIEVEMENT_FLAG_TRACKING
680 if (achievement->flags & ACHIEVEMENT_FLAG_HIDDEN)
681 return;
682
683 LOG_DEBUG("achievement", "AchievementMgr::SendAchievementEarned({})", achievement->ID);
684
685 Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId());
686 if (guild)
687 {
690 guild->BroadcastWorker(_localizer, GetPlayer());
691 }
692
694 {
695 // If guild exists - send its name to the server
696 // If guild does not exist - send player's name to the server
697 if (achievement->flags & ACHIEVEMENT_FLAG_REALM_FIRST_KILL && guild)
698 {
699 WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, guild->GetName().size() + 1 + 8 + 4 + 4);
700 data << guild->GetName();
701 data << GetPlayer()->GetGUID();
702 data << uint32(achievement->ID);
703 data << uint32(0); // display name as plain string in chat (always 0 for guild)
704 sWorld->SendGlobalMessage(&data);
705 }
706 else
707 {
708 TeamId teamId = GetPlayer()->GetTeamId();
709
710 // broadcast realm first reached
711 WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, GetPlayer()->GetName().size() + 1 + 8 + 4 + 4);
712 data << GetPlayer()->GetName();
713 data << GetPlayer()->GetGUID();
714 data << uint32(achievement->ID);
715 std::size_t linkTypePos = data.wpos();
716 data << uint32(1); // display name as clickable link in chat
717 sWorld->SendGlobalMessage(&data, nullptr, teamId);
718
719 data.put<uint32>(linkTypePos, 0); // display name as plain string in chat
720 sWorld->SendGlobalMessage(&data, nullptr, teamId == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE);
721 }
722 }
723 // if player is in world he can tell his friends about new achievement
724 else if (GetPlayer()->IsInWorld())
725 {
726 CellCoord p = Acore::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
727
728 Cell cell(p);
729 cell.SetNoCreate();
730
736 }
737
738 WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 8);
739 data << GetPlayer()->GetPackGUID();
740 data << uint32(achievement->ID);
741 data.AppendPackedTime(GameTime::GetGameTime().count());
742 data << uint32(0);
743 GetPlayer()->SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
744}
#define sGuildMgr
Definition: GuildMgr.h:51
@ BROADCAST_TEXT_ACHIEVEMENT_EARNED
Definition: Language.h:23
@ CONFIG_LISTEN_RANGE_SAY
Definition: IWorld.h:195
@ CHAT_MSG_GUILD_ACHIEVEMENT
Definition: SharedDefines.h:3201
@ CHAT_MSG_ACHIEVEMENT
Definition: SharedDefines.h:3200
TeamId
Definition: SharedDefines.h:759
@ SMSG_ACHIEVEMENT_EARNED
Definition: Opcodes.h:1158
@ SMSG_SERVER_FIRST_ACHIEVEMENT
Definition: Opcodes.h:1206
#define sWorld
Definition: World.h:447
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:191
bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:228
Definition: TypeContainer.h:103
Definition: TypeContainerVisitor.h:85
bool IsInWorld() const
Definition: Object.h:101
std::string const & GetName() const
Definition: Object.h:446
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2072
void SendMessageToSetInRange(WorldPacket const *data, float dist, bool self, bool includeMargin=false, Player const *skipped_rcvr=nullptr) const override
Definition: Player.cpp:5586
Definition: Cell.h:46
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:193
Definition: GridNotifiers.h:589
Definition: GridNotifiers.h:1703
Definition: Guild.h:295
void BroadcastWorker(Do &_do, Player *except=nullptr)
Definition: Guild.h:754
std::string const & GetName() const
Definition: Guild.h:691
Definition: ChatTextBuilder.h:31

References ACHIEVEMENT_FLAG_HIDDEN, ACHIEVEMENT_FLAG_REALM_FIRST_KILL, ACHIEVEMENT_FLAG_REALM_FIRST_REACH, ByteBuffer::AppendPackedTime(), BROADCAST_TEXT_ACHIEVEMENT_EARNED, Guild::BroadcastWorker(), CHAT_MSG_ACHIEVEMENT, CHAT_MSG_GUILD_ACHIEVEMENT, Acore::ComputeCellCoord(), CONFIG_LISTEN_RANGE_SAY, AchievementEntry::flags, GameTime::GetGameTime(), Object::GetGUID(), WorldObject::GetName(), Guild::GetName(), Object::GetPackGUID(), GetPlayer(), Player::GetTeamId(), AchievementEntry::ID, Object::IsInWorld(), LOG_DEBUG, ByteBuffer::put(), Player::SendMessageToSetInRange(), Cell::SetNoCreate(), sGuildMgr, SMSG_ACHIEVEMENT_EARNED, SMSG_SERVER_FIRST_ACHIEVEMENT, sWorld, TEAM_ALLIANCE, TEAM_HORDE, Cell::VisitWorldObjects(), and ByteBuffer::wpos().

Referenced by CompletedAchievement().

◆ SendAllAchievementData()

void AchievementMgr::SendAllAchievementData ( ) const
2340{
2341 WorldPacket data(SMSG_ALL_ACHIEVEMENT_DATA, _completedAchievements.size() * 8 + 4 + _criteriaProgress.size() * 38 + 4);
2342 BuildAllDataPacket(&data);
2343 GetPlayer()->GetSession()->SendPacket(&data);
2344}
@ SMSG_ALL_ACHIEVEMENT_DATA
Definition: Opcodes.h:1179
void BuildAllDataPacket(WorldPacket *data) const
Definition: AchievementMgr.cpp:2357
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:212

References _completedAchievements, _criteriaProgress, BuildAllDataPacket(), GetPlayer(), Player::GetSession(), WorldSession::SendPacket(), and SMSG_ALL_ACHIEVEMENT_DATA.

Referenced by Player::SendInitialPacketsBeforeAddToMap().

◆ SendCriteriaUpdate()

void AchievementMgr::SendCriteriaUpdate ( AchievementCriteriaEntry const *  entry,
CriteriaProgress const *  progress,
uint32  timeElapsed,
bool  timedCompleted 
) const
private
747{
748 WorldPacket data(SMSG_CRITERIA_UPDATE, 8 + 4 + 8);
749 data << uint32(entry->ID);
750
751 // the counter is packed like a packed Guid
752 data.appendPackGUID(progress->counter);
753
754 data << GetPlayer()->GetPackGUID();
755 if (!entry->timeLimit)
756 data << uint32(0);
757 else
758 data << uint32(timedCompleted ? 0 : 1); // 1 is for keeping the counter at 0 in client
759 data.AppendPackedTime(progress->date);
760 data << uint32(timeElapsed); // time elapsed in seconds
761
762 if (sAchievementMgr->IsAverageCriteria(entry))
763 data << uint32(GameTime::GetGameTime().count() - GetPlayer()->GetCreationTime().count()); // for average achievements
764 else
765 data << uint32(timeElapsed); // time elapsed in seconds
766
768}
@ SMSG_CRITERIA_UPDATE
Definition: Opcodes.h:1160

References ByteBuffer::AppendPackedTime(), ByteBuffer::appendPackGUID(), CriteriaProgress::counter, CriteriaProgress::date, GameTime::GetGameTime(), Object::GetPackGUID(), GetPlayer(), AchievementCriteriaEntry::ID, sAchievementMgr, Player::SendDirectMessage(), SMSG_CRITERIA_UPDATE, and AchievementCriteriaEntry::timeLimit.

Referenced by SetCriteriaProgress().

◆ SendRespondInspectAchievements()

void AchievementMgr::SendRespondInspectAchievements ( Player player) const

◆ SetCriteriaProgress()

void AchievementMgr::SetCriteriaProgress ( AchievementCriteriaEntry const *  entry,
uint32  changeValue,
ProgressType  ptype = PROGRESS_SET 
)
private
2073{
2074 // Don't allow to cheat - doing timed achievements without timer active
2075 TimedAchievementMap::iterator timedIter = _timedAchievements.find(entry->ID);
2076 if (entry->timeLimit && timedIter == _timedAchievements.end())
2077 return;
2078
2079 if (!sScriptMgr->OnBeforeCriteriaProgress(GetPlayer(), entry))
2080 {
2081 return;
2082 }
2083
2084 LOG_DEBUG("achievement", "AchievementMgr::SetCriteriaProgress({}, {}) for {}", entry->ID, changeValue, _player->GetGUID().ToString());
2085
2086 CriteriaProgress* progress = GetCriteriaProgress(entry);
2087 if (!progress)
2088 {
2089 // not create record for 0 counter but allow it for timed achievements
2090 // we will need to send 0 progress to client to start the timer
2091 if (changeValue == 0 && !entry->timeLimit)
2092 return;
2093
2094 progress = &_criteriaProgress[entry->ID];
2095 progress->counter = changeValue;
2096 }
2097 else
2098 {
2099 uint32 newValue = 0;
2100 switch (ptype)
2101 {
2102 case PROGRESS_SET:
2103 case PROGRESS_RESET:
2104 newValue = changeValue;
2105 break;
2107 {
2108 // avoid overflow
2109 uint32 max_value = std::numeric_limits<uint32>::max();
2110 newValue = max_value - progress->counter > changeValue ? progress->counter + changeValue : max_value;
2111 break;
2112 }
2113 case PROGRESS_HIGHEST:
2114 newValue = progress->counter < changeValue ? changeValue : progress->counter;
2115 break;
2116 }
2117
2118 // not update (not mark as changed) if counter will have same value
2119 if (ptype != PROGRESS_RESET && progress->counter == newValue && !entry->timeLimit)
2120 return;
2121
2122 progress->counter = newValue;
2123 }
2124
2125 progress->changed = true;
2126 progress->date = GameTime::GetGameTime().count(); // set the date to the latest update.
2127
2128 uint32 timeElapsed = 0;
2129 bool timedCompleted = false;
2130
2131 if (entry->timeLimit)
2132 {
2133 // has to exist else we wouldn't be here
2134 timedCompleted = IsCompletedCriteria(entry, sAchievementStore.LookupEntry(entry->referredAchievement));
2135 // Client expects this in packet
2136 timeElapsed = entry->timeLimit - (timedIter->second / IN_MILLISECONDS);
2137
2138 // Remove the timer, we wont need it anymore
2139 if (timedCompleted)
2140 _timedAchievements.erase(timedIter);
2141 }
2142
2143 SendCriteriaUpdate(entry, progress, timeElapsed, true);
2144
2145 sScriptMgr->OnCriteriaProgress(GetPlayer(), entry);
2146}
constexpr auto IN_MILLISECONDS
Definition: Common.h:55
void SendCriteriaUpdate(AchievementCriteriaEntry const *entry, CriteriaProgress const *progress, uint32 timeElapsed, bool timedCompleted) const
Definition: AchievementMgr.cpp:746
std::string ToString() const
Definition: ObjectGuid.cpp:47

References _criteriaProgress, _player, _timedAchievements, CriteriaProgress::changed, CriteriaProgress::counter, CriteriaProgress::date, GetCriteriaProgress(), GameTime::GetGameTime(), Object::GetGUID(), GetPlayer(), AchievementCriteriaEntry::ID, IN_MILLISECONDS, IsCompletedCriteria(), LOG_DEBUG, PROGRESS_ACCUMULATE, PROGRESS_HIGHEST, PROGRESS_RESET, PROGRESS_SET, AchievementCriteriaEntry::referredAchievement, sAchievementStore, SendCriteriaUpdate(), sScriptMgr, AchievementCriteriaEntry::timeLimit, and ObjectGuid::ToString().

Referenced by StartTimedAchievement(), and UpdateAchievementCriteria().

◆ StartTimedAchievement()

void AchievementMgr::StartTimedAchievement ( AchievementCriteriaTimedTypes  type,
uint32  entry,
uint32  timeLost = 0 
)
2184{
2185 AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr->GetTimedAchievementCriteriaByType(type);
2186 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i != achievementCriteriaList.end(); ++i)
2187 {
2188 if ((*i)->timerStartEvent != entry)
2189 continue;
2190
2191 AchievementEntry const* achievement = sAchievementStore.LookupEntry((*i)->referredAchievement);
2192 if (_timedAchievements.find((*i)->ID) == _timedAchievements.end() && !IsCompletedCriteria(*i, achievement))
2193 {
2194 // Start the timer
2195 if ((*i)->timeLimit * IN_MILLISECONDS > timeLost)
2196 {
2197 _timedAchievements[(*i)->ID] = (*i)->timeLimit * IN_MILLISECONDS - timeLost;
2198
2199 // and at client too
2201 }
2202 }
2203 }
2204}
void SetCriteriaProgress(AchievementCriteriaEntry const *entry, uint32 changeValue, ProgressType ptype=PROGRESS_SET)
Definition: AchievementMgr.cpp:2072

References _timedAchievements, IN_MILLISECONDS, IsCompletedCriteria(), PROGRESS_SET, sAchievementMgr, sAchievementStore, and SetCriteriaProgress().

Referenced by Player::StartTimedAchievement().

◆ UpdateAchievementCriteria()

void AchievementMgr::UpdateAchievementCriteria ( AchievementCriteriaTypes  type,
uint32  miscValue1 = 0,
uint32  miscValue2 = 0,
Unit unit = nullptr 
)

this function will be called whenever the user might have done a criteria relevant action

796{
797 // disable for gamemasters with GM-mode enabled
798 if (_player->IsGameMaster())
799 return;
800
802 {
803 LOG_DEBUG("achievement", "UpdateAchievementCriteria: Wrong criteria type {}", type);
804 return;
805 }
806
807 LOG_DEBUG("achievement", "AchievementMgr::UpdateAchievementCriteria({}, {}, {})", type, miscValue1, miscValue2);
808
809 AchievementCriteriaEntryList const* achievementCriteriaList = nullptr;
810
811 switch (type)
812 {
843 if (miscValue1)
844 {
845 achievementCriteriaList = sAchievementMgr->GetSpecialAchievementCriteriaByType(type, miscValue1);
846 break;
847 }
848 achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByType(type);
849 break;
851 if (miscValue2)
852 {
853 achievementCriteriaList = sAchievementMgr->GetSpecialAchievementCriteriaByType(type, miscValue2);
854 break;
855 }
856 achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByType(type);
857 break;
858 default:
859 achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByType(type);
860 break;
861 }
862
863 if (!achievementCriteriaList)
864 return;
865
866 sScriptMgr->OnBeforeCheckCriteria(this, achievementCriteriaList);
867
868 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList->begin(); i != achievementCriteriaList->end(); ++i)
869 {
870 AchievementCriteriaEntry const* achievementCriteria = (*i);
871 AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement);
872 if (!achievement)
873 continue;
874
875 if (!CanUpdateCriteria(achievementCriteria, achievement))
876 continue;
877
878 if (!sScriptMgr->CanCheckCriteria(this, achievementCriteria))
879 continue;
880
881 switch (type)
882 {
883 // std. case: increment at 1
887 case ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS: /* FIXME: for online player only currently */
894 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
895 if (!miscValue1)
896 continue;
897 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
898 break;
899 // std case: increment at miscvalue1
907 case ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS:/* FIXME: for online player only currently */
911 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
912 if (!miscValue1)
913 continue;
914 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_ACCUMULATE);
915 break;
916 // std case: high value at miscvalue1
918 case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD: /* FIXME: for online player only currently */
923 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
924 if (!miscValue1)
925 continue;
926 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_HIGHEST);
927 break;
928
929 // specialized cases
931 {
932 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
933 if (!miscValue1)
934 continue;
935
936 if (achievement->categoryId == CATEGORY_CHILDRENS_WEEK)
937 {
938 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
939 if (!data || !data->Meets(GetPlayer(), nullptr))
940 continue;
941 }
942
943 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
944 break;
945 }
947 {
948 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
949 if (!miscValue1)
950 continue;
951 if (achievementCriteria->win_bg.bgMapID != GetPlayer()->GetMapId())
952 continue;
953
954 // those requirements couldn't be found in the dbc
955 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
956 if (!data || !data->Meets(GetPlayer(), unit))
957 continue;
958
959 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
960 break;
961 }
963 {
964 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
965 if (!miscValue1)
966 continue;
967 if (achievementCriteria->kill_creature.creatureID != miscValue1)
968 continue;
969
970 // those requirements couldn't be found in the dbc
971 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
972 if (!data || !data->Meets(GetPlayer(), unit))
973 continue;
974
975 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
976 break;
977 }
979 {
980 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
981 if (!miscValue2)
982 continue;
983
984 // those requirements couldn't be found in the dbc
985 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
986 if (!data || !data->Meets(GetPlayer(), unit, miscValue1))
987 continue;
988
989 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
990 break;
991 }
993 if (AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria))
994 if (!data->Meets(GetPlayer(), unit))
995 continue;
996 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetLevel());
997 break;
999 // update at loading or specific skill update
1000 if (miscValue1 && miscValue1 != achievementCriteria->reach_skill_level.skillID)
1001 continue;
1002 if (uint32 skillvalue = GetPlayer()->GetBaseSkillValue(achievementCriteria->reach_skill_level.skillID))
1003 SetCriteriaProgress(achievementCriteria, skillvalue);
1004 break;
1006 // update at loading or specific skill update
1007 if (miscValue1 && miscValue1 != achievementCriteria->learn_skill_level.skillID)
1008 continue;
1009 if (uint32 maxSkillvalue = GetPlayer()->GetPureMaxSkillValue(achievementCriteria->learn_skill_level.skillID))
1010 SetCriteriaProgress(achievementCriteria, maxSkillvalue);
1011 break;
1013 if ((miscValue1 && achievementCriteria->complete_achievement.linkedAchievement == miscValue1) || (!miscValue1 && GetPlayer()->HasAchieved(achievementCriteria->complete_achievement.linkedAchievement)))
1014 SetCriteriaProgress(achievementCriteria, 1);
1015 break;
1017 {
1018 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetRewardedQuestCount());
1019 break;
1020 }
1022 {
1023 Seconds nextDailyResetTime = sWorld->GetNextDailyQuestsResetTime();
1024 CriteriaProgress* progress = GetCriteriaProgress(achievementCriteria);
1025
1026 if (!miscValue1) // Login case.
1027 {
1028 // reset if player missed one day.
1029 if (progress && Seconds(progress->date) < (nextDailyResetTime - 2_days))
1030 SetCriteriaProgress(achievementCriteria, 0, PROGRESS_SET);
1031 continue;
1032 }
1033
1034 ProgressType progressType;
1035 if (!progress)
1036 // 1st time. Start count.
1037 progressType = PROGRESS_SET;
1038 else if (Seconds(progress->date) < (nextDailyResetTime - 2_days))
1039 // last progress is older than 2 days. Player missed 1 day => Retart count.
1040 progressType = PROGRESS_RESET;
1041 else if (Seconds(progress->date) < (nextDailyResetTime - 1_days))
1042 // last progress is between 1 and 2 days. => 1st time of the day.
1043 progressType = PROGRESS_ACCUMULATE;
1044 else
1045 // last progress is within the day before the reset => Already counted today.
1046 continue;
1047
1048 SetCriteriaProgress(achievementCriteria, 1, progressType);
1049 break;
1050 }
1052 {
1053 // speedup for non-login case
1054 if (miscValue1 && miscValue1 != achievementCriteria->complete_quests_in_zone.zoneID)
1055 continue;
1056
1057 uint32 counter = 0;
1058
1059 const RewardedQuestSet& rewQuests = GetPlayer()->getRewardedQuests();
1060 for (RewardedQuestSet::const_iterator itr = rewQuests.begin(); itr != rewQuests.end(); ++itr)
1061 {
1062 Quest const* quest = sObjectMgr->GetQuestTemplate(*itr);
1063 if (quest && quest->GetZoneOrSort() >= 0 && uint32(quest->GetZoneOrSort()) == achievementCriteria->complete_quests_in_zone.zoneID)
1064 ++counter;
1065 }
1066 SetCriteriaProgress(achievementCriteria, counter);
1067 break;
1068 }
1070 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1071 if (!miscValue1)
1072 continue;
1073 if (GetPlayer()->GetMapId() != achievementCriteria->complete_battleground.mapID)
1074 continue;
1075 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1076 break;
1078 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1079 if (!miscValue1)
1080 continue;
1081 if (GetPlayer()->GetMapId() != achievementCriteria->death_at_map.mapID)
1082 continue;
1083 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1084 break;
1086 {
1087 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1088 if (!miscValue1)
1089 continue;
1090 // skip wrong arena achievements, if not achievIdByArenaSlot then normal total death counter
1091 bool notfit = false;
1092 for (int j = 0; j < MAX_ARENA_SLOT; ++j)
1093 {
1094 if (achievIdByArenaSlot[j] == achievement->ID)
1095 {
1097 if (!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != j)
1098 notfit = true;
1099
1100 break;
1101 }
1102 }
1103 if (notfit)
1104 continue;
1105
1106 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1107 break;
1108 }
1110 {
1111 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1112 if (!miscValue1)
1113 continue;
1114
1115 Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : sMapMgr->FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId());
1116 if (!map || !map->IsDungeon())
1117 continue;
1118
1119 // search case
1120 bool found = false;
1121 for (int j = 0; achievIdForDungeon[j][0]; ++j)
1122 {
1123 if (achievIdForDungeon[j][0] == achievement->ID)
1124 {
1125 if (map->IsRaid())
1126 {
1127 // if raid accepted (ignore difficulty)
1128 if (!achievIdForDungeon[j][2])
1129 break; // for
1130 }
1131 else if (GetPlayer()->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL)
1132 {
1133 // dungeon in normal mode accepted
1134 if (!achievIdForDungeon[j][1])
1135 break; // for
1136 }
1137 else
1138 {
1139 // dungeon in heroic mode accepted
1140 if (!achievIdForDungeon[j][3])
1141 break; // for
1142 }
1143
1144 found = true;
1145 break; // for
1146 }
1147 }
1148 if (!found)
1149 continue;
1150
1151 //FIXME: work only for instances where max == min for players
1152 if (map->ToInstanceMap()->GetMaxPlayers() != achievementCriteria->death_in_dungeon.manLimit)
1153 continue;
1154 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1155 break;
1156 }
1158 {
1159 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1160 if (!miscValue1)
1161 continue;
1162
1163 Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : sMapMgr->FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId());
1164 if (!map || !map->IsDungeon())
1165 continue;
1166
1167 if (map->ToInstanceMap()->GetMaxPlayers() != achievementCriteria->complete_raid.groupSize)
1168 continue;
1169 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1170 break;
1171 }
1173 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1174 if (!miscValue1)
1175 continue;
1176 if (miscValue1 != achievementCriteria->killed_by_creature.creatureEntry)
1177 continue;
1178 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1179 break;
1181 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1182 if (!miscValue1)
1183 continue;
1184
1185 // if team check required: must kill by opposition faction
1186 if (achievement->ID == 318 && miscValue2 == GetPlayer()->GetTeamId())
1187 continue;
1188
1189 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1190 break;
1192 {
1193 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1194 if (!miscValue1)
1195 continue;
1196
1197 // those requirements couldn't be found in the dbc
1198 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1199 if (!data || !data->Meets(GetPlayer(), unit))
1200 continue;
1201
1202 // miscvalue1 is the ingame fallheight*100 as stored in dbc
1203 SetCriteriaProgress(achievementCriteria, miscValue1);
1204 break;
1205 }
1207 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1208 if (!miscValue1)
1209 continue;
1210 if (miscValue2 != achievementCriteria->death_from.type)
1211 continue;
1212 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1213 break;
1215 {
1216 // if miscvalues != 0, it contains the questID.
1217 if (miscValue1)
1218 {
1219 if (miscValue1 != achievementCriteria->complete_quest.questID)
1220 continue;
1221 }
1222 else
1223 {
1224 // login case.
1225 if (!GetPlayer()->GetQuestRewardStatus(achievementCriteria->complete_quest.questID))
1226 continue;
1227 }
1228
1229 if (AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria))
1230 if (!data->Meets(GetPlayer(), unit))
1231 continue;
1232
1233 SetCriteriaProgress(achievementCriteria, 1);
1234 break;
1235 }
1238 {
1239 if (!miscValue1 || miscValue1 != achievementCriteria->be_spell_target.spellID)
1240 continue;
1241
1242 // those requirements couldn't be found in the dbc
1243 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1244 if (!data)
1245 continue;
1246
1247 if (!data->Meets(GetPlayer(), unit))
1248 continue;
1249
1250 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1251 break;
1252 }
1255 {
1256 if (!miscValue1 || miscValue1 != achievementCriteria->cast_spell.spellID)
1257 continue;
1258
1259 // those requirements couldn't be found in the dbc
1260 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1261 if (!data)
1262 continue;
1263
1264 if (!data->Meets(GetPlayer(), unit))
1265 continue;
1266
1267 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1268 break;
1269 }
1271 if (miscValue1 && miscValue1 != achievementCriteria->learn_spell.spellID)
1272 continue;
1273
1274 if (GetPlayer()->HasSpell(achievementCriteria->learn_spell.spellID))
1275 SetCriteriaProgress(achievementCriteria, 1);
1276 break;
1278 {
1279 // miscvalue1=loot_type (note: 0 = LOOT_CORPSE and then it ignored)
1280 // miscvalue2=count of item loot
1281 if (!miscValue1 || !miscValue2)
1282 continue;
1283 if (miscValue1 != achievementCriteria->loot_type.lootType)
1284 continue;
1285
1286 // zone specific
1287 if (achievementCriteria->loot_type.lootTypeCount == 1)
1288 {
1289 // those requirements couldn't be found in the dbc
1290 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1291 if (!data || !data->Meets(GetPlayer(), unit))
1292 continue;
1293 }
1294
1295 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1296 break;
1297 }
1299 // speedup for non-login case
1300 if (miscValue1 && achievementCriteria->own_item.itemID != miscValue1)
1301 continue;
1302 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1303 break;
1305 if (!miscValue1) // no update at login
1306 continue;
1307
1308 // additional requirements
1310 {
1311 // those requirements couldn't be found in the dbc
1312 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1313 if (!data || !data->Meets(GetPlayer(), unit, miscValue1))
1314 {
1315 // reset the progress as we have a win without the requirement.
1316 SetCriteriaProgress(achievementCriteria, 0);
1317 continue;
1318 }
1319 }
1320
1321 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1322 break;
1324 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1325 if (!miscValue1)
1326 continue;
1327
1328 if (achievementCriteria->use_item.itemID != miscValue1)
1329 continue;
1330
1331 // Children's Week achievements have extra requirements
1332 //if (achievement->categoryId == CATEGORY_CHILDRENS_WEEK || achievement->ID == 1291) // Lonely?
1333 {
1334 // Xinef: skip progress only if data exists and is not meet
1335 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1336 if (data && !data->Meets(GetPlayer(), nullptr))
1337 continue;
1338 }
1339
1340 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1341 break;
1343 // You _have_ to loot that item, just owning it when logging in does _not_ count!
1344 if (!miscValue1)
1345 continue;
1346 if (miscValue1 != achievementCriteria->own_item.itemID)
1347 continue;
1348 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1349 break;
1351 {
1352 WorldMapOverlayEntry const* worldOverlayEntry = sWorldMapOverlayStore.LookupEntry(achievementCriteria->explore_area.areaReference);
1353 if (!worldOverlayEntry)
1354 break;
1355
1356 bool matchFound = false;
1357 for (int j = 0; j < MAX_WORLD_MAP_OVERLAY_AREA_IDX; ++j)
1358 {
1359 AreaTableEntry const* area = sAreaTableStore.LookupEntry(worldOverlayEntry->areatableID[j]);
1360 if (!area)
1361 break;
1362
1363 uint32 playerIndexOffset = uint32(area->exploreFlag) / 32;
1364 if (playerIndexOffset >= PLAYER_EXPLORED_ZONES_SIZE)
1365 continue;
1366
1367 uint32 mask = 1 << (uint32(area->exploreFlag) % 32);
1368 if (GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask)
1369 {
1370 matchFound = true;
1371 break;
1372 }
1373 }
1374
1375 if (matchFound)
1376 SetCriteriaProgress(achievementCriteria, 1);
1377 break;
1378 }
1380 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetBankBagSlotCount());
1381 break;
1383 {
1384 // skip faction check only at loading
1385 if (miscValue1 && miscValue1 != achievementCriteria->gain_reputation.factionID)
1386 continue;
1387
1388 int32 reputation = GetPlayer()->GetReputationMgr().GetReputation(achievementCriteria->gain_reputation.factionID);
1389 if (reputation > 0)
1390 SetCriteriaProgress(achievementCriteria, reputation);
1391 break;
1392 }
1394 {
1395 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetExaltedFactionCount());
1396 break;
1397 }
1399 {
1400 // skip for login case
1401 if (!miscValue1)
1402 continue;
1403 SetCriteriaProgress(achievementCriteria, 1);
1404 break;
1405 }
1407 {
1408 // miscvalue1 = itemid
1409 // miscvalue2 = itemSlot
1410 if (!miscValue1)
1411 continue;
1412
1413 if (miscValue2 != achievementCriteria->equip_epic_item.itemSlot)
1414 continue;
1415
1416 // check item level and quality via achievement_criteria_data
1417 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1418 if (!data || !data->Meets(GetPlayer(), 0, miscValue1))
1419 continue;
1420
1421 SetCriteriaProgress(achievementCriteria, 1);
1422 break;
1423 }
1424
1427 {
1428 // miscvalue1 = itemid
1429 // miscvalue2 = diced value
1430 if (!miscValue1)
1431 continue;
1432 if (miscValue2 != achievementCriteria->roll_greed_on_loot.rollValue)
1433 continue;
1434
1435 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(miscValue1);
1436 if (!pProto)
1437 continue;
1438
1439 // check item level via achievement_criteria_data
1440 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1441 if (!data || !data->Meets(GetPlayer(), 0, pProto->ItemLevel))
1442 continue;
1443
1444 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1445 break;
1446 }
1448 {
1449 // miscvalue1 = emote
1450 if (!miscValue1)
1451 continue;
1452 if (miscValue1 != achievementCriteria->do_emote.emoteID)
1453 continue;
1454 if (achievementCriteria->do_emote.count)
1455 {
1456 // those requirements couldn't be found in the dbc
1457 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1458 if (!data || !data->Meets(GetPlayer(), unit))
1459 continue;
1460 }
1461
1462 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1463 break;
1464 }
1467 {
1468 if (!miscValue1)
1469 continue;
1470
1472 {
1473 if (GetPlayer()->GetMapId() != achievementCriteria->additionalRequirements[0].additionalRequirement_value)
1474 continue;
1475
1476 // map specific case (BG in fact) expected player targeted damage/heal
1477 if (!unit || unit->GetTypeId() != TYPEID_PLAYER)
1478 continue;
1479 }
1480
1481 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_ACCUMULATE);
1482 break;
1483 }
1485 // miscvalue1 = item_id
1486 if (!miscValue1)
1487 continue;
1488 if (miscValue1 != achievementCriteria->equip_item.itemID)
1489 continue;
1490
1491 SetCriteriaProgress(achievementCriteria, 1);
1492 break;
1494 // miscvalue1 = go entry
1495 if (!miscValue1)
1496 continue;
1497 if (miscValue1 != achievementCriteria->use_gameobject.goEntry)
1498 continue;
1499
1500 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1501 break;
1503 if (!miscValue1)
1504 continue;
1505 if (miscValue1 != achievementCriteria->fish_in_gameobject.goEntry)
1506 continue;
1507
1508 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1509 break;
1511 {
1512 if (miscValue1 && miscValue1 != achievementCriteria->learn_skillline_spell.skillLine)
1513 continue;
1514
1515 uint32 spellCount = 0;
1516 for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin(); spellIter != GetPlayer()->GetSpellMap().end(); ++spellIter)
1517 {
1518 SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
1519 for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
1520 {
1521 if (skillIter->second->SkillLine == achievementCriteria->learn_skillline_spell.skillLine)
1522 {
1523 // xinef: do not add couter twice if by any chance skill is listed twice in dbc (eg. skill 777 and spell 22717)
1524 ++spellCount;
1525 break;
1526 }
1527 }
1528 }
1529
1530 SetCriteriaProgress(achievementCriteria, spellCount);
1531 break;
1532 }
1534 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1535 if (!miscValue1)
1536 continue;
1537
1538 if (achievementCriteria->win_duel.duelCount)
1539 {
1540 // those requirements couldn't be found in the dbc
1541 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1542 if (!data)
1543 continue;
1544
1545 if (!data->Meets(GetPlayer(), unit))
1546 continue;
1547 }
1548
1549 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1550 break;
1552 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetReveredFactionCount());
1553 break;
1555 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetHonoredFactionCount());
1556 break;
1558 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetVisibleFactionCount());
1559 break;
1562 {
1563 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1564 if (!miscValue1)
1565 continue;
1566 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(miscValue1);
1567 if (!proto || proto->Quality < ITEM_QUALITY_EPIC)
1568 continue;
1569 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1570 if (!data || !data->Meets(GetPlayer(), unit, miscValue1))
1571 continue;
1572 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1573 break;
1574 }
1576 {
1577 if (miscValue1 && miscValue1 != achievementCriteria->learn_skill_line.skillLine)
1578 continue;
1579
1580 uint32 spellCount = 0;
1581 for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin(); spellIter != GetPlayer()->GetSpellMap().end(); ++spellIter)
1582 {
1583 SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
1584 for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
1585 {
1586 if (skillIter->second->SkillLine == achievementCriteria->learn_skill_line.skillLine)
1587 {
1588 // xinef: do not add couter twice if by any chance skill is listed twice in dbc (eg. skill 777 and spell 22717)
1589 ++spellCount;
1590 break;
1591 }
1592 }
1593 }
1594
1595 SetCriteriaProgress(achievementCriteria, spellCount);
1596 break;
1597 }
1599 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
1600 break;
1602 if (!miscValue1 || miscValue1 != achievementCriteria->hk_class.classID)
1603 continue;
1604
1605 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1606 break;
1608 if (!miscValue1 || miscValue1 != achievementCriteria->hk_race.raceID)
1609 continue;
1610
1611 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1612 break;
1614 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetMoney(), PROGRESS_HIGHEST);
1615 break;
1617 {
1618 if (!miscValue1)
1619 {
1620 uint32 points = 0;
1621 for (CompletedAchievementMap::iterator itr = _completedAchievements.begin(); itr != _completedAchievements.end(); ++itr)
1622 if (AchievementEntry const* pAchievement = sAchievementStore.LookupEntry(itr->first))
1623 points += pAchievement->points;
1624 SetCriteriaProgress(achievementCriteria, points, PROGRESS_SET);
1625 }
1626 else
1627 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_ACCUMULATE);
1628 break;
1629 }
1631 {
1632 if (!miscValue1 || miscValue1 != achievementCriteria->bg_objective.objectiveId)
1633 continue;
1634
1635 // those requirements couldn't be found in the dbc
1636 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1637 if (!data || !data->Meets(GetPlayer(), unit))
1638 continue;
1639
1640 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1641 break;
1642 }
1646 {
1647 // skip login update
1648 if (!miscValue1)
1649 continue;
1650
1651 // those requirements couldn't be found in the dbc
1652 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1653 if (!data || !data->Meets(GetPlayer(), unit))
1654 continue;
1655
1656 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1657 break;
1658 }
1660 {
1661 if (!miscValue1 || miscValue1 != achievementCriteria->honorable_kill_at_area.areaID)
1662 continue;
1663
1664 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1665 break;
1666 }
1668 {
1669 uint32 reqTeamType = achievementCriteria->highest_team_rating.teamtype;
1670
1671 if (miscValue1)
1672 {
1673 if (miscValue2 != reqTeamType)
1674 continue;
1675
1676 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_HIGHEST);
1677 }
1678 else // login case
1679 {
1680 for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
1681 {
1682 uint32 arenaTeamId = GetPlayer()->GetArenaTeamId(arena_slot);
1683 if (!arenaTeamId)
1684 continue;
1685
1686 ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
1687 if (!team || team->GetType() != reqTeamType)
1688 continue;
1689
1690 SetCriteriaProgress(achievementCriteria, team->GetStats().Rating, PROGRESS_HIGHEST);
1691 break;
1692 }
1693 }
1694
1695 break;
1696 }
1698 {
1699 uint32 reqTeamType = achievementCriteria->highest_personal_rating.teamtype;
1700
1701 if (miscValue1)
1702 {
1703 if (miscValue2 != reqTeamType)
1704 continue;
1705
1706 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_HIGHEST);
1707 }
1708 else // login case
1709 {
1710 for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
1711 {
1712 uint32 arenaTeamId = GetPlayer()->GetArenaTeamId(arena_slot);
1713 if (!arenaTeamId)
1714 continue;
1715
1716 ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
1717 if (!team || team->GetType() != reqTeamType)
1718 continue;
1719
1720 if (ArenaTeamMember const* member = team->GetMember(GetPlayer()->GetGUID()))
1721 {
1722 SetCriteriaProgress(achievementCriteria, member->PersonalRating, PROGRESS_HIGHEST);
1723 break;
1724 }
1725 }
1726 }
1727
1728 break;
1729 }
1731 {
1732 // This criteria is only called directly after login - with expected miscvalue1 == 1
1733 if (!miscValue1)
1734 continue;
1735
1736 // They have no proper requirements in dbc
1737 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1738 if (!data || !data->Meets(GetPlayer(), unit))
1739 continue;
1740
1741 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1742 break;
1743 }
1745 case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA: // This also behaves like ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
1746 {
1747 // those requirements couldn't be found in the dbc
1748 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1749 if (!data || !data->Meets(GetPlayer(), nullptr))
1750 continue;
1751
1752 // Check map id requirement
1753 if (miscValue1 == achievementCriteria->win_arena.mapID)
1754 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1755 break;
1756 }
1758 {
1759 // those requirements couldn't be found in the dbc
1760 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1761 if (!data || !data->Meets(GetPlayer(), nullptr))
1762 continue;
1763
1764 SetCriteriaProgress(achievementCriteria, 1);
1765 break;
1766 }
1767 // std case: not exist in DBC, not triggered in code as result
1774 break;
1775 // FIXME: not triggered in code as result, need to implement
1777 break; // Not implemented yet :(
1778 }
1779
1780 if (IsCompletedCriteria(achievementCriteria, achievement))
1781 CompletedCriteriaFor(achievement);
1782
1783 // check again the completeness for SUMM and REQ COUNT achievements,
1784 // as they don't depend on the completed criteria but on the sum of the progress of each individual criteria
1785 if (achievement->flags & ACHIEVEMENT_FLAG_SUMM)
1786 if (IsCompletedAchievement(achievement))
1787 CompletedAchievement(achievement);
1788
1789 if (AchievementEntryList const* achRefList = sAchievementMgr->GetAchievementByReferencedId(achievement->ID))
1790 for (AchievementEntryList::const_iterator itr = achRefList->begin(); itr != achRefList->end(); ++itr)
1791 if (IsCompletedAchievement(*itr))
1793 }
1794}
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
static const uint32 achievIdByArenaSlot[MAX_ARENA_SLOT]
Definition: AchievementMgr.cpp:780
static const uint32 achievIdForDungeon[][4]
Definition: AchievementMgr.cpp:781
#define MAX_ARENA_SLOT
Definition: ArenaTeam.h:135
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
DBCStorage< WorldMapOverlayEntry > sWorldMapOverlayStore(WorldMapOverlayEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ PLAYER_EXPLORED_ZONES_1
Definition: UpdateFields.h:357
@ PLAYER_FIELD_LIFETIME_HONORABLE_KILLS
Definition: UpdateFields.h:377
std::unordered_set< uint32 > RewardedQuestSet
Definition: Player.h:616
#define PLAYER_EXPLORED_ZONES_SIZE
Definition: Player.h:73
#define sObjectMgr
Definition: ObjectMgr.h:1640
#define sMapMgr
Definition: MapMgr.h:221
#define sSpellMgr
Definition: SpellMgr.h:825
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
Definition: SpellMgr.h:584
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:277
@ ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE
Definition: DBCEnums.h:99
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER
Definition: DBCEnums.h:211
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED
Definition: DBCEnums.h:217
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED
Definition: DBCEnums.h:221
@ ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED
Definition: DBCEnums.h:220
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING
Definition: DBCEnums.h:184
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING
Definition: DBCEnums.h:215
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED
Definition: DBCEnums.h:219
@ ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED
Definition: DBCEnums.h:218
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT
Definition: DBCEnums.h:212
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT
Definition: DBCEnums.h:216
@ CATEGORY_CHILDRENS_WEEK
Definition: DBCEnums.h:237
#define MAX_WORLD_MAP_OVERLAY_AREA_IDX
Definition: DBCStructure.h:2163
@ ITEM_QUALITY_EPIC
Definition: SharedDefines.h:333
Definition: AchievementMgr.h:233
bool Meets(Player const *source, Unit const *target, uint32 miscvalue=0) const
Definition: AchievementMgr.cpp:472
void CompletedCriteriaFor(AchievementEntry const *achievement)
Definition: AchievementMgr.cpp:1986
ProgressType
Definition: AchievementMgr.h:306
bool CanUpdateCriteria(AchievementCriteriaEntry const *criteria, AchievementEntry const *achievement)
Definition: AchievementMgr.cpp:2396
Definition: ArenaTeam.h:109
uint16 Rating
Definition: ArenaTeam.h:127
Definition: ArenaTeam.h:138
ArenaTeamMember * GetMember(ObjectGuid guid)
Definition: ArenaTeam.cpp:1012
uint32 GetType() const
Definition: ArenaTeam.h:150
const ArenaTeamStats & GetStats() const
Definition: ArenaTeam.h:156
static uint8 GetSlotByType(uint32 type)
Definition: ArenaTeam.cpp:618
Definition: Battleground.h:298
uint8 GetArenaType() const
Definition: Battleground.h:340
bool isArena() const
Definition: Battleground.h:396
Definition: ItemTemplate.h:628
uint32 Quality
Definition: ItemTemplate.h:635
uint32 ItemLevel
Definition: ItemTemplate.h:644
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
TypeID GetTypeId() const
Definition: Object.h:121
Map * GetMap() const
Definition: Object.h:517
RewardedQuestSet const & getRewardedQuests() const
Definition: Player.h:1597
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:12117
PlayerSpellMap const & GetSpellMap() const
Definition: Player.h:1739
uint32 GetArenaTeamId(uint8 slot) const
Definition: Player.cpp:16129
ReputationMgr & GetReputationMgr()
Definition: Player.h:2089
Definition: Map.h:313
bool IsDungeon() const
Definition: Map.h:448
bool IsRaid() const
Definition: Map.h:450
InstanceMap * ToInstanceMap()
Definition: Map.h:545
uint32 GetMaxPlayers() const
Definition: Map.cpp:3207
Definition: QuestDef.h:207
int32 GetZoneOrSort() const
Definition: QuestDef.h:227
int32 GetReputation(uint32 faction_id) const
Definition: ReputationMgr.cpp:78
uint32 categoryId
Definition: DBCStructure.h:49
struct AchievementCriteriaEntry::@301::@322 cast_spell
struct AchievementCriteriaEntry::@301::@314 death_at_map
struct AchievementCriteriaEntry::@301::@344 hk_class
struct AchievementCriteriaEntry::@301::@304 kill_creature
uint32 areaReference
Definition: DBCStructure.h:290
uint32 creatureEntry
Definition: DBCStructure.h:166
struct AchievementCriteriaEntry::@301::@338 gain_reputation
uint32 skillLine
Definition: DBCStructure.h:432
struct AchievementCriteriaEntry::@301::@311 complete_quests_in_zone
uint32 objectiveId
Definition: DBCStructure.h:208
struct AchievementCriteriaEntry::@301::@361 loot_type
struct AchievementCriteriaEntry::@301::@330 highest_team_rating
struct AchievementCriteriaEntry::@301::@335 explore_area
uint32 bgMapID
Definition: DBCStructure.h:87
struct AchievementCriteriaEntry::@301::@349 equip_item
struct AchievementCriteriaEntry::@301::@321 be_spell_target
struct AchievementCriteriaEntry::@301::@327 learn_spell
uint32 manLimit
Definition: DBCStructure.h:154
uint32 zoneID
Definition: DBCStructure.h:128
struct AchievementCriteriaEntry::@301::@319 death_from
struct AchievementCriteriaEntry::@301::@317 killed_by_creature
uint32 itemID
Definition: DBCStructure.h:241
uint32 mapID
Definition: DBCStructure.h:142
uint32 rollValue
Definition: DBCStructure.h:339
uint32 spellID
Definition: DBCStructure.h:193
struct AchievementCriteriaEntry::@301::@307 reach_skill_level
uint32 groupSize
Definition: DBCStructure.h:160
uint32 goEntry
Definition: DBCStructure.h:410
uint32 emoteID
Definition: DBCStructure.h:367
struct AchievementCriteriaEntry::@301::@354 fish_in_gameobject
uint32 skillID
Definition: DBCStructure.h:101
uint32 lootTypeCount
Definition: DBCStructure.h:471
uint32 type
Definition: DBCStructure.h:179
struct AchievementCriteriaEntry::@301::@316 complete_raid
struct AchievementCriteriaEntry::@301::@331 highest_personal_rating
uint32 classID
Definition: DBCStructure.h:352
struct AchievementCriteriaEntry::@301::@308 complete_achievement
struct AchievementCriteriaEntry::@301::@323 bg_objective
uint32 lootType
Definition: DBCStructure.h:470
struct AchievementCriteriaEntry::@301::@325 win_arena
struct AchievementCriteriaEntry::@301::@343 roll_greed_on_loot
uint32 itemSlot
Definition: DBCStructure.h:332
struct AchievementCriteriaEntry::@301::@305 win_bg
uint32 questID
Definition: DBCStructure.h:185
struct AchievementCriteriaEntry::@301::@346 do_emote
uint32 duelCount
Definition: DBCStructure.h:440
struct AchievementCriteriaEntry::@303 additionalRequirements[MAX_CRITERIA_REQUIREMENTS]
struct AchievementCriteriaEntry::@301::@313 complete_battleground
struct AchievementCriteriaEntry::@301::@352 use_gameobject
struct AchievementCriteriaEntry::@301::@345 hk_race
uint32 raceID
Definition: DBCStructure.h:359
struct AchievementCriteriaEntry::@301::@333 use_item
struct AchievementCriteriaEntry::@301::@355 learn_skillline_spell
uint32 additionalRequirement_value
Definition: DBCStructure.h:504
uint32 linkedAchievement
Definition: DBCStructure.h:108
struct AchievementCriteriaEntry::@301::@362 learn_skill_line
uint32 areaID
Definition: DBCStructure.h:215
uint32 creatureID
Definition: DBCStructure.h:80
uint32 additionalRequirement_type
Definition: DBCStructure.h:503
struct AchievementCriteriaEntry::@301::@315 death_in_dungeon
struct AchievementCriteriaEntry::@301::@320 complete_quest
struct AchievementCriteriaEntry::@301::@332 learn_skill_level
struct AchievementCriteriaEntry::@301::@341 equip_epic_item
uint32 teamtype
Definition: DBCStructure.h:255
uint32 factionID
Definition: DBCStructure.h:310
struct AchievementCriteriaEntry::@301::@356 win_duel
struct AchievementCriteriaEntry::@301::@324 honorable_kill_at_area
struct AchievementCriteriaEntry::@301::@328 own_item
Definition: DBCStructure.h:519
uint32 exploreFlag
Definition: DBCStructure.h:523
Definition: DBCStructure.h:2166
uint32 areatableID[MAX_WORLD_MAP_OVERLAY_AREA_IDX]
Definition: DBCStructure.h:2169

References _completedAchievements, _player, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE, ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID, ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_TYPE_DEATH, ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP, ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON, ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS, ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA, ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN, ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING, ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING, ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS, ACHIEVEMENT_CRITERIA_TYPE_HK_RACE, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL, ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK, ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA, ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED, ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_ROLL_DISENCHANT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_TYPE_TOTAL, ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, ACHIEVEMENT_FLAG_SUMM, achievIdByArenaSlot, achievIdForDungeon, AchievementCriteriaEntry::additionalRequirement_type, AchievementCriteriaEntry::additionalRequirement_value, AchievementCriteriaEntry::additionalRequirements, AchievementCriteriaEntry::areaID, AchievementCriteriaEntry::areaReference, WorldMapOverlayEntry::areatableID, AchievementCriteriaEntry::be_spell_target, AchievementCriteriaEntry::bg_objective, AchievementCriteriaEntry::bgMapID, CanUpdateCriteria(), AchievementCriteriaEntry::cast_spell, CATEGORY_CHILDRENS_WEEK, AchievementEntry::categoryId, AchievementCriteriaEntry::classID, AchievementCriteriaEntry::complete_achievement, AchievementCriteriaEntry::complete_battleground, AchievementCriteriaEntry::complete_quest, AchievementCriteriaEntry::complete_quests_in_zone, AchievementCriteriaEntry::complete_raid, CompletedAchievement(), CompletedCriteriaFor(), AchievementCriteriaEntry::count, AchievementCriteriaEntry::creatureEntry, AchievementCriteriaEntry::creatureID, CriteriaProgress::date, AchievementCriteriaEntry::death_at_map, AchievementCriteriaEntry::death_from, AchievementCriteriaEntry::death_in_dungeon, AchievementCriteriaEntry::do_emote, AchievementCriteriaEntry::duelCount, DUNGEON_DIFFICULTY_NORMAL, AchievementCriteriaEntry::emoteID, AchievementCriteriaEntry::equip_epic_item, AchievementCriteriaEntry::equip_item, AchievementCriteriaEntry::explore_area, AreaTableEntry::exploreFlag, AchievementCriteriaEntry::factionID, AchievementCriteriaEntry::fish_in_gameobject, AchievementEntry::flags, AchievementCriteriaEntry::gain_reputation, Player::GetArenaTeamId(), Battleground::GetArenaType(), Player::GetBattleground(), GetCriteriaProgress(), WorldObject::GetMap(), InstanceMap::GetMaxPlayers(), ArenaTeam::GetMember(), GetPlayer(), ReputationMgr::GetReputation(), Player::GetReputationMgr(), Player::getRewardedQuests(), ArenaTeam::GetSlotByType(), Player::GetSpellMap(), ArenaTeam::GetStats(), GetTeamId(), ArenaTeam::GetType(), Object::GetTypeId(), Object::GetUInt32Value(), Quest::GetZoneOrSort(), AchievementCriteriaEntry::goEntry, AchievementCriteriaEntry::groupSize, HasAchieved(), AchievementCriteriaEntry::highest_personal_rating, AchievementCriteriaEntry::highest_team_rating, AchievementCriteriaEntry::hk_class, AchievementCriteriaEntry::hk_race, AchievementCriteriaEntry::honorable_kill_at_area, AchievementEntry::ID, Battleground::isArena(), IsCompletedAchievement(), IsCompletedCriteria(), Map::IsDungeon(), Player::IsGameMaster(), Object::IsInWorld(), Map::IsRaid(), ITEM_QUALITY_EPIC, AchievementCriteriaEntry::itemID, ItemTemplate::ItemLevel, AchievementCriteriaEntry::itemSlot, AchievementCriteriaEntry::kill_creature, AchievementCriteriaEntry::killed_by_creature, AchievementCriteriaEntry::learn_skill_level, AchievementCriteriaEntry::learn_skill_line, AchievementCriteriaEntry::learn_skillline_spell, AchievementCriteriaEntry::learn_spell, AchievementCriteriaEntry::linkedAchievement, LOG_DEBUG, AchievementCriteriaEntry::loot_type, AchievementCriteriaEntry::lootType, AchievementCriteriaEntry::lootTypeCount, AchievementCriteriaEntry::manLimit, AchievementCriteriaEntry::mapID, MAX_ARENA_SLOT, MAX_WORLD_MAP_OVERLAY_AREA_IDX, AchievementCriteriaDataSet::Meets(), AchievementCriteriaEntry::objectiveId, AchievementCriteriaEntry::own_item, AchievementCriteriaEntry::PersonalRating, PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE, PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, PROGRESS_ACCUMULATE, PROGRESS_HIGHEST, PROGRESS_RESET, PROGRESS_SET, ItemTemplate::Quality, AchievementCriteriaEntry::questID, AchievementCriteriaEntry::raceID, ArenaTeamStats::Rating, AchievementCriteriaEntry::reach_skill_level, AchievementCriteriaEntry::referredAchievement, AchievementCriteriaEntry::roll_greed_on_loot, AchievementCriteriaEntry::rollValue, sAchievementMgr, sAchievementStore, sAreaTableStore, sArenaTeamMgr, SetCriteriaProgress(), AchievementCriteriaEntry::skillID, AchievementCriteriaEntry::skillLine, sMapMgr, sObjectMgr, AchievementCriteriaEntry::spellID, sScriptMgr, sSpellMgr, sWorld, sWorldMapOverlayStore, AchievementCriteriaEntry::teamtype, Map::ToInstanceMap(), AchievementCriteriaEntry::type, TYPEID_PLAYER, AchievementCriteriaEntry::use_gameobject, AchievementCriteriaEntry::use_item, AchievementCriteriaEntry::win_arena, AchievementCriteriaEntry::win_bg, AchievementCriteriaEntry::win_duel, and AchievementCriteriaEntry::zoneID.

Referenced by CheckAllAchievementCriteria(), CompletedAchievement(), and Player::UpdateAchievementCriteria().

◆ UpdateTimedAchievements()

void AchievementMgr::UpdateTimedAchievements ( uint32  timeDiff)
2162{
2163 if (!_timedAchievements.empty())
2164 {
2165 for (TimedAchievementMap::iterator itr = _timedAchievements.begin(); itr != _timedAchievements.end();)
2166 {
2167 // Time is up, remove timer and reset progress
2168 if (itr->second <= timeDiff)
2169 {
2170 AchievementCriteriaEntry const* entry = sAchievementCriteriaStore.LookupEntry(itr->first);
2172 _timedAchievements.erase(itr++);
2173 }
2174 else
2175 {
2176 itr->second -= timeDiff;
2177 ++itr;
2178 }
2179 }
2180 }
2181}

References _timedAchievements, RemoveCriteriaProgress(), and sAchievementCriteriaStore.

Referenced by Player::Update().

Member Data Documentation

◆ _completedAchievements

◆ _criteriaProgress

◆ _player

◆ _timedAchievements