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

#include "ConditionMgr.h"

Public Member Functions

 Condition ()
 
bool Meets (ConditionSourceInfo &sourceInfo)
 
uint32 GetSearcherTypeMaskForCondition ()
 
bool isLoaded () const
 
uint32 GetMaxAvailableConditionTargets ()
 

Public Attributes

ConditionSourceType SourceType
 
uint32 SourceGroup
 
int32 SourceEntry
 
uint32 SourceId
 
uint32 ElseGroup
 
ConditionTypes ConditionType
 
uint32 ConditionValue1
 
uint32 ConditionValue2
 
uint32 ConditionValue3
 
uint32 ErrorType
 
uint32 ErrorTextId
 
uint32 ReferenceId
 
uint32 ScriptId
 
uint8 ConditionTarget
 
bool NegativeCondition
 

Detailed Description

Constructor & Destructor Documentation

◆ Condition()

Condition::Condition ( )
inline
212 {
214 SourceGroup = 0;
215 SourceEntry = 0;
216 SourceId = 0;
217 ElseGroup = 0;
219 ConditionTarget = 0;
220 ConditionValue1 = 0;
221 ConditionValue2 = 0;
222 ConditionValue3 = 0;
223 ReferenceId = 0;
224 ErrorType = 0;
225 ErrorTextId = 0;
226 ScriptId = 0;
227 NegativeCondition = false;
228 }
@ CONDITION_SOURCE_TYPE_NONE
Definition: ConditionMgr.h:122
@ CONDITION_NONE
Definition: ConditionMgr.h:35
uint32 SourceGroup
Definition: ConditionMgr.h:196
ConditionTypes ConditionType
Definition: ConditionMgr.h:200
uint32 ErrorType
Definition: ConditionMgr.h:204
uint32 SourceId
Definition: ConditionMgr.h:198
int32 SourceEntry
Definition: ConditionMgr.h:197
uint32 ElseGroup
Definition: ConditionMgr.h:199
uint32 ScriptId
Definition: ConditionMgr.h:207
bool NegativeCondition
Definition: ConditionMgr.h:209
ConditionSourceType SourceType
Definition: ConditionMgr.h:195
uint32 ConditionValue2
Definition: ConditionMgr.h:202
uint8 ConditionTarget
Definition: ConditionMgr.h:208
uint32 ReferenceId
Definition: ConditionMgr.h:206
uint32 ErrorTextId
Definition: ConditionMgr.h:205
uint32 ConditionValue3
Definition: ConditionMgr.h:203
uint32 ConditionValue1
Definition: ConditionMgr.h:201

References CONDITION_NONE, CONDITION_SOURCE_TYPE_NONE, ConditionTarget, ConditionType, ConditionValue1, ConditionValue2, ConditionValue3, ElseGroup, ErrorTextId, ErrorType, NegativeCondition, ReferenceId, ScriptId, SourceEntry, SourceGroup, SourceId, and SourceType.

Member Function Documentation

◆ GetMaxAvailableConditionTargets()

uint32 Condition::GetMaxAvailableConditionTargets ( )
781{
782 // returns number of targets which are available for given source type
783 switch (SourceType)
784 {
786 return 3;
797 return 2;
798 default:
799 break;
800 }
801
802 return 1;
803}
@ CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY
Definition: ConditionMgr.h:152
@ CONDITION_SOURCE_TYPE_VEHICLE_SPELL
Definition: ConditionMgr.h:143
@ CONDITION_SOURCE_TYPE_NPC_VENDOR
Definition: ConditionMgr.h:145
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION
Definition: ConditionMgr.h:137
@ CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT
Definition: ConditionMgr.h:140
@ CONDITION_SOURCE_TYPE_SMART_EVENT
Definition: ConditionMgr.h:144
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU
Definition: ConditionMgr.h:136
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition: ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET
Definition: ConditionMgr.h:135
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition: ConditionMgr.h:146

References CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY, CONDITION_SOURCE_TYPE_GOSSIP_MENU, CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION, CONDITION_SOURCE_TYPE_NPC_VENDOR, CONDITION_SOURCE_TYPE_SMART_EVENT, CONDITION_SOURCE_TYPE_SPELL, CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT, CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET, CONDITION_SOURCE_TYPE_SPELL_PROC, CONDITION_SOURCE_TYPE_VEHICLE_SPELL, and SourceType.

Referenced by ConditionMgr::isConditionTypeValid().

◆ GetSearcherTypeMaskForCondition()

uint32 Condition::GetSearcherTypeMaskForCondition ( )
589{
590 // build mask of types for which condition can return true
591 // this is used for speeding up gridsearches
593 return (GRID_MAP_TYPE_MASK_ALL);
594 uint32 mask = 0;
595 switch (ConditionType)
596 {
597 case CONDITION_NONE:
599 break;
600 case CONDITION_AURA:
602 break;
603 case CONDITION_ITEM:
605 break;
608 break;
609 case CONDITION_ZONEID:
611 break;
614 break;
617 break;
618 case CONDITION_TEAM:
620 break;
621 case CONDITION_CLASS:
623 break;
624 case CONDITION_RACE:
626 break;
627 case CONDITION_SKILL:
629 break;
632 break;
635 break;
638 break;
641 break;
644 break;
647 break;
650 break;
651 case CONDITION_MAPID:
653 break;
654 case CONDITION_AREAID:
656 break;
657 case CONDITION_SPELL:
659 break;
660 case CONDITION_LEVEL:
662 break;
665 break;
668 break;
671 break;
673 switch (ConditionValue1)
674 {
675 case TYPEID_UNIT:
677 break;
678 case TYPEID_PLAYER:
680 break;
683 break;
684 case TYPEID_CORPSE:
686 break;
687 default:
688 break;
689 }
690 break;
700 break;
703 break;
706 break;
709 break;
710 case CONDITION_ALIVE:
712 break;
713 case CONDITION_HP_VAL:
715 break;
716 case CONDITION_HP_PCT:
718 break;
721 break;
724 break;
725 case CONDITION_TITLE:
727 break;
730 break;
731 case CONDITION_GENDER:
733 break;
736 break;
739 break;
742 break;
745 break;
748 break;
751 break;
754 break;
757 break;
760 break;
763 break;
766 break;
767 case CONDITION_TAXI:
769 break;
772 break;
773 default:
774 ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!");
775 break;
776 }
777 return mask;
778}
std::uint32_t uint32
Definition: Define.h:107
#define ASSERT
Definition: Errors.h:68
@ CONDITION_TAXI
Definition: ConditionMgr.h:81
@ CONDITION_MAPID
Definition: ConditionMgr.h:57
@ CONDITION_SKILL
Definition: ConditionMgr.h:42
@ CONDITION_RACE
Definition: ConditionMgr.h:51
@ CONDITION_REACTION_TO
Definition: ConditionMgr.h:69
@ CONDITION_NEAR_GAMEOBJECT
Definition: ConditionMgr.h:65
@ CONDITION_QUESTREWARDED
Definition: ConditionMgr.h:43
@ CONDITION_REALM_ACHIEVEMENT
Definition: ConditionMgr.h:74
@ CONDITION_PHASEMASK
Definition: ConditionMgr.h:61
@ CONDITION_QUEST_OBJECTIVE_PROGRESS
Definition: ConditionMgr.h:83
@ CONDITION_DAILY_QUEST_DONE
Definition: ConditionMgr.h:78
@ CONDITION_ACTIVE_EVENT
Definition: ConditionMgr.h:47
@ CONDITION_INSTANCE_INFO
Definition: ConditionMgr.h:48
@ CONDITION_RELATION_TO
Definition: ConditionMgr.h:68
@ CONDITION_STAND_STATE
Definition: ConditionMgr.h:77
@ CONDITION_DRUNKENSTATE
Definition: ConditionMgr.h:45
@ CONDITION_AURA
Definition: ConditionMgr.h:36
@ CONDITION_ACHIEVEMENT
Definition: ConditionMgr.h:52
@ CONDITION_OBJECT_ENTRY_GUID
Definition: ConditionMgr.h:66
@ CONDITION_PET_TYPE
Definition: ConditionMgr.h:80
@ CONDITION_DIFFICULTY_ID
Definition: ConditionMgr.h:84
@ CONDITION_DISTANCE_TO
Definition: ConditionMgr.h:70
@ CONDITION_HP_VAL
Definition: ConditionMgr.h:72
@ CONDITION_GENDER
Definition: ConditionMgr.h:55
@ CONDITION_REPUTATION_RANK
Definition: ConditionMgr.h:40
@ CONDITION_HP_PCT
Definition: ConditionMgr.h:73
@ CONDITION_QUEST_COMPLETE
Definition: ConditionMgr.h:63
@ CONDITION_SPELL
Definition: ConditionMgr.h:60
@ CONDITION_ZONEID
Definition: ConditionMgr.h:39
@ CONDITION_CHARMED
Definition: ConditionMgr.h:79
@ CONDITION_TYPE_MASK
Definition: ConditionMgr.h:67
@ CONDITION_AREAID
Definition: ConditionMgr.h:58
@ CONDITION_IN_WATER
Definition: ConditionMgr.h:75
@ CONDITION_ITEM
Definition: ConditionMgr.h:37
@ CONDITION_WORLD_STATE
Definition: ConditionMgr.h:46
@ CONDITION_SPAWNMASK
Definition: ConditionMgr.h:54
@ CONDITION_CLASS
Definition: ConditionMgr.h:50
@ CONDITION_TEAM
Definition: ConditionMgr.h:41
@ CONDITION_QUEST_NONE
Definition: ConditionMgr.h:49
@ CONDITION_QUESTSTATE
Definition: ConditionMgr.h:82
@ CONDITION_ITEM_EQUIPPED
Definition: ConditionMgr.h:38
@ CONDITION_QUEST_SATISFY_EXCLUSIVE
Definition: ConditionMgr.h:88
@ CONDITION_LEVEL
Definition: ConditionMgr.h:62
@ CONDITION_QUESTTAKEN
Definition: ConditionMgr.h:44
@ CONDITION_NEAR_CREATURE
Definition: ConditionMgr.h:64
@ CONDITION_TITLE
Definition: ConditionMgr.h:53
@ CONDITION_ALIVE
Definition: ConditionMgr.h:71
@ CONDITION_CREATURE_TYPE
Definition: ConditionMgr.h:59
@ CONDITION_UNIT_STATE
Definition: ConditionMgr.h:56
@ CONDITION_HAS_AURA_TYPE
Definition: ConditionMgr.h:89
@ GRID_MAP_TYPE_MASK_PLAYER
Definition: GridDefines.h:73
@ GRID_MAP_TYPE_MASK_CREATURE
Definition: GridDefines.h:70
@ GRID_MAP_TYPE_MASK_ALL
Definition: GridDefines.h:74
@ GRID_MAP_TYPE_MASK_GAMEOBJECT
Definition: GridDefines.h:72
@ GRID_MAP_TYPE_MASK_CORPSE
Definition: GridDefines.h:69
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
@ TYPEID_CORPSE
Definition: ObjectGuid.h:39
@ TYPEID_PLAYER
Definition: ObjectGuid.h:36
@ TYPEMASK_UNIT
Definition: ObjectGuid.h:49
@ TYPEMASK_CORPSE
Definition: ObjectGuid.h:53
@ TYPEMASK_GAMEOBJECT
Definition: ObjectGuid.h:51
@ TYPEMASK_PLAYER
Definition: ObjectGuid.h:50

References ASSERT, CONDITION_ACHIEVEMENT, CONDITION_ACTIVE_EVENT, CONDITION_ALIVE, CONDITION_AREAID, CONDITION_AURA, CONDITION_CHARMED, CONDITION_CLASS, CONDITION_CREATURE_TYPE, CONDITION_DAILY_QUEST_DONE, CONDITION_DIFFICULTY_ID, CONDITION_DISTANCE_TO, CONDITION_DRUNKENSTATE, CONDITION_GENDER, CONDITION_HAS_AURA_TYPE, CONDITION_HP_PCT, CONDITION_HP_VAL, CONDITION_IN_WATER, CONDITION_INSTANCE_INFO, CONDITION_ITEM, CONDITION_ITEM_EQUIPPED, CONDITION_LEVEL, CONDITION_MAPID, CONDITION_NEAR_CREATURE, CONDITION_NEAR_GAMEOBJECT, CONDITION_NONE, CONDITION_OBJECT_ENTRY_GUID, CONDITION_PET_TYPE, CONDITION_PHASEMASK, CONDITION_QUEST_COMPLETE, CONDITION_QUEST_NONE, CONDITION_QUEST_OBJECTIVE_PROGRESS, CONDITION_QUEST_SATISFY_EXCLUSIVE, CONDITION_QUESTREWARDED, CONDITION_QUESTSTATE, CONDITION_QUESTTAKEN, CONDITION_RACE, CONDITION_REACTION_TO, CONDITION_REALM_ACHIEVEMENT, CONDITION_RELATION_TO, CONDITION_REPUTATION_RANK, CONDITION_SKILL, CONDITION_SPAWNMASK, CONDITION_SPELL, CONDITION_STAND_STATE, CONDITION_TAXI, CONDITION_TEAM, CONDITION_TITLE, CONDITION_TYPE_MASK, CONDITION_UNIT_STATE, CONDITION_WORLD_STATE, CONDITION_ZONEID, ConditionType, ConditionValue1, GRID_MAP_TYPE_MASK_ALL, GRID_MAP_TYPE_MASK_CORPSE, GRID_MAP_TYPE_MASK_CREATURE, GRID_MAP_TYPE_MASK_GAMEOBJECT, GRID_MAP_TYPE_MASK_PLAYER, NegativeCondition, TYPEID_CORPSE, TYPEID_GAMEOBJECT, TYPEID_PLAYER, TYPEID_UNIT, TYPEMASK_CORPSE, TYPEMASK_GAMEOBJECT, TYPEMASK_PLAYER, and TYPEMASK_UNIT.

◆ isLoaded()

bool Condition::isLoaded ( ) const
inline

◆ Meets()

bool Condition::Meets ( ConditionSourceInfo sourceInfo)
35{
36 // ASSERT(ConditionTarget < MAX_CONDITION_TARGETS);
38 {
39 LOG_ERROR("condition", "ConditionTarget {} for for condition (Entry: {} Type: {} Group: {}) is greater or equal than MAX_CONDITION_TARGETS", ConditionTarget, SourceEntry, SourceType, SourceGroup);
40 return false;
41 }
42
43 WorldObject* object = sourceInfo.mConditionTargets[ConditionTarget];
44 // object not present, return false
45 if (!object)
46 {
47 LOG_DEBUG("condition", "Condition object not found for condition (Entry: {} Type: {} Group: {})", SourceEntry, SourceType, SourceGroup);
48 return false;
49 }
50 bool condMeets = false;
51 switch (ConditionType)
52 {
53 case CONDITION_NONE:
54 condMeets = true; // empty condition, always met
55 break;
56 case CONDITION_AURA:
57 {
58 if (Unit* unit = object->ToUnit())
59 condMeets = unit->HasAuraEffect(ConditionValue1, ConditionValue2);
60 break;
61 }
62 case CONDITION_ITEM:
63 {
64 if (Unit* unit = object->ToUnit())
65 {
67 {
68 // don't allow 0 items (it's checked during table load)
70 bool checkBank = !!ConditionValue3;
71 condMeets = player->HasItemCount(ConditionValue1, ConditionValue2, checkBank);
72 }
73 }
74 break;
75 }
77 {
78 if (Unit* unit = object->ToUnit())
79 {
81 {
82 condMeets = player->HasItemOrGemWithIdEquipped(ConditionValue1, 1);
83 }
84 }
85 break;
86 }
88 condMeets = object->GetZoneId() == ConditionValue1;
89 break;
91 {
92 if (Unit* unit = object->ToUnit())
93 {
95 {
96 if (FactionEntry const* faction = sFactionStore.LookupEntry(ConditionValue1))
97 {
98 condMeets = (ConditionValue2 & (1 << player->GetReputationMgr().GetRank(faction)));
99 }
100 }
101 }
102 break;
103 }
105 {
106 if (Unit* unit = object->ToUnit())
107 {
108 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
109 {
110 condMeets = player->HasAchieved(ConditionValue1);
111 }
112 }
113 break;
114 }
115 case CONDITION_TEAM:
116 {
117 if (Unit* unit = object->ToUnit())
118 {
119 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
120 {
121 // Xinef: DB Data compatibility...
122 uint32 teamOld = player->GetTeamId() == TEAM_ALLIANCE ? ALLIANCE : HORDE;
123 condMeets = teamOld == ConditionValue1;
124 }
125 }
126 break;
127 }
128 case CONDITION_CLASS:
129 {
130 if (Unit* unit = object->ToUnit())
131 condMeets = unit->getClassMask() & ConditionValue1;
132 break;
133 }
134 case CONDITION_RACE:
135 {
136 if (Unit* unit = object->ToUnit())
137 condMeets = unit->getRaceMask() & ConditionValue1;
138 break;
139 }
140 case CONDITION_GENDER:
141 {
142 if (Unit* unit = object->ToUnit())
143 {
144 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
145 {
146 condMeets = player->getGender() == ConditionValue1;
147 }
148 }
149 break;
150 }
151 case CONDITION_SKILL:
152 {
153 if (Unit* unit = object->ToUnit())
154 {
155 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
156 {
157 condMeets = player->HasSkill(ConditionValue1) && player->GetBaseSkillValue(ConditionValue1) >= ConditionValue2;
158 }
159 }
160 break;
161 }
163 {
164 if (Unit* unit = object->ToUnit())
165 {
166 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
167 {
168 condMeets = player->GetQuestRewardStatus(ConditionValue1);
169 }
170 }
171 break;
172 }
174 {
175 if (Unit* unit = object->ToUnit())
176 {
177 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
178 {
179 QuestStatus status = player->GetQuestStatus(ConditionValue1);
180 condMeets = (status == QUEST_STATUS_INCOMPLETE);
181 }
182 }
183 break;
184 }
186 {
187 if (Unit* unit = object->ToUnit())
188 {
189 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
190 {
191 QuestStatus status = player->GetQuestStatus(ConditionValue1);
192 condMeets = (status == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(ConditionValue1));
193 }
194 }
195 break;
196 }
198 {
199 if (Unit* unit = object->ToUnit())
200 {
201 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
202 {
203 QuestStatus status = player->GetQuestStatus(ConditionValue1);
204 condMeets = (status == QUEST_STATUS_NONE);
205 }
206 }
207 break;
208 }
210 {
211 if (Unit* unit = object->ToUnit())
212 {
213 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
214 {
215 // Xinef: cannot be null, checked at loading
216 const Quest* quest = sObjectMgr->GetQuestTemplate(ConditionValue1);
217 condMeets = !player->IsQuestRewarded(ConditionValue1) && player->SatisfyQuestExclusiveGroup(quest, false);
218 }
219 }
220 break;
221 }
223 condMeets = sGameEventMgr->IsActiveEvent(ConditionValue1);
224 break;
226 {
227 Map* map = object->GetMap();
228 if (map->IsDungeon())
229 {
230 if (InstanceScript const* instance = map->ToInstanceMap()->GetInstanceScript())
231 {
232 switch (ConditionValue3)
233 {
235 condMeets = instance->GetData(ConditionValue1) == ConditionValue2;
236 break;
238 condMeets = instance->GetGuidData(ConditionValue1) == ObjectGuid(uint64(ConditionValue2));
239 break;
241 condMeets = instance->GetBossState(ConditionValue1) == EncounterState(ConditionValue2);
242 break;
244 condMeets = instance->GetData64(ConditionValue1) == ConditionValue2;
245 break;
246 }
247 }
248 }
249 break;
250 }
251 case CONDITION_MAPID:
252 condMeets = object->GetMapId() == ConditionValue1;
253 break;
254 case CONDITION_AREAID:
255 condMeets = object->GetAreaId() == ConditionValue1;
256 break;
257 case CONDITION_SPELL:
258 {
259 if (Unit* unit = object->ToUnit())
260 {
261 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
262 {
263 condMeets = player->HasSpell(ConditionValue1);
264 }
265 }
266 break;
267 }
268 case CONDITION_LEVEL:
269 {
270 if (Unit* unit = object->ToUnit())
271 condMeets = CompareValues(static_cast<ComparisionType>(ConditionValue2), static_cast<uint32>(unit->GetLevel()), ConditionValue1);
272 break;
273 }
275 {
276 if (Unit* unit = object->ToUnit())
277 {
278 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
279 {
280 condMeets = (uint32)Player::GetDrunkenstateByValue(player->GetDrunkValue()) >= ConditionValue1;
281 }
282 }
283 break;
284 }
286 {
287 condMeets = static_cast<bool>(GetClosestCreatureWithEntry(object, ConditionValue1, static_cast<float>(ConditionValue2), !ConditionValue3));
288 break;
289 }
291 {
292 if (!ConditionValue3)
293 {
294 condMeets = static_cast<bool>(GetClosestGameObjectWithEntry(object, ConditionValue1, static_cast<float>(ConditionValue2)));
295 break;
296 }
297 else
298 {
299 if (GameObject* go = GetClosestGameObjectWithEntry(object, ConditionValue1, static_cast<float>(ConditionValue2)))
300 {
301 if ((go->GetGoState() == GO_STATE_READY && ConditionValue3 == 1) || (go->GetGoState() != GO_STATE_READY && ConditionValue3 == 2))
302 condMeets = true;
303 else
304 condMeets = false;
305 }
306 break;
307 }
308 }
310 {
311 if (ConditionValue3 == 1 && object->ToUnit()) // pussywizard: if == 1, ignore not attackable/selectable targets
313 break;
314
315 if (uint32(object->GetTypeId()) == ConditionValue1)
316 {
317 condMeets = !ConditionValue2 || (object->GetEntry() == ConditionValue2);
318
319 if (ConditionValue3 > 1)
320 {
321 switch (object->GetTypeId())
322 {
323 case TYPEID_UNIT:
324 condMeets &= object->ToCreature()->GetSpawnId() == ConditionValue3;
325 break;
327 condMeets &= object->ToGameObject()->GetSpawnId() == ConditionValue3;
328 break;
329 default:
330 break;
331 }
332 }
333 }
334 break;
335 }
337 {
338 condMeets = object->isType(ConditionValue1);
339 break;
340 }
342 {
343 if (WorldObject* toObject = sourceInfo.mConditionTargets[ConditionValue1])
344 {
345 Unit* toUnit = toObject->ToUnit();
346 Unit* unit = object->ToUnit();
347 if (toUnit && unit)
348 {
349 switch (ConditionValue2)
350 {
351 case RELATION_SELF:
352 condMeets = unit == toUnit;
353 break;
355 condMeets = unit->IsInPartyWith(toUnit);
356 break;
358 condMeets = unit->IsInRaidWith(toUnit);
359 break;
361 condMeets = unit->GetOwnerGUID() == toUnit->GetGUID();
362 break;
364 condMeets = unit->IsOnVehicle(toUnit);
365 break;
367 condMeets = unit->GetCreatorGUID() == toUnit->GetGUID();
368 break;
369 }
370 }
371 }
372 break;
373 }
375 {
376 if (WorldObject* toObject = sourceInfo.mConditionTargets[ConditionValue1])
377 {
378 Unit* toUnit = toObject->ToUnit();
379 Unit* unit = object->ToUnit();
380 if (toUnit && unit)
381 condMeets = (1 << unit->GetReactionTo(toUnit)) & ConditionValue2;
382 }
383 break;
384 }
386 {
387 if (WorldObject* toObject = sourceInfo.mConditionTargets[ConditionValue1])
388 condMeets = CompareValues(static_cast<ComparisionType>(ConditionValue3), object->GetDistance(toObject), static_cast<float>(ConditionValue2));
389 break;
390 }
391 case CONDITION_ALIVE:
392 {
393 if (Unit* unit = object->ToUnit())
394 condMeets = unit->IsAlive();
395 break;
396 }
397 case CONDITION_HP_VAL:
398 {
399 if (Unit* unit = object->ToUnit())
400 condMeets = CompareValues(static_cast<ComparisionType>(ConditionValue2), unit->GetHealth(), static_cast<uint32>(ConditionValue1));
401 break;
402 }
403 case CONDITION_HP_PCT:
404 {
405 if (Unit* unit = object->ToUnit())
406 condMeets = CompareValues(static_cast<ComparisionType>(ConditionValue2), unit->GetHealthPct(), static_cast<float>(ConditionValue1));
407 break;
408 }
410 {
411 condMeets = ConditionValue2 == sWorld->getWorldState(ConditionValue1);
412 break;
413 }
415 {
416 condMeets = object->GetPhaseMask() & ConditionValue1;
417 break;
418 }
419 case CONDITION_TITLE:
420 {
421 if (Unit* unit = object->ToUnit())
422 {
423 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
424 {
425 condMeets = player->HasTitle(ConditionValue1);
426 }
427 }
428 break;
429 }
431 {
432 condMeets = ((1 << object->GetMap()->GetSpawnMode()) & ConditionValue1);
433 break;
434 }
436 {
437 if (Unit* unit = object->ToUnit())
438 condMeets = unit->HasUnitState(ConditionValue1);
439 break;
440 }
442 {
443 if (Creature* creature = object->ToCreature())
444 condMeets = creature->GetCreatureTemplate()->type == ConditionValue1;
445 break;
446 }
448 {
449 AchievementEntry const* achievement = sAchievementStore.LookupEntry(ConditionValue1);
450 if (achievement && sAchievementMgr->IsRealmCompleted(achievement))
451 condMeets = true;
452 break;
453 }
455 {
456 if (Unit* unit = object->ToUnit())
457 condMeets = unit->IsInWater();
458 break;
459 }
461 {
462 if (Unit* unit = object->ToUnit())
463 {
464 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
465 {
466 uint32 queststateConditionValue1 = player->GetQuestStatus(ConditionValue1);
467 if (((ConditionValue2 & (1 << QUEST_STATUS_NONE)) && (queststateConditionValue1 == QUEST_STATUS_NONE)) ||
468 ((ConditionValue2 & (1 << QUEST_STATUS_COMPLETE)) && (queststateConditionValue1 == QUEST_STATUS_COMPLETE)) ||
469 ((ConditionValue2 & (1 << QUEST_STATUS_INCOMPLETE)) && (queststateConditionValue1 == QUEST_STATUS_INCOMPLETE)) ||
470 ((ConditionValue2 & (1 << QUEST_STATUS_FAILED)) && (queststateConditionValue1 == QUEST_STATUS_FAILED)) ||
471 ((ConditionValue2 & (1 << QUEST_STATUS_REWARDED)) && player->GetQuestRewardStatus(ConditionValue1)))
472 {
473 condMeets = true;
474 }
475 }
476 }
477 break;
478 }
480 {
481 if (Unit* unit = object->ToUnit())
482 {
483 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
484 {
485 condMeets = player->IsDailyQuestDone(ConditionValue1);
486 }
487 }
488 break;
489 }
491 {
492 if (Unit* unit = object->ToUnit())
493 {
494 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
495 {
496 Quest const* quest = ASSERT_NOTNULL(sObjectMgr->GetQuestTemplate(ConditionValue1));
497 uint16 log_slot = player->FindQuestSlot(quest->GetQuestId());
498 if (log_slot >= MAX_QUEST_LOG_SIZE)
499 {
500 break;
501 }
502
503 if (player->GetQuestSlotCounter(log_slot, ConditionValue2) == ConditionValue3)
504 {
505 condMeets = true;
506 }
507 }
508 }
509 break;
510 }
512 {
513 if (Unit* unit = object->ToUnit())
514 condMeets = unit->HasAuraType(AuraType(ConditionValue1));
515 break;
516 }
518 {
519 if (Unit* unit = object->ToUnit())
520 {
521 if (ConditionValue1 == 0)
522 {
523 condMeets = (unit->getStandState() == ConditionValue2);
524 }
525 else if (ConditionValue2 == 0)
526 {
527 condMeets = unit->IsStandState();
528 }
529 else if (ConditionValue2 == 1)
530 {
531 condMeets = unit->IsSitState();
532 }
533 }
534
535 break;
536 }
538 {
539 condMeets = object->GetMap()->GetDifficulty() == ConditionValue1;
540 break;
541 }
543 {
544 if (Unit* unit = object->ToUnit())
545 {
546 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
547 {
548 if (Pet* pet = player->GetPet())
549 {
550 condMeets = (((1 << pet->getPetType()) & ConditionValue1) != 0);
551 }
552 }
553 }
554 break;
555 }
556 case CONDITION_TAXI:
557 {
558 if (Unit* unit = object->ToUnit())
559 {
560 if (Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
561 {
562 condMeets = player->IsInFlight();
563 }
564 }
565 break;
566 }
568 {
569 if (Unit* unit = object->ToUnit())
570 condMeets = unit->IsCharmed();
571 break;
572 }
573 default:
574 condMeets = false;
575 break;
576 }
577
579 condMeets = !condMeets;
580
581 if (!condMeets)
582 sourceInfo.mLastFailedCondition = this;
583
584 // bool script = sScriptMgr->OnConditionCheck(this, sourceInfo); // Returns true by default. // pussywizard: optimization
585 return condMeets; // && script;
586}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
bool CompareValues(ComparisionType type, T val1, T val2)
Definition: Util.h:597
ComparisionType
Definition: Util.h:587
std::uint64_t uint64
Definition: Define.h:106
std::uint16_t uint16
Definition: Define.h:108
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:85
@ INSTANCE_INFO_DATA64
Definition: ConditionMgr.h:172
@ INSTANCE_INFO_DATA
Definition: ConditionMgr.h:169
@ INSTANCE_INFO_BOSS_STATE
Definition: ConditionMgr.h:171
@ INSTANCE_INFO_GUID_DATA
Definition: ConditionMgr.h:170
@ RELATION_IN_PARTY
Definition: ConditionMgr.h:159
@ RELATION_IN_RAID_OR_PARTY
Definition: ConditionMgr.h:160
@ RELATION_CREATED_BY
Definition: ConditionMgr.h:163
@ RELATION_SELF
Definition: ConditionMgr.h:158
@ RELATION_PASSENGER_OF
Definition: ConditionMgr.h:162
@ RELATION_OWNED_BY
Definition: ConditionMgr.h:161
@ MAX_CONDITION_TARGETS
Definition: ConditionMgr.h:177
EncounterState
Definition: InstanceScript.h:56
#define MAX_QUEST_LOG_SIZE
Definition: QuestDef.h:33
QuestStatus
Definition: QuestDef.h:99
@ QUEST_STATUS_REWARDED
Definition: QuestDef.h:106
@ QUEST_STATUS_FAILED
Definition: QuestDef.h:105
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:103
@ QUEST_STATUS_NONE
Definition: QuestDef.h:100
@ QUEST_STATUS_COMPLETE
Definition: QuestDef.h:101
#define sObjectMgr
Definition: ObjectMgr.h:1623
#define sGameEventMgr
Definition: GameEventMgr.h:186
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition: ScriptedCreature.cpp:817
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition: ScriptedCreature.cpp:822
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
#define sAchievementMgr
Definition: AchievementMgr.h:452
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:230
@ UNIT_FLAG_NOT_SELECTABLE
Definition: UnitDefines.h:254
@ GO_STATE_READY
Definition: GameObjectData.h:691
AuraType
Definition: SpellAuraDefines.h:62
@ ALLIANCE
Definition: SharedDefines.h:768
@ HORDE
Definition: SharedDefines.h:767
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
#define sWorld
Definition: World.h:444
Condition * mLastFailedCondition
Definition: ConditionMgr.h:183
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition: ConditionMgr.h:182
Definition: Creature.h:46
Definition: GameObject.h:121
TypeID GetTypeId() const
Definition: Object.h:124
Creature * ToCreature()
Definition: Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Unit * ToUnit()
Definition: Object.h:206
Definition: Object.h:405
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
Definition: ObjectGuid.h:118
Definition: Pet.h:41
Definition: Player.h:1064
static DrunkenState GetDrunkenstateByValue(uint8 value)
Definition: Player.cpp:960
Definition: Unit.h:630
ReputationRank GetReactionTo(Unit const *target, bool checkOriginalFaction=false) const
Definition: Unit.cpp:10026
bool IsCharmed() const
Definition: Unit.h:1266
float GetHealthPct() const
Definition: Unit.h:877
ObjectGuid GetCreatorGUID() const
Definition: Unit.h:1212
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:10578
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:682
bool IsAlive() const
Definition: Unit.h:1204
bool IsStandState() const
Definition: Unit.cpp:16676
bool IsOnVehicle(Unit const *vehicle) const
Definition: Unit.h:1674
virtual bool IsInWater() const
Definition: Unit.cpp:4321
uint32 GetHealth() const
Definition: Unit.h:869
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:5676
uint8 getStandState() const
Definition: Unit.h:982
bool HasUnitState(const uint32 f) const
Definition: Unit.h:673
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:18753
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1210
bool IsInPartyWith(Unit const *unit) const
Definition: Unit.cpp:18730
bool IsSitState() const
Definition: Unit.cpp:16667
Definition: InstanceScript.h:142
Definition: Map.h:313
bool IsDungeon() const
Definition: Map.h:448
InstanceMap * ToInstanceMap()
Definition: Map.h:546
InstanceScript * GetInstanceScript()
Definition: Map.h:831
Definition: QuestDef.h:210
uint32 GetQuestId() const
Definition: QuestDef.h:228
Definition: DBCStructure.h:40
Definition: DBCStructure.h:907

References ALLIANCE, ASSERT, ASSERT_NOTNULL, CompareValues(), CONDITION_ACHIEVEMENT, CONDITION_ACTIVE_EVENT, CONDITION_ALIVE, CONDITION_AREAID, CONDITION_AURA, CONDITION_CHARMED, CONDITION_CLASS, CONDITION_CREATURE_TYPE, CONDITION_DAILY_QUEST_DONE, CONDITION_DIFFICULTY_ID, CONDITION_DISTANCE_TO, CONDITION_DRUNKENSTATE, CONDITION_GENDER, CONDITION_HAS_AURA_TYPE, CONDITION_HP_PCT, CONDITION_HP_VAL, CONDITION_IN_WATER, CONDITION_INSTANCE_INFO, CONDITION_ITEM, CONDITION_ITEM_EQUIPPED, CONDITION_LEVEL, CONDITION_MAPID, CONDITION_NEAR_CREATURE, CONDITION_NEAR_GAMEOBJECT, CONDITION_NONE, CONDITION_OBJECT_ENTRY_GUID, CONDITION_PET_TYPE, CONDITION_PHASEMASK, CONDITION_QUEST_COMPLETE, CONDITION_QUEST_NONE, CONDITION_QUEST_OBJECTIVE_PROGRESS, CONDITION_QUEST_SATISFY_EXCLUSIVE, CONDITION_QUESTREWARDED, CONDITION_QUESTSTATE, CONDITION_QUESTTAKEN, CONDITION_RACE, CONDITION_REACTION_TO, CONDITION_REALM_ACHIEVEMENT, CONDITION_RELATION_TO, CONDITION_REPUTATION_RANK, CONDITION_SKILL, CONDITION_SPAWNMASK, CONDITION_SPELL, CONDITION_STAND_STATE, CONDITION_TAXI, CONDITION_TEAM, CONDITION_TITLE, CONDITION_TYPE_MASK, CONDITION_UNIT_STATE, CONDITION_WORLD_STATE, CONDITION_ZONEID, ConditionTarget, ConditionType, ConditionValue1, ConditionValue2, ConditionValue3, Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Unit::GetCreatorGUID(), WorldObject::GetDistance(), Player::GetDrunkenstateByValue(), Object::GetGUID(), InstanceMap::GetInstanceScript(), Unit::GetOwnerGUID(), Quest::GetQuestId(), Unit::GetReactionTo(), Object::GetTypeId(), GO_STATE_READY, Unit::HasUnitFlag(), HORDE, INSTANCE_INFO_BOSS_STATE, INSTANCE_INFO_DATA, INSTANCE_INFO_DATA64, INSTANCE_INFO_GUID_DATA, Map::IsDungeon(), Unit::IsInPartyWith(), Unit::IsInRaidWith(), Unit::IsOnVehicle(), LOG_DEBUG, LOG_ERROR, MAX_CONDITION_TARGETS, MAX_QUEST_LOG_SIZE, ConditionSourceInfo::mConditionTargets, ConditionSourceInfo::mLastFailedCondition, NegativeCondition, QUEST_STATUS_COMPLETE, QUEST_STATUS_FAILED, QUEST_STATUS_INCOMPLETE, QUEST_STATUS_NONE, QUEST_STATUS_REWARDED, RELATION_CREATED_BY, RELATION_IN_PARTY, RELATION_IN_RAID_OR_PARTY, RELATION_OWNED_BY, RELATION_PASSENGER_OF, RELATION_SELF, sAchievementMgr, sAchievementStore, sFactionStore, sGameEventMgr, sObjectMgr, SourceEntry, SourceGroup, SourceType, sWorld, TEAM_ALLIANCE, Object::ToCreature(), Map::ToInstanceMap(), Object::ToUnit(), TYPEID_GAMEOBJECT, TYPEID_UNIT, UNIT_FLAG_NON_ATTACKABLE, and UNIT_FLAG_NOT_SELECTABLE.

Member Data Documentation

◆ ConditionTarget

◆ ConditionType

◆ ConditionValue1

◆ ConditionValue2

◆ ConditionValue3

◆ ElseGroup

uint32 Condition::ElseGroup

◆ ErrorTextId

uint32 Condition::ErrorTextId

◆ ErrorType

uint32 Condition::ErrorType

◆ NegativeCondition

bool Condition::NegativeCondition

◆ ReferenceId

uint32 Condition::ReferenceId

◆ ScriptId

◆ SourceEntry

◆ SourceGroup

◆ SourceId

uint32 Condition::SourceId

◆ SourceType