Skip to content

Commit

Permalink
feat(NpcBots/bot_ai): Changed ranged bots to run to a tank or to thei…
Browse files Browse the repository at this point in the history
…r master when they have aggro
  • Loading branch information
atrapalis authored Jul 26, 2024
1 parent 88bb14d commit e1d9b02
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5430,7 +5430,24 @@ void bot_ai::CalculateAttackPos(Unit* target, Position& pos, bool& force) const
force = true;
return;
}

// Ranged bots that are being targeted should move towards a tank bot or towards the player
if (!IsTank(me) && HasRole(BOT_ROLE_RANGED) && target->GetVictim() == me)
{
// By default go to the master
Unit* moveTarget = master;

// Look for a tank in the master's bots
BotMap const* map = master->GetBotMgr()->GetBotMap();
for (BotMap::const_iterator itr = map->begin(); itr != map->end(); ++itr)
if (itr->second && (IsTank(itr->second) || IsOffTank(itr->second)))
moveTarget = itr->second;

pos.Relocate(moveTarget);
force = true;
return;
}

pos.Relocate(ppos);
if (!me->IsWithinLOSInMap(target, VMAP::ModelIgnoreFlags::M2, LINEOFSIGHT_ALL_CHECKS))
force = true;
Expand Down

0 comments on commit e1d9b02

Please sign in to comment.