Skip to content

Commit

Permalink
AI: Fix creature interaction with spell cast and melee flee flag
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Jan 1, 2025
1 parent 57a165c commit 4fd9221
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/game/AI/BaseAI/CreatureAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void CreatureAI::Reset()
void CreatureAI::EnterCombat(Unit* enemy)
{
UnitAI::EnterCombat(enemy);
// TODO: Monitor this condition to see if it conflicts with any pets
if (m_creature->GetSettings().HasFlag(CreatureStaticFlags::NO_MELEE_FLEE) && !m_creature->IsRooted() && !m_creature->IsInPanic() && !m_creature->IsNonMeleeSpellCasted(false) && enemy && enemy->IsPlayerControlled())
{
DoFlee(30000);
SetAIOrder(ORDER_CRITTER_FLEE); // mark as critter flee for custom handling
}
if (enemy && (m_creature->IsGuard() || m_creature->IsCivilian()))
{
// Send Zone Under Attack message to the LocalDefense and WorldDefense Channels
Expand Down
7 changes: 7 additions & 0 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8330,6 +8330,13 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
if (creature->AI())
creature->AI()->EnterCombat(enemy);

// can be overriden by spellcast on Aggro hook, hence must be done after EnterCombat hook
if (!creature->GetCreatedBySpellId() && creature->GetSettings().HasFlag(CreatureStaticFlags::NO_MELEE_FLEE) && !creature->IsRooted() && !creature->IsInPanic() && !creature->IsNonMeleeSpellCasted(false) && enemy && enemy->IsPlayerControlled())
{
creature->AI()->DoFlee(30000);
creature->AI()->SetAIOrder(ORDER_CRITTER_FLEE); // mark as critter flee for custom handling
}

// Some bosses are set into combat with zone
if (GetMap()->IsDungeon() && (creature->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_AGGRO_ZONE) && enemy && enemy->IsControlledByPlayer())
creature->SetInCombatWithZone();
Expand Down

0 comments on commit 4fd9221

Please sign in to comment.