mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 03:42:37 +01:00
Merge pull request #15501 from Treeston/3.3.5-proximitycombat
Creature/SmartAI: Fix creature aggression behavior
This commit is contained in:
@@ -29,7 +29,15 @@
|
|||||||
void UnitAI::AttackStart(Unit* victim)
|
void UnitAI::AttackStart(Unit* victim)
|
||||||
{
|
{
|
||||||
if (victim && me->Attack(victim, true))
|
if (victim && me->Attack(victim, true))
|
||||||
|
{
|
||||||
|
// Clear distracted state on attacking
|
||||||
|
if (me->HasUnitState(UNIT_STATE_DISTRACTED))
|
||||||
|
{
|
||||||
|
me->ClearUnitState(UNIT_STATE_DISTRACTED);
|
||||||
|
me->GetMotionMaster()->Clear();
|
||||||
|
}
|
||||||
me->GetMotionMaster()->MoveChase(victim);
|
me->GetMotionMaster()->MoveChase(victim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitAI::AttackStartCaster(Unit* victim, float dist)
|
void UnitAI::AttackStartCaster(Unit* victim, float dist)
|
||||||
|
|||||||
@@ -453,45 +453,15 @@ void SmartAI::MoveInLineOfSight(Unit* who)
|
|||||||
|
|
||||||
GetScript()->OnMoveInLineOfSight(who);
|
GetScript()->OnMoveInLineOfSight(who);
|
||||||
|
|
||||||
if (me->HasReactState(REACT_PASSIVE) || AssistPlayerInCombat(who))
|
if (AssistPlayerInCombat(who))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!CanAIAttack(who))
|
CreatureAI::MoveInLineOfSight(who);
|
||||||
return;
|
|
||||||
|
|
||||||
if (!me->CanStartAttack(who, false))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (me->IsHostileTo(who))
|
|
||||||
{
|
|
||||||
float fAttackRadius = me->GetAttackDistance(who);
|
|
||||||
if (me->IsWithinDistInMap(who, fAttackRadius) && me->IsWithinLOSInMap(who))
|
|
||||||
{
|
|
||||||
if (!me->GetVictim())
|
|
||||||
{
|
|
||||||
// Clear distracted state on combat
|
|
||||||
if (me->HasUnitState(UNIT_STATE_DISTRACTED))
|
|
||||||
{
|
|
||||||
me->ClearUnitState(UNIT_STATE_DISTRACTED);
|
|
||||||
me->GetMotionMaster()->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
AttackStart(who);
|
|
||||||
}
|
|
||||||
else/* if (me->GetMap()->IsDungeon())*/
|
|
||||||
{
|
|
||||||
who->SetInCombatWith(me);
|
|
||||||
me->AddThreat(who, 0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SmartAI::CanAIAttack(const Unit* /*who*/) const
|
bool SmartAI::CanAIAttack(const Unit* /*who*/) const
|
||||||
{
|
{
|
||||||
if (me->GetReactState() == REACT_PASSIVE)
|
return !(me->HasReactState(REACT_PASSIVE));
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SmartAI::AssistPlayerInCombat(Unit* who)
|
bool SmartAI::AssistPlayerInCombat(Unit* who)
|
||||||
|
|||||||
Reference in New Issue
Block a user