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

View File

@ -17,11 +17,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef COMMON_DATA_VERIFICATION_H #pragma once
#define COMMON_DATA_VERIFICATION_H
#include <algorithm> #include <algorithm>
#include <cmath>
namespace EQEmu namespace EQEmu
{ {
@ -52,4 +51,3 @@ namespace EQEmu
} /*EQEmu*/ } /*EQEmu*/
#endif /*COMMON_DATA_VERIFICATION_H*/

View File

@ -87,28 +87,5 @@ public:
~InitWinsock(); ~InitWinsock();
}; };
template<class T> class AutoDelete {
public:
AutoDelete(T** iVar, T* iSetTo = 0) {
init(iVar, iSetTo);
}
AutoDelete() { pVar = nullptr; }
void init(T** iVar, T* iSetTo = 0)
{
pVar = iVar;
if (iSetTo)
*pVar = iSetTo;
}
~AutoDelete() {
if(pVar != nullptr)
safe_delete(*pVar);
}
void ReallyClearIt() {
pVar = nullptr;
}
private:
T** pVar;
};
#endif #endif

View File

@ -2687,14 +2687,7 @@ void Bot::AI_Process() {
Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName());
Goal = GetTarget()->GetPosition(); Goal = GetTarget()->GetPosition();
if (RuleB(Bots, UsePathing) && zone->pathing) {
bool WaypointChanged, NodeReached;
Goal = UpdatePath(Goal.x, Goal.y, Goal.z,
GetBotRunspeed(), WaypointChanged, NodeReached);
}
CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetBotRunspeed()); CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetBotRunspeed());
return; return;
} }
@ -2813,13 +2806,6 @@ void Bot::AI_Process() {
Goal = follow_mob->GetPosition(); Goal = follow_mob->GetPosition();
if (RuleB(Bots, UsePathing) && zone->pathing) {
bool WaypointChanged, NodeReached;
Goal = UpdatePath(Goal.x, Goal.y, Goal.z,
speed, WaypointChanged, NodeReached);
}
CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed); CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed);
return; return;
} }

View File

@ -496,7 +496,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) {
} }
} }
void Doors::NPCOpen(NPC* sender, bool alt_mode) void Doors::Open(Mob* sender, bool alt_mode)
{ {
if (sender) { if (sender) {
if (GetTriggerType() == 255 || GetTriggerDoorID() > 0 || GetLockpick() != 0 || GetKeyItem() != 0 || open_type == 59 || open_type == 58 || !sender->IsNPC()) { // this object isnt triggered or door is locked - NPCs should not open locked doors! if (GetTriggerType() == 255 || GetTriggerDoorID() > 0 || GetLockpick() != 0 || GetKeyItem() != 0 || open_type == 59 || open_type == 58 || !sender->IsNPC()) { // this object isnt triggered or door is locked - NPCs should not open locked doors!

View File

@ -49,7 +49,7 @@ public:
void ForceClose(Mob *sender, bool alt_mode = false); void ForceClose(Mob *sender, bool alt_mode = false);
void ForceOpen(Mob *sender, bool alt_mode = false); void ForceOpen(Mob *sender, bool alt_mode = false);
void HandleClick(Client *sender, uint8 trigger); void HandleClick(Client *sender, uint8 trigger);
void NPCOpen(NPC *sender, bool alt_mode = false); void Open(Mob *sender, bool alt_mode = false);
void SetDisableTimer(bool flag); void SetDisableTimer(bool flag);
void SetDoorName(const char *name); void SetDoorName(const char *name);
void SetEntityID(uint32 entity) { entity_id = entity; } void SetEntityID(uint32 entity) { entity_id = entity; }

View File

@ -3263,7 +3263,7 @@ void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 hate)
} }
} }
void EntityList::OpenDoorsNear(NPC *who) void EntityList::OpenDoorsNear(Mob *who)
{ {
for (auto it = door_list.begin();it != door_list.end(); ++it) { for (auto it = door_list.begin();it != door_list.end(); ++it) {
@ -3276,7 +3276,7 @@ void EntityList::OpenDoorsNear(NPC *who)
float curdist = diff.x * diff.x + diff.y * diff.y; float curdist = diff.x * diff.x + diff.y * diff.y;
if (diff.z * diff.z < 10 && curdist <= 100) if (diff.z * diff.z < 10 && curdist <= 100)
cdoor->NPCOpen(who); cdoor->Open(who);
} }
} }

View File

@ -370,7 +370,7 @@ public:
void AddHealAggro(Mob* target, Mob* caster, uint16 hate); void AddHealAggro(Mob* target, Mob* caster, uint16 hate);
Mob* FindDefenseNPC(uint32 npcid); Mob* FindDefenseNPC(uint32 npcid);
void OpenDoorsNear(NPC* opener); void OpenDoorsNear(Mob* opener);
void UpdateWho(bool iSendFullUpdate = false); void UpdateWho(bool iSendFullUpdate = false);
void SendPositionUpdates(Client* client, uint32 cLastUpdate = 0, float update_range = 0, Entity* always_send = 0, bool iSendEvenIfNotChanged = false); void SendPositionUpdates(Client* client, uint32 cLastUpdate = 0, float update_range = 0, Entity* always_send = 0, bool iSendEvenIfNotChanged = false);
char* MakeNameUnique(char* name); char* MakeNameUnique(char* name);

View File

@ -231,7 +231,7 @@ void Lua_EntityList::ReplaceWithTarget(Lua_Mob target, Lua_Mob new_target) {
self->ReplaceWithTarget(target, new_target); self->ReplaceWithTarget(target, new_target);
} }
void Lua_EntityList::OpenDoorsNear(Lua_NPC opener) { void Lua_EntityList::OpenDoorsNear(Lua_Mob opener) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
self->OpenDoorsNear(opener); self->OpenDoorsNear(opener);
} }
@ -479,7 +479,7 @@ luabind::scope lua_register_entity_list() {
.def("RemoveFromTargets", (void(Lua_EntityList::*)(Lua_Mob))&Lua_EntityList::RemoveFromTargets) .def("RemoveFromTargets", (void(Lua_EntityList::*)(Lua_Mob))&Lua_EntityList::RemoveFromTargets)
.def("RemoveFromTargets", (void(Lua_EntityList::*)(Lua_Mob, bool))&Lua_EntityList::RemoveFromTargets) .def("RemoveFromTargets", (void(Lua_EntityList::*)(Lua_Mob, bool))&Lua_EntityList::RemoveFromTargets)
.def("ReplaceWithTarget", (void(Lua_EntityList::*)(Lua_Mob, Lua_Mob))&Lua_EntityList::ReplaceWithTarget) .def("ReplaceWithTarget", (void(Lua_EntityList::*)(Lua_Mob, Lua_Mob))&Lua_EntityList::ReplaceWithTarget)
.def("OpenDoorsNear", (void(Lua_EntityList::*)(Lua_NPC))&Lua_EntityList::OpenDoorsNear) .def("OpenDoorsNear", (void(Lua_EntityList::*)(Lua_Mob))&Lua_EntityList::OpenDoorsNear)
.def("MakeNameUnique", (std::string(Lua_EntityList::*)(const char*))&Lua_EntityList::MakeNameUnique) .def("MakeNameUnique", (std::string(Lua_EntityList::*)(const char*))&Lua_EntityList::MakeNameUnique)
.def("RemoveNumbers", (std::string(Lua_EntityList::*)(const char*))&Lua_EntityList::RemoveNumbers) .def("RemoveNumbers", (std::string(Lua_EntityList::*)(const char*))&Lua_EntityList::RemoveNumbers)
.def("SignalMobsByNPCID", (void(Lua_EntityList::*)(uint32, int))&Lua_EntityList::SignalMobsByNPCID) .def("SignalMobsByNPCID", (void(Lua_EntityList::*)(uint32, int))&Lua_EntityList::SignalMobsByNPCID)

View File

@ -84,7 +84,7 @@ public:
void RemoveFromTargets(Lua_Mob mob); void RemoveFromTargets(Lua_Mob mob);
void RemoveFromTargets(Lua_Mob mob, bool RemoveFromXTargets); void RemoveFromTargets(Lua_Mob mob, bool RemoveFromXTargets);
void ReplaceWithTarget(Lua_Mob target, Lua_Mob new_target); void ReplaceWithTarget(Lua_Mob target, Lua_Mob new_target);
void OpenDoorsNear(Lua_NPC opener); void OpenDoorsNear(Lua_Mob opener);
std::string MakeNameUnique(const char *name); std::string MakeNameUnique(const char *name);
std::string RemoveNumbers(const char *name); std::string RemoveNumbers(const char *name);
void SignalMobsByNPCID(uint32 npc_id, int signal); void SignalMobsByNPCID(uint32 npc_id, int signal);

View File

@ -1478,25 +1478,8 @@ void Merc::AI_Process() {
return; return;
} }
else if (!CheckLosFN(GetTarget())) { else if (!CheckLosFN(GetTarget())) {
if (RuleB(Mercs, MercsUsePathing) && zone->pathing) { auto Goal = GetTarget()->GetPosition();
bool WaypointChanged, NodeReached; CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetRunspeed());
glm::vec3 Goal = UpdatePath(
GetTarget()->GetX(),
GetTarget()->GetY(),
GetTarget()->GetZ(),
GetRunspeed(),
WaypointChanged,
NodeReached
);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetRunspeed());
}
else {
Mob* follow = entity_list.GetMob(GetFollowID());
if (follow)
CalculateNewPosition(follow->GetX(), follow->GetY(), follow->GetZ(), GetRunspeed());
}
return; return;
} }
@ -1775,17 +1758,7 @@ void Merc::AI_Process() {
SetRunAnimSpeed(0); SetRunAnimSpeed(0);
if (dist > GetFollowDistance()) { if (dist > GetFollowDistance()) {
if (RuleB(Mercs, MercsUsePathing) && zone->pathing) { CalculateNewPosition(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(),
speed, WaypointChanged, NodeReached);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed);
}
else {
CalculateNewPosition(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
}
if (rest_timer.Enabled()) if (rest_timer.Enabled())
rest_timer.Disable(); rest_timer.Disable();

View File

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

View File

@ -165,7 +165,7 @@ void MobMovementManager::SendPositionUpdate(Mob *who, bool send_to_self)
bool MobMovementManager::HeadingEqual(float a, float b) bool MobMovementManager::HeadingEqual(float a, float b)
{ {
const float eps = 0.001f; const float eps = 0.0001f;
return abs(a - b) < eps; return abs(a - b) < eps;
} }

View File

@ -1355,7 +1355,7 @@ XS(XS_EntityList_OpenDoorsNear) {
Perl_croak(aTHX_ "Usage: EntityList::OpenDoorsNear(THIS, NPC* opener)"); Perl_croak(aTHX_ "Usage: EntityList::OpenDoorsNear(THIS, NPC* opener)");
{ {
EntityList *THIS; EntityList *THIS;
NPC *opener; Mob *opener;
if (sv_derived_from(ST(0), "EntityList")) { if (sv_derived_from(ST(0), "EntityList")) {
IV tmp = SvIV((SV *) SvRV(ST(0))); IV tmp = SvIV((SV *) SvRV(ST(0)));
@ -1365,11 +1365,11 @@ XS(XS_EntityList_OpenDoorsNear) {
if (THIS == nullptr) if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
if (sv_derived_from(ST(1), "NPC")) { if (sv_derived_from(ST(1), "Mob")) {
IV tmp = SvIV((SV *) SvRV(ST(1))); IV tmp = SvIV((SV *) SvRV(ST(1)));
opener = INT2PTR(NPC *, tmp); opener = INT2PTR(Mob *, tmp);
} else } else
Perl_croak(aTHX_ "opener is not of type NPC"); Perl_croak(aTHX_ "opener is not of type Mob");
if (opener == nullptr) if (opener == nullptr)
Perl_croak(aTHX_ "opener is nullptr, avoiding crash."); Perl_croak(aTHX_ "opener is nullptr, avoiding crash.");

View File

@ -454,6 +454,17 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
return true; return true;
} }
bool WaypointChanged = false;
bool NodeReached = false;
glm::vec3 Goal = UpdatePath(
x, y, z, speed, WaypointChanged, NodeReached
);
if (WaypointChanged || NodeReached) {
calculate_heading = true;
entity_list.OpenDoorsNear(this);
}
SetCurrentSpeed(static_cast<int>(speed)); SetCurrentSpeed(static_cast<int>(speed));
pRunAnimSpeed = speed; pRunAnimSpeed = speed;
@ -467,7 +478,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
} }
//Setup Vectors //Setup Vectors
glm::vec3 tar(x, y, z); glm::vec3 tar(Goal.x, Goal.y, Goal.z);
glm::vec3 pos(m_Position.x, m_Position.y, m_Position.z); glm::vec3 pos(m_Position.x, m_Position.y, m_Position.z);
double len = glm::distance(pos, tar); double len = glm::distance(pos, tar);
if (len == 0) { if (len == 0) {
@ -476,20 +487,16 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
glm::vec3 dir = tar - pos; glm::vec3 dir = tar - pos;
glm::vec3 ndir = glm::normalize(dir); glm::vec3 ndir = glm::normalize(dir);
if (calculate_heading) {
m_Position.w = CalculateHeadingToTarget(x, y);
}
double time_since_last = static_cast<double>(frame_time) / 1000.0; double time_since_last = static_cast<double>(frame_time) / 1000.0;
double distance_moved = time_since_last * speed * 2.275f; double distance_moved = time_since_last * speed * 2.275f;
if (distance_moved > len) { if (distance_moved > len) {
m_Position.x = x; m_Position.x = Goal.x;
m_Position.y = y; m_Position.y = Goal.y;
m_Position.z = z; m_Position.z = Goal.z;
if (IsNPC()) { if (IsNPC()) {
entity_list.ProcessMove(CastToNPC(), x, y, z); entity_list.ProcessMove(CastToNPC(), Goal.x, Goal.y, Goal.z);
} }
if (check_z && fix_z_timer.Check() && (!IsEngaged() || flee_mode || currently_fleeing)) { if (check_z && fix_z_timer.Check() && (!IsEngaged() || flee_mode || currently_fleeing)) {
@ -505,10 +512,14 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
m_Position.z = npos.z; m_Position.z = npos.z;
if (IsNPC()) { if (IsNPC()) {
entity_list.ProcessMove(CastToNPC(), x, y, z); entity_list.ProcessMove(CastToNPC(), npos.x, npos.y, npos.z);
} }
} }
if (calculate_heading) {
m_Position.w = CalculateHeadingToTarget(Goal.x, Goal.y);
}
if (check_z && fix_z_timer.Check() && !IsEngaged()) { if (check_z && fix_z_timer.Check() && !IsEngaged()) {
FixZ(); FixZ();
} }