mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Collision check in movement
This commit is contained in:
@@ -95,7 +95,7 @@ bool MoveToRpgTargetAction::Execute(Event event)
|
||||
x += cos(angle) * INTERACTION_DISTANCE * distance;
|
||||
y += sin(angle) * INTERACTION_DISTANCE * distance;
|
||||
if (!wo->GetMap()->CheckCollisionAndGetValidCoords(wo, wo->GetPositionX(), wo->GetPositionY(), wo->GetPositionZ(),
|
||||
x, y, z, false))
|
||||
x, y, z))
|
||||
{
|
||||
x = wo->GetPositionX();
|
||||
y = wo->GetPositionY();
|
||||
|
||||
@@ -820,7 +820,7 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
||||
tx += targetMoveDist * cos(target->GetOrientation());
|
||||
ty += targetMoveDist * sin(target->GetOrientation());
|
||||
if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(),
|
||||
target->GetPositionZ(), tx, ty, tz, false))
|
||||
target->GetPositionZ(), tx, ty, tz))
|
||||
{
|
||||
// disable prediction if position is invalid
|
||||
tx = target->GetPositionX();
|
||||
@@ -2357,10 +2357,15 @@ bool MoveRandomAction::Execute(Event event)
|
||||
float angle = (float)rand_norm() * static_cast<float>(M_PI);
|
||||
x += urand(0, distance) * cos(angle);
|
||||
y += urand(0, distance) * sin(angle);
|
||||
float ox = x;
|
||||
float oy = y;
|
||||
float oz = z;
|
||||
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||
bot->GetPositionZ(), x, y, z, false))
|
||||
bot->GetPositionZ(), x, y, z))
|
||||
{
|
||||
continue;
|
||||
x = ox;
|
||||
y = oy;
|
||||
z = oz;
|
||||
}
|
||||
if (map->IsInWater(bot->GetPhaseMask(), x, y, z, bot->GetCollisionHeight()))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user