mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
swimming
This commit is contained in:
@@ -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)
|
||||
{
|
||||
UpdateMovementState();
|
||||
if (!IsMovingAllowed(mapId, x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
UpdateMovementState();
|
||||
// if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_FALLING_FAR)) {
|
||||
// if (bot->Unit::IsFalling()) {
|
||||
// bot->Say("I'm falling!, flag:" + std::to_string(bot->m_movementInfo.GetMovementFlags()), LANG_UNIVERSAL);
|
||||
// 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;
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
// z += 0.5f;
|
||||
@@ -750,7 +756,7 @@ bool MovementAction::Follow(Unit* target, float distance)
|
||||
|
||||
void MovementAction::UpdateMovementState()
|
||||
{
|
||||
if (bot->IsInWater() || bot->IsUnderWater())
|
||||
if (bot->Unit::IsInWater() || bot->Unit::IsUnderWater())
|
||||
{
|
||||
bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
bot->UpdateSpeed(MOVE_SWIM, true);
|
||||
@@ -769,69 +775,69 @@ void MovementAction::UpdateMovementState()
|
||||
//bot->SetSpeedRate(MOVE_RUN, 1.1f);
|
||||
|
||||
// check if target is not reachable (from Vmangos)
|
||||
if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() && !bot->InBattleground())
|
||||
{
|
||||
if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
|
||||
{
|
||||
if (!bot->IsWithinMeleeRange(pTarget) && pTarget->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
float angle = bot->GetAngle(pTarget);
|
||||
float distance = 5.0f;
|
||||
float x = bot->GetPositionX() + cos(angle) * distance;
|
||||
float y = bot->GetPositionY() + sin(angle) * distance;
|
||||
float z = bot->GetPositionZ();
|
||||
// if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() && !bot->InBattleground())
|
||||
// {
|
||||
// if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
|
||||
// {
|
||||
// if (!bot->IsWithinMeleeRange(pTarget) && pTarget->GetTypeId() == TYPEID_UNIT)
|
||||
// {
|
||||
// float angle = bot->GetAngle(pTarget);
|
||||
// float distance = 5.0f;
|
||||
// float x = bot->GetPositionX() + cos(angle) * distance;
|
||||
// float y = bot->GetPositionY() + sin(angle) * distance;
|
||||
// float z = bot->GetPositionZ();
|
||||
|
||||
z += CONTACT_DISTANCE;
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
// z += CONTACT_DISTANCE;
|
||||
// bot->UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
bot->StopMoving();
|
||||
bot->GetMotionMaster()->Clear();
|
||||
bot->NearTeleportTo(x, y, z, bot->GetOrientation());
|
||||
//bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false);
|
||||
return;
|
||||
/*if (pTarget->IsCreature() && !bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f))
|
||||
{
|
||||
// Cheating to prevent getting stuck because of bad mmaps.
|
||||
bot->StopMoving();
|
||||
bot->GetMotionMaster()->Clear();
|
||||
bot->GetMotionMaster()->MovePoint(bot->GetMapId(), pTarget->GetPosition(), FORCED_MOVEMENT_RUN, false);
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
// bot->StopMoving();
|
||||
// bot->GetMotionMaster()->Clear();
|
||||
// bot->NearTeleportTo(x, y, z, bot->GetOrientation());
|
||||
// //bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false);
|
||||
// return;
|
||||
// /*if (pTarget->IsCreature() && !bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f))
|
||||
// {
|
||||
// // Cheating to prevent getting stuck because of bad mmaps.
|
||||
// bot->StopMoving();
|
||||
// bot->GetMotionMaster()->Clear();
|
||||
// bot->GetMotionMaster()->MovePoint(bot->GetMapId(), pTarget->GetPosition(), FORCED_MOVEMENT_RUN, false);
|
||||
// return;
|
||||
// }*/
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if ((bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE ||
|
||||
bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) && bot->CanNotReachTarget() && !bot->InBattleground())
|
||||
{
|
||||
if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
|
||||
{
|
||||
if (pTarget != botAI->GetGroupMaster())
|
||||
return;
|
||||
// if ((bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE ||
|
||||
// bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) && bot->CanNotReachTarget() && !bot->InBattleground())
|
||||
// {
|
||||
// if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
|
||||
// {
|
||||
// if (pTarget != botAI->GetGroupMaster())
|
||||
// return;
|
||||
|
||||
if (!bot->IsWithinMeleeRange(pTarget))
|
||||
{
|
||||
if (!bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f))
|
||||
{
|
||||
// Cheating to prevent getting stuck because of bad mmaps.
|
||||
float angle = bot->GetAngle(pTarget);
|
||||
float distance = 5.0f;
|
||||
float x = bot->GetPositionX() + cos(angle) * distance;
|
||||
float y = bot->GetPositionY() + sin(angle) * distance;
|
||||
float z = bot->GetPositionZ();
|
||||
// if (!bot->IsWithinMeleeRange(pTarget))
|
||||
// {
|
||||
// if (!bot->isMoving() && bot->IsWithinDist(pTarget, 10.0f))
|
||||
// {
|
||||
// // Cheating to prevent getting stuck because of bad mmaps.
|
||||
// float angle = bot->GetAngle(pTarget);
|
||||
// float distance = 5.0f;
|
||||
// float x = bot->GetPositionX() + cos(angle) * distance;
|
||||
// float y = bot->GetPositionY() + sin(angle) * distance;
|
||||
// float z = bot->GetPositionZ();
|
||||
|
||||
z += CONTACT_DISTANCE;
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
// z += CONTACT_DISTANCE;
|
||||
// bot->UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
bot->StopMoving();
|
||||
bot->GetMotionMaster()->Clear();
|
||||
bot->NearTeleportTo(x, y, z, bot->GetOrientation());
|
||||
//bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// bot->StopMoving();
|
||||
// bot->GetMotionMaster()->Clear();
|
||||
// bot->NearTeleportTo(x, y, z, bot->GetOrientation());
|
||||
// //bot->GetMotionMaster()->MovePoint(bot->GetMapId(), x, y, z, FORCED_MOVEMENT_RUN, false);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
bool MovementAction::Follow(Unit* target, float distance, float angle)
|
||||
|
||||
Reference in New Issue
Block a user