AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AchievementCriteriaData Struct Reference

#include "AchievementMgr.h"

Public Member Functions

 AchievementCriteriaData ()
 
 AchievementCriteriaData (uint32 _dataType, uint32 _value1, uint32 _value2, uint32 _scriptId)
 
bool IsValid (AchievementCriteriaEntry const *criteria)
 
bool Meets (uint32 criteria_id, Player const *source, Unit const *target, uint32 miscvalue1=0) const
 

Public Attributes

AchievementCriteriaDataType dataType {ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE}
 
union {
   struct {
      uint32   id
 
   }   creature
 
   struct {
      uint32   class_id
 
      uint32   race_id
 
   }   classRace
 
   struct {
      uint32   percent
 
   }   health
 
   struct {
      uint32   own_team_flag
 
   }   player_dead
 
   struct {
      uint32   spell_id
 
      uint32   effect_idx
 
   }   aura
 
   struct {
      uint32   id
 
   }   area
 
   struct {
      uint32   value
 
      uint32   compType
 
   }   value
 
   struct {
      uint32   minlevel
 
   }   level
 
   struct {
      uint32   gender
 
   }   gender
 
   struct {
      uint32   difficulty
 
   }   difficulty
 
   struct {
      uint32   maxcount
 
   }   map_players
 
   struct {
      uint32   team
 
   }   team
 
   struct {
      uint32   state
 
   }   drunk
 
   struct {
      uint32   id
 
   }   holiday
 
   struct {
      uint32   min_score
 
      uint32   max_score
 
   }   bg_loss_team_score
 
   struct {
      uint32   item_level
 
      uint32   item_quality
 
   }   equipped_item
 
   struct {
      uint32   mapId
 
   }   map_id
 
   struct {
      uint32   nth_birthday
 
   }   birthday_login
 
   struct {
      uint32   title_id
 
   }   known_title
 
   struct {
      uint32   winner_score
 
      uint32   loser_score
 
   }   teams_scores
 
   struct {
      uint32   item_quality
 
   }   item
 
   struct {
      uint32   value1
 
      uint32   value2
 
   }   raw
 
}; 
 
uint32 ScriptId
 

Detailed Description

Constructor & Destructor Documentation

◆ AchievementCriteriaData() [1/2]

AchievementCriteriaData::AchievementCriteriaData ( )
inline
228 {
229 raw.value1 = 0;
230 raw.value2 = 0;
231 ScriptId = 0;
232 }
uint32 ScriptId
Definition: AchievementMgr.h:225
struct AchievementCriteriaData::@6::@29 raw

References raw, and ScriptId.

◆ AchievementCriteriaData() [2/2]

AchievementCriteriaData::AchievementCriteriaData ( uint32  _dataType,
uint32  _value1,
uint32  _value2,
uint32  _scriptId 
)
inline
235 {
236 raw.value1 = _value1;
237 raw.value2 = _value2;
238 ScriptId = _scriptId;
239 }
AchievementCriteriaDataType
Definition: AchievementMgr.h:57
AchievementCriteriaDataType dataType
Definition: AchievementMgr.h:99

References raw, and ScriptId.

Member Function Documentation

◆ IsValid()

bool AchievementCriteriaData::IsValid ( AchievementCriteriaEntry const *  criteria)
49{
51 {
52 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` for criteria (Entry: {}) has wrong data type ({}), ignored.", criteria->ID, dataType);
53 return false;
54 }
55
56 switch (criteria->requiredType)
57 {
62 case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST: // only hardcoded list
78 case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST: // only Children's Week achievements
79 case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM: // only Children's Week achievements
86 break;
87 default:
89 {
90 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` has data for non-supported criteria type (Entry: {} Type: {}), ignored.", criteria->ID, criteria->requiredType);
91 return false;
92 }
93 break;
94 }
95
96 switch (dataType)
97 {
101 return true;
103 if (!creature.id || !sObjectMgr->GetCreatureTemplate(creature.id))
104 {
105 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_CREATURE ({}) has non-existing creature id in value1 ({}), ignored.",
106 criteria->ID, criteria->requiredType, dataType, creature.id);
107 return false;
108 }
109 return true;
111 if (classRace.class_id && ((1 << (classRace.class_id - 1)) & CLASSMASK_ALL_PLAYABLE) == 0)
112 {
113 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE ({}) has non-existing class in value1 ({}), ignored.",
114 criteria->ID, criteria->requiredType, dataType, classRace.class_id);
115 return false;
116 }
117 if (classRace.race_id && ((1 << (classRace.race_id - 1)) & RACEMASK_ALL_PLAYABLE) == 0)
118 {
119 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE ({}) has non-existing race in value2 ({}), ignored.",
120 criteria->ID, criteria->requiredType, dataType, classRace.race_id);
121 return false;
122 }
123 return true;
125 if (health.percent < 1 || health.percent > 100)
126 {
127 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_PLAYER_LESS_HEALTH ({}) has wrong percent value in value1 ({}), ignored.",
128 criteria->ID, criteria->requiredType, dataType, health.percent);
129 return false;
130 }
131 return true;
133 if (player_dead.own_team_flag > 1)
134 {
135 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD ({}) has wrong boolean value1 ({}).",
136 criteria->ID, criteria->requiredType, dataType, player_dead.own_team_flag);
137 return false;
138 }
139 return true;
142 {
143 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(aura.spell_id);
144 if (!spellInfo)
145 {
146 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type {} ({}) has wrong spell id in value1 ({}), ignored.",
147 criteria->ID, criteria->requiredType, (dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA ? "ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA" : "ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"), dataType, aura.spell_id);
148 return false;
149 }
150 if (aura.effect_idx >= 3)
151 {
152 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type {} ({}) has wrong spell effect index in value2 ({}), ignored.",
153 criteria->ID, criteria->requiredType, (dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA ? "ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA" : "ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"), dataType, aura.effect_idx);
154 return false;
155 }
156 if (!spellInfo->Effects[aura.effect_idx].ApplyAuraName)
157 {
158 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type {} ({}) has non-aura spell effect (ID: {} Effect: {}), ignores.",
159 criteria->ID, criteria->requiredType, (dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA ? "ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA" : "ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"), dataType, aura.spell_id, aura.effect_idx);
160 return false;
161 }
162 return true;
163 }
165 if (!sAreaTableStore.LookupEntry(area.id))
166 {
167 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA ({}) has wrong area id in value1 ({}), ignored.",
168 criteria->ID, criteria->requiredType, dataType, area.id);
169 return false;
170 }
171 return true;
173 if (value.compType >= COMP_TYPE_MAX)
174 {
175 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE ({}) has wrong ComparisionType in value2 ({}), ignored.",
176 value.compType, criteria->requiredType, dataType, value.value);
177 return false;
178 }
179 return true;
181 if (level.minlevel > STRONG_MAX_LEVEL)
182 {
183 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL ({}) has wrong minlevel in value1 ({}), ignored.",
184 criteria->ID, criteria->requiredType, dataType, level.minlevel);
185 return false;
186 }
187 return true;
189 if (gender.gender > GENDER_NONE)
190 {
191 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER ({}) has wrong gender in value1 ({}), ignored.",
192 criteria->ID, criteria->requiredType, dataType, gender.gender);
193 return false;
194 }
195 return true;
197 if (!ScriptId)
198 {
199 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT ({}) does not have ScriptName set, ignored.",
200 criteria->ID, criteria->requiredType, dataType);
201 return false;
202 }
203 return true;
205 if (difficulty.difficulty >= MAX_DIFFICULTY)
206 {
207 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY ({}) has wrong difficulty in value1 ({}), ignored.",
208 criteria->ID, criteria->requiredType, dataType, difficulty.difficulty);
209 return false;
210 }
211 return true;
213 if (map_players.maxcount <= 0)
214 {
215 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT ({}) has wrong max players count in value1 ({}), ignored.",
216 criteria->ID, criteria->requiredType, dataType, map_players.maxcount);
217 return false;
218 }
219 return true;
221 if (team.team != ALLIANCE && team.team != HORDE)
222 {
223 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM ({}) has unknown team in value1 ({}), ignored.",
224 criteria->ID, criteria->requiredType, dataType, team.team);
225 return false;
226 }
227 return true;
229 if (drunk.state >= MAX_DRUNKEN)
230 {
231 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK ({}) has unknown drunken state in value1 ({}), ignored.",
232 criteria->ID, criteria->requiredType, dataType, drunk.state);
233 return false;
234 }
235 return true;
237 if (!sHolidaysStore.LookupEntry(holiday.id))
238 {
239 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY ({}) has unknown holiday in value1 ({}), ignored.",
240 criteria->ID, criteria->requiredType, dataType, holiday.id);
241 return false;
242 }
243 return true;
246 return true; // not check correctness node indexes
249 if (equipped_item.item_quality >= MAX_ITEM_QUALITY)
250 {
251 LOG_ERROR("sql.sql", "Table `achievement_criteria_requirement` (Entry: {} Type: {}) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_EQUIPPED_ITEM ({}) has unknown quality state in value1 ({}), ignored.",
252 criteria->ID, criteria->requiredType, dataType, equipped_item.item_quality);
253 return false;
254 }
255 return true;
257 if (!sMapStore.LookupEntry(map_id.mapId))
258 {
259 LOG_ERROR("sql.sql", "Table `achievement_criteria_requirement` (Entry: {} Type: {}) for requirement ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_ID ({}) has unknown map id in value1 ({}), ignored.",
260 criteria->ID, criteria->requiredType, dataType, map_id.mapId);
261 return false;
262 }
263 return true;
265 if (!classRace.class_id && !classRace.race_id)
266 {
267 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE ({}) must not have 0 in either value field, ignored.",
268 criteria->ID, criteria->requiredType, dataType);
269 return false;
270 }
271 if (classRace.class_id && ((1 << (classRace.class_id - 1)) & CLASSMASK_ALL_PLAYABLE) == 0)
272 {
273 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE ({}) has non-existing class in value1 ({}), ignored.",
274 criteria->ID, criteria->requiredType, dataType, classRace.class_id);
275 return false;
276 }
277 if (classRace.race_id && ((1 << (classRace.race_id - 1)) & RACEMASK_ALL_PLAYABLE) == 0)
278 {
279 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE ({}) has non-existing race in value2 ({}), ignored.",
280 criteria->ID, criteria->requiredType, dataType, classRace.race_id);
281 return false;
282 }
283 return true;
285 {
286 if (!sCharTitlesStore.LookupEntry(known_title.title_id))
287 {
288 LOG_ERROR("sql.sql", "Table `achievement_criteria_requirement` (Entry: {} Type: {}) for requirement ACHIEVEMENT_CRITERIA_DATA_TYPE_S_KNOWN_TITLE ({}) have unknown title_id in value1 ({}), ignore.",
289 criteria->ID, criteria->requiredType, dataType, known_title.title_id);
290 return false;
291 }
292 return true;
293 }
294 default:
295 LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) has data for non-supported data type ({}), ignored.", criteria->ID, criteria->requiredType, dataType);
296 return false;
297 }
298}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
@ COMP_TYPE_MAX
Definition: Util.h:593
#define MAX_DIFFICULTY
Definition: DBCEnums.h:283
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE
Definition: DBCEnums.h:216
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2
Definition: DBCEnums.h:181
@ ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM
Definition: DBCEnums.h:155
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET
Definition: DBCEnums.h:142
@ ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING
Definition: DBCEnums.h:139
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL
Definition: DBCEnums.h:143
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST
Definition: DBCEnums.h:131
@ ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK
Definition: DBCEnums.h:158
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT
Definition: DBCEnums.h:165
@ ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE
Definition: DBCEnums.h:168
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL
Definition: DBCEnums.h:124
@ ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE
Definition: DBCEnums.h:188
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM
Definition: DBCEnums.h:198
@ ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL
Definition: DBCEnums.h:149
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2
Definition: DBCEnums.h:217
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST
Definition: DBCEnums.h:141
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
Definition: DBCEnums.h:151
@ ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM
Definition: DBCEnums.h:163
@ ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE
Definition: DBCEnums.h:122
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL
Definition: DBCEnums.h:186
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_BG
Definition: DBCEnums.h:123
@ ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL
Definition: DBCEnums.h:182
@ ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE
Definition: DBCEnums.h:144
@ ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS
Definition: DBCEnums.h:170
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA
Definition: DBCEnums.h:146
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT
Definition: DBCEnums.h:164
@ ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM
Definition: DBCEnums.h:199
@ ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN
Definition: DBCEnums.h:184
#define STRONG_MAX_LEVEL
Definition: DBCEnums.h:43
@ GENDER_NONE
Definition: SharedDefines.h:63
#define MAX_ITEM_QUALITY
Definition: SharedDefines.h:339
@ ALLIANCE
Definition: SharedDefines.h:768
@ HORDE
Definition: SharedDefines.h:767
#define CLASSMASK_ALL_PLAYABLE
Definition: SharedDefines.h:157
#define RACEMASK_ALL_PLAYABLE
Definition: SharedDefines.h:97
#define sObjectMgr
Definition: ObjectMgr.h:1635
#define sSpellMgr
Definition: SpellMgr.h:825
#define MAX_DRUNKEN
Definition: Player.h:475
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
DBCStorage< HolidaysEntry > sHolidaysStore(Holidaysfmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_NTH_BIRTHDAY
Definition: AchievementMgr.h:81
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT
Definition: AchievementMgr.h:70
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT
Definition: AchievementMgr.h:72
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER
Definition: AchievementMgr.h:69
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_S_KNOWN_TITLE
Definition: AchievementMgr.h:82
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA
Definition: AchievementMgr.h:65
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE
Definition: AchievementMgr.h:61
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE
Definition: AchievementMgr.h:67
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY
Definition: AchievementMgr.h:71
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_S_EQUIPPED_ITEM
Definition: AchievementMgr.h:78
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK
Definition: AchievementMgr.h:74
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_ID
Definition: AchievementMgr.h:79
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA
Definition: AchievementMgr.h:64
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY
Definition: AchievementMgr.h:75
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA
Definition: AchievementMgr.h:66
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE
Definition: AchievementMgr.h:80
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE
Definition: AchievementMgr.h:76
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL
Definition: AchievementMgr.h:68
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE
Definition: AchievementMgr.h:60
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH
Definition: AchievementMgr.h:62
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM
Definition: AchievementMgr.h:73
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_INSTANCE_SCRIPT
Definition: AchievementMgr.h:77
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD
Definition: AchievementMgr.h:63
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE
Definition: AchievementMgr.h:59
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_S_ITEM_QUALITY
Definition: AchievementMgr.h:84
@ ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_TEAMS_SCORES
Definition: AchievementMgr.h:83
#define MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE
Definition: AchievementMgr.h:86
struct AchievementCriteriaData::@6::@11 player_dead
struct AchievementCriteriaData::@6::@15 level
struct AchievementCriteriaData::@6::@23 equipped_item
uint32 team
Definition: AchievementMgr.h:167
struct AchievementCriteriaData::@6::@26 known_title
uint32 value
Definition: AchievementMgr.h:140
uint32 difficulty
Definition: AchievementMgr.h:157
struct AchievementCriteriaData::@6::@12 aura
struct AchievementCriteriaData::@6::@8 creature
struct AchievementCriteriaData::@6::@9 classRace
struct AchievementCriteriaData::@6::@13 area
struct AchievementCriteriaData::@6::@20 drunk
struct AchievementCriteriaData::@6::@21 holiday
struct AchievementCriteriaData::@6::@10 health
struct AchievementCriteriaData::@6::@18 map_players
uint32 gender
Definition: AchievementMgr.h:151
Definition: SpellInfo.h:316
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393
Definition: System.cpp:62

References ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE, ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_TEAMS_SCORES, ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY, ACHIEVEMENT_CRITERIA_DATA_TYPE_INSTANCE_SCRIPT, ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY, ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_ID, ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT, ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE, ACHIEVEMENT_CRITERIA_DATA_TYPE_NTH_BIRTHDAY, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_EQUIPPED_ITEM, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_ITEM_QUALITY, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_KNOWN_TITLE, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE, ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM, ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE, ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK, ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ALLIANCE, area, aura, CLASSMASK_ALL_PLAYABLE, classRace, COMP_TYPE_MAX, creature, dataType, difficulty, drunk, SpellInfo::Effects, equipped_item, gender, GENDER_NONE, health, holiday, HORDE, AchievementCriteriaEntry::ID, known_title, level, LOG_ERROR, map_players, MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE, MAX_DIFFICULTY, MAX_DRUNKEN, MAX_ITEM_QUALITY, player_dead, RACEMASK_ALL_PLAYABLE, AchievementCriteriaEntry::requiredType, sAreaTableStore, sCharTitlesStore, ScriptId, sHolidaysStore, sMapStore, sObjectMgr, sSpellMgr, STRONG_MAX_LEVEL, team, and value.

Referenced by AchievementGlobalMgr::LoadAchievementCriteriaData().

◆ Meets()

bool AchievementCriteriaData::Meets ( uint32  criteria_id,
Player const *  source,
Unit const *  target,
uint32  miscvalue1 = 0 
) const
301{
302 switch (dataType)
303 {
305 return true;
307 if (!target || !target->IsCreature())
308 return false;
309 return target->GetEntry() == creature.id;
311 if (!target || !target->IsPlayer())
312 return false;
313 if (classRace.class_id && classRace.class_id != target->ToPlayer()->getClass())
314 return false;
315 if (classRace.race_id && classRace.race_id != target->ToPlayer()->getRace())
316 return false;
317 return true;
319 if (!source || !source->IsPlayer())
320 return false;
321 if (classRace.class_id && classRace.class_id != source->ToPlayer()->getClass())
322 return false;
323 if (classRace.race_id && classRace.race_id != source->ToPlayer()->getRace())
324 return false;
325 return true;
327 if (!target || !target->IsPlayer())
328 return false;
329 return !target->HealthAbovePct(health.percent);
331 if (target && !target->IsAlive())
332 if (Player const* player = target->ToPlayer())
333 if (player->GetDeathTimer() != 0)
334 // flag set == must be same team, not set == different team
335 return (player->GetTeamId() == source->GetTeamId()) == (player_dead.own_team_flag != 0);
336 return false;
338 return source->HasAuraEffect(aura.spell_id, aura.effect_idx);
340 {
341 uint32 zone_id, area_id;
342 source->GetZoneAndAreaId(zone_id, area_id);
343 return area.id == zone_id || area.id == area_id;
344 }
346 return target && target->HasAuraEffect(aura.spell_id, aura.effect_idx);
348 return CompareValues(ComparisionType(value.compType), miscvalue1, value.value);
350 if (!target)
351 return false;
352 return target->GetLevel() >= level.minlevel;
354 if (!target)
355 return false;
356 return target->getGender() == gender.gender;
358 return sScriptMgr->OnCriteriaCheck(ScriptId, const_cast<Player*>(source), const_cast<Unit*>(target), criteria_id);
360 {
361 if (source->GetMap()->IsRaid())
362 if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0))
363 return false;
364
365 AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(criteria_id);
366 uint8 spawnMode = source->GetMap()->GetSpawnMode();
367 // Dungeons completed on heroic mode count towards both in general achievement, but not in statistics.
368 return sAchievementMgr->IsStatisticCriteria(criteria) ? spawnMode == difficulty.difficulty : spawnMode >= difficulty.difficulty;
369 }
371 return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount;
373 {
374 if (!target || !target->IsPlayer())
375 return false;
376
377 // DB data compatibility...
378 uint32 teamOld = target->ToPlayer()->GetTeamId() == TEAM_ALLIANCE ? ALLIANCE : HORDE;
379 return teamOld == team.team;
380 }
382 return Player::GetDrunkenstateByValue(source->GetDrunkValue()) >= DrunkenState(drunk.state);
386 {
387 Battleground* bg = source->GetBattleground();
388 if (!bg)
389 return false;
390
391 uint32 score = bg->GetTeamScore(source->GetTeamId() == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE);
392 return score >= bg_loss_team_score.min_score && score <= bg_loss_team_score.max_score;
393 }
395 {
396 if (!source->IsInWorld())
397 return false;
398 Map* map = source->GetMap();
399 if (!map->IsDungeon())
400 {
401 LOG_ERROR("sql.sql", "Achievement system call ACHIEVEMENT_CRITERIA_DATA_TYPE_INSTANCE_SCRIPT ({}) for achievement criteria {} for non-dungeon/non-raid map {}",
403 return false;
404 }
405 InstanceScript* instance = map->ToInstanceMap()->GetInstanceScript();
406 if (!instance)
407 {
408 LOG_ERROR("sql.sql", "Achievement system call ACHIEVEMENT_CRITERIA_DATA_TYPE_INSTANCE_SCRIPT ({}) for achievement criteria {} for map {} but map does not have a instance script",
410 return false;
411 }
412 return instance->CheckAchievementCriteriaMeet(criteria_id, source, target, miscvalue1);
413 }
415 {
416 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(miscvalue1);
417 if (!pProto)
418 return false;
419 return pProto->ItemLevel >= equipped_item.item_level && pProto->Quality >= equipped_item.item_quality;
420 }
422 return source->GetMapId() == map_id.mapId;
424 {
425 tm birthday_tm = Acore::Time::TimeBreakdown(sWorld->getIntConfig(CONFIG_BIRTHDAY_TIME));
426
427 // exactly N birthday
428 birthday_tm.tm_year += birthday_login.nth_birthday;
429
430 time_t birthday = mktime(&birthday_tm);
431 time_t now = GameTime::GetGameTime().count();
432 return now <= birthday + DAY && now >= birthday;
433 }
435 {
436 if (CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(known_title.title_id))
437 return source && source->HasTitle(titleInfo->bit_index);
438
439 return false;
440 }
442 {
443 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(miscvalue1);
444 if (!pProto)
445 return false;
446 return pProto->Quality == item.item_quality;
447 }
449 {
450 Battleground* bg = source->GetBattleground();
451 if (!bg)
452 {
453 return false;
454 }
455
456 TeamId winnerTeam = GetTeamId(bg->GetWinner());
457 if (winnerTeam == TEAM_NEUTRAL)
458 {
459 return false;
460 }
461
462 uint32 winnnerScore = bg->GetTeamScore(winnerTeam);
463 uint32 loserScore = bg->GetTeamScore(TeamId(!uint32(winnerTeam)));
464 return source->GetTeamId() == winnerTeam && winnnerScore == teams_scores.winner_score && loserScore == teams_scores.loser_score;
465 }
466 default:
467 break;
468 }
469 return false;
470}
bool CompareValues(ComparisionType type, T val1, T val2)
Definition: Util.h:597
ComparisionType
Definition: Util.h:587
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
#define RAID_DIFFICULTY_MASK_25MAN
Definition: DBCEnums.h:279
TeamId GetTeamId(PvPTeamId teamId)
Definition: SharedDefines.h:3462
TeamId
Definition: SharedDefines.h:759
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
HolidayIds
Definition: SharedDefines.h:2741
bool IsHolidayActive(HolidayIds id)
Definition: GameEventMgr.cpp:1909
@ CONFIG_BIRTHDAY_TIME
Definition: IWorld.h:381
DrunkenState
Definition: Player.h:468
DBCStorage< AchievementCriteriaEntry > sAchievementCriteriaStore(AchievementCriteriafmt)
#define sScriptMgr
Definition: ScriptMgr.h:709
#define sAchievementMgr
Definition: AchievementMgr.h:451
#define sWorld
Definition: World.h:443
AC_COMMON_API std::tm TimeBreakdown(time_t t=0)
Definition: Timer.cpp:233
Seconds GetGameTime()
Definition: GameTime.cpp:38
struct AchievementCriteriaData::@6::@28 item
struct AchievementCriteriaData::@6::@27 teams_scores
struct AchievementCriteriaData::@6::@22 bg_loss_team_score
struct AchievementCriteriaData::@6::@25 birthday_login
Definition: Battleground.h:303
uint32 GetTeamScore(TeamId teamId) const
Definition: Battleground.cpp:1837
PvPTeamId GetWinner() const
Definition: Battleground.h:358
Definition: ItemTemplate.h:619
uint32 Quality
Definition: ItemTemplate.h:626
uint32 ItemLevel
Definition: ItemTemplate.h:635
Player * ToPlayer()
Definition: Object.h:201
Definition: Player.h:1081
static DrunkenState GetDrunkenstateByValue(uint8 value)
Definition: Player.cpp:961
Definition: Unit.h:630
Definition: InstanceScript.h:142
virtual bool CheckAchievementCriteriaMeet(uint32, Player const *, Unit const *=nullptr, uint32=0)
Definition: InstanceScript.cpp:713
Definition: Map.h:311
bool IsDungeon() const
Definition: Map.h:446
uint32 GetId() const
Definition: Map.h:377
InstanceMap * ToInstanceMap()
Definition: Map.h:544
InstanceScript * GetInstanceScript()
Definition: Map.h:829
Definition: DBCStructure.h:69
Definition: DBCStructure.h:631

References ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE, ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_TEAMS_SCORES, ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY, ACHIEVEMENT_CRITERIA_DATA_TYPE_INSTANCE_SCRIPT, ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY, ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_ID, ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT, ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE, ACHIEVEMENT_CRITERIA_DATA_TYPE_NTH_BIRTHDAY, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_EQUIPPED_ITEM, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_ITEM_QUALITY, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_KNOWN_TITLE, ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE, ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH, ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM, ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE, ALLIANCE, area, aura, bg_loss_team_score, birthday_login, InstanceScript::CheckAchievementCriteriaMeet(), classRace, CompareValues(), CONFIG_BIRTHDAY_TIME, creature, dataType, difficulty, drunk, equipped_item, gender, Player::GetBattleground(), Unit::getClass(), Player::GetDrunkenstateByValue(), Player::GetDrunkValue(), Object::GetEntry(), GameTime::GetGameTime(), Unit::getGender(), Map::GetId(), InstanceMap::GetInstanceScript(), Unit::GetLevel(), WorldObject::GetMap(), WorldLocation::GetMapId(), Map::GetPlayersCountExceptGMs(), Unit::getRace(), Map::GetSpawnMode(), Player::GetTeamId(), GetTeamId(), Battleground::GetTeamScore(), Battleground::GetWinner(), WorldObject::GetZoneAndAreaId(), Unit::HasAuraEffect(), Player::HasTitle(), health, Unit::HealthAbovePct(), holiday, HORDE, Map::Is25ManRaid(), Unit::IsAlive(), Object::IsCreature(), Map::IsDungeon(), IsHolidayActive(), Object::IsInWorld(), Object::IsPlayer(), Map::IsRaid(), item, ItemTemplate::ItemLevel, known_title, level, LOG_ERROR, map_players, player_dead, ItemTemplate::Quality, RAID_DIFFICULTY_MASK_25MAN, sAchievementCriteriaStore, sAchievementMgr, sCharTitlesStore, ScriptId, sObjectMgr, sScriptMgr, sWorld, team, TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, teams_scores, Acore::Time::TimeBreakdown(), Map::ToInstanceMap(), Object::ToPlayer(), and value.

Member Data Documentation

◆ 

union { ... } AchievementCriteriaData::@7

◆ 

struct { ... } AchievementCriteriaData::area

Referenced by IsValid(), and Meets().

◆ 

struct { ... } AchievementCriteriaData::aura

Referenced by IsValid(), and Meets().

◆ 

struct { ... } AchievementCriteriaData::bg_loss_team_score

Referenced by Meets().

◆ 

struct { ... } AchievementCriteriaData::birthday_login

Referenced by Meets().

◆ class_id

uint32 AchievementCriteriaData::class_id

◆ 

struct { ... } AchievementCriteriaData::classRace

Referenced by IsValid(), and Meets().

◆ compType

uint32 AchievementCriteriaData::compType

◆ 

struct { ... } AchievementCriteriaData::creature

Referenced by IsValid(), and Meets().

◆ dataType

◆ difficulty [1/2]

uint32 AchievementCriteriaData::difficulty

Referenced by IsValid(), and Meets().

◆  [2/2]

struct { ... } AchievementCriteriaData::difficulty

◆ 

struct { ... } AchievementCriteriaData::drunk

Referenced by IsValid(), and Meets().

◆ effect_idx

uint32 AchievementCriteriaData::effect_idx

◆ 

struct { ... } AchievementCriteriaData::equipped_item

Referenced by IsValid(), and Meets().

◆ gender [1/2]

uint32 AchievementCriteriaData::gender

Referenced by IsValid(), and Meets().

◆  [2/2]

struct { ... } AchievementCriteriaData::gender

◆ 

struct { ... } AchievementCriteriaData::health

Referenced by IsValid(), and Meets().

◆ 

struct { ... } AchievementCriteriaData::holiday

Referenced by IsValid(), and Meets().

◆ id

uint32 AchievementCriteriaData::id

◆ 

struct { ... } AchievementCriteriaData::item

Referenced by Meets().

◆ item_level

uint32 AchievementCriteriaData::item_level

◆ item_quality

uint32 AchievementCriteriaData::item_quality

◆ 

struct { ... } AchievementCriteriaData::known_title

Referenced by IsValid(), and Meets().

◆ 

struct { ... } AchievementCriteriaData::level

Referenced by IsValid(), and Meets().

◆ loser_score

uint32 AchievementCriteriaData::loser_score

◆ 

struct { ... } AchievementCriteriaData::map_id

◆ 

struct { ... } AchievementCriteriaData::map_players

Referenced by IsValid(), and Meets().

◆ mapId

uint32 AchievementCriteriaData::mapId

◆ max_score

uint32 AchievementCriteriaData::max_score

◆ maxcount

uint32 AchievementCriteriaData::maxcount

◆ min_score

uint32 AchievementCriteriaData::min_score

◆ minlevel

uint32 AchievementCriteriaData::minlevel

◆ nth_birthday

uint32 AchievementCriteriaData::nth_birthday

◆ own_team_flag

uint32 AchievementCriteriaData::own_team_flag

◆ percent

uint32 AchievementCriteriaData::percent

◆ 

struct { ... } AchievementCriteriaData::player_dead

Referenced by IsValid(), and Meets().

◆ race_id

uint32 AchievementCriteriaData::race_id

◆ 

struct { ... } AchievementCriteriaData::raw

Referenced by AchievementCriteriaData().

◆ ScriptId

uint32 AchievementCriteriaData::ScriptId

◆ spell_id

uint32 AchievementCriteriaData::spell_id

◆ state

uint32 AchievementCriteriaData::state

◆ team [1/2]

uint32 AchievementCriteriaData::team

Referenced by IsValid(), and Meets().

◆  [2/2]

struct { ... } AchievementCriteriaData::team

◆ 

struct { ... } AchievementCriteriaData::teams_scores

Referenced by Meets().

◆ title_id

uint32 AchievementCriteriaData::title_id

◆ value [1/2]

uint32 AchievementCriteriaData::value

Referenced by IsValid(), and Meets().

◆  [2/2]

struct { ... } AchievementCriteriaData::value

◆ value1

uint32 AchievementCriteriaData::value1

◆ value2

uint32 AchievementCriteriaData::value2

◆ winner_score

uint32 AchievementCriteriaData::winner_score