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
213 {
215 SourceGroup = 0;
216 SourceEntry = 0;
217 SourceId = 0;
218 ElseGroup = 0;
220 ConditionTarget = 0;
221 ConditionValue1 = 0;
222 ConditionValue2 = 0;
223 ConditionValue3 = 0;
224 ReferenceId = 0;
225 ErrorType = 0;
226 ErrorTextId = 0;
227 ScriptId = 0;
228 NegativeCondition = false;
229 }
@ CONDITION_SOURCE_TYPE_NONE
Definition: ConditionMgr.h:123
@ CONDITION_NONE
Definition: ConditionMgr.h:34
uint32 SourceGroup
Definition: ConditionMgr.h:197
ConditionTypes ConditionType
Definition: ConditionMgr.h:201
uint32 ErrorType
Definition: ConditionMgr.h:205
uint32 SourceId
Definition: ConditionMgr.h:199
int32 SourceEntry
Definition: ConditionMgr.h:198
uint32 ElseGroup
Definition: ConditionMgr.h:200
uint32 ScriptId
Definition: ConditionMgr.h:208
bool NegativeCondition
Definition: ConditionMgr.h:210
ConditionSourceType SourceType
Definition: ConditionMgr.h:196
uint32 ConditionValue2
Definition: ConditionMgr.h:203
uint8 ConditionTarget
Definition: ConditionMgr.h:209
uint32 ReferenceId
Definition: ConditionMgr.h:207
uint32 ErrorTextId
Definition: ConditionMgr.h:206
uint32 ConditionValue3
Definition: ConditionMgr.h:204
uint32 ConditionValue1
Definition: ConditionMgr.h:202

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 ( )
790{
791 // returns number of targets which are available for given source type
792 switch (SourceType)
793 {
795 return 3;
806 return 2;
807 default:
808 break;
809 }
810
811 return 1;
812}
@ CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY
Definition: ConditionMgr.h:153
@ CONDITION_SOURCE_TYPE_VEHICLE_SPELL
Definition: ConditionMgr.h:144
@ CONDITION_SOURCE_TYPE_NPC_VENDOR
Definition: ConditionMgr.h:146
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION
Definition: ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT
Definition: ConditionMgr.h:141
@ CONDITION_SOURCE_TYPE_SMART_EVENT
Definition: ConditionMgr.h:145
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:140
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU
Definition: ConditionMgr.h:137
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition: ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET
Definition: ConditionMgr.h:136
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition: ConditionMgr.h:147

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 ( )
595{
596 // build mask of types for which condition can return true
597 // this is used for speeding up gridsearches
599 return (GRID_MAP_TYPE_MASK_ALL);
600 uint32 mask = 0;
601 switch (ConditionType)
602 {
603 case CONDITION_NONE:
605 break;
606 case CONDITION_AURA:
608 break;
609 case CONDITION_ITEM:
611 break;
614 break;
615 case CONDITION_ZONEID:
617 break;
620 break;
623 break;
624 case CONDITION_TEAM:
626 break;
627 case CONDITION_CLASS:
629 break;
630 case CONDITION_RACE:
632 break;
633 case CONDITION_SKILL:
635 break;
638 break;
641 break;
644 break;
647 break;
650 break;
653 break;
656 break;
657 case CONDITION_MAPID:
659 break;
660 case CONDITION_AREAID:
662 break;
663 case CONDITION_SPELL:
665 break;
666 case CONDITION_LEVEL:
668 break;
671 break;
674 break;
677 break;
679 switch (ConditionValue1)
680 {
681 case TYPEID_UNIT:
683 break;
684 case TYPEID_PLAYER:
686 break;
689 break;
690 case TYPEID_CORPSE:
692 break;
693 default:
694 break;
695 }
696 break;
706 break;
709 break;
712 break;
715 break;
716 case CONDITION_ALIVE:
718 break;
719 case CONDITION_HP_VAL:
721 break;
722 case CONDITION_HP_PCT:
724 break;
727 break;
730 break;
731 case CONDITION_TITLE:
733 break;
736 break;
737 case CONDITION_GENDER:
739 break;
742 break;
745 break;
748 break;
751 break;
754 break;
757 break;
760 break;
763 break;
766 break;
769 break;
772 break;
773 case CONDITION_TAXI:
775 break;
778 break;
781 break;
782 default:
783 ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!");
784 break;
785 }
786 return mask;
787}
#define ASSERT
Definition: Errors.h:68
std::uint32_t uint32
Definition: Define.h:107
@ GRID_MAP_TYPE_MASK_PLAYER
Definition: GridDefines.h:72
@ GRID_MAP_TYPE_MASK_CREATURE
Definition: GridDefines.h:69
@ GRID_MAP_TYPE_MASK_ALL
Definition: GridDefines.h:73
@ GRID_MAP_TYPE_MASK_GAMEOBJECT
Definition: GridDefines.h:71
@ GRID_MAP_TYPE_MASK_CORPSE
Definition: GridDefines.h:68
@ 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
@ CONDITION_WORLD_SCRIPT
Definition: ConditionMgr.h:89
@ CONDITION_TAXI
Definition: ConditionMgr.h:80
@ CONDITION_MAPID
Definition: ConditionMgr.h:56
@ CONDITION_SKILL
Definition: ConditionMgr.h:41
@ CONDITION_RACE
Definition: ConditionMgr.h:50
@ CONDITION_REACTION_TO
Definition: ConditionMgr.h:68
@ CONDITION_NEAR_GAMEOBJECT
Definition: ConditionMgr.h:64
@ CONDITION_QUESTREWARDED
Definition: ConditionMgr.h:42
@ CONDITION_REALM_ACHIEVEMENT
Definition: ConditionMgr.h:73
@ CONDITION_PHASEMASK
Definition: ConditionMgr.h:60
@ CONDITION_QUEST_OBJECTIVE_PROGRESS
Definition: ConditionMgr.h:82
@ CONDITION_DAILY_QUEST_DONE
Definition: ConditionMgr.h:77
@ CONDITION_ACTIVE_EVENT
Definition: ConditionMgr.h:46
@ CONDITION_INSTANCE_INFO
Definition: ConditionMgr.h:47
@ CONDITION_RELATION_TO
Definition: ConditionMgr.h:67
@ CONDITION_STAND_STATE
Definition: ConditionMgr.h:76
@ CONDITION_DRUNKENSTATE
Definition: ConditionMgr.h:44
@ CONDITION_AURA
Definition: ConditionMgr.h:35
@ CONDITION_ACHIEVEMENT
Definition: ConditionMgr.h:51
@ CONDITION_OBJECT_ENTRY_GUID
Definition: ConditionMgr.h:65
@ CONDITION_PET_TYPE
Definition: ConditionMgr.h:79
@ CONDITION_DIFFICULTY_ID
Definition: ConditionMgr.h:83
@ CONDITION_DISTANCE_TO
Definition: ConditionMgr.h:69
@ CONDITION_HP_VAL
Definition: ConditionMgr.h:71
@ CONDITION_GENDER
Definition: ConditionMgr.h:54
@ CONDITION_REPUTATION_RANK
Definition: ConditionMgr.h:39
@ CONDITION_HP_PCT
Definition: ConditionMgr.h:72
@ CONDITION_QUEST_COMPLETE
Definition: ConditionMgr.h:62
@ CONDITION_SPELL
Definition: ConditionMgr.h:59
@ CONDITION_ZONEID
Definition: ConditionMgr.h:38
@ CONDITION_CHARMED
Definition: ConditionMgr.h:78
@ CONDITION_TYPE_MASK
Definition: ConditionMgr.h:66
@ CONDITION_AREAID
Definition: ConditionMgr.h:57
@ CONDITION_IN_WATER
Definition: ConditionMgr.h:74
@ CONDITION_ITEM
Definition: ConditionMgr.h:36
@ CONDITION_WORLD_STATE
Definition: ConditionMgr.h:45
@ CONDITION_SPAWNMASK
Definition: ConditionMgr.h:53
@ CONDITION_CLASS
Definition: ConditionMgr.h:49
@ CONDITION_TEAM
Definition: ConditionMgr.h:40
@ CONDITION_QUEST_NONE
Definition: ConditionMgr.h:48
@ CONDITION_QUESTSTATE
Definition: ConditionMgr.h:81
@ CONDITION_ITEM_EQUIPPED
Definition: ConditionMgr.h:37
@ CONDITION_QUEST_SATISFY_EXCLUSIVE
Definition: ConditionMgr.h:87
@ CONDITION_LEVEL
Definition: ConditionMgr.h:61
@ CONDITION_QUESTTAKEN
Definition: ConditionMgr.h:43
@ CONDITION_NEAR_CREATURE
Definition: ConditionMgr.h:63
@ CONDITION_TITLE
Definition: ConditionMgr.h:52
@ CONDITION_ALIVE
Definition: ConditionMgr.h:70
@ CONDITION_CREATURE_TYPE
Definition: ConditionMgr.h:58
@ CONDITION_UNIT_STATE
Definition: ConditionMgr.h:55
@ CONDITION_HAS_AURA_TYPE
Definition: ConditionMgr.h:88

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

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_SCRIPT, 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, sWorldState, 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