From 70a74d661540b6012fc64cb04085fa7469109a19 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 15 Jul 2017 23:57:08 -0500 Subject: [PATCH] Fix for mobs who are hailed while moving - this allows them to properly stop, and return on their grid after pause time --- zone/mob.cpp | 30 ++++++++++++++---------------- zone/mob.h | 2 +- zone/waypoints.cpp | 10 ++++------ 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index fc7772b8d..33863081a 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1437,10 +1437,8 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal } } -/* Used for NPCs mainly */ -void Mob::SendPosition() -{ - +/* Used for mobs standing still - this does not send a delta */ +void Mob::SendPosition() { auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer; MakeSpawnUpdateNoDelta(spu); @@ -1457,7 +1455,7 @@ void Mob::SendPosition() safe_delete(app); } -// this one is for mobs on the move, with deltas - this makes them walk +/* Position updates for mobs on the move */ void Mob::SendPositionUpdate(uint8 iSendToSelf) { auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer; @@ -2729,25 +2727,25 @@ bool Mob::HateSummon() { return false; } -void Mob::FaceTarget(Mob* MobToFace) { - Mob* facemob = MobToFace; - if(!facemob) { +void Mob::FaceTarget(Mob* mob_to_face /*= 0*/) { + Mob* faced_mob = mob_to_face; + if(!faced_mob) { if(!GetTarget()) { return; } else { - facemob = GetTarget(); + faced_mob = GetTarget(); } } - float oldheading = GetHeading(); - float newheading = CalculateHeadingToTarget(facemob->GetX(), facemob->GetY()); - if(oldheading != newheading) { - SetHeading(newheading); - if(moving) + float current_heading = GetHeading(); + float new_heading = CalculateHeadingToTarget(faced_mob->GetX(), faced_mob->GetY()); + if(current_heading != new_heading) { + SetHeading(new_heading); + if (moving) { SendPositionUpdate(); - else - { + } + else { SendPosition(); } } diff --git a/zone/mob.h b/zone/mob.h index 56004157d..8286bf647 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -556,7 +556,7 @@ public: void SetPrimaryAggro(bool value) { PrimaryAggro = value; if (value) AssistAggro = false; } void SetAssistAggro(bool value) { AssistAggro = value; if (PrimaryAggro) AssistAggro = false; } bool HateSummon(); - void FaceTarget(Mob* MobToFace = 0); + void FaceTarget(Mob* mob_to_face = 0); void SetHeading(float iHeading) { if(m_Position.w != iHeading) { pLastChange = Timer::GetCurrentTime(); m_Position.w = iHeading; } } void WipeHateList(); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 61fc7983f..d1581a21c 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -134,17 +134,15 @@ void NPC::PauseWandering(int pausetime) { // causes wandering to stop but is resumable // 0 pausetime means pause until resumed // otherwise automatically resume when time is up - if (GetGrid() != 0) - { + if (GetGrid() != 0) { + moving = false; DistractedFromGrid = true; Log(Logs::Detail, Logs::Pathing, "Paused Wandering requested. Grid %d. Resuming in %d ms (0=not until told)", GetGrid(), pausetime); SendPosition(); - if (pausetime<1) - { // negative grid number stops him dead in his tracks until ResumeWandering() + if (pausetime < 1) { // negative grid number stops him dead in his tracks until ResumeWandering() SetGrid(0 - GetGrid()); } - else - { // specified waiting time, he'll resume after that + else { // specified waiting time, he'll resume after that AI_walking_timer->Start(pausetime * 1000); // set the timer } }