mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix transport movement
This commit is contained in:
@@ -95,7 +95,7 @@ bool MoveToRpgTargetAction::Execute(Event event)
|
|||||||
x += cos(angle) * INTERACTION_DISTANCE * distance;
|
x += cos(angle) * INTERACTION_DISTANCE * distance;
|
||||||
y += sin(angle) * INTERACTION_DISTANCE * distance;
|
y += sin(angle) * INTERACTION_DISTANCE * distance;
|
||||||
if (!wo->GetMap()->CheckCollisionAndGetValidCoords(wo, wo->GetPositionX(), wo->GetPositionY(), wo->GetPositionZ(),
|
if (!wo->GetMap()->CheckCollisionAndGetValidCoords(wo, wo->GetPositionX(), wo->GetPositionY(), wo->GetPositionZ(),
|
||||||
x, y, z))
|
x, y, z, false))
|
||||||
{
|
{
|
||||||
x = wo->GetPositionX();
|
x = wo->GetPositionX();
|
||||||
y = wo->GetPositionY();
|
y = wo->GetPositionY();
|
||||||
|
|||||||
@@ -820,22 +820,28 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
|||||||
tx += targetMoveDist * cos(target->GetOrientation());
|
tx += targetMoveDist * cos(target->GetOrientation());
|
||||||
ty += targetMoveDist * sin(target->GetOrientation());
|
ty += targetMoveDist * sin(target->GetOrientation());
|
||||||
if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(),
|
if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(),
|
||||||
target->GetPositionZ(), tx, ty, tz))
|
target->GetPositionZ(), tx, ty, tz, false))
|
||||||
{
|
{
|
||||||
// disable prediction if position is invalid
|
// disable prediction if position is invalid
|
||||||
tx = target->GetPositionX();
|
tx = target->GetPositionX();
|
||||||
ty = target->GetPositionY();
|
ty = target->GetPositionY();
|
||||||
tz = target->GetPositionZ();
|
tz = target->GetPositionZ();
|
||||||
}
|
}
|
||||||
}
|
// Prediction may cause this, which makes ShortenPathUntilDist fail
|
||||||
if (bot->GetExactDist(tx, ty, tz) <= distance)
|
if (bot->GetExactDist(tx, ty, tz) <= distance)
|
||||||
{
|
{
|
||||||
return false;
|
tx = target->GetPositionX();
|
||||||
|
ty = target->GetPositionY();
|
||||||
|
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();
|
||||||
if (type != PATHFIND_NORMAL && type != PATHFIND_INCOMPLETE)
|
int typeOk = PATHFIND_NORMAL | PATHFIND_INCOMPLETE;
|
||||||
|
if (!(type & typeOk))
|
||||||
return false;
|
return false;
|
||||||
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), distance);
|
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), distance);
|
||||||
G3D::Vector3 endPos = path.GetPath().back();
|
G3D::Vector3 endPos = path.GetPath().back();
|
||||||
@@ -881,7 +887,7 @@ bool MovementAction::IsMovingAllowed(Unit* target)
|
|||||||
|
|
||||||
bool MovementAction::IsMovingAllowed(uint32 mapId, float x, float y, float z)
|
bool MovementAction::IsMovingAllowed(uint32 mapId, float x, float y, float z)
|
||||||
{
|
{
|
||||||
// removed sqrt as means distance limit was effectively 22500 (ReactDistance<63>)
|
// removed sqrt as means distance limit was effectively 22500 (ReactDistance<63>)
|
||||||
// leaving it commented incase we find ReactDistance limit causes problems
|
// leaving it commented incase we find ReactDistance limit causes problems
|
||||||
// float distance = sqrt(bot->GetDistance(x, y, z));
|
// float distance = sqrt(bot->GetDistance(x, y, z));
|
||||||
float distance = bot->GetDistance(x, y, z);
|
float distance = bot->GetDistance(x, y, z);
|
||||||
@@ -2352,7 +2358,7 @@ bool MoveRandomAction::Execute(Event event)
|
|||||||
x += urand(0, distance) * cos(angle);
|
x += urand(0, distance) * cos(angle);
|
||||||
y += urand(0, distance) * sin(angle);
|
y += urand(0, distance) * sin(angle);
|
||||||
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||||
bot->GetPositionZ(), x, y, z))
|
bot->GetPositionZ(), x, y, z, false))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ WorldLocation ArrowFormation::GetLocationInternal()
|
|||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
|
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||||
master->GetPositionZ(), x, y, z))
|
master->GetPositionZ(), x, y, z, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
// master->UpdateGroundPositionZ(x, y, z);
|
// master->UpdateGroundPositionZ(x, y, z);
|
||||||
return WorldLocation(master->GetMapId(), x, y, z);
|
return WorldLocation(master->GetMapId(), x, y, z);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public:
|
|||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
|
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||||
master->GetPositionZ(), x, y, z))
|
master->GetPositionZ(), x, y, z, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
return WorldLocation(master->GetMapId(), x, y, z);
|
return WorldLocation(master->GetMapId(), x, y, z);
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
float y = master->GetPositionY() + sin(angle) * range + dy;
|
float y = master->GetPositionY() + sin(angle) * range + dy;
|
||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
|
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
// bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
// bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||||
// bot->GetPositionZ(), x, y, z);
|
// bot->GetPositionZ(), x, y, z);
|
||||||
@@ -146,7 +146,7 @@ public:
|
|||||||
float y = master->GetPositionY() + sin(angle) * range + dy;
|
float y = master->GetPositionY() + sin(angle) * range + dy;
|
||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||||
master->GetPositionZ(), x, y, z))
|
master->GetPositionZ(), x, y, z, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
return WorldLocation(master->GetMapId(), x, y, z);
|
return WorldLocation(master->GetMapId(), x, y, z);
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ public:
|
|||||||
float y = target->GetPositionY() + sin(angle) * range;
|
float y = target->GetPositionY() + sin(angle) * range;
|
||||||
float z = target->GetPositionZ();
|
float z = target->GetPositionZ();
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||||
master->GetPositionZ(), x, y, z))
|
master->GetPositionZ(), x, y, z, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
|
|
||||||
return WorldLocation(bot->GetMapId(), x, y, z);
|
return WorldLocation(bot->GetMapId(), x, y, z);
|
||||||
@@ -363,7 +363,7 @@ public:
|
|||||||
if (minDist)
|
if (minDist)
|
||||||
{
|
{
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
|
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
return WorldLocation(bot->GetMapId(), minX, minY, z);
|
return WorldLocation(bot->GetMapId(), minX, minY, z);
|
||||||
}
|
}
|
||||||
@@ -372,7 +372,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||||
master->GetPositionZ(), x, y, z))
|
master->GetPositionZ(), x, y, z, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
return WorldLocation(bot->GetMapId(), x, y, z);
|
return WorldLocation(bot->GetMapId(), x, y, z);
|
||||||
}
|
}
|
||||||
@@ -635,7 +635,7 @@ WorldLocation MoveFormation::MoveSingleLine(std::vector<Player*> line, float dif
|
|||||||
|
|
||||||
Player* master = botAI->GetMaster();
|
Player* master = botAI->GetMaster();
|
||||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), lx, ly, lz))
|
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), lx, ly, lz, false))
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
|
|
||||||
return WorldLocation(bot->GetMapId(), lx, ly, lz);
|
return WorldLocation(bot->GetMapId(), lx, ly, lz);
|
||||||
|
|||||||
Reference in New Issue
Block a user