TrinityCore
Loading...
Searching...
No Matches
GridNotifiers.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_GRIDNOTIFIERS_H
19#define TRINITY_GRIDNOTIFIERS_H
20
21#include "AreaTrigger.h"
22#include "Creature.h"
23#include "Corpse.h"
24#include "Conversation.h"
25#include "DynamicObject.h"
26#include "GameObject.h"
27#include "Player.h"
28#include "SceneObject.h"
29#include "Spell.h"
30#include "SpellInfo.h"
31#include "UnitAI.h"
32#include "UpdateData.h"
33
34namespace Trinity
35{
36 template<typename ObjectType>
37 struct GridMapTypeMaskForType : std::integral_constant<GridMapTypeMask, GridMapTypeMask(0)> { };
38
39 template<> struct GridMapTypeMaskForType<Corpse> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_CORPSE> { };
40 template<> struct GridMapTypeMaskForType<Creature> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_CREATURE> { };
41 template<> struct GridMapTypeMaskForType<DynamicObject> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_DYNAMICOBJECT> { };
42 template<> struct GridMapTypeMaskForType<GameObject> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_GAMEOBJECT> { };
43 template<> struct GridMapTypeMaskForType<Player> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_PLAYER> { };
44 template<> struct GridMapTypeMaskForType<AreaTrigger> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_AREATRIGGER> { };
45 template<> struct GridMapTypeMaskForType<SceneObject> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_SCENEOBJECT> { };
46 template<> struct GridMapTypeMaskForType<Conversation> : std::integral_constant<GridMapTypeMask, GRID_MAP_TYPE_MASK_CONVERSATION> { };
47
49 {
52 std::set<WorldObject*> i_visibleNow;
54
55 VisibleNotifier(Player &player);
57 template<class T> void Visit(GridRefManager<T> &m);
58 void SendToSelf(void);
59
64 };
65
76
78 {
80
81 template<class T> void Visit(GridRefManager<T> &m) { VisibleNotifier::Visit(m); }
82 void Visit(CreatureMapType &);
83 void Visit(PlayerMapType &);
84 };
85
87 {
89 CreatureRelocationNotifier(Creature &c) : i_creature(c) { }
90 template<class T> void Visit(GridRefManager<T> &) { }
91 void Visit(CreatureMapType &);
92 void Visit(PlayerMapType &);
93 };
94
96 {
100 const float i_radius;
101 DelayedUnitRelocation(Cell &c, CellCoord &pair, Map &map, float radius) :
102 i_map(map), cell(c), p(pair), i_radius(radius) { }
103 template<class T> void Visit(GridRefManager<T> &) { }
104 void Visit(CreatureMapType &);
105 void Visit(PlayerMapType &);
106 };
107
109 {
112 explicit AIRelocationNotifier(Unit &unit) : i_unit(unit), isCreature(unit.GetTypeId() == TYPEID_UNIT) { }
113 template<class T> void Visit(GridRefManager<T> &) { }
114 void Visit(CreatureMapType &);
115 };
116
118 {
121 template<class T> void Visit(GridRefManager<T>&) { }
122 void Visit(CreatureMapType&);
123 void Visit(PlayerMapType&);
124 };
125
127 {
130 GridUpdater(GridType &grid, uint32 diff) : i_grid(grid), i_timeDiff(diff) { }
131
132 template<class T> void updateObjects(GridRefManager<T> &m)
133 {
134 for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
135 iter->GetSource()->Update(i_timeDiff);
136 }
137
138 void Visit(PlayerMapType &m) { updateObjects<Player>(m); }
139 void Visit(CreatureMapType &m){ updateObjects<Creature>(m); }
140 void Visit(GameObjectMapType &m) { updateObjects<GameObject>(m); }
141 void Visit(DynamicObjectMapType &m) { updateObjects<DynamicObject>(m); }
142 void Visit(CorpseMapType &m) { updateObjects<Corpse>(m); }
143 void Visit(AreaTriggerMapType &m) { updateObjects<AreaTrigger>(m); }
144 void Visit(SceneObjectMapType &m) { updateObjects<SceneObject>(m); }
145 void Visit(ConversationMapType &m) { updateObjects<Conversation>(m); }
146 };
147
149 {
151
152 PacketSenderRef(WorldPacket const* message) : Data(message) { }
153
154 void operator()(Player const* player) const
155 {
156 player->SendDirectMessage(Data);
157 }
158 };
159
160 template<typename Packet>
162 {
163 Packet Data;
164
165 void operator()(Player const* player) const
166 {
167 player->SendDirectMessage(Data.GetRawPacket());
168 }
169 };
170
171 template<typename PacketSender>
173 {
175 PacketSender& i_packetSender;
177 float i_distSq;
181 MessageDistDeliverer(WorldObject const* src, PacketSender& packetSender, float dist, bool own_team_only = false, Player const* skipped = nullptr, bool req3dDist = false)
182 : i_source(src), i_packetSender(packetSender), i_phaseShift(&src->GetPhaseShift()), i_distSq(dist * dist)
184 , skipped_receiver(skipped)
185 , required3dDist(req3dDist)
186 {
187 if (own_team_only)
188 if (Player const* player = src->ToPlayer())
189 team = player->GetEffectiveTeam();
190 }
191
192 void Visit(PlayerMapType &m) const;
193 void Visit(CreatureMapType &m) const;
194 void Visit(DynamicObjectMapType &m) const;
195 template<class SKIP> void Visit(GridRefManager<SKIP> &) const { }
196
197 void SendPacket(Player const* player) const
198 {
199 // never send packet to self
200 if (player == i_source || (team && player->GetEffectiveTeam() != team) || skipped_receiver == player)
201 return;
202
203 if (!player->HaveAtClient(i_source))
204 return;
205
206 i_packetSender(player);
207 }
208 };
209
210 template<typename PacketSender>
212 {
214 PacketSender& i_packetSender;
216 float i_distSq;
217
218 MessageDistDelivererToHostile(Unit* src, PacketSender& packetSender, float dist)
219 : i_source(src), i_packetSender(packetSender), i_phaseShift(&src->GetPhaseShift()), i_distSq(dist * dist)
220 {
221 }
222
223 void Visit(PlayerMapType &m) const;
224 void Visit(CreatureMapType &m) const;
225 void Visit(DynamicObjectMapType &m) const;
226 template<class SKIP> void Visit(GridRefManager<SKIP> &) const { }
227
228 void SendPacket(Player const* player) const
229 {
230 // never send packet to self
231 if (player == i_source || !player->HaveAtClient(i_source) || player->IsFriendlyTo(i_source))
232 return;
233
234 i_packetSender(player);
235 }
236 };
237
239 {
241 explicit ObjectUpdater(const uint32 diff) : i_timeDiff(diff) { }
242 template<class T> void Visit(GridRefManager<T> &m);
245 };
246
247 // SEARCHERS & LIST SEARCHERS & WORKERS
248
249 // WorldObject searchers & workers
251 {
252 Continue,
253 Return
254 };
255
256 template<typename Type>
258 {
259 Type& result;
260
261 protected:
262 explicit SearcherFirstObjectResult(Type& ref_) : result(ref_) { }
263
268
269 void Insert(Type object)
270 {
271 result = object;
272 }
273 };
274
275 template<typename Type>
277 {
278 Type& result;
279
280 protected:
281 explicit SearcherLastObjectResult(Type& ref_) : result(ref_) { }
282
287
288 void Insert(Type object)
289 {
290 result = object;
291 }
292 };
293
294 // Generic base class to insert elements into arbitrary containers using push_back
295 template<typename Type>
297 {
298 using InserterType = void(*)(void*, Type&&);
299
300 void* ref;
302
303 protected:
304 template<typename T>
305 explicit SearcherContainerResult(T& ref_) : ref(&ref_)
306 {
307 inserter = [](void* containerRaw, Type&& object)
308 {
309 T* container = reinterpret_cast<T*>(containerRaw);
310 container->insert(container->end(), std::move(object));
311 };
312 }
313
318
319 void Insert(Type object)
320 {
321 inserter(ref, std::move(object));
322 }
323 };
324
326 {
328
329 static constexpr bool IsStatic = false;
330
332
333 constexpr bool Includes(uint32 mapTypeMask) const
334 {
335 return (MaskValue & mapTypeMask) != 0;
336 }
337 };
338
339 template <uint32 MapTypeMask>
341 {
343
344 static constexpr bool IsStatic = true;
345
346 static constexpr bool Includes(uint32 mapTypeMask)
347 {
348 return (MapTypeMask & mapTypeMask) != 0;
349 }
350 };
351
352 template<class Check, class Result, class MapTypeMaskCheck = DynamicGridMapTypeMaskCheck>
354 {
355 MapTypeMaskCheck i_mapTypeMask;
357 Check& i_check;
358
359 template<class T>
361 {
362 if constexpr (MapTypeMaskCheck::IsStatic)
363 {
364 if constexpr (MapTypeMaskCheck::Includes(GridMapTypeMaskForType<T>::value))
365 VisitImpl(m);
366 }
367 else
368 {
370 VisitImpl(m);
371 }
372 }
373
374 protected:
375 template<typename Container>
376 WorldObjectSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
377 : Result(result), i_mapTypeMask(mapTypeMask), i_phaseShift(&phaseShift), i_check(check) { }
378
379 private:
380 template<class T>
382 };
383
384 template<class Work, class MapTypeMaskCheck = DynamicGridMapTypeMaskCheck>
386 {
387 MapTypeMaskCheck i_mapTypeMask;
389 Work& i_work;
390
391 template<class T>
393 {
394 if constexpr (MapTypeMaskCheck::IsStatic)
395 {
396 if constexpr (MapTypeMaskCheck::Includes(GridMapTypeMaskForType<T>::value))
397 VisitImpl(m);
398 }
399 else
400 {
402 VisitImpl(m);
403 }
404 }
405
406 protected:
407 WorldObjectWorkerBase(PhaseShift const& phaseShift, Work& work, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
408 : i_mapTypeMask(mapTypeMask), i_phaseShift(&phaseShift), i_work(work) { }
409
410 private:
411 template<class T>
412 inline void VisitImpl(GridRefManager<T> const& m)
413 {
414 for (GridReference<T> const& ref : m)
415 if (ref.GetSource()->InSamePhase(*i_phaseShift))
416 this->i_work(ref.GetSource());
417 }
418 };
419
420 template<class Check>
421 struct WorldObjectSearcher : WorldObjectSearcherBase<Check, SearcherFirstObjectResult<WorldObject*>>
422 {
423 WorldObjectSearcher(PhaseShift const& phaseShift, WorldObject*& result, Check& check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
424 : WorldObjectSearcherBase<Check, SearcherFirstObjectResult<WorldObject*>>(phaseShift, result, check, mapTypeMask) { }
425
426 WorldObjectSearcher(WorldObject const* searcher, WorldObject*& result, Check& check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
427 : WorldObjectSearcher(searcher->GetPhaseShift(), result, check, mapTypeMask) { }
428 };
429
430 template<class Check>
431 struct WorldObjectLastSearcher : WorldObjectSearcherBase<Check, SearcherLastObjectResult<WorldObject*>>
432 {
433 WorldObjectLastSearcher(PhaseShift const& phaseShift, WorldObject*& result, Check& check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
434 : WorldObjectSearcherBase<Check, SearcherLastObjectResult<WorldObject*>>(phaseShift, result, check, mapTypeMask) { }
435
437 : WorldObjectLastSearcher(searcher->GetPhaseShift(), result, check, mapTypeMask) { }
438 };
439
440 template<class Check>
441 struct WorldObjectListSearcher : WorldObjectSearcherBase<Check, SearcherContainerResult<WorldObject*>>
442 {
443 template<typename Container>
444 WorldObjectListSearcher(PhaseShift const& phaseShift, Container& container, Check& check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
445 : WorldObjectSearcherBase<Check, SearcherContainerResult<WorldObject*>>(phaseShift, container, check, mapTypeMask) { }
446
447 template<typename Container>
448 WorldObjectListSearcher(WorldObject const* searcher, Container& container, Check& check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
449 : WorldObjectListSearcher(searcher->GetPhaseShift(), container, check, mapTypeMask) { }
450 };
451
452 template<class Check, typename Container>
454
455 template<class Check, typename Container>
457
458 template<class Work>
460 {
461 WorldObjectWorker(PhaseShift const& phaseShift, Work& work, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
462 : WorldObjectWorkerBase<Work>(phaseShift, work, mapTypeMask) { }
463
464 WorldObjectWorker(WorldObject const* searcher, Work& work, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
465 : WorldObjectWorker(searcher->GetPhaseShift(), work, mapTypeMask) { }
466 };
467
468 // Gameobject searchers
469
470 template<class Check, class Result>
471 struct GameObjectSearcherBase : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_GAMEOBJECT>>
472 {
473 template<typename Container>
474 GameObjectSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check)
475 : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_GAMEOBJECT>>(phaseShift, result, check) { }
476 };
477
478 template<class Check>
479 struct GameObjectSearcher : GameObjectSearcherBase<Check, SearcherFirstObjectResult<GameObject*>>
480 {
481 GameObjectSearcher(PhaseShift const& phaseShift, GameObject*& result, Check& check)
482 : GameObjectSearcherBase<Check, SearcherFirstObjectResult<GameObject*>>(phaseShift, result, check) { }
483
484 GameObjectSearcher(WorldObject const* searcher, GameObject*& result, Check& check)
485 : GameObjectSearcher(searcher->GetPhaseShift(), result, check) { }
486 };
487
488 // Last accepted by Check GO if any (Check can change requirements at each call)
489 template<class Check>
490 struct GameObjectLastSearcher : GameObjectSearcherBase<Check, SearcherLastObjectResult<GameObject*>>
491 {
492 GameObjectLastSearcher(PhaseShift const& phaseShift, GameObject*& result, Check& check)
493 : GameObjectSearcherBase<Check, SearcherLastObjectResult<GameObject*>>(phaseShift, result, check) { }
494
495 GameObjectLastSearcher(WorldObject const* searcher, GameObject*& result, Check& check)
496 : GameObjectLastSearcher(searcher->GetPhaseShift(), result, check) { }
497 };
498
499 template<class Check>
500 struct GameObjectListSearcher : GameObjectSearcherBase<Check, SearcherContainerResult<GameObject*>>
501 {
502 template<typename Container>
503 GameObjectListSearcher(PhaseShift const& phaseShift, Container& container, Check& check)
504 : GameObjectSearcherBase<Check, SearcherContainerResult<GameObject*>>(phaseShift, container, check) { }
505
506 template<typename Container>
507 GameObjectListSearcher(WorldObject const* searcher, Container& container, Check& check)
508 : GameObjectListSearcher(searcher->GetPhaseShift(), container, check) { }
509 };
510
511 template<class Check, typename Container>
513
514 template<class Check, typename Container>
516
517 template<class Work>
518 struct GameObjectWorker : WorldObjectWorkerBase<Work, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_GAMEOBJECT>>
519 {
520 GameObjectWorker(PhaseShift const& phaseShift, Work& work)
522
523 GameObjectWorker(WorldObject const* searcher, Work& work)
524 : GameObjectWorker(searcher->GetPhaseShift(), work) { }
525 };
526
527 // Unit searchers
528
529 template<class Check, class Result>
530 struct UnitSearcherBase : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER>>
531 {
532 template<typename Container>
533 UnitSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check)
535 };
536
537 // First accepted by Check Unit if any
538 template<class Check>
539 struct UnitSearcher : UnitSearcherBase<Check, SearcherFirstObjectResult<Unit*>>
540 {
541 UnitSearcher(PhaseShift const& phaseShift, Unit*& result, Check& check)
542 : UnitSearcherBase<Check, SearcherFirstObjectResult<Unit*>>(phaseShift, result, check) { }
543
544 UnitSearcher(WorldObject const* searcher, Unit*& result, Check& check)
545 : UnitSearcher(searcher->GetPhaseShift(), result, check) { }
546 };
547
548 // Last accepted by Check Unit if any (Check can change requirements at each call)
549 template<class Check>
550 struct UnitLastSearcher : UnitSearcherBase<Check, SearcherLastObjectResult<Unit*>>
551 {
552 UnitLastSearcher(PhaseShift const& phaseShift, Unit*& result, Check& check)
553 : UnitSearcherBase<Check, SearcherLastObjectResult<Unit*>>(phaseShift, result, check) { }
554
555 UnitLastSearcher(WorldObject const* searcher, Unit*& result, Check& check)
556 : UnitLastSearcher(searcher->GetPhaseShift(), result, check) { }
557 };
558
559 // All accepted by Check units if any
560 template<class Check>
561 struct UnitListSearcher : UnitSearcherBase<Check, SearcherContainerResult<Unit*>>
562 {
563 template<typename Container>
564 UnitListSearcher(PhaseShift const& phaseShift, Container& container, Check& check)
565 : UnitSearcherBase<Check, SearcherContainerResult<Unit*>>(phaseShift, container, check) { }
566
567 template<typename Container>
568 UnitListSearcher(WorldObject const* searcher, Container& container, Check& check)
569 : UnitListSearcher(searcher->GetPhaseShift(), container, check) { }
570 };
571
572 template<class Work>
573 struct UnitWorker : WorldObjectWorkerBase<Work, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER>>
574 {
577
578 UnitWorker(WorldObject const* searcher, Work& work)
579 : UnitWorker(searcher->GetPhaseShift(), work) { }
580 };
581
582 // Creature searchers
583
584 template<class Check, class Result>
585 struct CreatureSearcherBase : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CREATURE>>
586 {
587 template<typename Container>
588 CreatureSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check)
589 : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CREATURE>>(phaseShift, result, check) { }
590 };
591
592 template<class Check>
593 struct CreatureSearcher : CreatureSearcherBase<Check, SearcherFirstObjectResult<Creature*>>
594 {
595 CreatureSearcher(PhaseShift const& phaseShift, Creature*& result, Check& check)
596 : CreatureSearcherBase<Check, SearcherFirstObjectResult<Creature*>>(phaseShift, result, check) { }
597
598 CreatureSearcher(WorldObject const* searcher, Creature*& result, Check& check)
599 : CreatureSearcher(searcher->GetPhaseShift(), result, check) { }
600 };
601
602 // Last accepted by Check Creature if any (Check can change requirements at each call)
603 template<class Check>
604 struct CreatureLastSearcher : CreatureSearcherBase<Check, SearcherLastObjectResult<Creature*>>
605 {
606 CreatureLastSearcher(PhaseShift const& phaseShift, Creature*& result, Check& check)
607 : CreatureSearcherBase<Check, SearcherLastObjectResult<Creature*>>(phaseShift, result, check) { }
608
609 CreatureLastSearcher(WorldObject const* searcher, Creature*& result, Check& check)
610 : CreatureLastSearcher(searcher->GetPhaseShift(), result, check) { }
611 };
612
613 template<class Check>
614 struct CreatureListSearcher : CreatureSearcherBase<Check, SearcherContainerResult<Creature*>>
615 {
616 template<typename Container>
617 CreatureListSearcher(PhaseShift const& phaseShift, Container& container, Check & check)
618 : CreatureSearcherBase<Check, SearcherContainerResult<Creature*>>(phaseShift, container, check) { }
619
620 template<typename Container>
621 CreatureListSearcher(WorldObject const* searcher, Container& container, Check & check)
622 : CreatureListSearcher(searcher->GetPhaseShift(), container, check) { }
623 };
624
625 template<class Work>
626 struct CreatureWorker : WorldObjectWorkerBase<Work, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CREATURE>>
627 {
628 CreatureWorker(PhaseShift const& phaseShift, Work& work)
630
631 CreatureWorker(WorldObject const* searcher, Work& work)
632 : CreatureWorker(searcher->GetPhaseShift(), work) { }
633 };
634
635 // Player searchers
636
637 template<class Check, class Result>
638 struct PlayerSearcherBase : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_PLAYER>>
639 {
640 template<typename Container>
641 PlayerSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check)
642 : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_PLAYER>>(phaseShift, result, check) { }
643 };
644
645 template<class Check>
646 struct PlayerSearcher : PlayerSearcherBase<Check, SearcherFirstObjectResult<Player*>>
647 {
648 PlayerSearcher(PhaseShift const& phaseShift, Player*& result, Check& check)
649 : PlayerSearcherBase<Check, SearcherFirstObjectResult<Player*>>(phaseShift, result, check) { }
650
651 PlayerSearcher(WorldObject const* searcher, Player*& result, Check& check)
652 : PlayerSearcher(searcher->GetPhaseShift(), result, check) { }
653 };
654
655 template<class Check>
656 struct PlayerLastSearcher : PlayerSearcherBase<Check, SearcherLastObjectResult<Player*>>
657 {
658 PlayerLastSearcher(PhaseShift const& phaseShift, Player*& result, Check& check)
659 : PlayerSearcherBase<Check, SearcherLastObjectResult<Player*>>(phaseShift, result, check) { }
660
661 PlayerLastSearcher(WorldObject const* searcher, Player*& result, Check& check)
662 : PlayerLastSearcher(searcher->GetPhaseShift(), result, check) { }
663 };
664
665 template<class Check>
666 struct PlayerListSearcher : PlayerSearcherBase<Check, SearcherContainerResult<Player*>>
667 {
668 template<typename Container>
669 PlayerListSearcher(PhaseShift const& phaseShift, Container& container, Check& check)
670 : PlayerSearcherBase<Check, SearcherContainerResult<Player*>>(phaseShift, container, check) { }
671
672 template<typename Container>
673 PlayerListSearcher(WorldObject const* searcher, Container& container, Check& check)
674 : PlayerListSearcher(searcher->GetPhaseShift(), container, check) { }
675 };
676
677 template<class Work>
678 struct PlayerWorker : WorldObjectWorkerBase<Work, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_PLAYER>>
679 {
680 PlayerWorker(PhaseShift const& phaseShift, Work& work)
682
683 PlayerWorker(WorldObject const* searcher, Work& work)
684 : PlayerWorker(searcher->GetPhaseShift(), work) { }
685 };
686
687 template<class Work>
689 {
691 float i_dist;
692 Work& i_work;
693
694 PlayerDistWorker(WorldObject const* searcher, float _dist, Work& _do)
695 : i_searcher(searcher), i_dist(_dist), i_work(_do) { }
696
697 void Visit(PlayerMapType const& m) const
698 {
699 for (GridReference<Player> const& ref : m)
700 if (ref.GetSource()->InSamePhase(i_searcher) && ref.GetSource()->IsWithinDist(i_searcher, i_dist))
701 i_work(ref.GetSource());
702 }
703
704 template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> const&) const { }
705 };
706
707 // AreaTrigger searchers
708 template<class Check, class Result>
709 struct AreaTriggerSearcherBase : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_AREATRIGGER>>
710 {
711 template<typename Container>
712 AreaTriggerSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check)
713 : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_AREATRIGGER>>(phaseShift, result, check) { }
714 };
715
716 template<class Check>
717 struct AreaTriggerSearcher : AreaTriggerSearcherBase<Check, SearcherFirstObjectResult<AreaTrigger*>>
718 {
719 AreaTriggerSearcher(PhaseShift const& phaseShift, AreaTrigger*& result, Check& check)
720 : AreaTriggerSearcherBase<Check, SearcherFirstObjectResult<AreaTrigger*>>(phaseShift, result, check) { }
721
722 AreaTriggerSearcher(WorldObject const* searcher, AreaTrigger*& result, Check& check)
723 : AreaTriggerSearcher(searcher->GetPhaseShift(), result, check) { }
724 };
725
726 template<class Check>
727 struct AreaTriggerLastSearcher : AreaTriggerSearcherBase<Check, SearcherLastObjectResult<AreaTrigger*>>
728 {
729 AreaTriggerLastSearcher(PhaseShift const& phaseShift, AreaTrigger*& result, Check& check)
730 : AreaTriggerSearcherBase<Check, SearcherLastObjectResult<AreaTrigger*>>(phaseShift, result, check) { }
731
732 AreaTriggerLastSearcher(WorldObject const* searcher, AreaTrigger*& result, Check& check)
733 : AreaTriggerLastSearcher(searcher->GetPhaseShift(), result, check) { }
734 };
735
736 template<class Check>
737 struct AreaTriggerListSearcher : AreaTriggerSearcherBase<Check, SearcherContainerResult<AreaTrigger*>>
738 {
739 template<typename Container>
740 AreaTriggerListSearcher(PhaseShift const& phaseShift, Container& container, Check& check)
741 : AreaTriggerSearcherBase<Check, SearcherContainerResult<AreaTrigger*>>(phaseShift, container, check) { }
742
743 template<typename Container>
744 AreaTriggerListSearcher(WorldObject const* searcher, Container& container, Check& check)
745 : AreaTriggerListSearcher(searcher->GetPhaseShift(), container, check) { }
746 };
747
748 template<class Work>
749 struct AreaTriggerWorker : WorldObjectWorkerBase<Work, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_AREATRIGGER>>
750 {
751 AreaTriggerWorker(PhaseShift const& phaseShift, Work& work)
753
754 AreaTriggerWorker(WorldObject const* searcher, Work& work)
755 : AreaTriggerWorker(searcher->GetPhaseShift(), work) { }
756 };
757
758 // SceneObject searchers
759 template<class Check, class Result>
760 struct SceneObjectSearcherBase : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_SCENEOBJECT>>
761 {
762 template<typename Container>
763 SceneObjectSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check)
764 : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_SCENEOBJECT>>(phaseShift, result, check) { }
765 };
766
767 template<class Check>
768 struct SceneObjectSearcher : SceneObjectSearcherBase<Check, SearcherFirstObjectResult<SceneObject*>>
769 {
770 SceneObjectSearcher(PhaseShift const& phaseShift, SceneObject*& result, Check& check)
771 : SceneObjectSearcherBase<Check, SearcherFirstObjectResult<SceneObject*>>(phaseShift, result, check) { }
772
773 SceneObjectSearcher(WorldObject const* searcher, SceneObject*& result, Check& check)
774 : SceneObjectSearcher(searcher->GetPhaseShift(), result, check) { }
775 };
776
777 template<class Check>
778 struct SceneObjectLastSearcher : SceneObjectSearcherBase<Check, SearcherLastObjectResult<SceneObject*>>
779 {
780 SceneObjectLastSearcher(PhaseShift const& phaseShift, SceneObject*& result, Check& check)
781 : SceneObjectSearcherBase<Check, SearcherLastObjectResult<SceneObject*>>(phaseShift, result, check) { }
782
783 SceneObjectLastSearcher(WorldObject const* searcher, SceneObject*& result, Check& check)
784 : SceneObjectLastSearcher(searcher->GetPhaseShift(), result, check) { }
785 };
786
787 template<class Check>
788 struct SceneObjectListSearcher : SceneObjectSearcherBase<Check, SearcherContainerResult<SceneObject*>>
789 {
790 template<typename Container>
791 SceneObjectListSearcher(PhaseShift const& phaseShift, Container& container, Check& check)
792 : SceneObjectSearcherBase<Check, SearcherContainerResult<SceneObject*>>(phaseShift, container, check) { }
793
794 template<typename Container>
795 SceneObjectListSearcher(WorldObject const* searcher, Container& container, Check& check)
796 : SceneObjectListSearcher(searcher->GetPhaseShift(), container, check) { }
797 };
798
799 template<class Work>
800 struct SceneObjectWorker : WorldObjectWorkerBase<Work, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_SCENEOBJECT>>
801 {
802 SceneObjectWorker(PhaseShift const& phaseShift, Work& work)
804
805 SceneObjectWorker(WorldObject const* searcher, Work& work)
806 : SceneObjectWorker(searcher->GetPhaseShift(), work) { }
807 };
808
809 // Conversation searchers
810 template<class Check, class Result>
811 struct ConversationSearcherBase : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CONVERSATION>>
812 {
813 template<typename Container>
814 ConversationSearcherBase(PhaseShift const& phaseShift, Container& result, Check& check)
815 : WorldObjectSearcherBase<Check, Result, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CONVERSATION>>(phaseShift, result, check) { }
816 };
817
818 template<class Check>
819 struct ConversationSearcher : ConversationSearcherBase<Check, SearcherFirstObjectResult<Conversation*>>
820 {
821 ConversationSearcher(PhaseShift const& phaseShift, Conversation*& result, Check& check)
822 : ConversationSearcherBase<Check, SearcherFirstObjectResult<Conversation*>>(phaseShift, result, check) { }
823
824 ConversationSearcher(WorldObject const* searcher, Conversation*& result, Check& check)
825 : ConversationSearcher(searcher->GetPhaseShift(), result, check) { }
826 };
827
828 template<class Check>
829 struct ConversationLastSearcher : ConversationSearcherBase<Check, SearcherLastObjectResult<Conversation*>>
830 {
831 ConversationLastSearcher(PhaseShift const& phaseShift, Conversation*& result, Check& check)
832 : ConversationSearcherBase<Check, SearcherLastObjectResult<Conversation*>>(phaseShift, result, check) { }
833
834 ConversationLastSearcher(WorldObject const* searcher, Conversation*& result, Check& check)
835 : ConversationLastSearcher(searcher->GetPhaseShift(), result, check) { }
836 };
837
838 template<class Check>
839 struct ConversationListSearcher : ConversationSearcherBase<Check, SearcherContainerResult<Conversation*>>
840 {
841 template<typename Container>
842 ConversationListSearcher(PhaseShift const& phaseShift, Container& container, Check& check)
843 : ConversationSearcherBase<Check, SearcherContainerResult<Conversation*>>(phaseShift, container, check) { }
844
845 template<typename Container>
846 ConversationListSearcher(WorldObject const* searcher, Container& container, Check& check)
847 : ConversationListSearcher(searcher->GetPhaseShift(), container, check) { }
848 };
849
850 template<class Work>
851 struct ConversationWorker : WorldObjectWorkerBase<Work, StaticGridMapTypeMaskCheck<GRID_MAP_TYPE_MASK_CONVERSATION>>
852 {
855
856 ConversationWorker(WorldObject const* searcher, Work& work)
857 : ConversationWorker(searcher->GetPhaseShift(), work) { }
858 };
859
860 // CHECKS && DO classes
861
862 // CHECK modifiers
864 {
865 public:
866 explicit InRangeCheckCustomizer(WorldObject const& obj, float range) : i_obj(obj), i_range(range) { }
867
868 bool Test(WorldObject const* o) const
869 {
870 return i_obj.IsWithinDist(o, i_range);
871 }
872
873 void Update(WorldObject const* /*o*/) { }
874
875 private:
877 float i_range;
878 };
879
881 {
882 public:
883 explicit NearestCheckCustomizer(WorldObject const& obj, float range) : i_obj(obj), i_range(range) { }
884
885 bool Test(WorldObject const* o) const
886 {
887 return i_obj.IsWithinDist(o, i_range);
888 }
889
890 void Update(WorldObject const* o)
891 {
893 }
894
895 private:
897 float i_range;
898 };
899
900 // WorldObject check classes
901
903 {
904 public:
905 AnyDeadUnitObjectInRangeCheck(WorldObject* searchObj, float range) : i_searchObj(searchObj), i_range(range) { }
906 bool operator()(Player* u);
907 bool operator()(Corpse* u);
908 bool operator()(Creature* u);
909 template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
910 protected:
912 float i_range;
913 };
914
916 {
917 public:
919 : AnyDeadUnitObjectInRangeCheck(searchObj, range), WorldObjectSpellTargetCheck(searchObj, searchObj, spellInfo, check, nullptr, objectType)
920 { }
921 bool operator()(Player* u);
922 bool operator()(Corpse* u);
923 bool operator()(Creature* u);
924 template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
925 };
926
927 // WorldObject do classes
928
930 {
931 public:
933 void operator()(Creature* u) const { u->Respawn(); }
934 void operator()(GameObject* u) const { u->Respawn(); }
935 void operator()(WorldObject const*) const { }
936 };
937
938 // GameObject checks
939
941 {
942 public:
943 GameObjectFocusCheck(WorldObject const* caster, uint32 focusId) : _caster(caster), _focusId(focusId) { }
944
945 bool operator()(GameObject* go) const
946 {
947 if (go->GetGOInfo()->GetSpellFocusType() != _focusId)
948 return false;
949
950 if (!go->isSpawned())
951 return false;
952
953 float const dist = go->GetGOInfo()->GetSpellFocusRadius();
954 return go->IsWithinDist(_caster, dist);
955 }
956
957 private:
960 };
961
962 // Find the nearest Fishing hole and return true only if source object is in range of hole
964 {
965 public:
966 NearestGameObjectFishingHole(WorldObject const& obj, float range) : i_obj(obj), i_range(range) { }
967
969 {
971 {
973 return true;
974 }
975 return false;
976 }
977
978 private:
980 float i_range;
981
982 // prevent clone
984 };
985
987 {
988 public:
989 NearestGameObjectCheck(WorldObject const& obj) : i_obj(obj), i_range(999.f) { }
990
992 {
993 if (i_obj.IsWithinDist(go, i_range))
994 {
995 i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
996 return true;
997 }
998 return false;
999 }
1000
1001 private:
1003 float i_range;
1004
1005 // prevent clone this object
1007 };
1008
1009 // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO)
1011 {
1012 public:
1013 NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range, bool spawnedOnly = true) : i_obj(obj), i_entry(entry), i_range(range), i_spawnedOnly(spawnedOnly) { }
1014
1016 {
1017 if ((!i_spawnedOnly || go->isSpawned()) && go->GetEntry() == i_entry && go->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDist(go, i_range))
1018 {
1019 i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
1020 return true;
1021 }
1022 return false;
1023 }
1024
1025 private:
1028 float i_range;
1030
1031 // prevent clone this object
1033 };
1034
1035 // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest unspawned GO)
1037 {
1038 public:
1039 NearestUnspawnedGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) { }
1040
1042 {
1043 if (!go->isSpawned() && go->GetEntry() == i_entry && go->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDist(go, i_range))
1044 {
1045 i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
1046 return true;
1047 }
1048 return false;
1049 }
1050
1051 private:
1054 float i_range;
1055
1056 // prevent clone this object
1058 };
1059
1060 // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO with a certain type)
1062 {
1063 public:
1064 NearestGameObjectTypeInObjectRangeCheck(WorldObject const& obj, GameobjectTypes type, float range) : i_obj(obj), i_type(type), i_range(range) { }
1065
1067 {
1068 if (go->GetGoType() == i_type && i_obj.IsWithinDist(go, i_range))
1069 {
1070 i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
1071 return true;
1072 }
1073 return false;
1074 }
1075
1076 private:
1079 float i_range;
1080
1081 // prevent clone this object
1083 };
1084
1085 // Unit checks
1086
1088 {
1089 public:
1090 MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) { }
1091
1093 {
1094 if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDist(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
1095 {
1096 i_hp = u->GetMaxHealth() - u->GetHealth();
1097 return true;
1098 }
1099 return false;
1100 }
1101
1102 private:
1103 Unit const* i_obj;
1104 float i_range;
1106 };
1107
1109 {
1110 public:
1111 MostHPPercentMissingInRange(Unit const* obj, float range, uint32 minHpPct, uint32 maxHpPct) : i_obj(obj), i_range(range), i_minHpPct(minHpPct), i_maxHpPct(maxHpPct), i_hpPct(101.f) { }
1112
1114 {
1115 if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDist(u, i_range) && i_minHpPct <= u->GetHealthPct() && u->GetHealthPct() <= i_maxHpPct && u->GetHealthPct() < i_hpPct)
1116 {
1117 i_hpPct = u->GetHealthPct();
1118 return true;
1119 }
1120 return false;
1121 }
1122
1123 private:
1124 Unit const* i_obj;
1125 float i_range;
1127 };
1128
1130 {
1131 public:
1132 FriendlyBelowHpPctEntryInRange(Unit const* obj, uint32 entry, float range, uint8 pct, bool excludeSelf) : i_obj(obj), i_entry(entry), i_range(range), i_pct(pct), i_excludeSelf(excludeSelf) { }
1133
1135 {
1136 if (i_excludeSelf && i_obj->GetGUID() == u->GetGUID())
1137 return false;
1138 if (u->GetEntry() == i_entry && u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDist(u, i_range) && u->HealthBelowPct(i_pct))
1139 return true;
1140 return false;
1141 }
1142
1143 private:
1144 Unit const* i_obj;
1146 float i_range;
1149 };
1150
1152 {
1153 public:
1154 FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) { }
1155
1156 bool operator()(Unit* u) const
1157 {
1158 if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDist(u, i_range) &&
1160 {
1161 return true;
1162 }
1163 return false;
1164 }
1165
1166 private:
1167 Unit const* i_obj;
1168 float i_range;
1169 };
1170
1172 {
1173 public:
1174 FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) { }
1175
1176 bool operator()(Unit* u) const
1177 {
1178 if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDist(u, i_range) && !u->HasAura(i_spell))
1179 return true;
1180
1181 return false;
1182 }
1183
1184 private:
1185 Unit const* i_obj;
1186 float i_range;
1188 };
1189
1191 {
1192 public:
1193 AnyUnfriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
1194
1195 bool operator()(Unit* u) const
1196 {
1197 if (u->IsAlive() && i_obj->IsWithinDist(u, i_range) && !i_funit->IsFriendlyTo(u))
1198 return true;
1199
1200 return false;
1201 }
1202
1203 private:
1206 float i_range;
1207 };
1208
1210 {
1211 public:
1213
1215 {
1216 if (!u->IsAlive())
1217 return false;
1218
1220 return false;
1221
1222 if (u->GetTypeId() == TYPEID_UNIT && u->ToCreature()->IsTotem())
1223 return false;
1224
1225 if (!u->isTargetableForAttack(false))
1226 return false;
1227
1229 return false;
1230
1231 i_range = i_obj->GetDistance(*u);
1232 return true;
1233 }
1234
1235 private:
1237 float i_range;
1238 };
1239
1241 {
1242 public:
1243 AnyFriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool playerOnly = false, bool incOwnRadius = true, bool incTargetRadius = true)
1244 : i_obj(obj), i_funit(funit), i_range(range), i_playerOnly(playerOnly), i_incOwnRadius(incOwnRadius), i_incTargetRadius(incTargetRadius) { }
1245
1246 bool operator()(Unit* u) const
1247 {
1248 if (!u->IsAlive())
1249 return false;
1250
1251 float searchRadius = i_range;
1252 if (i_incOwnRadius)
1253 searchRadius += i_obj->GetCombatReach();
1255 searchRadius += u->GetCombatReach();
1256
1257 if (!u->IsInMap(i_obj) || !u->InSamePhase(i_obj) || !u->IsWithinVerticalCylinder(*i_obj, searchRadius, searchRadius, true))
1258 return false;
1259
1260 if (!i_funit->IsFriendlyTo(u))
1261 return false;
1262
1263 return !i_playerOnly || u->GetTypeId() == TYPEID_PLAYER;
1264 }
1265
1266 private:
1269 float i_range;
1273 };
1274
1276 {
1277 public:
1278 AnyGroupedUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool raid, bool playerOnly = false, bool incOwnRadius = true, bool incTargetRadius = true)
1279 : _source(obj), _refUnit(funit), _range(range), _raid(raid), _playerOnly(playerOnly), i_incOwnRadius(incOwnRadius), i_incTargetRadius(incTargetRadius) { }
1280
1281 bool operator()(Unit* u) const
1282 {
1283 if (_playerOnly && u->GetTypeId() != TYPEID_PLAYER)
1284 return false;
1285
1286 if (_raid)
1287 {
1288 if (!_refUnit->IsInRaidWith(u))
1289 return false;
1290 }
1291 else if (!_refUnit->IsInPartyWith(u))
1292 return false;
1293
1294 if (_refUnit->IsHostileTo(u))
1295 return false;
1296
1297 if (!u->IsAlive())
1298 return false;
1299
1300 float searchRadius = _range;
1301 if (i_incOwnRadius)
1302 searchRadius += _source->GetCombatReach();
1304 searchRadius += u->GetCombatReach();
1305
1306 return u->IsInMap(_source) && u->InSamePhase(_source) && u->IsWithinVerticalCylinder(*_source, searchRadius, searchRadius, true);
1307 }
1308
1309 private:
1312 float _range;
1313 bool _raid;
1317 };
1318
1320 {
1321 public:
1322 AnyUnitInObjectRangeCheck(WorldObject const* obj, float range, bool check3D = true, bool reqAlive = true) : i_obj(obj), i_range(range), i_check3D(check3D), i_reqAlive(reqAlive) { }
1323
1324 bool operator()(Unit* u) const
1325 {
1326 if (i_reqAlive && !u->IsAlive())
1327 return false;
1328
1330 return false;
1331
1332 return true;
1333 }
1334
1335 private:
1337 float i_range;
1340 };
1341
1342 // Success at unit in range, range update for next check (this can be use with UnitLastSearcher to find nearest unit)
1344 {
1345 public:
1346 NearestAttackableUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
1347
1349 {
1352 {
1353 i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
1354 return true;
1355 }
1356
1357 return false;
1358 }
1359
1360 private:
1363 float i_range;
1364
1365 // prevent clone this object
1367 };
1368
1370 {
1371 public:
1372 AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, SpellInfo const* spellInfo = nullptr, bool incOwnRadius = true, bool incTargetRadius = true)
1373 : i_obj(obj), i_funit(funit), _spellInfo(spellInfo), i_range(range), i_incOwnRadius(incOwnRadius), i_incTargetRadius(incTargetRadius)
1374 {
1375 }
1376
1377 bool operator()(Unit* u) const
1378 {
1379 // Check contains checks for: live, uninteractible, non-attackable flags, flight check and GM check, ignore totems
1380 if (u->GetTypeId() == TYPEID_UNIT && u->IsTotem())
1381 return false;
1382
1383 if (_spellInfo)
1384 {
1385 if (!u->IsPlayer())
1386 {
1388 return false;
1389
1391 return false;
1392 }
1394 return false;
1395 }
1396
1398 return false;
1399
1400 float searchRadius = i_range;
1401 if (i_incOwnRadius)
1402 searchRadius += i_obj->GetCombatReach();
1404 searchRadius += u->GetCombatReach();
1405
1406 return u->IsInMap(i_obj) && u->InSamePhase(i_obj) && u->IsWithinVerticalCylinder(*i_obj, searchRadius, searchRadius, true);
1407 }
1408
1409 private:
1413 float i_range;
1416 };
1417
1418 // do attack at call of help to friendly crearture
1420 {
1421 public:
1422 CallOfHelpCreatureInRangeDo(Unit* funit, Unit* enemy, float range)
1423 : i_funit(funit), i_enemy(enemy), i_range(range) { }
1424
1425 void operator()(Creature* u) const
1426 {
1427 if (u == i_funit)
1428 return;
1429
1430 if (!u->CanAssistTo(i_funit, i_enemy, false))
1431 return;
1432
1433 // too far
1434 // Don't use combat reach distance, range must be an absolute value, otherwise the chain aggro range will be too big
1435 if (!u->IsWithinDist(i_funit, i_range, true, false, false))
1436 return;
1437
1438 // only if see assisted creature's enemy
1439 if (!u->IsWithinLOSInMap(i_enemy))
1440 return;
1441
1443 }
1444 private:
1447 float i_range;
1448 };
1449
1451 {
1452 bool operator()(Unit* u) const
1453 {
1454 return !u->IsAlive();
1455 }
1456 };
1457
1458 // Creature checks
1459
1461 {
1462 public:
1463 explicit NearestHostileUnitCheck(Creature const* creature, float dist = 0.f, bool playerOnly = false) : me(creature), i_playerOnly(playerOnly)
1464 {
1465 m_range = (dist == 0.f ? 9999.f : dist);
1466 }
1467
1469 {
1470 if (!me->IsWithinDist(u, m_range))
1471 return false;
1472
1473 if (!me->IsValidAttackTarget(u))
1474 return false;
1475
1476 if (i_playerOnly && u->GetTypeId() != TYPEID_PLAYER)
1477 return false;
1478
1479 m_range = me->GetDistance(u); // use found unit range as new range limit for next check
1480 return true;
1481 }
1482
1483 private:
1484 Creature const* me;
1485 float m_range;
1488 };
1489
1491 {
1492 public:
1493 explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0.f) : me(creature)
1494 {
1495 m_range = (dist == 0.f ? 9999.f : dist);
1496 m_force = (dist == 0.f ? false : true);
1497 }
1498
1500 {
1501 if (!me->IsWithinDist(u, m_range))
1502 return false;
1503
1504 if (!me->CanSeeOrDetect(u))
1505 return false;
1506
1507 if (m_force)
1508 {
1509 if (!me->IsValidAttackTarget(u))
1510 return false;
1511 }
1512 else if (!me->CanStartAttack(u, false))
1513 return false;
1514
1515 m_range = me->GetDistance(u); // use found unit range as new range limit for next check
1516 return true;
1517 }
1518
1519 private:
1520 Creature const* me;
1521 float m_range;
1524 };
1525
1527 {
1528 public:
1529 explicit NearestHostileUnitInAggroRangeCheck(Creature const* creature, bool useLOS = false, bool ignoreCivilians = false) : _me(creature), _useLOS(useLOS), _ignoreCivilians(ignoreCivilians) { }
1530
1531 bool operator()(Unit* u) const
1532 {
1533 if (!u->IsHostileTo(_me))
1534 return false;
1535
1536 if (!u->IsWithinDist(_me, _me->GetAggroRange(u)))
1537 return false;
1538
1539 if (!_me->IsValidAttackTarget(u))
1540 return false;
1541
1542 if (_useLOS && !u->IsWithinLOSInMap(_me))
1543 return false;
1544
1545 // pets in aggressive do not attack civilians
1546 if (_ignoreCivilians)
1547 if (Creature* c = u->ToCreature())
1548 if (c->IsCivilian())
1549 return false;
1550
1551 return true;
1552 }
1553
1554 private:
1559 };
1560
1562 {
1563 public:
1564 AnyAssistCreatureInRangeCheck(Unit* funit, Unit* enemy, float range)
1565 : i_funit(funit), i_enemy(enemy), i_range(range) { }
1566
1567 bool operator()(Creature* u) const
1568 {
1569 if (u == i_funit)
1570 return false;
1571
1572 if (!u->CanAssistTo(i_funit, i_enemy))
1573 return false;
1574
1575 // too far
1576 // Don't use combat reach distance, range must be an absolute value, otherwise the chain aggro range will be too big
1577 if (!i_funit->IsWithinDist(u, i_range, true, false, false))
1578 return false;
1579
1580 // only if see assisted creature
1581 if (!i_funit->IsWithinLOSInMap(u))
1582 return false;
1583
1584 return true;
1585 }
1586
1587 private:
1590 float i_range;
1591 };
1592
1594 {
1595 public:
1597 : i_obj(obj), i_enemy(enemy), i_range(range) { }
1598
1600 {
1601 if (u == i_obj)
1602 return false;
1603 if (!u->CanAssistTo(i_obj, i_enemy))
1604 return false;
1605
1606 // Don't use combat reach distance, range must be an absolute value, otherwise the chain aggro range will be too big
1607 if (!i_obj->IsWithinDist(u, i_range, true, false, false))
1608 return false;
1609
1610 if (!i_obj->IsWithinLOSInMap(u))
1611 return false;
1612
1613 i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
1614 return true;
1615 }
1616
1617 private:
1620 float i_range;
1621
1622 // prevent clone this object
1624 };
1625
1626 // Success at unit in range, range update for next check (this can be use with CreatureLastSearcher to find nearest creature)
1628 {
1629 public:
1631 : i_obj(obj), i_entry(entry), i_alive(alive), i_range(range) { }
1632
1634 {
1635 if (u->getDeathState() != DEAD
1636 && u->GetEntry() == i_entry
1637 && u->IsAlive() == i_alive
1638 && u->GetGUID() != i_obj.GetGUID()
1641 {
1642 i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
1643 return true;
1644 }
1645 return false;
1646 }
1647
1648 private:
1652 float i_range;
1653
1654 // prevent clone this object
1656 };
1657
1658 template <typename Customizer = InRangeCheckCustomizer>
1660 {
1661 public:
1662 CreatureWithOptionsInObjectRangeCheck(WorldObject const& obj, Customizer& customizer, FindCreatureOptions const& args)
1663 : i_obj(obj), i_args(args), i_customizer(customizer) { }
1664
1665 bool operator()(Creature const* u) const
1666 {
1667 if (u->getDeathState() == DEAD) // Despawned
1668 return false;
1669
1670 if (u->GetGUID() == i_obj.GetGUID())
1671 return false;
1672
1673 if (!i_customizer.Test(u))
1674 return false;
1675
1677 return false;
1678
1680 return false;
1681
1682 if (i_args.IsAlive.has_value())
1683 {
1684 switch (*i_args.IsAlive)
1685 {
1687 {
1688 if (!u->IsAlive())
1689 return false;
1690 break;
1691 }
1693 {
1694 if (u->IsAlive())
1695 return false;
1696 break;
1697 }
1699 {
1701 return false;
1702 break;
1703 }
1705 {
1707 return false;
1708 break;
1709 }
1710 default:
1711 break;
1712 }
1713 }
1714
1715 if (i_args.IsSummon.has_value() && u->IsSummon() != i_args.IsSummon)
1716 return false;
1717
1718 if (i_args.IsInCombat.has_value() && u->IsInCombat() != i_args.IsInCombat)
1719 return false;
1720
1726 return false;
1727
1729 return false;
1730
1732 return false;
1733
1735 return false;
1736
1737 i_customizer.Update(u);
1738 return true;
1739 }
1740
1741 private:
1744 Customizer& i_customizer;
1745 };
1746
1747 template <typename Customizer = InRangeCheckCustomizer>
1749 {
1750 public:
1751 GameObjectWithOptionsInObjectRangeCheck(WorldObject const& obj, Customizer& customizer, FindGameObjectOptions const& args)
1752 : i_obj(obj), i_args(args), i_customizer(customizer) { }
1753
1754 bool operator()(GameObject const* go) const
1755 {
1756 if (i_args.IsSpawned.has_value() && i_args.IsSpawned != go->isSpawned()) // Despawned
1757 return false;
1758
1759 if (go->GetGUID() == i_obj.GetGUID())
1760 return false;
1761
1762 if (!i_customizer.Test(go))
1763 return false;
1764
1766 return false;
1767
1769 return false;
1770
1771 if (i_args.IsSummon.has_value() && (go->GetSpawnId() == 0) != i_args.IsSummon)
1772 return false;
1773
1774 if ((i_args.OwnerGuid && go->GetOwnerGUID() != i_args.OwnerGuid)
1776 return false;
1777
1779 return false;
1780
1782 return false;
1783
1785 return false;
1786
1787 i_customizer.Update(go);
1788 return true;
1789 }
1790
1791 private:
1794 Customizer& i_customizer;
1795 };
1796
1798 {
1799 public:
1800 AnyPlayerInPositionRangeCheck(Position const* pos, float range, bool reqAlive = true) : _pos(pos), _range(range), _reqAlive(reqAlive) { }
1802 {
1803 if (_reqAlive && !u->IsAlive())
1804 return false;
1805
1806 if (!u->IsWithinDist3d(_pos, _range))
1807 return false;
1808
1809 return true;
1810 }
1811
1812 private:
1814 float _range;
1816 };
1817
1819 {
1820 public:
1821 NearestPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { }
1822
1824 {
1825 if (u->IsAlive() && i_obj->IsWithinDist(u, i_range))
1826 {
1828 return true;
1829 }
1830
1831 return false;
1832 }
1833 private:
1835 float i_range;
1836
1838 };
1839
1841 {
1842 public:
1843 AllFriendlyCreaturesInGrid(Unit const* obj) : unit(obj) { }
1844
1845 bool operator()(Unit* u) const
1846 {
1847 if (u->IsAlive() && u->IsVisible() && u->IsFriendlyTo(unit))
1848 return true;
1849
1850 return false;
1851 }
1852
1853 private:
1854 Unit const* unit;
1855 };
1856
1858 {
1859 public:
1860 AllGameObjectsWithEntryInRange(WorldObject const* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { }
1861
1862 bool operator()(GameObject* go) const
1863 {
1864 if ((!m_uiEntry || go->GetEntry() == m_uiEntry) && m_pObject->IsWithinDist(go, m_fRange, false))
1865 return true;
1866
1867 return false;
1868 }
1869
1870 private:
1874 };
1875
1877 {
1878 public:
1879 AllCreaturesOfEntryInRange(WorldObject const* object, uint32 entry, float maxRange = 0.0f) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { }
1880
1881 bool operator()(Unit* unit) const
1882 {
1883 if (m_uiEntry)
1884 {
1885 if (unit->GetEntry() != m_uiEntry)
1886 return false;
1887 }
1888
1889 if (m_fRange)
1890 {
1891 if (m_fRange > 0.0f && !m_pObject->IsWithinDist(unit, m_fRange, false))
1892 return false;
1893 if (m_fRange < 0.0f && m_pObject->IsWithinDist(unit, m_fRange, false))
1894 return false;
1895 }
1896
1897 return true;
1898 }
1899
1900 private:
1904 };
1905
1907 {
1908 public:
1909 PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : unit(unit), fRange(fMinRange) { }
1910
1911 bool operator()(Player* player) const
1912 {
1913 //No threat list check, must be done explicit if expected to be in combat with creature
1914 if (!player->IsGameMaster() && player->IsAlive() && !unit->IsWithinDist(player, fRange, false))
1915 return true;
1916
1917 return false;
1918 }
1919
1920 private:
1921 Unit const* unit;
1922 float fRange;
1923 };
1924
1926 {
1927 public:
1928 GameObjectInRangeCheck(float _x, float _y, float _z, float _range, uint32 _entry = 0) :
1929 x(_x), y(_y), z(_z), range(_range), entry(_entry) { }
1930
1931 bool operator()(GameObject* go) const
1932 {
1933 if (!entry || (go->GetGOInfo() && go->GetGOInfo()->entry == entry))
1934 return go->IsInRange(x, y, z, range);
1935 else return false;
1936 }
1937
1938 private:
1939 float x, y, z, range;
1941 };
1942
1944 {
1945 public:
1946 AllWorldObjectsInRange(WorldObject const* object, float maxRange) : m_pObject(object), m_fRange(maxRange) { }
1947
1948 bool operator()(WorldObject* go) const
1949 {
1950 return m_pObject->IsWithinDist(go, m_fRange, false) && m_pObject->InSamePhase(go);
1951 }
1952
1953 private:
1956 };
1957
1959 {
1960 public:
1961 ObjectTypeIdCheck(TypeID typeId, bool equals) : _typeId(typeId), _equals(equals) { }
1962
1963 bool operator()(WorldObject* object) const
1964 {
1965 return (object->GetTypeId() == _typeId) == _equals;
1966 }
1967
1968 private:
1971 };
1972
1974 {
1975 public:
1977
1978 bool operator()(WorldObject* object) const
1979 {
1980 return object->GetGUID() == _GUID;
1981 }
1982
1983 private:
1985 };
1986
1988 {
1989 public:
1990 HeightDifferenceCheck(WorldObject* go, float diff, bool reverse)
1991 : _baseObject(go), _difference(diff), _reverse(reverse)
1992 {
1993 }
1994
1995 bool operator()(WorldObject* unit) const
1996 {
1997 return (unit->GetPositionZ() - _baseObject->GetPositionZ() > _difference) != _reverse;
1998 }
1999
2000 private:
2004 };
2005
2007 {
2008 public:
2009 UnitAuraCheck(bool present, uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty) : _present(present), _spellId(spellId), _casterGUID(casterGUID) { }
2010
2011 bool operator()(Unit* unit) const
2012 {
2013 return unit->HasAura(_spellId, _casterGUID) == _present;
2014 }
2015
2016 bool operator()(WorldObject* object) const
2017 {
2018 return object->ToUnit() && object->ToUnit()->HasAura(_spellId, _casterGUID) == _present;
2019 }
2020
2021 private:
2025 };
2026
2028 {
2029 public:
2031
2032 bool operator()(WorldObject* object) const
2033 {
2034 return object->GetEntry() == _entry && (!object->IsPrivateObject() || object->GetPrivateObjectOwner() == _ownerGUID);
2035 }
2036
2037 private:
2040 };
2041
2043 {
2044 public:
2045 NearestAreaTriggerEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range, bool spawnedOnly = false) : i_obj(obj), i_entry(entry), i_range(range), i_spawnedOnly(spawnedOnly) { }
2046
2047 bool operator()(AreaTrigger const* at)
2048 {
2049 if ((!i_spawnedOnly || at->IsStaticSpawn()) && at->GetEntry() == i_entry && at->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDist(at, i_range))
2050 {
2052 return true;
2053 }
2054 return false;
2055 }
2056
2057 private:
2060 float i_range;
2062
2063 // prevent clone this object
2065 };
2066
2067 // Player checks and do
2068
2069 // Prepare using Builder localized packets with caching and send to player
2070 template<typename Localizer>
2072 {
2073 using LocalizedAction = std::remove_pointer_t<decltype(std::declval<Localizer>()(LocaleConstant{}))>;
2074
2075 public:
2076 explicit LocalizedDo(Localizer& localizer) : _localizer(localizer) { }
2077
2078 void operator()(Player const* p);
2079
2080 private:
2081 Localizer& _localizer;
2082 std::vector<std::unique_ptr<LocalizedAction>> _localizedCache; // 0 = default, i => i-1 locale index
2083 };
2084}
2085#endif
LocaleConstant
Definition Common.h:51
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
@ GRID_MAP_TYPE_MASK_PLAYER
Definition GridDefines.h:80
@ GRID_MAP_TYPE_MASK_CREATURE
Definition GridDefines.h:77
@ GRID_MAP_TYPE_MASK_CONVERSATION
Definition GridDefines.h:83
@ GRID_MAP_TYPE_MASK_SCENEOBJECT
Definition GridDefines.h:82
@ GRID_MAP_TYPE_MASK_ALL
Definition GridDefines.h:84
@ GRID_MAP_TYPE_MASK_GAMEOBJECT
Definition GridDefines.h:79
@ GRID_MAP_TYPE_MASK_AREATRIGGER
Definition GridDefines.h:81
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition ObjectGuid.h:435
TypeID
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:43
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
GameobjectTypes
@ GAMEOBJECT_TYPE_FISHINGHOLE
@ SPELL_ATTR5_NOT_ON_PLAYER_CONTROLLED_NPC
@ SPELL_ATTR5_NOT_ON_PLAYER
@ CREATURE_TYPE_NON_COMBAT_PET
@ SPELL_ATTR3_ONLY_ON_PLAYER
@ TEAM_OTHER
SpellTargetCheckTypes
Definition SpellInfo.h:80
SpellTargetObjectTypes
Definition SpellInfo.h:64
@ UNIT_FLAG2_FEIGN_DEATH
@ DEAD
Definition Unit.h:255
@ UNIT_STATE_CONFUSED
Definition Unit.h:272
@ UNIT_STATE_STUNNED
Definition Unit.h:264
bool IsStaticSpawn() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool IsPlayer() const
Definition BaseEntity.h:173
TypeID GetTypeId() const
Definition BaseEntity.h:166
void Respawn(bool force=false)
float GetAggroRange(Unit const *target) const
bool HasStringId(std::string_view id) const
bool CanAssistTo(Unit const *u, Unit const *enemy, bool checkfaction=true) const
bool CanStartAttack(Unit const *u, bool force) const
bool HasStringId(std::string_view id) const
ObjectGuid GetOwnerGUID() const override
Definition GameObject.h:245
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:203
bool isSpawned() const
Definition GameObject.h:259
bool IsInRange(float x, float y, float z, float radius) const
GameobjectTypes GetGoType() const
Definition GameObject.h:282
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:212
Definition Grid.h:42
Definition Map.h:225
static ObjectGuid const Empty
Definition ObjectGuid.h:314
Player * ToPlayer()
Definition Object.h:126
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:6283
bool HaveAtClient(BaseEntity const *u) const
Definition Player.cpp:24475
bool IsGameMaster() const
Definition Player.h:1309
Team GetEffectiveTeam() const
Definition Player.h:2427
iterator end()
Definition RefManager.h:36
iterator begin()
Definition RefManager.h:35
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:456
AllCreaturesOfEntryInRange(WorldObject const *object, uint32 entry, float maxRange=0.0f)
bool operator()(GameObject *go) const
AllGameObjectsWithEntryInRange(WorldObject const *object, uint32 entry, float maxRange)
bool operator()(WorldObject *go) const
AllWorldObjectsInRange(WorldObject const *object, float maxRange)
AnyAoETargetUnitInObjectRangeCheck(WorldObject const *obj, Unit const *funit, float range, SpellInfo const *spellInfo=nullptr, bool incOwnRadius=true, bool incTargetRadius=true)
AnyAssistCreatureInRangeCheck(Unit *funit, Unit *enemy, float range)
WorldObject const *const i_searchObj
AnyDeadUnitObjectInRangeCheck(WorldObject *searchObj, float range)
AnyDeadUnitSpellTargetInRangeCheck(WorldObject *searchObj, float range, SpellInfo const *spellInfo, SpellTargetCheckTypes check, SpellTargetObjectTypes objectType)
AnyFriendlyUnitInObjectRangeCheck(WorldObject const *obj, Unit const *funit, float range, bool playerOnly=false, bool incOwnRadius=true, bool incTargetRadius=true)
AnyGroupedUnitInObjectRangeCheck(WorldObject const *obj, Unit const *funit, float range, bool raid, bool playerOnly=false, bool incOwnRadius=true, bool incTargetRadius=true)
AnyPlayerInPositionRangeCheck(Position const *pos, float range, bool reqAlive=true)
AnyUnfriendlyUnitInObjectRangeCheck(WorldObject const *obj, Unit const *funit, float range)
AnyUnitInObjectRangeCheck(WorldObject const *obj, float range, bool check3D=true, bool reqAlive=true)
CallOfHelpCreatureInRangeDo(Unit *funit, Unit *enemy, float range)
CreatureWithOptionsInObjectRangeCheck(WorldObject const &obj, Customizer &customizer, FindCreatureOptions const &args)
FriendlyBelowHpPctEntryInRange(Unit const *obj, uint32 entry, float range, uint8 pct, bool excludeSelf)
FriendlyCCedInRange(Unit const *obj, float range)
bool operator()(Unit *u) const
FriendlyMissingBuffInRange(Unit const *obj, float range, uint32 spellid)
bool operator()(GameObject *go) const
GameObjectFocusCheck(WorldObject const *caster, uint32 focusId)
WorldObject const * _caster
GameObjectInRangeCheck(float _x, float _y, float _z, float _range, uint32 _entry=0)
bool operator()(GameObject *go) const
bool operator()(GameObject const *go) const
GameObjectWithOptionsInObjectRangeCheck(WorldObject const &obj, Customizer &customizer, FindGameObjectOptions const &args)
bool operator()(WorldObject *unit) const
HeightDifferenceCheck(WorldObject *go, float diff, bool reverse)
bool Test(WorldObject const *o) const
void Update(WorldObject const *)
InRangeCheckCustomizer(WorldObject const &obj, float range)
Utility class to enable range for loop syntax for multimap.equal_range uses.
void operator()(Player const *p)
LocalizedDo(Localizer &localizer)
std::remove_pointer_t< decltype(std::declval< Localizer >()(LocaleConstant{}))> LocalizedAction
std::vector< std::unique_ptr< LocalizedAction > > _localizedCache
MostHPMissingInRange(Unit const *obj, float range, uint32 hp)
MostHPPercentMissingInRange(Unit const *obj, float range, uint32 minHpPct, uint32 maxHpPct)
NearestAreaTriggerEntryInObjectRangeCheck(WorldObject const &obj, uint32 entry, float range, bool spawnedOnly=false)
NearestAreaTriggerEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const &)=delete
NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const &)=delete
NearestAssistCreatureInCreatureRangeCheck(Creature *obj, Unit *enemy, float range)
NearestAttackableNoTotemUnitInObjectRangeCheck(WorldObject const *obj, float range)
NearestAttackableUnitInObjectRangeCheck(WorldObject const *obj, Unit const *funit, float range)
NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const &)=delete
NearestCheckCustomizer(WorldObject const &obj, float range)
bool Test(WorldObject const *o) const
void Update(WorldObject const *o)
NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const &obj, uint32 entry, bool alive, float range)
NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const &)=delete
NearestGameObjectCheck(WorldObject const &obj)
bool operator()(GameObject *go)
NearestGameObjectCheck(NearestGameObjectCheck const &)=delete
NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const &)=delete
NearestGameObjectEntryInObjectRangeCheck(WorldObject const &obj, uint32 entry, float range, bool spawnedOnly=true)
NearestGameObjectFishingHole(NearestGameObjectFishingHole const &)=delete
NearestGameObjectFishingHole(WorldObject const &obj, float range)
NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const &)=delete
NearestGameObjectTypeInObjectRangeCheck(WorldObject const &obj, GameobjectTypes type, float range)
NearestHostileUnitCheck(NearestHostileUnitCheck const &)=delete
NearestHostileUnitCheck(Creature const *creature, float dist=0.f, bool playerOnly=false)
NearestHostileUnitInAggroRangeCheck(NearestHostileUnitInAggroRangeCheck const &)=delete
NearestHostileUnitInAggroRangeCheck(Creature const *creature, bool useLOS=false, bool ignoreCivilians=false)
NearestHostileUnitInAttackDistanceCheck(Creature const *creature, float dist=0.f)
NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const &)=delete
NearestPlayerInObjectRangeCheck(NearestPlayerInObjectRangeCheck const &)=delete
NearestPlayerInObjectRangeCheck(WorldObject const *obj, float range)
NearestUnspawnedGameObjectEntryInObjectRangeCheck(NearestUnspawnedGameObjectEntryInObjectRangeCheck const &)=delete
NearestUnspawnedGameObjectEntryInObjectRangeCheck(WorldObject const &obj, uint32 entry, float range)
ObjectEntryAndPrivateOwnerIfExistsCheck(ObjectGuid ownerGUID, uint32 entry)
bool operator()(WorldObject *object) const
ObjectGUIDCheck(ObjectGuid GUID)
ObjectTypeIdCheck(TypeID typeId, bool equals)
bool operator()(WorldObject *object) const
bool operator()(Player *player) const
PlayerAtMinimumRangeAway(Unit const *unit, float fMinRange)
void operator()(GameObject *u) const
void operator()(WorldObject const *) const
void operator()(Creature *u) const
WorldObjectSearcherContinuation ShouldContinue() const
void(*)(void *, Type &&) InserterType
WorldObjectSearcherContinuation ShouldContinue() const
WorldObjectSearcherContinuation ShouldContinue() const
UnitAuraCheck(bool present, uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty)
bool operator()(WorldObject *object) const
bool operator()(Unit *unit) const
Definition Unit.h:635
bool IsCharmed() const
Definition Unit.h:1236
bool isTargetableForAttack(bool checkFakeDeath=true) const
Definition Unit.cpp:8585
float GetHealthPct() const
Definition Unit.h:796
ObjectGuid GetDemonCreatorGUID() const
Definition Unit.h:1203
ObjectGuid GetOwnerGUID() const override
Definition Unit.h:1191
bool HasUnitFlag2(UnitFlags2 flags) const
Definition Unit.h:850
bool IsAlive() const
Definition Unit.h:1185
float GetCombatReach() const override
Definition Unit.h:705
bool IsInCombatWith(Unit const *who) const
Definition Unit.h:1059
ObjectGuid GetCreatorGUID() const override
Definition Unit.h:1193
uint32 GetCreatureType() const
Definition Unit.cpp:9451
uint64 GetMaxHealth() const
Definition Unit.h:789
uint64 GetHealth() const
Definition Unit.h:788
bool IsSummon() const
Definition Unit.h:749
bool IsVisible() const
Definition Unit.cpp:8763
void EngageWithTarget(Unit *who)
Definition Unit.cpp:8494
bool HasRootAura() const
Definition Unit.h:1091
DeathState getDeathState() const
Definition Unit.h:1188
bool HealthBelowPct(float pct) const
Definition Unit.h:792
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool IsInRaidWith(Unit const *unit) const
Definition Unit.cpp:12177
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
bool IsControlledByPlayer() const
Definition Unit.h:1214
ObjectGuid GetCharmerGUID() const
Definition Unit.h:1208
bool IsTotem() const
Definition Unit.h:753
bool IsFeared() const
Definition Unit.h:1090
bool IsInPartyWith(Unit const *unit) const
Definition Unit.cpp:12158
bool IsInCombat() const
Definition Unit.h:1058
bool InSamePhase(PhaseShift const &phaseShift) const
Definition Object.h:314
bool IsWithinDist3d(float x, float y, float z, float dist) const
Definition Object.cpp:476
bool CheckPrivateObjectOwnerVisibility(WorldObject const *seer) const
Definition Object.cpp:829
ObjectGuid GetPrivateObjectOwner() const
Definition Object.h:569
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
Definition Object.cpp:2324
bool IsHostileTo(WorldObject const *target) const
Definition Object.cpp:2181
bool IsPrivateObject() const
Definition Object.h:568
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition Object.cpp:535
bool CanSeeOrDetect(WorldObject const *obj, CanSeeOrDetectExtraArgs const &args={ }) const
Definition Object.cpp:857
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:432
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:496
bool IsFriendlyTo(WorldObject const *target) const
Definition Object.cpp:2186
virtual float GetCombatReach() const
Definition Object.h:302
bool IsInMap(WorldObject const *obj) const
Definition Object.cpp:469
WorldObjectSearcherContinuation
Definition Cell.h:47
Optional< FindCreatureAliveState > IsAlive
Definition Object.h:236
Optional< std::string_view > StringId
Definition Object.h:234
Optional< ObjectGuid > CreatorGuid
Definition Object.h:247
Optional< bool > IsSummon
Definition Object.h:238
bool IgnoreNotOwnedPrivateObjects
Definition Object.h:241
bool IgnorePrivateObjects
Definition Object.h:242
Optional< uint32 > AuraSpellId
Definition Object.h:244
Optional< ObjectGuid > PrivateObjectOwnerGuid
Definition Object.h:249
Optional< uint32 > CreatureId
Definition Object.h:233
Optional< ObjectGuid > DemonCreatorGuid
Definition Object.h:248
Optional< bool > IsInCombat
Definition Object.h:237
Optional< ObjectGuid > OwnerGuid
Definition Object.h:245
Optional< ObjectGuid > CharmerGuid
Definition Object.h:246
bool IgnoreNotOwnedPrivateObjects
Definition Object.h:261
Optional< ObjectGuid > OwnerGuid
Definition Object.h:264
Optional< std::string_view > StringId
Definition Object.h:255
Optional< GameobjectTypes > GameObjectType
Definition Object.h:266
Optional< uint32 > GameObjectId
Definition Object.h:254
Optional< ObjectGuid > PrivateObjectOwnerGuid
Definition Object.h:265
Optional< bool > IsSummon
Definition Object.h:257
Optional< bool > IsSpawned
Definition Object.h:258
struct GameObjectTemplate::@197::@224 fishingHole
uint32 GetSpellFocusRadius() const
uint32 GetSpellFocusType() const
bool IsWithinVerticalCylinder(Position const &cylinderOrigin, float radius, float height, bool isDoubleVertical=false) const
Definition Position.cpp:96
constexpr float GetPositionZ() const
Definition Position.h:89
void Visit(GridRefManager< T > &)
bool operator()(Unit *u) const
AreaTriggerLastSearcher(WorldObject const *searcher, AreaTrigger *&result, Check &check)
AreaTriggerLastSearcher(PhaseShift const &phaseShift, AreaTrigger *&result, Check &check)
AreaTriggerListSearcher(PhaseShift const &phaseShift, Container &container, Check &check)
AreaTriggerListSearcher(WorldObject const *searcher, Container &container, Check &check)
AreaTriggerSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check)
AreaTriggerSearcher(PhaseShift const &phaseShift, AreaTrigger *&result, Check &check)
AreaTriggerSearcher(WorldObject const *searcher, AreaTrigger *&result, Check &check)
AreaTriggerWorker(WorldObject const *searcher, Work &work)
AreaTriggerWorker(PhaseShift const &phaseShift, Work &work)
ConversationLastSearcher(WorldObject const *searcher, Conversation *&result, Check &check)
ConversationLastSearcher(PhaseShift const &phaseShift, Conversation *&result, Check &check)
ConversationListSearcher(WorldObject const *searcher, Container &container, Check &check)
ConversationListSearcher(PhaseShift const &phaseShift, Container &container, Check &check)
ConversationSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check)
ConversationSearcher(WorldObject const *searcher, Conversation *&result, Check &check)
ConversationSearcher(PhaseShift const &phaseShift, Conversation *&result, Check &check)
ConversationWorker(PhaseShift const &phaseShift, Work &work)
ConversationWorker(WorldObject const *searcher, Work &work)
CreatureLastSearcher(WorldObject const *searcher, Creature *&result, Check &check)
CreatureLastSearcher(PhaseShift const &phaseShift, Creature *&result, Check &check)
CreatureListSearcher(WorldObject const *searcher, Container &container, Check &check)
CreatureListSearcher(PhaseShift const &phaseShift, Container &container, Check &check)
void Visit(GridRefManager< T > &)
CreatureSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check)
CreatureSearcher(PhaseShift const &phaseShift, Creature *&result, Check &check)
CreatureSearcher(WorldObject const *searcher, Creature *&result, Check &check)
CreatureWorker(PhaseShift const &phaseShift, Work &work)
CreatureWorker(WorldObject const *searcher, Work &work)
void Visit(GridRefManager< T > &)
DelayedUnitRelocation(Cell &c, CellCoord &pair, Map &map, float radius)
constexpr bool Includes(uint32 mapTypeMask) const
GameObjectLastSearcher(PhaseShift const &phaseShift, GameObject *&result, Check &check)
GameObjectLastSearcher(WorldObject const *searcher, GameObject *&result, Check &check)
GameObjectListSearcher(PhaseShift const &phaseShift, Container &container, Check &check)
GameObjectListSearcher(WorldObject const *searcher, Container &container, Check &check)
GameObjectSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check)
GameObjectSearcher(WorldObject const *searcher, GameObject *&result, Check &check)
GameObjectSearcher(PhaseShift const &phaseShift, GameObject *&result, Check &check)
GameObjectWorker(PhaseShift const &phaseShift, Work &work)
GameObjectWorker(WorldObject const *searcher, Work &work)
void Visit(CorpseMapType &m)
void Visit(PlayerMapType &m)
void Visit(SceneObjectMapType &m)
void updateObjects(GridRefManager< T > &m)
void Visit(CreatureMapType &m)
void Visit(DynamicObjectMapType &m)
void Visit(AreaTriggerMapType &m)
GridUpdater(GridType &grid, uint32 diff)
void Visit(ConversationMapType &m)
void Visit(GameObjectMapType &m)
MessageDistDelivererToHostile(Unit *src, PacketSender &packetSender, float dist)
void Visit(GridRefManager< SKIP > &) const
void SendPacket(Player const *player) const
void Visit(GridRefManager< SKIP > &) const
void SendPacket(Player const *player) const
MessageDistDeliverer(WorldObject const *src, PacketSender &packetSender, float dist, bool own_team_only=false, Player const *skipped=nullptr, bool req3dDist=false)
WorldObject const * i_source
PhaseShift const * i_phaseShift
void Visit(PlayerMapType &m) const
void Visit(PlayerMapType &)
void Visit(GridRefManager< T > &m)
void Visit(CorpseMapType &)
ObjectUpdater(const uint32 diff)
void operator()(Player const *player) const
WorldPacket const * Data
void operator()(Player const *player) const
PacketSenderRef(WorldPacket const *message)
void Visit(GridRefManager< NOT_INTERESTED > const &) const
WorldObject const * i_searcher
PlayerDistWorker(WorldObject const *searcher, float _dist, Work &_do)
void Visit(PlayerMapType const &m) const
PlayerLastSearcher(PhaseShift const &phaseShift, Player *&result, Check &check)
PlayerLastSearcher(WorldObject const *searcher, Player *&result, Check &check)
PlayerListSearcher(PhaseShift const &phaseShift, Container &container, Check &check)
PlayerListSearcher(WorldObject const *searcher, Container &container, Check &check)
void Visit(GridRefManager< T > &m)
PlayerSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check)
PlayerSearcher(WorldObject const *searcher, Player *&result, Check &check)
PlayerSearcher(PhaseShift const &phaseShift, Player *&result, Check &check)
PlayerWorker(PhaseShift const &phaseShift, Work &work)
PlayerWorker(WorldObject const *searcher, Work &work)
SceneObjectLastSearcher(PhaseShift const &phaseShift, SceneObject *&result, Check &check)
SceneObjectLastSearcher(WorldObject const *searcher, SceneObject *&result, Check &check)
SceneObjectListSearcher(WorldObject const *searcher, Container &container, Check &check)
SceneObjectListSearcher(PhaseShift const &phaseShift, Container &container, Check &check)
SceneObjectSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check)
SceneObjectSearcher(WorldObject const *searcher, SceneObject *&result, Check &check)
SceneObjectSearcher(PhaseShift const &phaseShift, SceneObject *&result, Check &check)
SceneObjectWorker(PhaseShift const &phaseShift, Work &work)
SceneObjectWorker(WorldObject const *searcher, Work &work)
static constexpr bool Includes(uint32 mapTypeMask)
UnitLastSearcher(WorldObject const *searcher, Unit *&result, Check &check)
UnitLastSearcher(PhaseShift const &phaseShift, Unit *&result, Check &check)
UnitListSearcher(WorldObject const *searcher, Container &container, Check &check)
UnitListSearcher(PhaseShift const &phaseShift, Container &container, Check &check)
UnitSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check)
UnitSearcher(WorldObject const *searcher, Unit *&result, Check &check)
UnitSearcher(PhaseShift const &phaseShift, Unit *&result, Check &check)
UnitWorker(PhaseShift const &phaseShift, Work &work)
UnitWorker(WorldObject const *searcher, Work &work)
IteratorPair< WorldObject ** > i_objects
void Visit(GridRefManager< T > &)
VisibleChangesNotifier(IteratorPair< WorldObject ** > objects)
VisibleNotifier(VisibleNotifier &&)=delete
VisibleNotifier & operator=(VisibleNotifier const &)=delete
GuidUnorderedSet vis_guids
VisibleNotifier & operator=(VisibleNotifier &&)=delete
VisibleNotifier(VisibleNotifier const &)=delete
std::set< WorldObject * > i_visibleNow
WorldObjectLastSearcher(PhaseShift const &phaseShift, WorldObject *&result, Check &check, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
WorldObjectLastSearcher(WorldObject const *searcher, WorldObject *&result, Check &check, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
WorldObjectListSearcher(PhaseShift const &phaseShift, Container &container, Check &check, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
WorldObjectListSearcher(WorldObject const *searcher, Container &container, Check &check, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
WorldObjectSearcherBase(PhaseShift const &phaseShift, Container &result, Check &check, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
void VisitImpl(GridRefManager< T > &)
void Visit(GridRefManager< T > &m)
WorldObjectSearcher(WorldObject const *searcher, WorldObject *&result, Check &check, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
WorldObjectSearcher(PhaseShift const &phaseShift, WorldObject *&result, Check &check, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
void VisitImpl(GridRefManager< T > const &m)
WorldObjectWorkerBase(PhaseShift const &phaseShift, Work &work, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
PhaseShift const * i_phaseShift
void Visit(GridRefManager< T > const &m)
WorldObjectWorker(WorldObject const *searcher, Work &work, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)
WorldObjectWorker(PhaseShift const &phaseShift, Work &work, uint32 mapTypeMask=GRID_MAP_TYPE_MASK_ALL)