aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorQAston <qaston@gmail.com>2011-09-17 00:56:59 +0200
committerQAston <qaston@gmail.com>2011-09-17 00:56:59 +0200
commitfe25ce4fa3ce306beebc4c95b22cd14052a92566 (patch)
treee8bbe02f5b43e8d648230cb2532dd24780ff113e /src/server/game
parent580264b5a56f742e5eaf1eeb2ea3729740e36478 (diff)
Core/AI: Replace many Unit::IsHostileTo with Unit::IsValidAttackTarget or Creature::canCreatureAttack.
Diffstat (limited to 'src/server/game')
-rwxr-xr-xsrc/server/game/AI/CoreAI/GuardAI.cpp2
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiers.h4
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp4
-rwxr-xr-xsrc/server/game/Spells/Spell.h17
4 files changed, 5 insertions, 22 deletions
diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp
index 16e04c363ea..2efe0eebee0 100755
--- a/src/server/game/AI/CoreAI/GuardAI.cpp
+++ b/src/server/game/AI/CoreAI/GuardAI.cpp
@@ -58,7 +58,7 @@ void GuardAI::MoveInLineOfSight(Unit* unit)
return;
if (!me->getVictim() && me->IsValidAttackTarget(unit) &&
- (unit->IsHostileToPlayers() || me->IsHostileTo(unit) /*|| u->getVictim() && me->IsFriendlyTo(u->getVictim())*/) &&
+ (unit->IsHostileToPlayers() || me->IsHostileTo(unit)) &&
unit->isInAccessiblePlaceFor(me))
{
float attackRadius = me->GetAttackDistance(unit);
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index 27e8706fa37..ec93c3c5580 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -902,12 +902,10 @@ namespace Trinity
bool operator()(Unit* u)
{
// Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems
- if (!u->isTargetableForAttack())
- return false;
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isTotem())
return false;
- if ((i_targetForPlayer ? !i_funit->IsFriendlyTo(u) : i_funit->IsHostileTo(u))&& i_obj->IsWithinDistInMap(u, i_range))
+ if (i_funit->IsValidAttackTarget(u) && i_obj->IsWithinDistInMap(u, i_range))
return true;
return false;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 388aa8df2aa..c5392a0e55b 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1462,9 +1462,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, const uint32 effectMask, bool
if (m_spellInfo->Speed > 0.0f && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE) && unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID())
return SPELL_MISS_EVADE;
- // check for IsHostileTo() instead of !IsFriendlyTo()
- // ex: spell 47463 needs to be casted by different units on the same neutral target
- if (m_caster->IsHostileTo(unit))
+ if (m_caster->IsValidAttackTarget(unit))
{
unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL);
//TODO: This is a hack. But we do not know what types of stealth should be interrupted by CC
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index e8a9a1dc95e..be6e16b30d2 100755
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -701,26 +701,13 @@ namespace Trinity
case SPELL_TARGETS_ENEMY:
if (target->isTotem())
continue;
- // can't be checked in SpellInfo::CheckTarget - needs more research
- if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE))
+ if (!i_source->_IsValidAttackTarget(target, i_spellProto))
continue;
- if (target->HasUnitState(UNIT_STAT_UNATTACKABLE))
- continue;
- if (i_source->IsControlledByPlayer())
- {
- if (i_source->IsFriendlyTo(target))
- continue;
- }
- else
- {
- if (!i_source->IsHostileTo(target))
- continue;
- }
break;
case SPELL_TARGETS_ALLY:
if (target->isTotem())
continue;
- if (!i_source->IsFriendlyTo(target))
+ if (!i_source->_IsValidAssistTarget(target, i_spellProto))
continue;
break;
case SPELL_TARGETS_ENTRY: