Skip to content

Commit

Permalink
AI should only approach the target for ranged spells and AOE spells. …
Browse files Browse the repository at this point in the history
…Self-buffs won't cause the AI to approach anymore.
  • Loading branch information
dfighter1985 committed Jul 15, 2023
1 parent d1627e5 commit 4155c44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/world/Game/AI/AIInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,11 @@ void AIInterface::_UpdateCombat(uint32 p_time)
{
los = CollideInterface.CheckLOS(m_Unit->GetMapId(), m_Unit->GetPositionNC(), getNextTarget()->GetPositionNC());
}
if(los
&& ((distance <= m_nextSpell->maxrange + m_Unit->GetModelHalfSize()
// && distance >= m_nextSpell->minrange
)
/*|| m_nextSpell->maxrange == 0*/)) // Target is in Range -> Attack

/// If target is in range, or spell has no range and is not AOE cast the spell
if( ( los && ( distance <= m_nextSpell->maxrange + m_Unit->GetModelHalfSize() ) ) ||
( !m_nextSpell->hasRange() && ( m_nextSpell->spellType != STYPE_AOEDAMAGE ) )
)
{
SpellEntry* spellInfo = m_nextSpell->spell;

Expand Down
8 changes: 8 additions & 0 deletions src/world/Game/AI/AIInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ struct AI_Spell
float minrange;
float maxrange;
uint32 autocast_type;

bool hasRange() const
{
if( ( minrange != 0 ) || ( maxrange != 0 ) )
return true;
else
return false;
}
};

//Assume previous point can be reached through linked list or current creature position.
Expand Down

0 comments on commit 4155c44

Please sign in to comment.