Add pathfinding interfaces, still heavily wip

This commit is contained in:
KimLS
2017-07-18 00:01:59 -07:00
parent 596e3b28b5
commit 5f1063acb9
26 changed files with 705 additions and 1181 deletions
+17 -21
View File
@@ -563,10 +563,6 @@ void Client::AI_Stop() {
// only call this on a zone shutdown event
void Mob::AI_ShutDown() {
safe_delete(PathingLOSCheckTimer);
safe_delete(PathingRouteUpdateTimerShort);
safe_delete(PathingRouteUpdateTimerLong);
attack_timer.Disable();
attack_dw_timer.Disable();
ranged_timer.Disable();
@@ -770,7 +766,7 @@ void Client::AI_Process()
CalculateNewFearpoint();
}
if(!RuleB(Pathing, Fear) || !zone->pathing)
CalculateNewPosition2(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, speed, true);
CalculateNewPosition(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, speed, true);
else
{
bool WaypointChanged, NodeReached;
@@ -781,7 +777,7 @@ void Client::AI_Process()
if(WaypointChanged)
tar_ndx = 20;
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, speed);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed);
}
}
return;
@@ -853,7 +849,7 @@ void Client::AI_Process()
newspeed *= 2;
SetCurrentSpeed(newspeed);
if(!RuleB(Pathing, Aggro) || !zone->pathing)
CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), newspeed);
CalculateNewPosition(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), newspeed);
else
{
bool WaypointChanged, NodeReached;
@@ -863,7 +859,7 @@ void Client::AI_Process()
if(WaypointChanged)
tar_ndx = 20;
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, newspeed);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, newspeed);
}
}
}
@@ -912,7 +908,7 @@ void Client::AI_Process()
nspeed *= 2;
SetCurrentSpeed(nspeed);
CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), nspeed);
CalculateNewPosition(owner->GetX(), owner->GetY(), owner->GetZ(), nspeed);
}
}
else
@@ -969,7 +965,7 @@ void Mob::AI_Process() {
}
if(!RuleB(Pathing, Fear) || !zone->pathing)
{
CalculateNewPosition2(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, GetFearSpeed(), true);
CalculateNewPosition(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, GetFearSpeed(), true);
}
else
{
@@ -981,7 +977,7 @@ void Mob::AI_Process() {
if(WaypointChanged)
tar_ndx = 20;
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetFearSpeed());
CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetFearSpeed());
}
}
return;
@@ -1300,7 +1296,7 @@ void Mob::AI_Process() {
if (!IsRooted()) {
Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", target->GetName());
if (!RuleB(Pathing, Aggro) || !zone->pathing)
CalculateNewPosition2(target->GetX(), target->GetY(), target->GetZ(), GetRunspeed());
CalculateNewPosition(target->GetX(), target->GetY(), target->GetZ(), GetRunspeed());
else
{
bool WaypointChanged, NodeReached;
@@ -1311,7 +1307,7 @@ void Mob::AI_Process() {
if (WaypointChanged)
tar_ndx = 20;
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetRunspeed());
CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetRunspeed());
}
}
@@ -1395,7 +1391,7 @@ void Mob::AI_Process() {
if (dist >= 5625)
speed = GetRunspeed();
CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), speed);
CalculateNewPosition(owner->GetX(), owner->GetY(), owner->GetZ(), speed);
}
else
{
@@ -1454,7 +1450,7 @@ void Mob::AI_Process() {
int speed = GetWalkspeed();
if (dist2 >= followdist + 150)
speed = GetRunspeed();
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
CalculateNewPosition(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
}
else
{
@@ -1536,7 +1532,7 @@ void NPC::AI_DoMovement() {
Log(Logs::Detail, Logs::AI, "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)",
roambox_distance, roambox_min_x, roambox_max_x, roambox_min_y, roambox_max_y, roambox_movingto_x, roambox_movingto_y);
if (!CalculateNewPosition2(roambox_movingto_x, roambox_movingto_y, GetZ(), walksp, true))
if (!CalculateNewPosition(roambox_movingto_x, roambox_movingto_y, GetZ(), walksp, true))
{
roambox_movingto_x = roambox_max_x + 1; // force update
pLastFightingDelayMoving = Timer::GetCurrentTime() + RandomTimer(roambox_min_delay, roambox_delay);
@@ -1593,7 +1589,7 @@ void NPC::AI_DoMovement() {
if (doMove)
{ // not at waypoint yet or at 0 pause WP, so keep moving
if(!RuleB(Pathing, AggroReturnToGrid) || !zone->pathing || (DistractedFromGrid == 0))
CalculateNewPosition2(m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, walksp, true);
CalculateNewPosition(m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, walksp, true);
else
{
bool WaypointChanged;
@@ -1605,13 +1601,13 @@ void NPC::AI_DoMovement() {
if(NodeReached)
entity_list.OpenDoorsNear(CastToNPC());
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, walksp, true);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, walksp, true);
}
}
}
} // endif (gridno > 0)
// handle new quest grid command processing
// handle new quest grid command processing
else if (gridno < 0)
{ // this mob is under quest control
if (movetimercompleted==true)
@@ -1630,7 +1626,7 @@ void NPC::AI_DoMovement() {
{
bool CP2Moved;
if(!RuleB(Pathing, Guard) || !zone->pathing)
CP2Moved = CalculateNewPosition2(m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z, walksp);
CP2Moved = CalculateNewPosition(m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z, walksp);
else
{
if(!((m_Position.x == m_GuardPoint.x) && (m_Position.y == m_GuardPoint.y) && (m_Position.z == m_GuardPoint.z)))
@@ -1643,7 +1639,7 @@ void NPC::AI_DoMovement() {
if(NodeReached)
entity_list.OpenDoorsNear(CastToNPC());
CP2Moved = CalculateNewPosition2(Goal.x, Goal.y, Goal.z, walksp);
CP2Moved = CalculateNewPosition(Goal.x, Goal.y, Goal.z, walksp);
}
else
CP2Moved = false;