mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Update far move to prevent invalid movement
This commit is contained in:
@@ -1525,7 +1525,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
|
|||||||
uint32 c_entry = fields[6].Get<uint32>();
|
uint32 c_entry = fields[6].Get<uint32>();
|
||||||
const FactionTemplateEntry* entry = sFactionTemplateStore.LookupEntry(faction);
|
const FactionTemplateEntry* entry = sFactionTemplateStore.LookupEntry(faction);
|
||||||
|
|
||||||
WorldLocation loc(mapId, x, y, z, orient + M_PI);
|
WorldLocation loc(mapId, x + cos(orient) * 5.0f, y + sin(orient) * 5.0f, z + 0.5f, orient + M_PI);
|
||||||
collected_locs++;
|
collected_locs++;
|
||||||
Map* map = sMapMgr->FindMap(loc.GetMapId(), 0);
|
Map* map = sMapMgr->FindMap(loc.GetMapId(), 0);
|
||||||
if (!map)
|
if (!map)
|
||||||
@@ -1631,6 +1631,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
|
|||||||
"AND t.faction != 69 "
|
"AND t.faction != 69 "
|
||||||
"AND t.entry != 30606 "
|
"AND t.entry != 30606 "
|
||||||
"AND t.entry != 30608 "
|
"AND t.entry != 30608 "
|
||||||
|
"AND t.entry != 29282 "
|
||||||
"AND t.faction != 69 "
|
"AND t.faction != 69 "
|
||||||
"AND map IN ({}) "
|
"AND map IN ({}) "
|
||||||
"ORDER BY "
|
"ORDER BY "
|
||||||
|
|||||||
@@ -156,6 +156,10 @@ WorldPosition NewRpgStatusUpdateAction::SelectRandomGrindPos()
|
|||||||
if (bot->GetMapId() != loc.GetMapId())
|
if (bot->GetMapId() != loc.GetMapId())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (bot->GetMap()->GetZoneId(bot->GetPhaseMask(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ()) !=
|
||||||
|
bot->GetZoneId())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (bot->GetExactDist(loc) < 500.0f)
|
if (bot->GetExactDist(loc) < 500.0f)
|
||||||
{
|
{
|
||||||
hi_prepared_locs.push_back(loc);
|
hi_prepared_locs.push_back(loc);
|
||||||
@@ -220,35 +224,41 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest)
|
|||||||
return MoveTo(dest.getMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
|
return MoveTo(dest.getMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// performance optimization
|
||||||
|
if (IsWaitingForLastMove(MovementPriority::MOVEMENT_NORMAL))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
float minDelta = M_PI;
|
float minDelta = M_PI;
|
||||||
const float x = bot->GetPositionX();
|
const float x = bot->GetPositionX();
|
||||||
const float y = bot->GetPositionY();
|
const float y = bot->GetPositionY();
|
||||||
const float z = bot->GetPositionZ();
|
const float z = bot->GetPositionZ();
|
||||||
float rx, ry, rz;
|
float rx, ry, rz;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int attempt = 5;
|
int attempt = 10;
|
||||||
while (--attempt)
|
while (--attempt)
|
||||||
{
|
{
|
||||||
float angle = bot->GetAngle(&dest);
|
float angle = bot->GetAngle(&dest);
|
||||||
float delta = (rand_norm() - 0.5) * M_PI * 0.6;
|
float delta = (rand_norm() - 0.5) * M_PI * 2;
|
||||||
angle += delta;
|
angle += delta;
|
||||||
float dis = rand_norm() * pathFinderDis;
|
float dis = rand_norm() * pathFinderDis;
|
||||||
float dx = x + cos(angle) * dis;
|
float dx = x + cos(angle) * dis;
|
||||||
float dy = y + sin(angle) * dis;
|
float dy = y + sin(angle) * dis;
|
||||||
float dz = z;
|
float dz = z + 5.0f;
|
||||||
|
bot->UpdateAllowedPositionZ(dx, dy, dz);
|
||||||
PathGenerator path(bot);
|
PathGenerator path(bot);
|
||||||
path.CalculatePath(dx, dy, dz);
|
path.CalculatePath(dx, dy, dz);
|
||||||
// bool canReach = bot->GetMap()->CanReachPositionAndGetValidCoords(bot, x, y, z, dx, dy, dz, false);
|
|
||||||
bool canReach = path.GetPathType() & PATHFIND_NORMAL;
|
bool canReach = path.GetPathType() & PATHFIND_NORMAL;
|
||||||
|
|
||||||
if (canReach)
|
if (canReach && fabs(delta) <= minDelta)
|
||||||
{
|
{
|
||||||
G3D::Vector3 endPos = path.GetPath().back();
|
|
||||||
found = true;
|
found = true;
|
||||||
|
G3D::Vector3 endPos = path.GetPath().back();
|
||||||
rx = endPos.x;
|
rx = endPos.x;
|
||||||
ry = endPos.y;
|
ry = endPos.y;
|
||||||
rz = endPos.z;
|
rz = endPos.z;
|
||||||
break;
|
minDelta = fabs(delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
@@ -256,8 +266,9 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest)
|
|||||||
return MoveTo(bot->GetMapId(), rx, ry, rz, false, false, false, true);
|
return MoveTo(bot->GetMapId(), rx, ry, rz, false, false, false, true);
|
||||||
}
|
}
|
||||||
// fallback to direct move
|
// fallback to direct move
|
||||||
float angle = bot->GetAngle(&dest);
|
// float angle = bot->GetAngle(&dest);
|
||||||
return MoveTo(bot->GetMapId(), x + cos(angle) * pathFinderDis, y + sin(angle) * pathFinderDis, z);
|
// return MoveTo(bot->GetMapId(), x + cos(angle) * pathFinderDis, y + sin(angle) * pathFinderDis, z);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewRpgGoGrindAction::Execute(Event event) { return MoveFarTo(botAI->rpgInfo.grindPos); }
|
bool NewRpgGoGrindAction::Execute(Event event) { return MoveFarTo(botAI->rpgInfo.grindPos); }
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ protected:
|
|||||||
// const int32 setGrindInterval = 5 * 60 * 1000;
|
// const int32 setGrindInterval = 5 * 60 * 1000;
|
||||||
// const int32 setNpcInterval = 1 * 60 * 1000;
|
// const int32 setNpcInterval = 1 * 60 * 1000;
|
||||||
const int32 statusNearNpcDuration = 5 * 60 * 1000;
|
const int32 statusNearNpcDuration = 5 * 60 * 1000;
|
||||||
const int32 statusNearRandomDuration = 5 * 60 * 1000;
|
const int32 statusNearRandomDuration = 3 * 60 * 1000;
|
||||||
const int32 statusRestDuration = 2 * 60 * 1000;
|
const int32 statusRestDuration = 30 * 1000;
|
||||||
WorldPosition SelectRandomGrindPos();
|
WorldPosition SelectRandomGrindPos();
|
||||||
WorldPosition SelectRandomInnKeeperPos();
|
WorldPosition SelectRandomInnKeeperPos();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user