aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/server/game/AI/CoreAI/UnitAI.cpp9
-rwxr-xr-xsrc/server/game/AI/CoreAI/UnitAI.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index 82b0f5c7125..e11be0612a2 100755
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -255,6 +255,9 @@ SpellTargetSelector::SpellTargetSelector(Unit* caster, uint32 spellId) :
bool SpellTargetSelector::operator()(Unit const* target) const
{
+ if (!target)
+ return false;
+
if (_spellInfo->CheckTarget(_caster, target) != SPELL_CAST_OK)
return false;
@@ -289,5 +292,11 @@ bool SpellTargetSelector::operator()(Unit const* target) const
bool NonTankTargetSelector::operator()(Unit const* target) const
{
+ if (!target)
+ return false;
+
+ if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
+ return false;
+
return target != _source->getVictim();
}
diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h
index bd6a9b37b5a..8485559c7fa 100755
--- a/src/server/game/AI/CoreAI/UnitAI.h
+++ b/src/server/game/AI/CoreAI/UnitAI.h
@@ -116,11 +116,12 @@ struct SpellTargetSelector : public std::unary_function<Unit*, bool>
struct NonTankTargetSelector : public std::unary_function<Unit*, bool>
{
public:
- explicit NonTankTargetSelector(Creature* source) : _source(source) { }
+ NonTankTargetSelector(Creature* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { }
bool operator()(Unit const* target) const;
private:
Creature const* _source;
+ bool _playerOnly;
};
class UnitAI