*Let creature search nearby target before enter evade mode

*Add function canStartAttack to reduce code in MoveInLineOfSight
*Fix a bug that cancelling bind sight auras may crash the server

--HG--
branch : trunk
This commit is contained in:
megamage
2008-11-21 10:07:11 -06:00
parent 5528b7c512
commit 71707df1de
6 changed files with 53 additions and 38 deletions
+9 -19
View File
@@ -73,17 +73,7 @@ bool ScriptedAI::IsVisible(Unit* who) const
void ScriptedAI::MoveInLineOfSight(Unit *who)
{
if(m_creature->getVictim() || !m_creature->IsHostileTo(who) || !who->isInAccessiblePlaceFor(m_creature))
return;
if(!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return;
if(!m_creature->IsWithinDistInMap(who, m_creature->GetAttackDistance(who)) || !m_creature->IsWithinLOSInMap(who))
return;
if(m_creature->canAttack(who))
//who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
if(!m_creature->getVictim() && m_creature->canStartAttack(who))
AttackStart(who);
}
@@ -679,10 +669,10 @@ void ScriptedAI::DoZoneInCombat(Unit* pUnit)
return;
}
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())
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())
pUnit->AddThreat(i_pl, 0.0f);
}
@@ -725,10 +715,10 @@ void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
if (!map->IsDungeon())
return;
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())
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())
i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
}