diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/CreatureAI.h | 33 | ||||
| -rw-r--r-- | src/game/GridNotifiers.h | 129 |
2 files changed, 162 insertions, 0 deletions
diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 185fb571bb2..540a2e408b7 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -32,6 +32,39 @@ struct SpellEntry; #define TIME_INTERVAL_LOOK 5000 #define VISIBILITY_RANGE 10000 +//Spell targets used by SelectSpell +enum SelectTarget +{ + SELECT_TARGET_DONTCARE = 0, //All target types allowed + + SELECT_TARGET_SELF, //Only Self casting + + SELECT_TARGET_SINGLE_ENEMY, //Only Single Enemy + SELECT_TARGET_AOE_ENEMY, //Only AoE Enemy + SELECT_TARGET_ANY_ENEMY, //AoE or Single Enemy + + SELECT_TARGET_SINGLE_FRIEND, //Only Single Friend + SELECT_TARGET_AOE_FRIEND, //Only AoE Friend + SELECT_TARGET_ANY_FRIEND, //AoE or Single Friend +}; + +//Spell Effects used by SelectSpell +enum SelectEffect +{ + SELECT_EFFECT_DONTCARE = 0, //All spell effects allowed + SELECT_EFFECT_DAMAGE, //Spell does damage + SELECT_EFFECT_HEALING, //Spell does healing + SELECT_EFFECT_AURA, //Spell applies an aura +}; + +//Selection method used by SelectTarget +enum SelectAggroTarget +{ + SELECT_TARGET_RANDOM = 0, //Just selects a random target + SELECT_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom + SELECT_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top +}; + class MANGOS_DLL_SPEC CreatureAI { public: diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 98e25857638..70d5d7c8928 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -709,6 +709,31 @@ namespace MaNGOS Unit* const i_funit;
};
+ class NearestAssistCreatureInCreatureRangeCheck
+ {
+ public:
+ NearestAssistCreatureInCreatureRangeCheck(Creature* obj,Unit* enemy, float range)
+ : i_obj(obj), i_enemy(enemy), i_range(range) {}
+
+ bool operator()(Creature* u)
+ {
+ if(u->getFaction() == i_obj->getFaction() && !u->isInCombat() && !u->GetCharmerOrOwnerGUID() && u->IsHostileTo(i_enemy) && u->isAlive()&& i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsWithinLOSInMap(u))
+ {
+ i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
+ return true;
+ }
+ return false;
+ }
+ float GetLastRange() const { return i_range; }
+ private:
+ Creature* const i_obj;
+ Unit* const i_enemy;
+ float i_range;
+
+ // prevent clone this object
+ NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&);
+ };
+
class AnyAssistCreatureInRangeCheck
{
public:
@@ -800,6 +825,110 @@ namespace MaNGOS float i_range;
};
+ // Searchers used by ScriptedAI
+ class MostHPMissingInRange
+ {
+ public:
+ MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) {}
+ bool operator()(Unit* u)
+ {
+ if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
+ {
+ i_hp = u->GetMaxHealth() - u->GetHealth();
+ return true;
+ }
+ return false;
+ }
+ private:
+ Unit const* i_obj;
+ float i_range;
+ uint32 i_hp;
+ };
+
+ class FriendlyCCedInRange
+ {
+ public:
+ FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) {}
+ bool operator()(Unit* u)
+ {
+ if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
+ (u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_CONFUSED)))
+ {
+ return true;
+ }
+ return false;
+ }
+ private:
+ Unit const* i_obj;
+ float i_range;
+ };
+
+ class FriendlyMissingBuffInRange
+ {
+ public:
+ FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) {}
+ bool operator()(Unit* u)
+ {
+ if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
+ !(u->HasAura(i_spell, 0) || u->HasAura(i_spell, 1) || u->HasAura(i_spell, 2)))
+ {
+ return true;
+ }
+ return false;
+ }
+ private:
+ Unit const* i_obj;
+ float i_range;
+ uint32 i_spell;
+ };
+
+ class AllFriendlyCreaturesInGrid
+ {
+ public:
+ AllFriendlyCreaturesInGrid(Unit const* obj) : pUnit(obj) {}
+ bool operator() (Unit* u)
+ {
+ if(u->isAlive() && u->GetVisibility() == VISIBILITY_ON && u->IsFriendlyTo(pUnit))
+ return true;
+
+ return false;
+ }
+ private:
+ Unit const* pUnit;
+ };
+
+ class AllGameObjectsWithEntryInGrid
+ {
+ public:
+ AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {}
+ bool operator() (GameObject* g)
+ {
+ if(g->GetEntry() == entry)
+ return true;
+
+ return false;
+ }
+ private:
+ uint32 entry;
+ };
+
+ class AllCreaturesOfEntryInRange
+ {
+ public:
+ AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {}
+ bool operator() (Unit* u)
+ {
+ if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range))
+ return true;
+
+ return false;
+ }
+ private:
+ Unit const* pUnit;
+ uint32 entry;
+ float range;
+ };
+
#ifndef WIN32
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &);
template<> void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &);
|
