Merge [SD2]
r1080 Update code with new and faster functions for distance checks. --HG-- branch : trunk
This commit is contained in:
@@ -346,8 +346,7 @@ bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered)
|
||||
return false;
|
||||
|
||||
//Unit is out of range of this spell
|
||||
if (me->GetDistance(Target) > me->GetSpellMaxRangeForTarget(Target, TempRange)
|
||||
|| me->GetDistance(Target) < me->GetSpellMinRangeForTarget(Target, TempRange))
|
||||
if (me->IsInRange(Target,me->GetSpellMinRangeForTarget(Target, TempRange),me->GetSpellMaxRangeForTarget(Target, TempRange)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -568,7 +567,7 @@ void ScriptedAI::SetCombatMovement(bool CombatMove)
|
||||
{
|
||||
if( !m_creature->getVictim() && m_creature->canAttack(who) && ( m_creature->IsHostileTo( who )) && who->isInAccessiblePlaceFor(m_creature) )
|
||||
{
|
||||
if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
if (!m_creature->canFly() && !m_creature->IsWithinDist(who, CREATURE_Z_ATTACK_RANGE))
|
||||
return;
|
||||
|
||||
float attackRadius = m_creature->GetAttackDistance(who);
|
||||
|
||||
@@ -156,7 +156,7 @@ struct TRINITY_DLL_DECL custom_exampleAI : public ScriptedAI
|
||||
//Cast spell one on our current target.
|
||||
if (rand()%50 > 10)
|
||||
DoCast(m_creature->getVictim(),SPELL_ONE_ALT);
|
||||
else if (m_creature->GetDistance(m_creature->getVictim()) < 25)
|
||||
else if (m_creature->IsWithinDist(m_creature->getVictim(), 25))
|
||||
DoCast(m_creature->getVictim(),SPELL_ONE);
|
||||
|
||||
Spell_1_Timer = 5000;
|
||||
|
||||
@@ -141,7 +141,7 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
|
||||
//Cast spell one on our current target.
|
||||
if (rand()%50 > 10)
|
||||
DoCast(m_creature->getVictim(),SPELL_ONE_ALT);
|
||||
else if (m_creature->GetDistance(m_creature->getVictim()) < 25)
|
||||
else if (m_creature->IsWithinDist(m_creature->getVictim(), 25))
|
||||
DoCast(m_creature->getVictim(),SPELL_ONE);
|
||||
|
||||
Spell_1_Timer = 5000;
|
||||
|
||||
@@ -152,7 +152,7 @@ void npc_escortAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
Unit* p = Unit::GetUnit(*m_creature, PlayerGUID);
|
||||
|
||||
if (DespawnAtFar && (!p || m_creature->GetDistance(p) > GetMaxPlayerDistance()))
|
||||
if (DespawnAtFar && (!p || !m_creature->IsWithinDist(p,GetMaxPlayerDistance())))
|
||||
{
|
||||
JustDied(m_creature);
|
||||
IsBeingEscorted = false;
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
|
||||
Map::PlayerList const &PlayerList = map->GetPlayers();
|
||||
for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
if (Player* i_pl = i->getSource())
|
||||
if (i_pl->isAlive() && (dist = i_pl->GetDistance(m_creature)) < 45)
|
||||
if (i_pl->isAlive() && (dist = i_pl->IsWithinDist(m_creature, 45)))
|
||||
{
|
||||
i_pl->RemoveAurasDueToSpell(SPELL_INHIBITMAGIC);
|
||||
m_creature->AddAura(SPELL_INHIBITMAGIC, i_pl);
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ struct TRINITY_DLL_DECL mob_voidtravelerAI : public ScriptedAI
|
||||
return;
|
||||
}
|
||||
m_creature->GetMotionMaster()->MoveFollow(Vorpil,0,0);
|
||||
if(m_creature->GetDistance(Vorpil) < 3)
|
||||
if(m_creature->IsWithinDist(Vorpil, 3))
|
||||
{
|
||||
DoCast(m_creature, SPELL_SACRIFICE, false);
|
||||
sacrificed = true;
|
||||
|
||||
@@ -155,7 +155,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public Scripted_NoMovementAI
|
||||
std::list<HostilReference*>& m_threatlist = m_creature->getThreatManager().getThreatList();
|
||||
for(std::list<HostilReference*>::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
|
||||
if(Unit* target = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()))
|
||||
if(target->isAlive() && m_creature->GetDistance2d(target) > 35)
|
||||
if(target->isAlive() && !m_creature->IsWithinDist(target, 35, false))
|
||||
DoCast(target, SPELL_THUNDERING_STORM, true);
|
||||
ThunderingStorm_Timer = 15000;
|
||||
}else ThunderingStorm_Timer -= diff;
|
||||
|
||||
@@ -345,8 +345,8 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
|
||||
Despawn();
|
||||
return;
|
||||
}
|
||||
float dist = m_creature->GetDistance(player);
|
||||
if(dist < 10 && m_creature->GetPositionX() > player->GetPositionX() && !Reached)
|
||||
|
||||
if(m_creature->IsWithinDist(player, 10) && m_creature->GetPositionX() > player->GetPositionX() && !Reached)
|
||||
{
|
||||
DoScriptText(SAY_RIZZLE_FINAL, m_creature);
|
||||
m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 1);
|
||||
|
||||
@@ -59,7 +59,7 @@ struct TargetDistanceOrder : public std::binary_function<const Unit, const Unit,
|
||||
// functor for operator ">"
|
||||
bool operator()(const Unit* _Left, const Unit* _Right) const
|
||||
{
|
||||
return (MainTarget->GetDistance(_Left) > MainTarget->GetDistance(_Right));
|
||||
return !MainTarget->GetDistanceOrder(_Left, _Right);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ struct TargetDistanceOrder : public std::binary_function<const Unit, const Unit,
|
||||
// functor for operator "<"
|
||||
bool operator()(const Unit* _Left, const Unit* _Right) const
|
||||
{
|
||||
return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right));
|
||||
return MainTarget->GetDistanceOrder(_Left, _Right);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ struct TRINITY_DLL_DECL mob_ashtongue_sorcererAI : public ScriptedAI
|
||||
Creature* Shade = Unit::GetCreature((*m_creature), ShadeGUID);
|
||||
if(Shade && Shade->isAlive() && m_creature->isAlive())
|
||||
{
|
||||
if(m_creature->GetDistance2d(Shade) < 20)
|
||||
if(m_creature->IsWithinDist(Shade, 20,false))
|
||||
{
|
||||
m_creature->GetMotionMaster()->Clear(false);
|
||||
m_creature->GetMotionMaster()->MoveIdle();
|
||||
|
||||
@@ -111,7 +111,7 @@ struct TargetDistanceOrder : public std::binary_function<const Unit, const Unit,
|
||||
// functor for operator "<"
|
||||
bool operator()(const Unit* _Left, const Unit* _Right) const
|
||||
{
|
||||
return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right));
|
||||
return MainTarget->GetDistanceOrder(_Left, _Right);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -518,7 +518,7 @@ struct TRINITY_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_coun
|
||||
if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
|
||||
{
|
||||
// is in ~10-40 yd range
|
||||
if(m_creature->GetDistance2d(target) > 10 && m_creature->GetDistance2d(target) < 40)
|
||||
if (m_creature->IsInRange(target, 10.0f, 40.0f, false))
|
||||
{
|
||||
DoCast(target, SPELL_HAMMER_OF_JUSTICE);
|
||||
HammerOfJusticeTimer = 20000;
|
||||
|
||||
@@ -69,8 +69,7 @@ struct TRINITY_DLL_DECL boss_broodlordAI : public ScriptedAI
|
||||
{
|
||||
float rx,ry,rz;
|
||||
m_creature->GetRespawnCoord(rx, ry, rz);
|
||||
float spawndist = m_creature->GetDistance(rx,ry,rz);
|
||||
if ( spawndist > 250 )
|
||||
if(!m_creature->IsWithinDist3d(rx,ry,rz,250.0f))
|
||||
{
|
||||
DoScriptText(SAY_LEASH, m_creature);
|
||||
EnterEvadeMode();
|
||||
|
||||
@@ -259,7 +259,7 @@ struct TRINITY_DLL_DECL mob_towering_infernalAI : public ScriptedAI
|
||||
|
||||
void MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if (m_creature->GetDistance(who) <= 50 && !m_creature->isInCombat() && m_creature->IsHostileTo(who))
|
||||
if (m_creature->IsWithinDist(who, 50) && !m_creature->isInCombat() && m_creature->IsHostileTo(who))
|
||||
AttackStart(who);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ struct TargetDistanceOrder : public std::binary_function<const Unit, const Unit,
|
||||
// functor for operator "<"
|
||||
bool operator()(const Unit* _Left, const Unit* _Right) const
|
||||
{
|
||||
return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right));
|
||||
return MainTarget->GetDistanceOrder(_Left, _Right);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ struct TRINITY_DLL_DECL mob_lesser_doomguardAI : public hyjal_trashAI
|
||||
|
||||
void MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if (m_creature->GetDistance(who) <= 50 && !m_creature->isInCombat() && m_creature->IsHostileTo(who))
|
||||
if (m_creature->IsWithinDist(who, 50) && !m_creature->isInCombat() && m_creature->IsHostileTo(who))
|
||||
AttackStart(who);
|
||||
}
|
||||
|
||||
|
||||
@@ -1024,7 +1024,7 @@ void hyjalAI::WaypointReached(uint32 i)
|
||||
{
|
||||
if((*itr) && (*itr)->isAlive() && (*itr) != m_creature && (*itr)->GetEntry() != JAINA)
|
||||
{
|
||||
if((*itr)->GetDistance(m_creature) >= 60)
|
||||
if(!(*itr)->IsWithinDist(m_creature, 60))
|
||||
(*itr)->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
|
||||
float x, y, z;
|
||||
(*itr)->SetDefaultMovementType(IDLE_MOTION_TYPE);
|
||||
|
||||
@@ -1174,7 +1174,7 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
|
||||
}
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) >= 25){
|
||||
if(!m_creature->IsWithinDist(m_creature->getVictim(), 25)){
|
||||
if(MoveTimer<diff)
|
||||
{
|
||||
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
|
||||
@@ -1184,7 +1184,7 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
|
||||
|
||||
if(FrostBreathTimer<diff)
|
||||
{
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) < 25)
|
||||
if(!m_creature->IsWithinDist(m_creature->getVictim(), 25))
|
||||
{
|
||||
DoCast(m_creature->getVictim(),SPELL_FROST_BREATH);
|
||||
m_creature->StopMoving();
|
||||
@@ -1297,7 +1297,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
|
||||
}
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) >= 20 || forcemove)
|
||||
if(!m_creature->IsWithinDist(m_creature->getVictim(), 20) || forcemove)
|
||||
{
|
||||
forcemove = false;
|
||||
if(forcemove)
|
||||
@@ -1318,7 +1318,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
|
||||
}
|
||||
if(StrikeTimer<diff)
|
||||
{
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) < 20)
|
||||
if(m_creature->IsWithinDist(m_creature->getVictim(), 20))
|
||||
{
|
||||
DoCast(m_creature->getVictim(),SPELL_GARGOYLE_STRIKE);
|
||||
m_creature->StopMoving();
|
||||
|
||||
+2
-2
@@ -267,7 +267,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
|
||||
//PosCheck_Timer
|
||||
if (PosCheck_Timer < diff)
|
||||
{
|
||||
if (m_creature->GetDistance2d(HYDROSS_X, HYDROSS_Y) < SWITCH_RADIUS)
|
||||
if (m_creature->IsWithinDist2d(HYDROSS_X, HYDROSS_Y, SWITCH_RADIUS))
|
||||
{
|
||||
// switch to clean form
|
||||
m_creature->SetDisplayId( MODEL_CLEAN);
|
||||
@@ -334,7 +334,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
|
||||
//PosCheck_Timer
|
||||
if (PosCheck_Timer < diff)
|
||||
{
|
||||
if (m_creature->GetDistance2d(HYDROSS_X, HYDROSS_Y) >= SWITCH_RADIUS)
|
||||
if (!m_creature->IsWithinDist2d(HYDROSS_X, HYDROSS_Y, SWITCH_RADIUS))
|
||||
{
|
||||
// switch to corrupted form
|
||||
m_creature->SetDisplayId( MODEL_CORRUPT);
|
||||
|
||||
+2
-2
@@ -640,7 +640,7 @@ struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
|
||||
{
|
||||
m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
|
||||
}
|
||||
if (phase == 1 && m_creature->GetDistance(x,y,z) < 0.1)
|
||||
if (phase == 1 && m_creature->IsWithinDist3d(x,y,z, 0.1))
|
||||
{
|
||||
phase = 2;
|
||||
}
|
||||
@@ -652,7 +652,7 @@ struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
|
||||
if (phase == 3)
|
||||
{
|
||||
m_creature->GetMotionMaster()->MovePoint(0, MIDDLE_X, MIDDLE_Y, MIDDLE_Z);
|
||||
if(m_creature->GetDistance(MIDDLE_X, MIDDLE_Y, MIDDLE_Z) < 3)
|
||||
if(m_creature->IsWithinDist3d(MIDDLE_X, MIDDLE_Y, MIDDLE_Z, 3))
|
||||
{
|
||||
SpellEntry *spell = GET_SPELL(SPELL_SURGE);
|
||||
if( spell )
|
||||
|
||||
+4
-4
@@ -472,12 +472,12 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
|
||||
//ChaosBlast_Timer
|
||||
if (!m_creature->getVictim())
|
||||
return;
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) < 30)
|
||||
if(m_creature->IsWithinDist(m_creature->getVictim(), 30))
|
||||
m_creature->StopMoving();
|
||||
if(ChaosBlast_Timer < diff)
|
||||
{
|
||||
// will cast only when in range of spell
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) < 30)
|
||||
if(m_creature->IsWithinDist(m_creature->getVictim(), 30))
|
||||
{
|
||||
//m_creature->CastSpell(m_creature->getVictim(), SPELL_CHAOS_BLAST, true);
|
||||
int damage = 100;
|
||||
@@ -618,13 +618,13 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blind_demonformAI : public ScriptedAI
|
||||
if (!UpdateVictim() )
|
||||
return;
|
||||
//ChaosBlast_Timer
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) < 30)
|
||||
if(m_creature->IsWithinDist(m_creature->getVictim(), 30))
|
||||
m_creature->StopMoving();
|
||||
|
||||
if(ChaosBlast_Timer < diff)
|
||||
{
|
||||
// will cast only when in range od spell
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) < 30)
|
||||
if(m_creature->IsWithinDist(m_creature->getVictim(), 30))
|
||||
{
|
||||
//m_creature->CastSpell(m_creature->getVictim(),SPELL_CHAOS_BLAST,true);
|
||||
int damage = 100;
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
{
|
||||
Player *target = i->getSource();
|
||||
if(target && target->isAlive() && m_creature->HasInArc((double)diff/20000*(double)M_PI*2,target) && m_creature->GetDistance(target) <= SPOUT_DIST && !target->IsInWater())
|
||||
if(target && target->isAlive() && m_creature->HasInArc((double)diff/20000*(double)M_PI*2,target) && m_creature->IsWithinDist(target, SPOUT_DIST) && !target->IsInWater())
|
||||
DoCast(target,SPELL_SPOUT,true);//only knock back palyers in arc, in 100yards, not in water
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
|
||||
{
|
||||
float x,y,z,o;
|
||||
m_creature->GetHomePosition(x,y,z,o);
|
||||
if(m_creature->GetDistance(x,y,z) > 60)
|
||||
if(!m_creature->IsWithinDist3d(x,y,z, 60))
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return;
|
||||
|
||||
@@ -267,7 +267,7 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
|
||||
temp_prison = m_creature->FindNearestGameObject(acherus_soul_prison[i],30);
|
||||
if(temp_prison)
|
||||
{
|
||||
if(dist == 99.0f || dist > m_creature->GetDistance2d(temp_prison))
|
||||
if(dist == 99.0f || m_creature->IsWithinDist(temp_prison, dist, false))
|
||||
{
|
||||
temp_prison->GetPosition(x, y, z);
|
||||
dist = m_creature->GetDistance2d(temp_prison);
|
||||
|
||||
@@ -683,7 +683,7 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
|
||||
}
|
||||
|
||||
//GreaterFireball_Timer
|
||||
if(GreaterFireball_Timer < diff || m_creature->GetDistance(m_creature->getVictim()) < 30)
|
||||
if(GreaterFireball_Timer < diff || m_creature->IsWithinDist(m_creature->getVictim(), 30))
|
||||
{
|
||||
DoCast(m_creature->getVictim(), SPELL_GREATER_FIREBALL);
|
||||
GreaterFireball_Timer = 2000;
|
||||
@@ -707,7 +707,7 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
|
||||
{
|
||||
target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
|
||||
//15 yard radius minimum
|
||||
if(target && target->GetDistance2d(m_creature) < 15)
|
||||
if(target && target->IsWithinDist(m_creature, 15,false))
|
||||
target_list.push_back(target);
|
||||
target = NULL;
|
||||
}
|
||||
|
||||
+2
-2
@@ -146,7 +146,7 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
|
||||
if(Turn_Timer < diff)
|
||||
{
|
||||
uint32 waypoint = (Fly_Timer/10000)%2;
|
||||
if(m_creature->GetDistance(VazrudenRing[waypoint][0],VazrudenRing[waypoint][1],VazrudenRing[waypoint][2]) > 5)
|
||||
if(m_creature->IsWithinDist3d(VazrudenRing[waypoint][0],VazrudenRing[waypoint][1],VazrudenRing[waypoint][2], 5))
|
||||
m_creature->GetMotionMaster()->MovePoint(0,VazrudenRing[waypoint][0],VazrudenRing[waypoint][1],VazrudenRing[waypoint][2]);
|
||||
Turn_Timer = 10000;
|
||||
}else Turn_Timer -= diff;
|
||||
@@ -366,7 +366,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
|
||||
case 1: // go to the middle and begin the fight
|
||||
if(check < diff)
|
||||
{
|
||||
if(m_creature->GetDistance(VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2])>5)
|
||||
if(!m_creature->IsWithinDist3d(VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2],5))
|
||||
{
|
||||
m_creature->GetMotionMaster()->Clear();
|
||||
m_creature->GetMotionMaster()->MovePoint(0,VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2]);
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ struct TRINITY_DLL_DECL mob_fel_orc_convertAI : public ScriptedAI
|
||||
if (pInstance->GetData64(DATA_NETHEKURSE))
|
||||
{
|
||||
Creature *pKurse = Unit::GetCreature(*m_creature,pInstance->GetData64(DATA_NETHEKURSE));
|
||||
if (pKurse && m_creature->GetDistance(pKurse) < 45.0f)
|
||||
if (pKurse && m_creature->IsWithinDist(pKurse, 45.0f))
|
||||
{
|
||||
CAST_AI(boss_grand_warlock_nethekurseAI, pKurse->AI())->DoYellForPeonAggro();
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI
|
||||
for(std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
|
||||
{
|
||||
target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
|
||||
if(target && target->GetDistance2d(m_creature) > 5)
|
||||
if (target && !target->IsWithinDist(m_creature, ATTACK_DISTANCE, false))
|
||||
target_list.push_back(target);
|
||||
target = NULL;
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
|
||||
continue;
|
||||
|
||||
Unit* pUnit = Unit::GetUnit(*m_creature, FlameWreathTarget[i]);
|
||||
if (pUnit && pUnit->GetDistance2d(FWTargPosX[i], FWTargPosY[i]) > 3)
|
||||
if (pUnit && !pUnit->IsWithinDist2d(FWTargPosX[i], FWTargPosY[i], 3))
|
||||
{
|
||||
pUnit->CastSpell(pUnit, 20476, true, 0, 0, m_creature->GetGUID());
|
||||
pUnit->CastSpell(pUnit, 11027, true);
|
||||
|
||||
@@ -141,9 +141,9 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
|
||||
pCrystal = Unit::GetUnit(*m_creature, *itr);
|
||||
if (pCrystal && pCrystal->isAlive())
|
||||
{
|
||||
if (!ShortestDistance || (ShortestDistance > m_creature->GetDistance2d(pCrystal)))
|
||||
// select nearest
|
||||
if(!CrystalChosen || m_creature->GetDistanceOrder(pCrystal, CrystalChosen, false))
|
||||
{
|
||||
ShortestDistance = m_creature->GetDistance2d(pCrystal);
|
||||
CrystalGUID = pCrystal->GetGUID();
|
||||
CrystalChosen = pCrystal; // Store a copy of pCrystal so we don't need to recreate a pointer to closest crystal for the movement and yell.
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ struct TRINITY_DLL_DECL mob_wisp_invisAI : public ScriptedAI
|
||||
if (!who || Creaturetype != 1 || !who->isTargetableForAttack())
|
||||
return;
|
||||
|
||||
if (m_creature->GetDistance2d(who) < 0.1 && !who->HasAura(SPELL_SQUASH_SOUL))
|
||||
if (m_creature->IsWithinDist(who, 0.1, false) && !who->HasAura(SPELL_SQUASH_SOUL))
|
||||
DoCast(who,SPELL_SQUASH_SOUL);
|
||||
}
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ struct TRINITY_DLL_DECL npc_dark_fiendAI : public ScriptedAI
|
||||
InAction = true;
|
||||
WaitTimer = 500;
|
||||
}else{
|
||||
if(m_creature->GetDistance(m_creature->getVictim()) < 5){
|
||||
if(m_creature->IsWithinDist(m_creature->getVictim(), 5)){
|
||||
DoCastAOE(SPELL_DARKFIEND_AOE, false);
|
||||
m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
|
||||
m_creature->RemoveCorpse();
|
||||
|
||||
@@ -270,8 +270,8 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
|
||||
{
|
||||
m_creature->RemoveAurasDueToSpell(SPELL_DIVE_BOMB_VISUAL);
|
||||
m_creature->CastSpell(target, SPELL_DIVE_BOMB, true);
|
||||
float dist = m_creature->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
|
||||
if (dist < 5.0f) dist = 5.0f;
|
||||
float dist;
|
||||
if (m_creature->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f)) dist = 5.0f;
|
||||
WaitTimer = 1000 + floor(dist / 80 * 1000.0f);
|
||||
m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
|
||||
m_creature->StopMoving();
|
||||
|
||||
@@ -120,7 +120,7 @@ struct TRINITY_DLL_DECL boss_void_reaverAI : public ScriptedAI
|
||||
{
|
||||
target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
|
||||
//18 yard radius minimum
|
||||
if(target && target->GetTypeId() == TYPEID_PLAYER && target->isAlive() && target->GetDistance2d(m_creature) >= 18)
|
||||
if(target && target->GetTypeId() == TYPEID_PLAYER && target->isAlive() && !target->IsWithinDist(m_creature, 18, false))
|
||||
target_list.push_back(target);
|
||||
target = NULL;
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ struct TRINITY_DLL_DECL cthunAI : public Scripted_NoMovementAI
|
||||
DoCast(pUnit, SPELL_DIGESTIVE_ACID, true);
|
||||
|
||||
//Check if player should be kicked from stomach
|
||||
if (pUnit->GetDistance(KICK_X, KICK_Y, KICK_Z) < 15)
|
||||
if (pUnit->IsWithinDist3d(KICK_X, KICK_Y, KICK_Z, 15.0f))
|
||||
{
|
||||
//Teleport each player out
|
||||
DoTeleportPlayer(pUnit, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()+10, rand()%6);
|
||||
|
||||
@@ -197,7 +197,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
|
||||
if (Heal_Timer < diff)
|
||||
{
|
||||
Unit *pOtherBoss = GetOtherBoss();
|
||||
if (pOtherBoss && (pOtherBoss->GetDistance(m_creature) <= 60))
|
||||
if (pOtherBoss && pOtherBoss->IsWithinDist(m_creature,60))
|
||||
{
|
||||
DoCast(pOtherBoss, SPELL_HEAL_BROTHER);
|
||||
Heal_Timer = 1000;
|
||||
@@ -552,7 +552,7 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
|
||||
//ShadowBolt_Timer
|
||||
if (ShadowBolt_Timer < diff)
|
||||
{
|
||||
if (m_creature->GetDistance(m_creature->getVictim()) > 45)
|
||||
if (!m_creature->IsWithinDist(m_creature->getVictim(), 45.0f))
|
||||
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), VEKLOR_DIST, 0);
|
||||
else
|
||||
DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT);
|
||||
|
||||
@@ -114,7 +114,7 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
|
||||
temp = m_creature->FindNearestGameObject(entry_search[i],30);
|
||||
if(temp)
|
||||
{
|
||||
if(diff > m_creature->GetDistance2d(temp))
|
||||
if(m_creature->IsWithinDist(temp,diff,false))
|
||||
{
|
||||
near_f = i + 1;
|
||||
diff = m_creature->GetDistance2d(temp);
|
||||
|
||||
@@ -199,7 +199,7 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
|
||||
//dealdamege
|
||||
for(std::list<Unit*>::iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i)
|
||||
{
|
||||
if(Cloud->GetDistance2d(*i)>= 6)
|
||||
if(!Cloud->IsWithinDist(*i, 6, false))
|
||||
{
|
||||
Cloud->CastCustomSpell(*i, 43137, &bp0, NULL, NULL, true, 0, 0, m_creature->GetGUID());
|
||||
}
|
||||
@@ -274,8 +274,7 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
|
||||
m_creature->SetInFront(m_creature->getVictim());
|
||||
StaticDisruption_Timer = (10+rand()%8)*1000; // < 20s
|
||||
|
||||
/*float dist = m_creature->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
|
||||
if (dist < 5.0f) dist = 5.0f;
|
||||
/*if(float dist = m_creature->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f) dist = 5.0f;
|
||||
SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/
|
||||
}else StaticDisruption_Timer -= diff;
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
|
||||
|
||||
if(ResetTimer < diff)
|
||||
{
|
||||
if(m_creature->GetDistance(119.223,1035.45,29.4481) <= 10)
|
||||
if(m_creature->IsWithinDist3d(119.223,1035.45,29.4481, 10))
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user