Fix for mobs who are hailed while moving - this allows them to properly stop, and return on their grid after pause time

This commit is contained in:
Akkadius 2017-07-15 23:57:08 -05:00
parent f9480f2518
commit 70a74d6615
3 changed files with 19 additions and 23 deletions

View File

@ -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();
}
}

View File

@ -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();

View File

@ -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
}
}