Skip to content

Commit

Permalink
Tweaked the move position to be in a radius of +/- 1.5 from the target
Browse files Browse the repository at this point in the history
  • Loading branch information
atrapalis authored Jul 27, 2024
1 parent e1d9b02 commit 35130d5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5443,7 +5443,17 @@ void bot_ai::CalculateAttackPos(Unit* target, Position& pos, bool& force) const
if (itr->second && (IsTank(itr->second) || IsOffTank(itr->second)))
moveTarget = itr->second;

pos.Relocate(moveTarget);
// Decide if the bot needs to move
float thresholdDistance = 1.5f;
bool rangedBotNeedsToMove = std::abs(me->GetDistance(moveTarget)) > thresholdDistance;
if (rangedBotNeedsToMove)
{
// Randomise and adjust the bot's position
float randomModifier = irand(0, 1) ? 1.0f : -1.0f;
float absoluteAngle = me->GetAbsoluteAngle(moveTarget);
pos.Relocate(Position(moveTarget->GetPositionX() + randomModifier * thresholdDistance * std::cos(absoluteAngle), moveTarget->GetPositionY() + randomModifier * thresholdDistance * std::sin(absoluteAngle)));
}

force = true;
return;
}
Expand Down

0 comments on commit 35130d5

Please sign in to comment.