mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix move delay and reach combat
This commit is contained in:
@@ -187,8 +187,6 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
// if (bot->Unit::IsFalling()) {
|
// if (bot->Unit::IsFalling()) {
|
||||||
// bot->Say("I'm falling", LANG_UNIVERSAL);
|
// bot->Say("I'm falling", LANG_UNIVERSAL);
|
||||||
// }
|
// }
|
||||||
// !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) &&
|
|
||||||
|
|
||||||
bool generatePath = !bot->IsFlying() && !bot->isSwimming();
|
bool generatePath = !bot->IsFlying() && !bot->isSwimming();
|
||||||
bool disableMoveSplinePath = sPlayerbotAIConfig->disableMoveSplinePath >= 2 ||
|
bool disableMoveSplinePath = sPlayerbotAIConfig->disableMoveSplinePath >= 2 ||
|
||||||
(sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground());
|
(sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground());
|
||||||
@@ -208,7 +206,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
MotionMaster& mm = *bot->GetMotionMaster();
|
MotionMaster& mm = *bot->GetMotionMaster();
|
||||||
mm.Clear();
|
mm.Clear();
|
||||||
mm.MovePoint(mapId, x, y, z, generatePath);
|
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);
|
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
mm.Clear();
|
mm.Clear();
|
||||||
mm.MoveSplinePath(&path);
|
mm.MoveSplinePath(&path);
|
||||||
// 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);
|
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -792,7 +794,7 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
|||||||
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position
|
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position
|
||||||
{
|
{
|
||||||
float needToGo = bot->GetExactDist(target) - distance;
|
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);
|
float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN);
|
||||||
targetMoveDist = std::min(5.0f, targetMoveDist);
|
targetMoveDist = std::min(5.0f, targetMoveDist);
|
||||||
tx += targetMoveDist * cos(target->GetOrientation());
|
tx += targetMoveDist * cos(target->GetOrientation());
|
||||||
@@ -806,7 +808,10 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
|||||||
tz = target->GetPositionZ();
|
tz = target->GetPositionZ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (bot->GetExactDist(tx, ty, tz) <= distance)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
PathGenerator path(bot);
|
PathGenerator path(bot);
|
||||||
path.CalculatePath(tx, ty, tz, false);
|
path.CalculatePath(tx, ty, tz, false);
|
||||||
PathType type = path.GetPathType();
|
PathType type = path.GetPathType();
|
||||||
@@ -1249,9 +1254,7 @@ float MovementAction::MoveDelay(float distance)
|
|||||||
{
|
{
|
||||||
speed = bot->GetSpeed(MOVE_RUN);
|
speed = bot->GetSpeed(MOVE_RUN);
|
||||||
}
|
}
|
||||||
float delay = distance / speed - sPlayerbotAIConfig->reactDistance;
|
float delay = distance / speed;
|
||||||
if (delay < 0)
|
|
||||||
delay = 0;
|
|
||||||
return delay;
|
return delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,10 +97,10 @@ void GenericHunterStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
|||||||
triggers.push_back(
|
triggers.push_back(
|
||||||
new TriggerNode("misdirection on main tank",
|
new TriggerNode("misdirection on main tank",
|
||||||
NextAction::array(0, new NextAction("misdirection on main tank", ACTION_HIGH + 7), NULL)));
|
NextAction::array(0, new NextAction("misdirection on main tank", ACTION_HIGH + 7), NULL)));
|
||||||
triggers.push_back(
|
triggers.push_back(new TriggerNode("tranquilizing shot enrage",
|
||||||
new TriggerNode("tranquilizing shot enrage", NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
|
NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
|
||||||
triggers.push_back(
|
triggers.push_back(new TriggerNode("tranquilizing shot magic",
|
||||||
new TriggerNode("tranquilizing shot magic", NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
|
NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
NextAction** HunterBoostStrategy::getDefaultActions()
|
NextAction** HunterBoostStrategy::getDefaultActions()
|
||||||
|
|||||||
Reference in New Issue
Block a user