Skip to content

Commit

Permalink
Merge pull request liyunfan1223#440 from liyunfan1223/fix-combat-reach
Browse files Browse the repository at this point in the history
Fix move delay and reach combat
  • Loading branch information
liyunfan1223 authored Aug 5, 2024
2 parents 8764072 + 264c533 commit d341067
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
21 changes: 12 additions & 9 deletions src/strategy/actions/MovementActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// if (bot->Unit::IsFalling()) {
// bot->Say("I'm falling", LANG_UNIVERSAL);
// }
// !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) &&

bool generatePath = !bot->IsFlying() && !bot->isSwimming();
bool disableMoveSplinePath = sPlayerbotAIConfig->disableMoveSplinePath >= 2 ||
(sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground());
Expand All @@ -208,7 +206,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
MotionMaster& mm = *bot->GetMotionMaster();
mm.Clear();
mm.MovePoint(mapId, x, y, z, generatePath);
float delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, 1000.0f * MoveDelay(distance));
float delay = 1000.0f * MoveDelay(distance) - sPlayerbotAIConfig->reactDelay;
delay = std::max(.0f, delay);
delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, delay);
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay);
return true;
}
Expand Down Expand Up @@ -238,7 +238,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
mm.Clear();
mm.MoveSplinePath(&path);
// mm.MoveSplinePath(&path);
float delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, 1000.0f * MoveDelay(distance));
float delay = 1000.0f * MoveDelay(distance) - sPlayerbotAIConfig->reactDelay;
delay = std::max(.0f, delay);
delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, delay);
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay);
return true;
}
Expand Down Expand Up @@ -792,7 +794,7 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position
{
float needToGo = bot->GetExactDist(target) - distance;
float timeToGo = MoveDelay(abs(needToGo)) + sPlayerbotAIConfig->reactDelay;
float timeToGo = MoveDelay(abs(needToGo)) + sPlayerbotAIConfig->reactDelay / 1000.0f;
float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN);
targetMoveDist = std::min(5.0f, targetMoveDist);
tx += targetMoveDist * cos(target->GetOrientation());
Expand All @@ -806,7 +808,10 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
tz = target->GetPositionZ();
}
}

if (bot->GetExactDist(tx, ty, tz) <= distance)
{
return false;
}
PathGenerator path(bot);
path.CalculatePath(tx, ty, tz, false);
PathType type = path.GetPathType();
Expand Down Expand Up @@ -1249,9 +1254,7 @@ float MovementAction::MoveDelay(float distance)
{
speed = bot->GetSpeed(MOVE_RUN);
}
float delay = distance / speed - sPlayerbotAIConfig->reactDistance;
if (delay < 0)
delay = 0;
float delay = distance / speed;
return delay;
}

Expand Down
8 changes: 4 additions & 4 deletions src/strategy/hunter/GenericHunterStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ void GenericHunterStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
triggers.push_back(
new TriggerNode("misdirection on main tank",
NextAction::array(0, new NextAction("misdirection on main tank", ACTION_HIGH + 7), NULL)));
triggers.push_back(
new TriggerNode("tranquilizing shot enrage", NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
triggers.push_back(
new TriggerNode("tranquilizing shot magic", NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
triggers.push_back(new TriggerNode("tranquilizing shot enrage",
NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
triggers.push_back(new TriggerNode("tranquilizing shot magic",
NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
}

NextAction** HunterBoostStrategy::getDefaultActions()
Expand Down

0 comments on commit d341067

Please sign in to comment.