aboutsummaryrefslogtreecommitdiff
path: root/src/game/GridNotifiers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/GridNotifiers.h')
-rw-r--r--src/game/GridNotifiers.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h
index a1bee4df650..dd82ea2bd78 100644
--- a/src/game/GridNotifiers.h
+++ b/src/game/GridNotifiers.h
@@ -32,6 +32,7 @@
#include "GameObject.h"
#include "Player.h"
#include "Unit.h"
+#include "CreatureAI.h"
class Player;
//class Map;
@@ -802,6 +803,25 @@ namespace Trinity
float i_range;
};
+ class AnyUnfriendlyVisibleUnitInObjectRangeCheck
+ {
+ public:
+ AnyUnfriendlyVisibleUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range)
+ : i_obj(obj), i_funit(funit), i_range(range) {}
+
+ bool operator()(Unit* u)
+ {
+ return u->isAlive()
+ && i_obj->IsWithinDistInMap(u, i_range)
+ && !i_funit->IsFriendlyTo(u)
+ && u->isVisibleForOrDetect(i_funit, false);
+ }
+ private:
+ WorldObject const* i_obj;
+ Unit const* i_funit;
+ float i_range;
+ };
+
class CreatureWithDbGUIDCheck
{
public:
@@ -905,6 +925,38 @@ namespace Trinity
float i_range;
};
+ // do attack at call of help to friendly crearture
+ class CallOfHelpCreatureInRangeDo
+ {
+ public:
+ CallOfHelpCreatureInRangeDo(Unit* funit, Unit* enemy, float range)
+ : i_funit(funit), i_enemy(enemy), i_range(range)
+ {}
+ void operator()(Creature* u)
+ {
+ if (u == i_funit)
+ return;
+
+ if (!u->CanAssistTo(i_funit, i_enemy, false))
+ return;
+
+ // too far
+ if (!i_funit->IsWithinDistInMap(u, i_range))
+ return;
+
+ // only if see assisted creature
+ if (!i_funit->IsWithinLOSInMap(u))
+ return;
+
+ if (u->AI())
+ u->AI()->AttackStart(i_enemy);
+ }
+ private:
+ Unit* const i_funit;
+ Unit* const i_enemy;
+ float i_range;
+ };
+
struct AnyDeadUnitCheck
{
bool operator()(Unit* u) { return !u->isAlive(); }