fix(Core/AI): improve npc_escortAI (#4980)
This commit is contained in:
@@ -62,19 +62,54 @@ void npc_escortAI::AttackStart(Unit* who)
|
|||||||
bool npc_escortAI::AssistPlayerInCombat(Unit* who)
|
bool npc_escortAI::AssistPlayerInCombat(Unit* who)
|
||||||
{
|
{
|
||||||
if (!who || !who->GetVictim())
|
if (!who || !who->GetVictim())
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (me->HasReactState(REACT_PASSIVE))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//experimental (unknown) flag not present
|
//experimental (unknown) flag not present
|
||||||
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST))
|
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//not a player
|
//not a player
|
||||||
if (!who->GetVictim()->GetCharmerOrOwnerPlayerOrPlayerItself())
|
if (!who->GetVictim()->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!who->isInAccessiblePlaceFor(me))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CanAIAttack(who))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we cannot attack in evade mode
|
||||||
|
if (me->IsInEvadeMode())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// or if enemy is in evade mode
|
||||||
|
if (who->GetTypeId() == TYPEID_UNIT && who->ToCreature()->IsInEvadeMode())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//never attack friendly
|
//never attack friendly
|
||||||
if (!me->IsValidAttackTarget(who))
|
if (!me->IsValidAttackTarget(who))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//too far away and no free sight?
|
//too far away and no free sight?
|
||||||
if (me->IsWithinDistInMap(who, GetMaxPlayerDistance()) && me->IsWithinLOSInMap(who))
|
if (me->IsWithinDistInMap(who, GetMaxPlayerDistance()) && me->IsWithinLOSInMap(who))
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "ScriptSystem.h"
|
#include "ScriptSystem.h"
|
||||||
#include "ScriptedCreature.h"
|
#include "ScriptedCreature.h"
|
||||||
|
|
||||||
#define DEFAULT_MAX_PLAYER_DISTANCE 50
|
#define DEFAULT_MAX_PLAYER_DISTANCE 100
|
||||||
|
|
||||||
struct Escort_Waypoint
|
struct Escort_Waypoint
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user