This commit is contained in:
Yunfan Li
2023-08-25 02:28:56 +08:00
parent ccf619f92f
commit 54462b79c5

View File

@@ -132,14 +132,20 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged)
bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bool react) bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bool react)
{ {
UpdateMovementState();
if (!IsMovingAllowed(mapId, x, y, z)) { if (!IsMovingAllowed(mapId, x, y, z)) {
return false; return false;
} }
UpdateMovementState(); // if (bot->Unit::IsFalling()) {
// if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_FALLING_FAR)) {
// bot->Say("I'm falling!, flag:" + std::to_string(bot->m_movementInfo.GetMovementFlags()), LANG_UNIVERSAL); // bot->Say("I'm falling!, flag:" + std::to_string(bot->m_movementInfo.GetMovementFlags()), LANG_UNIVERSAL);
// return false; // return false;
// } // }
// if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING)) {
// bot->Say("I'm swimming", LANG_UNIVERSAL);
// }
// if (bot->Unit::IsFalling()) {
// bot->Say("I'm falling", LANG_UNIVERSAL);
// }
z += 2.0f; z += 2.0f;
bot->UpdateAllowedPositionZ(x, y, z); bot->UpdateAllowedPositionZ(x, y, z);
// z += 0.5f; // z += 0.5f;
@@ -750,7 +756,7 @@ bool MovementAction::Follow(Unit* target, float distance)
void MovementAction::UpdateMovementState() void MovementAction::UpdateMovementState()
{ {
if (bot->IsInWater() || bot->IsUnderWater()) if (bot->Unit::IsInWater() || bot->Unit::IsUnderWater())
{ {
bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_SWIMMING); bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_SWIMMING);
bot->UpdateSpeed(MOVE_SWIM, true); bot->UpdateSpeed(MOVE_SWIM, true);
@@ -769,69 +775,69 @@ void MovementAction::UpdateMovementState()
//bot->SetSpeedRate(MOVE_RUN, 1.1f); //bot->SetSpeedRate(MOVE_RUN, 1.1f);
// check if target is not reachable (from Vmangos) // check if target is not reachable (from Vmangos)
if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() && !bot->InBattleground()) // if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() && !bot->InBattleground())
{ // {
if (Unit* pTarget = sServerFacade->GetChaseTarget(bot)) // if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
{ // {
if (!bot->IsWithinMeleeRange(pTarget) && pTarget->GetTypeId() == TYPEID_UNIT) // if (!bot->IsWithinMeleeRange(pTarget) && pTarget->GetTypeId() == TYPEID_UNIT)
{ // {
float angle = bot->GetAngle(pTarget); // float angle = bot->GetAngle(pTarget);
float distance = 5.0f; // float distance = 5.0f;
float x = bot->GetPositionX() + cos(angle) * distance; // float x = bot->GetPositionX() + cos(angle) * distance;
float y = bot->GetPositionY() + sin(angle) * distance; // float y = bot->GetPositionY() + sin(angle) * distance;
float z = bot->GetPositionZ(); // float z = bot->GetPositionZ();
z += CONTACT_DISTANCE; // z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z); // bot->UpdateAllowedPositionZ(x, y, z);
bot->StopMoving(); // bot->StopMoving();
bot->GetMotionMaster()->Clear(); // bot->GetMotionMaster()->Clear();
bot->NearTeleportTo(x, y, z, bot->GetOrientation()); // bot->NearTeleportTo(x, y, z, bot->GetOrientation());
//bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false); // //bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false);
return; // return;
/*if (pTarget->IsCreature() && !bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f)) // /*if (pTarget->IsCreature() && !bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f))
{ // {
// Cheating to prevent getting stuck because of bad mmaps. // // Cheating to prevent getting stuck because of bad mmaps.
bot->StopMoving(); // bot->StopMoving();
bot->GetMotionMaster()->Clear(); // bot->GetMotionMaster()->Clear();
bot->GetMotionMaster()->MovePoint(bot->GetMapId(), pTarget->GetPosition(), FORCED_MOVEMENT_RUN, false); // bot->GetMotionMaster()->MovePoint(bot->GetMapId(), pTarget->GetPosition(), FORCED_MOVEMENT_RUN, false);
return; // return;
}*/ // }*/
} // }
} // }
} // }
if ((bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE || // if ((bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE ||
bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) && bot->CanNotReachTarget() && !bot->InBattleground()) // bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) && bot->CanNotReachTarget() && !bot->InBattleground())
{ // {
if (Unit* pTarget = sServerFacade->GetChaseTarget(bot)) // if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
{ // {
if (pTarget != botAI->GetGroupMaster()) // if (pTarget != botAI->GetGroupMaster())
return; // return;
if (!bot->IsWithinMeleeRange(pTarget)) // if (!bot->IsWithinMeleeRange(pTarget))
{ // {
if (!bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f)) // if (!bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f))
{ // {
// Cheating to prevent getting stuck because of bad mmaps. // // Cheating to prevent getting stuck because of bad mmaps.
float angle = bot->GetAngle(pTarget); // float angle = bot->GetAngle(pTarget);
float distance = 5.0f; // float distance = 5.0f;
float x = bot->GetPositionX() + cos(angle) * distance; // float x = bot->GetPositionX() + cos(angle) * distance;
float y = bot->GetPositionY() + sin(angle) * distance; // float y = bot->GetPositionY() + sin(angle) * distance;
float z = bot->GetPositionZ(); // float z = bot->GetPositionZ();
z += CONTACT_DISTANCE; // z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z); // bot->UpdateAllowedPositionZ(x, y, z);
bot->StopMoving(); // bot->StopMoving();
bot->GetMotionMaster()->Clear(); // bot->GetMotionMaster()->Clear();
bot->NearTeleportTo(x, y, z, bot->GetOrientation()); // bot->NearTeleportTo(x, y, z, bot->GetOrientation());
//bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false); // //bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false);
return; // return;
} // }
} // }
} // }
} // }
} }
bool MovementAction::Follow(Unit* target, float distance, float angle) bool MovementAction::Follow(Unit* target, float distance, float angle)