Move update path to movement manager so all movement will use paths

This commit is contained in:
KimLS
2018-09-18 23:06:56 -07:00
parent 2224b83ae0
commit f754cb1307
14 changed files with 66 additions and 236 deletions
+26 -141
View File
@@ -807,22 +807,7 @@ void Client::AI_Process()
CalculateNewFearpoint();
}
if (!RuleB(Pathing, Fear) || !zone->pathing)
CalculateNewPosition(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, speed, true);
else {
bool waypoint_changed, node_reached;
glm::vec3 Goal = UpdatePath(
m_FearWalkTarget.x,
m_FearWalkTarget.y,
m_FearWalkTarget.z,
speed,
waypoint_changed,
node_reached
);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed);
}
CalculateNewPosition(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, speed, true);
}
return;
}
@@ -892,16 +877,7 @@ void Client::AI_Process()
animation = newspeed;
newspeed *= 2;
SetCurrentSpeed(newspeed);
if(!RuleB(Pathing, Aggro) || !zone->pathing)
CalculateNewPosition(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), newspeed);
else
{
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
GetRunspeed(), WaypointChanged, NodeReached);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, newspeed);
}
CalculateNewPosition(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), newspeed);
}
}
else if(IsMoving())
@@ -1121,29 +1097,13 @@ void Mob::AI_Process() {
// Calculate a new point to run to
CalculateNewFearpoint();
}
if (!RuleB(Pathing, Fear) || !zone->pathing) {
CalculateNewPosition(
m_FearWalkTarget.x,
m_FearWalkTarget.y,
m_FearWalkTarget.z,
GetFearSpeed(),
true
);
}
else {
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(
m_FearWalkTarget.x,
m_FearWalkTarget.y,
m_FearWalkTarget.z,
GetFearSpeed(),
WaypointChanged,
NodeReached
);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetFearSpeed());
}
CalculateNewPosition(
m_FearWalkTarget.x,
m_FearWalkTarget.y,
m_FearWalkTarget.z,
GetFearSpeed(),
true
);
}
return;
}
@@ -1462,18 +1422,7 @@ void Mob::AI_Process() {
else if (AI_movement_timer->Check() && target) {
if (!IsRooted()) {
Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", target->GetName());
if (!RuleB(Pathing, Aggro) || !zone->pathing)
CalculateNewPosition(target->GetX(), target->GetY(), target->GetZ(), GetRunspeed());
else {
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(
target->GetX(), target->GetY(), target->GetZ(),
GetRunspeed(), WaypointChanged, NodeReached
);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetRunspeed());
}
CalculateNewPosition(target->GetX(), target->GetY(), target->GetZ(), GetRunspeed());
}
else if (IsMoving()) {
@@ -1572,14 +1521,7 @@ void Mob::AI_Process() {
else {
bool waypoint_changed, node_reached;
glm::vec3 Goal = UpdatePath(
owner->GetX(),
owner->GetY(),
owner->GetZ(),
pet_speed,
waypoint_changed,
node_reached
);
auto &Goal = owner->GetPosition();
CalculateNewPosition(Goal.x, Goal.y, Goal.z, pet_speed, true);
}
@@ -1633,14 +1575,7 @@ void Mob::AI_Process() {
bool waypoint_changed, node_reached;
glm::vec3 Goal = UpdatePath(
follow->GetX(),
follow->GetY(),
follow->GetZ(),
speed,
waypoint_changed,
node_reached
);
auto &Goal = follow->GetPosition();
CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed, true);
}
@@ -1768,18 +1703,7 @@ void NPC::AI_DoMovement() {
roambox_destination_y);
}
bool waypoint_changed, node_reached;
glm::vec3 Goal = UpdatePath(
roambox_destination_x,
roambox_destination_y,
roambox_destination_z,
move_speed,
waypoint_changed,
node_reached
);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, move_speed, true);
CalculateNewPosition(roambox_destination_x, roambox_destination_y, roambox_destination_z, move_speed, true);
if (m_Position.x == roambox_destination_x && m_Position.y == roambox_destination_y) {
time_until_can_move = Timer::GetCurrentTime() + RandomTimer(roambox_min_delay, roambox_delay);
@@ -1843,31 +1767,13 @@ void NPC::AI_DoMovement() {
ClearFeignMemory();
}
if (doMove) { // not at waypoint yet or at 0 pause WP, so keep moving
if (!RuleB(Pathing, AggroReturnToGrid) || !zone->pathing || (DistractedFromGrid == 0))
CalculateNewPosition(
m_CurrentWayPoint.x,
m_CurrentWayPoint.y,
m_CurrentWayPoint.z,
move_speed,
true
);
else {
bool WaypointChanged;
bool NodeReached;
glm::vec3 Goal = UpdatePath(
m_CurrentWayPoint.x,
m_CurrentWayPoint.y,
m_CurrentWayPoint.z,
move_speed,
WaypointChanged,
NodeReached
);
if (NodeReached)
entity_list.OpenDoorsNear(CastToNPC());
CalculateNewPosition(Goal.x, Goal.y, Goal.z, move_speed, true);
}
CalculateNewPosition(
m_CurrentWayPoint.x,
m_CurrentWayPoint.y,
m_CurrentWayPoint.z,
move_speed,
true
);
}
}
@@ -1887,35 +1793,14 @@ void NPC::AI_DoMovement() {
}
else if (IsGuarding()) {
bool CP2Moved;
if (!RuleB(Pathing, Guard) || !zone->pathing) {
CP2Moved = CalculateNewPosition(m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z, move_speed);
if (!((m_Position.x == m_GuardPoint.x) && (m_Position.y == m_GuardPoint.y) && (m_Position.z == m_GuardPoint.z))) {
CP2Moved = CalculateNewPosition(m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z, move_speed);
}
else {
if (!((m_Position.x == m_GuardPoint.x) && (m_Position.y == m_GuardPoint.y) &&
(m_Position.z == m_GuardPoint.z))) {
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(
m_GuardPoint.x,
m_GuardPoint.y,
m_GuardPoint.z,
move_speed,
WaypointChanged,
NodeReached
);
if (NodeReached) {
entity_list.OpenDoorsNear(CastToNPC());
}
CP2Moved = CalculateNewPosition(Goal.x, Goal.y, Goal.z, move_speed);
}
else {
CP2Moved = false;
}
CP2Moved = false;
}
if (!CP2Moved) {
if (moved) {
Log(Logs::Detail,
@@ -1981,7 +1866,7 @@ void NPC::AI_SetupNextWaypoint() {
SetAppearance(eaStanding, false);
entity_list.OpenDoorsNear(CastToNPC());
entity_list.OpenDoorsNear(this);
if (!DistractedFromGrid) {
//kick off event_waypoint depart