Better Z compensation on hills, while engaged and NPC's quickly recover if they go underground

This commit is contained in:
Akkadius 2017-07-08 22:17:39 -05:00
parent 900a5f83da
commit aae1d2f049
2 changed files with 9 additions and 7 deletions

View File

@ -997,17 +997,19 @@ void Mob::AI_Process() {
if (engaged) { if (engaged) {
/* Fix Z when following during pull, not when engaged and stationary */ /* Fix Z when following during pull, not when engaged and stationary */
if (moving && fix_z_timer_engaged.Check()) if (moving && fix_z_timer_engaged.Check()) {
if (this->GetTarget()) { if (this->GetTarget()) {
/* If we are engaged, moving and following client, let's look for best Z more often */ /* If we are engaged, moving and following client, let's look for best Z more often */
if (DistanceNoZ(this->GetPosition(), this->GetTarget()->GetPosition()) > 50) { float target_distance = DistanceNoZ(this->GetPosition(), this->GetTarget()->GetPosition());
if (target_distance >= 50) {
this->FixZ(); this->FixZ();
} }
/* If we are close to client and our Z differences aren't big, match the client */ else if (!this->CheckLosFN(this->GetTarget())) {
else if (std::abs(this->GetZ() - this->GetTarget()->GetZ()) <= 5 && this->GetTarget()->IsClient()) { Mob* target = this->GetTarget();
this->m_Position.z = this->GetTarget()->GetZ(); this->GMMove(target->GetX(), target->GetY(), target->GetZ(), target->GetHeading());
} }
} }
}
if (!(m_PlayerState & static_cast<uint32>(PlayerState::Aggressive))) if (!(m_PlayerState & static_cast<uint32>(PlayerState::Aggressive)))
SendAddPlayerState(PlayerState::Aggressive); SendAddPlayerState(PlayerState::Aggressive);

View File

@ -497,7 +497,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
m_Position.y = new_y; m_Position.y = new_y;
m_Position.z = new_z; m_Position.z = new_z;
if(fix_z_timer.Check()) if(fix_z_timer.Check() && !this->IsEngaged())
this->FixZ(); this->FixZ();
tar_ndx++; tar_ndx++;
@ -604,7 +604,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
m_Position.w = CalculateHeadingToTarget(x, y); m_Position.w = CalculateHeadingToTarget(x, y);
} }
if (fix_z_timer.Check()) if (fix_z_timer.Check() && !this->IsEngaged())
this->FixZ(); this->FixZ();
SetMoving(true); SetMoving(true);