aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Grids/Notifiers
diff options
context:
space:
mode:
authorQAston <qaston@gmail.com>2011-08-20 00:29:57 +0200
committerQAston <qaston@gmail.com>2011-08-20 00:30:38 +0200
commite2d8faea093ab9aeeca1bbd8bba98fb06527a35b (patch)
treee9b760a5496b934d852b8fb52eea6c60710dafbd /src/server/game/Grids/Notifiers
parentcd03dadb7fd46f186bb39c6848d553902a48f495 (diff)
Core/Spells: move Cannibalize and Carrion Feeder cast checks to SpellScripts.
Diffstat (limited to 'src/server/game/Grids/Notifiers')
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiers.cpp50
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiers.h53
2 files changed, 41 insertions, 62 deletions
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
index 13a88a26b89..9914426215c 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
@@ -26,6 +26,7 @@
#include "Transport.h"
#include "ObjectAccessor.h"
#include "CellImpl.h"
+#include "SpellInfo.h"
using namespace Trinity;
@@ -330,38 +331,41 @@ ObjectUpdater::Visit(GridRefManager<T> &m)
}
}
-bool CannibalizeObjectCheck::operator()(Corpse* u)
+bool AnyDeadUnitObjectInRangeCheck::operator()(Player* u)
{
- // ignore bones
- if (u->GetType() == CORPSE_BONES)
- return false;
-
- Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGUID());
-
- if (!owner || i_funit->IsFriendlyTo(owner))
- return false;
+ return !u->isAlive() && !u->HasAuraType(SPELL_AURA_GHOST) && i_searchObj->IsWithinDistInMap(u, i_range);
+}
- if (i_funit->IsWithinDistInMap(u, i_range))
- return true;
+bool AnyDeadUnitObjectInRangeCheck::operator()(Corpse* u)
+{
+ return u->GetType() != CORPSE_BONES && i_searchObj->IsWithinDistInMap(u, i_range);
+}
- return false;
+bool AnyDeadUnitObjectInRangeCheck::operator()(Creature* u)
+{
+ return !u->isAlive() && i_searchObj->IsWithinDistInMap(u, i_range);
}
-bool CarrionFeederObjectCheck::operator()(Corpse* u)
+bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Player* u)
{
- // ignore bones
- if (u->GetType() == CORPSE_BONES)
- return false;
+ return AnyDeadUnitObjectInRangeCheck::operator()(u)
+ && i_spellInfo->CheckTarget(i_searchObj, u, true)
+ && i_searchObj->IsTargetMatchingCheck(u, i_check);
+}
+bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Corpse* u)
+{
Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGUID());
+ return owner && AnyDeadUnitObjectInRangeCheck::operator()(u)
+ && i_spellInfo->CheckTarget(i_searchObj, owner, true)
+ && i_searchObj->IsTargetMatchingCheck(owner, i_check);
+}
- if (!owner || i_funit->IsFriendlyTo(owner))
- return false;
-
- if (i_funit->IsWithinDistInMap(u, i_range))
- return true;
-
- return false;
+bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Creature* u)
+{
+ return AnyDeadUnitObjectInRangeCheck::operator()(u)
+ && i_spellInfo->CheckTarget(i_searchObj, u, true)
+ && i_searchObj->IsTargetMatchingCheck(u, i_check);
}
template void ObjectUpdater::Visit<GameObject>(GameObjectMapType &);
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index b4d20f25740..4d4f0bfe05e 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -554,56 +554,31 @@ namespace Trinity
float i_range;
};
- class CannibalizeObjectCheck
+ class AnyDeadUnitObjectInRangeCheck
{
public:
- CannibalizeObjectCheck(Unit* funit, float range) : i_funit(funit), i_range(range) {}
- bool operator()(Player* u)
- {
- if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight())
- return false;
-
- return i_funit->IsWithinDistInMap(u, i_range);
- }
+ AnyDeadUnitObjectInRangeCheck(Unit const* searchObj, float range) : i_searchObj(searchObj), i_range(range) {}
+ bool operator()(Player* u);
bool operator()(Corpse* u);
- bool operator()(Creature* u)
- {
- if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() ||
- (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) == 0)
- return false;
-
- return i_funit->IsWithinDistInMap(u, i_range);
- }
+ bool operator()(Creature* u);
template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
- private:
- Unit* const i_funit;
+ protected:
+ Unit const* const i_searchObj;
float i_range;
};
- class CarrionFeederObjectCheck
+ class AnyDeadUnitSpellTargetInRangeCheck : public AnyDeadUnitObjectInRangeCheck
{
public:
- CarrionFeederObjectCheck(Unit* funit, float range) : i_funit(funit), i_range(range) {}
- bool operator()(Player* u)
- {
- if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight())
- return false;
-
- return i_funit->IsWithinDistInMap(u, i_range);
- }
+ AnyDeadUnitSpellTargetInRangeCheck(Unit const* searchObj, float range, SpellInfo const* spellInfo, SpellTargetSelectionCheckTypes check)
+ : AnyDeadUnitObjectInRangeCheck(searchObj, range), i_spellInfo(spellInfo), i_check(check) {}
+ bool operator()(Player* u);
bool operator()(Corpse* u);
- bool operator()(Creature* u)
- {
- if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() ||
- (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL) != 0)
- return false;
-
- return i_funit->IsWithinDistInMap(u, i_range);
- }
+ bool operator()(Creature* u);
template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
- private:
- Unit* const i_funit;
- float i_range;
+ protected:
+ SpellInfo const* i_spellInfo;
+ SpellTargetSelectionCheckTypes i_check;
};
// WorldObject do classes