diff --git a/zone/bot.cpp b/zone/bot.cpp index 2336b8c8d..b793e8520 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2723,7 +2723,7 @@ void Bot::AI_Process() { // Fix Z when following during pull, not when engaged and stationary if (IsMoving() && fix_z_timer_engaged.Check()) { - FixZ(); + TryFixZ(); return; } diff --git a/zone/entity.cpp b/zone/entity.cpp index f7f5b4594..9f08b7ea3 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -648,7 +648,7 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue) parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0); - npc->FixZ(); + npc->TryFixZ(); uint16 emoteid = npc->GetEmoteID(); if (emoteid != 0) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 3f99d86c7..00a7e98c3 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -782,7 +782,7 @@ void Client::AI_Process() if (currently_fleeing) { if (fix_z_timer.Check()) - this->FixZ(5, true); + TryFixZ(5, true); if (IsRooted()) { //make sure everybody knows were not moving, for appearance sake @@ -992,7 +992,7 @@ void Mob::ProcessForcedMovement() Teleport(m_Position + m_Delta); m_Delta = glm::vec4(); SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0, true); - FixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc + TryFixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc } else if (--ForcedMovement) { if (normal.z < -0.15f) // prevent too much wall climbing. ex. OMM's room in anguish normal.z = 0.0f; @@ -1104,7 +1104,7 @@ void Mob::AI_Process() { if (this->GetTarget()) { /* If we are engaged, moving and following client, let's look for best Z more often */ float target_distance = DistanceNoZ(this->GetPosition(), this->GetTarget()->GetPosition()); - FixZ(); + TryFixZ(); if (target_distance <= 15 && !this->CheckLosFN(this->GetTarget())) { Mob *target = this->GetTarget(); diff --git a/zone/mob_movement_manager.cpp b/zone/mob_movement_manager.cpp index 38cb253d4..d962860d3 100644 --- a/zone/mob_movement_manager.cpp +++ b/zone/mob_movement_manager.cpp @@ -323,101 +323,6 @@ public: } }; -//Just a swim to that can't travel in Z -class FloatToCommand : public MoveToCommand -{ -public: - FloatToCommand(float x, float y, MobMovementMode mode) : MoveToCommand(x, y, 0.0f, mode) { - - } - - virtual bool Process(MobMovementManager *mgr, Mob *m) - { - if (!m->IsAIControlled()) { - return true; - } - - //Send a movement packet when you start moving - double current_time = static_cast(Timer::GetCurrentTime()) / 1000.0; - int current_speed = 0; - - if (m_move_to_mode == MovementRunning) { - if (m->IsFeared()) { - current_speed = m->GetFearSpeed(); - } - else { - current_speed = m->GetRunspeed(); - } - } - else { - current_speed = m->GetWalkspeed(); - } - - if (!m_started) { - m_started = true; - //rotate to the point - m->SetMoving(true); - m->SetHeading(m->CalculateHeadingToTarget(m_move_to_x, m_move_to_y)); - - m_last_sent_speed = current_speed; - m_last_sent_time = current_time; - m_total_h_dist = DistanceNoZ(m->GetPosition(), glm::vec4(m_move_to_x, m_move_to_y, 0.0f, 0.0f)); - mgr->SendCommandToClients(m, 0.0, 0.0, 0.0, 0.0, current_speed, ClientRangeCloseMedium); - } - - //When speed changes - if (current_speed != m_last_sent_speed) { - m_last_sent_speed = current_speed; - m_last_sent_time = current_time; - mgr->SendCommandToClients(m, 0.0, 0.0, 0.0, 0.0, current_speed, ClientRangeCloseMedium); - } - - //If x seconds have passed without sending an update. - if (current_time - m_last_sent_time >= 0.8) { - m_last_sent_speed = current_speed; - m_last_sent_time = current_time; - mgr->SendCommandToClients(m, 0.0, 0.0, 0.0, 0.0, current_speed, ClientRangeCloseMedium); - } - - auto &p = m->GetPosition(); - glm::vec2 tar(m_move_to_x, m_move_to_y); - glm::vec2 pos(p.x, p.y); - double len = glm::distance(pos, tar); - if (len == 0) { - return true; - } - - m->SetMoved(true); - - glm::vec2 dir = tar - pos; - glm::vec2 ndir = glm::normalize(dir); - double distance_moved = frame_time * current_speed * 0.4f * 1.45f; - - if (distance_moved > len) { - if (m->IsNPC()) { - entity_list.ProcessMove(m->CastToNPC(), m_move_to_x, m_move_to_y, m_move_to_z); - } - - m->SetPosition(m_move_to_x, m_move_to_y, m->GetZ()); - return true; - } - else { - glm::vec2 npos = pos + (ndir * static_cast(distance_moved)); - - len -= distance_moved; - double total_distance_traveled = m_total_h_dist - len; - - if (m->IsNPC()) { - entity_list.ProcessMove(m->CastToNPC(), npos.x, npos.y, m->GetZ()); - } - - m->SetPosition(npos.x, npos.y, m->GetZ()); - } - - return false; - } -}; - class TeleportToCommand : public IMovementCommand { public: @@ -840,7 +745,7 @@ void MobMovementManager::UpdatePath(Mob *who, float x, float y, float z, MobMove PushStopMoving(ent.second); return; } - + if (who->IsBoat()) { UpdatePathBoat(who, x, y, z, mode); } else if (who->IsUnderwaterOnly()) { @@ -1021,7 +926,7 @@ void MobMovementManager::UpdatePathBoat(Mob *who, float x, float y, float z, Mob auto eiter = _impl->Entries.find(who); auto &ent = (*eiter); - PushFloatTo(ent.second, x, y, mode); + PushSwimTo(ent.second, x, y, z, mode); PushStopMoving(ent.second); } @@ -1040,11 +945,6 @@ void MobMovementManager::PushSwimTo(MobMovementEntry &ent, float x, float y, flo ent.Commands.push_back(std::unique_ptr(new SwimToCommand(x, y, z, mode))); } -void MobMovementManager::PushFloatTo(MobMovementEntry &ent, float x, float y, MobMovementMode mode) -{ - ent.Commands.push_back(std::unique_ptr(new FloatToCommand(x, y, mode))); -} - void MobMovementManager::PushRotateTo(MobMovementEntry &ent, Mob *who, float to, MobMovementMode mode) { auto from = FixHeading(who->GetHeading()); diff --git a/zone/mob_movement_manager.h b/zone/mob_movement_manager.h index 69a951f44..d9b2e7845 100644 --- a/zone/mob_movement_manager.h +++ b/zone/mob_movement_manager.h @@ -73,7 +73,6 @@ private: void PushTeleportTo(MobMovementEntry &ent, float x, float y, float z, float heading); void PushMoveTo(MobMovementEntry &ent, float x, float y, float z, MobMovementMode mode); void PushSwimTo(MobMovementEntry &ent, float x, float y, float z, MobMovementMode mode); - void PushFloatTo(MobMovementEntry &ent, float x, float y, MobMovementMode mode); void PushRotateTo(MobMovementEntry &ent, Mob *who, float to, MobMovementMode mode); void PushStopMoving(MobMovementEntry &ent); void PushEvadeCombat(MobMovementEntry &ent);