mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
*Fix a bug that creature ignore LOS in assistance case.
--HG-- branch : trunk
This commit is contained in:
@@ -240,9 +240,9 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
|
||||
|
||||
void MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if(who && !m_creature->getVictim() && m_creature->canStartAttack(who))
|
||||
AttackStart(who);
|
||||
if (!Intro && who && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who))
|
||||
ScriptedAI::MoveInLineOfSight(who);
|
||||
|
||||
if (!Intro && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who))
|
||||
{
|
||||
DoScriptText(SAY_INTRO, m_creature);
|
||||
Intro = true;
|
||||
|
||||
@@ -434,14 +434,10 @@ void hyjalAI::EnterCombat(Unit *who)
|
||||
|
||||
void hyjalAI::MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if(IsDummy)return;
|
||||
if (IsBeingEscorted && !GetAttack())
|
||||
if(IsDummy)
|
||||
return;
|
||||
|
||||
if(m_creature->getVictim() || !m_creature->canStartAttack(who))
|
||||
return;
|
||||
|
||||
AttackStart(who);
|
||||
npc_escortAI::MoveInLineOfSight(who);
|
||||
}
|
||||
|
||||
void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
|
||||
|
||||
@@ -649,22 +649,16 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
|
||||
WaveTimer = 0;
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* who){}
|
||||
|
||||
void MoveInLineOfSight(Unit* who)
|
||||
{
|
||||
if( who->GetTypeId() == TYPEID_PLAYER && !m_creature->canStartAttack(who) && !Progress)
|
||||
if(!Progress && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 10.0f))
|
||||
{
|
||||
if( CAST_PLR(who)->GetQuestStatus(QUEST_POWERING_OUR_DEFENSES) == QUEST_STATUS_INCOMPLETE )
|
||||
{
|
||||
float Radius = 10.0;
|
||||
if( m_creature->IsWithinDistInMap(who, Radius) )
|
||||
{
|
||||
PlayerGUID = who->GetGUID();
|
||||
WaveTimer = 1000;
|
||||
EndTimer = 60000;
|
||||
Progress = true;
|
||||
}
|
||||
PlayerGUID = who->GetGUID();
|
||||
WaveTimer = 1000;
|
||||
EndTimer = 60000;
|
||||
Progress = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,10 +170,7 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
|
||||
void MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if(!Intro && !Flying)
|
||||
{
|
||||
if(!m_creature->getVictim() && m_creature->canStartAttack(who))
|
||||
ScriptedAI::AttackStart(who);
|
||||
}
|
||||
ScriptedAI::MoveInLineOfSight(who);
|
||||
}
|
||||
|
||||
void MovementInform(uint32 type, uint32 id)
|
||||
|
||||
@@ -1646,15 +1646,17 @@ bool Creature::IsWithinSightDist(Unit const* u) const
|
||||
return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER));
|
||||
}
|
||||
|
||||
bool Creature::canStartAttack(Unit const* who) const
|
||||
bool Creature::canStartAttack(Unit const* who, bool force) const
|
||||
{
|
||||
if(isCivilian() || IsNeutralToAll()
|
||||
if(isCivilian()
|
||||
|| !who->isInAccessiblePlaceFor(this)
|
||||
|| !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE
|
||||
|| !IsWithinDistInMap(who, GetAttackDistance(who)))
|
||||
|| !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return false;
|
||||
|
||||
if(!canAttack(who, false))
|
||||
if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who))))
|
||||
return false;
|
||||
|
||||
if(!canAttack(who, force))
|
||||
return false;
|
||||
|
||||
return IsWithinLOSInMap(who);
|
||||
|
||||
@@ -643,7 +643,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
|
||||
bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
|
||||
bool IsWithinSightDist(Unit const* u) const;
|
||||
bool canStartAttack(Unit const* u) const;
|
||||
bool canStartAttack(Unit const* u, bool force) const;
|
||||
float GetAttackDistance(Unit const* pl) const;
|
||||
|
||||
Unit* SelectNearestTarget(float dist = 0) const;
|
||||
|
||||
@@ -100,11 +100,11 @@ void CreatureAI::MoveInLineOfSight(Unit *who)
|
||||
if(me->getVictim())
|
||||
return;
|
||||
|
||||
if(me->canStartAttack(who))
|
||||
if(me->canStartAttack(who, false))
|
||||
AttackStart(who);
|
||||
else if(who->getVictim() && me->IsFriendlyTo(who)
|
||||
&& me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
|
||||
&& me->canAttack(who->getVictim()))
|
||||
&& me->canStartAttack(who->getVictim(), true))
|
||||
AttackStart(who->getVictim());
|
||||
}
|
||||
|
||||
|
||||
@@ -957,11 +957,12 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
|
||||
}
|
||||
}
|
||||
|
||||
//if (m_creature->isCivilian() && m_creature->IsNeutralToAll())
|
||||
// return;
|
||||
|
||||
if(me->canStartAttack(who))
|
||||
if(me->canStartAttack(who, false))
|
||||
AttackStart(who);
|
||||
else if(who->getVictim() && me->IsFriendlyTo(who)
|
||||
&& me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
|
||||
&& me->canStartAttack(who->getVictim(), true))
|
||||
AttackStart(who->getVictim());
|
||||
}
|
||||
|
||||
void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
|
||||
|
||||
@@ -997,7 +997,7 @@ namespace Trinity
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!m_creature->canStartAttack(u))
|
||||
if(!m_creature->canStartAttack(u, false))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user