Core/AI: Replace many Unit::IsHostileTo with Unit::IsValidAttackTarget or Creature::canCreatureAttack.
This commit is contained in:
1 parent
580264b5a5
commit
fe25ce4fa3
27 files changed
+30
-49
No files matched your search
@@ -487,7 +487,7 @@ public:
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack() && me->IsHostileTo(who))
|
||||
if (me->IsValidAttackTarget(who))
|
||||
if (me->IsWithinDistInMap(who, 20) && me->IsWithinLOSInMap(who))
|
||||
AttackStart(who);
|
||||
}
|
||||
|
||||
@@ -800,7 +800,7 @@ public:
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (!who || !who->isTargetableForAttack() || !me->IsHostileTo(who) || me->getVictim())
|
||||
if (!who || !me->IsValidAttackTarget(who) || me->getVictim())
|
||||
return;
|
||||
|
||||
me->AddThreat(who, 0.0f);
|
||||
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (!who->isTargetableForAttack() || !me->IsHostileTo(who))
|
||||
if (!me->IsValidAttackTarget(who))
|
||||
return;
|
||||
if (pInstance && Intro)
|
||||
pInstance->SetData(DATA_BRUTALLUS_EVENT, SPECIAL);
|
||||
|
||||
@@ -437,9 +437,8 @@ public:
|
||||
if (!who || me->getVictim())
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me) && me->IsHostileTo(who))
|
||||
if (me->canCreatureAttack(who))
|
||||
{
|
||||
|
||||
float attackRadius = me->GetAttackDistance(who);
|
||||
if (me->IsWithinDistInMap(who, attackRadius) && me->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && me->IsWithinLOSInMap(who))
|
||||
{
|
||||
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
if (bJustReset)//boss is invisible, don't attack
|
||||
return;
|
||||
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)))
|
||||
if (!me->getVictim() && me->IsValidAttackTarget(who))
|
||||
{
|
||||
float attackRadius = me->GetAttackDistance(who);
|
||||
if (me->IsWithinDistInMap(who, attackRadius))
|
||||
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (me->IsWithinDist(who, 50) && !me->isInCombat() && me->IsHostileTo(who))
|
||||
if (me->IsWithinDist(who, 50) && !me->isInCombat() && me->IsValidAttackTarget(who))
|
||||
AttackStart(who);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (me->IsWithinDist(who, 50) && !me->isInCombat() && me->IsHostileTo(who))
|
||||
if (me->IsWithinDist(who, 50) && !me->isInCombat() && me->IsValidAttackTarget(who))
|
||||
AttackStart(who);
|
||||
}
|
||||
|
||||
|
||||
@@ -1437,7 +1437,7 @@ public:
|
||||
if (!who || me->getVictim())
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack() && me->IsHostileTo(who))
|
||||
if (me->IsValidAttackTarget(who))
|
||||
{
|
||||
//float attackRadius = me->GetAttackDistance(who);
|
||||
if (me->IsWithinDistInMap(who, 30))
|
||||
|
||||
@@ -294,7 +294,7 @@ struct boss_twinemperorsAI : public ScriptedAI
|
||||
if (!who || me->getVictim())
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me) && me->IsHostileTo(who))
|
||||
if (me->canCreatureAttack(who))
|
||||
{
|
||||
float attackRadius = me->GetAttackDistance(who);
|
||||
if (attackRadius < PULL_RANGE)
|
||||
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
if (pInstance->GetData(DATA_JEDOGA_SHADOWSEEKER_EVENT) != IN_PROGRESS || !bOnGround)
|
||||
return;
|
||||
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && me->IsHostileTo(who) && who->isInAccessiblePlaceFor(me))
|
||||
if (!me->getVictim() && me->canCreatureAttack(who))
|
||||
{
|
||||
float attackRadius = me->GetAttackDistance(who);
|
||||
if (me->IsWithinDistInMap(who, attackRadius) && me->IsWithinLOSInMap(who))
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
if (Phase == IDLE && who->isTargetableForAttack() && me->IsHostileTo(who) && me->IsWithinDistInMap(who, 40))
|
||||
if (Phase == IDLE && me->IsValidAttackTarget(who) && me->IsWithinDistInMap(who, 40))
|
||||
{
|
||||
Phase = INTRO;
|
||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
|
||||
if (!me->getVictim() && me->canCreatureAttack(who))
|
||||
{
|
||||
if (!Intro && me->IsWithinDistInMap(who, 100))
|
||||
{
|
||||
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
{
|
||||
ScriptedAI::MoveInLineOfSight(who);
|
||||
|
||||
if (!Intro && me->IsWithinLOSInMap(who)&& me->IsWithinDistInMap(who, 100) && me->IsHostileTo(who))
|
||||
if (!Intro && me->IsWithinLOSInMap(who)&& me->IsWithinDistInMap(who, 100) && me->IsValidAttackTarget(who))
|
||||
{
|
||||
DoScriptText(SAY_INTRO, me);
|
||||
Intro = true;
|
||||
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (!Intro && who->GetTypeId() == TYPEID_PLAYER && who->isTargetableForAttack() && me->IsHostileTo(who) && who->isInAccessiblePlaceFor(me))
|
||||
if (!Intro && who->GetTypeId() == TYPEID_PLAYER && me->canCreatureAttack(who))
|
||||
{
|
||||
if (me->IsWithinDistInMap(who, VISIBLE_RANGE) && me->IsWithinLOSInMap(who))
|
||||
{
|
||||
|
||||
@@ -282,7 +282,7 @@ public:
|
||||
if (!who || me->getVictim())
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me) && me->IsHostileTo(who))
|
||||
if (me->canCreatureAttack(who))
|
||||
{
|
||||
float attackRadius = me->GetAttackDistance(who);
|
||||
if (me->IsWithinDistInMap(who, attackRadius) && me->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && me->IsWithinLOSInMap(who))
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ public:
|
||||
if (me->HasAura(AURA_BANISH))
|
||||
return;
|
||||
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
|
||||
if (!me->getVictim() && me->canCreatureAttack(who))
|
||||
{
|
||||
if (me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return;
|
||||
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
{
|
||||
if (!CanStartEvent)//boss is invisible, don't attack
|
||||
return;
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)))
|
||||
if (!me->getVictim() && who->IsValidAttackTarget(me))
|
||||
{
|
||||
float attackRadius = me->GetAttackDistance(who);
|
||||
if (me->IsWithinDistInMap(who, attackRadius))
|
||||
@@ -424,7 +424,7 @@ public:
|
||||
{
|
||||
if (!who || me->getVictim()) return;
|
||||
|
||||
if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me) && me->IsHostileTo(who) && me->IsWithinDistInMap(who, 45))
|
||||
if (who->isInAccessiblePlaceFor(me) && me->IsValidAttackTarget(who) && me->IsWithinDistInMap(who, 45))
|
||||
{
|
||||
AttackStart(who);
|
||||
}
|
||||
|
||||
+1
-1
@@ -316,7 +316,7 @@ public:
|
||||
if (!who || me->getVictim())
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me) && me->IsHostileTo(who))
|
||||
if (me->canCreatureAttack(who))
|
||||
{
|
||||
//no attack radius check - it attacks the first target that moves in his los
|
||||
//who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ class boss_watchkeeper_gargolmar : public CreatureScript
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
|
||||
if (!me->getVictim() && me->canCreatureAttack(who))
|
||||
{
|
||||
if (!me->canFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return;
|
||||
|
||||
@@ -397,8 +397,7 @@ class boss_kaelthas : public CreatureScript
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (!me->HasUnitState(UNIT_STAT_STUNNED) && who->isTargetableForAttack() &&
|
||||
me->IsHostileTo(who) && who->isInAccessiblePlaceFor(me))
|
||||
if (!me->HasUnitState(UNIT_STAT_STUNNED) && me->canCreatureAttack(who))
|
||||
{
|
||||
if (!me->canFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return;
|
||||
|
||||
@@ -315,7 +315,7 @@ class npc_warden_mellichar : public CreatureScript
|
||||
if (IsRunning)
|
||||
return;
|
||||
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
|
||||
if (!me->getVictim() && me->canCreatureAttack(who))
|
||||
{
|
||||
if (!me->canFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return;
|
||||
|
||||
@@ -91,7 +91,7 @@ class boss_doomwalker : public CreatureScript
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (who && who->GetTypeId() == TYPEID_PLAYER && me->IsHostileTo(who))
|
||||
if (who && who->GetTypeId() == TYPEID_PLAYER && me->IsValidAttackTarget(who))
|
||||
if (who->HasAura(SPELL_MARK_DEATH, 0))
|
||||
who->CastSpell(who, SPELL_AURA_DEATH, 1);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
if (!SpawnAssoc)
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack() && me->IsHostileTo(who))
|
||||
if (me->IsValidAttackTarget(who))
|
||||
{
|
||||
Player* playerTarget = who->ToPlayer();
|
||||
|
||||
@@ -1718,7 +1718,7 @@ public:
|
||||
//Redefined for random target selection:
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
|
||||
if (!me->getVictim() && me->canCreatureAttack(who))
|
||||
{
|
||||
if (me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user