diff --git a/zone/bot.cpp b/zone/bot.cpp index a5dd4aa41..8223638eb 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -281,7 +281,6 @@ void Bot::Sit() { if(IsMoving()) { moved = false; SetCurrentSpeed(0); - tar_ndx = 0; } SetAppearance(eaSitting); @@ -2694,9 +2693,6 @@ void Bot::AI_Process() { Goal = UpdatePath(Goal.x, Goal.y, Goal.z, GetBotRunspeed(), WaypointChanged, NodeReached); - - if (WaypointChanged) - tar_ndx = 20; } CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetBotRunspeed()); @@ -2822,9 +2818,6 @@ void Bot::AI_Process() { Goal = UpdatePath(Goal.x, Goal.y, Goal.z, speed, WaypointChanged, NodeReached); - - if (WaypointChanged) - tar_ndx = 20; } CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed); diff --git a/zone/client_process.cpp b/zone/client_process.cpp index bd14dc70a..3894826d6 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -242,46 +242,46 @@ bool Client::Process() { } } - /* Build a close range list of NPC's */ - if (npc_close_scan_timer.Check()) { - close_mobs.clear(); - - /* Force spawn updates when traveled far */ - bool force_spawn_updates = false; - float client_update_range = (RuleI(Range, ClientForceSpawnUpdateRange) * RuleI(Range, ClientForceSpawnUpdateRange)); - if (DistanceSquared(last_major_update_position, m_Position) >= client_update_range) { - last_major_update_position = m_Position; - force_spawn_updates = true; - } - - float scan_range = (RuleI(Range, ClientNPCScan) * RuleI(Range, ClientNPCScan)); - auto &mob_list = entity_list.GetMobList(); - for (auto itr = mob_list.begin(); itr != mob_list.end(); ++itr) { - Mob* mob = itr->second; - - float distance = DistanceSquared(m_Position, mob->GetPosition()); - if (mob->IsNPC()) { - if (distance <= scan_range) { - close_mobs.insert(std::pair(mob, distance)); - } - else if ((mob->GetAggroRange() * mob->GetAggroRange()) > scan_range) { - close_mobs.insert(std::pair(mob, distance)); - } - } - - if (force_spawn_updates && mob != this) { - - if (mob->is_distance_roamer) { - mob->SendPositionUpdateToClient(this); - continue; - } - - if (distance <= client_update_range) - mob->SendPositionUpdateToClient(this); - } - - } - } + ///* Build a close range list of NPC's */ + //if (npc_close_scan_timer.Check()) { + // close_mobs.clear(); + // + // /* Force spawn updates when traveled far */ + // bool force_spawn_updates = false; + // float client_update_range = (RuleI(Range, ClientForceSpawnUpdateRange) * RuleI(Range, ClientForceSpawnUpdateRange)); + // if (DistanceSquared(last_major_update_position, m_Position) >= client_update_range) { + // last_major_update_position = m_Position; + // force_spawn_updates = true; + // } + // + // float scan_range = (RuleI(Range, ClientNPCScan) * RuleI(Range, ClientNPCScan)); + // auto &mob_list = entity_list.GetMobList(); + // for (auto itr = mob_list.begin(); itr != mob_list.end(); ++itr) { + // Mob* mob = itr->second; + // + // float distance = DistanceSquared(m_Position, mob->GetPosition()); + // if (mob->IsNPC()) { + // if (distance <= scan_range) { + // close_mobs.insert(std::pair(mob, distance)); + // } + // else if ((mob->GetAggroRange() * mob->GetAggroRange()) > scan_range) { + // close_mobs.insert(std::pair(mob, distance)); + // } + // } + // + // if (force_spawn_updates && mob != this) { + // + // if (mob->is_distance_roamer) { + // mob->SendPositionUpdateToClient(this); + // continue; + // } + // + // if (distance <= client_update_range) + // mob->SendPositionUpdateToClient(this); + // } + // + // } + //} bool may_use_attacks = false; /* diff --git a/zone/command.cpp b/zone/command.cpp index 8fe816fe0..4cc17c6ca 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7242,9 +7242,6 @@ void command_pf(Client *c, const Seperator *sep) Mob *who = c->GetTarget(); c->Message(0, "POS: (%.2f, %.2f, %.2f)", who->GetX(), who->GetY(), who->GetZ()); c->Message(0, "WP: %s (%d/%d)", to_string(who->GetCurrentWayPoint()).c_str(), who->IsNPC()?who->CastToNPC()->GetMaxWp():-1); - c->Message(0, "TAR: (%.2f, %.2f, %.2f)", who->GetTarX(), who->GetTarY(), who->GetTarZ()); - c->Message(0, "TARV: (%.2f, %.2f, %.2f)", who->GetTarVX(), who->GetTarVY(), who->GetTarVZ()); - c->Message(0, "|TV|=%.2f index=%d", who->GetTarVector(), who->GetTarNDX()); c->Message(0, "pause=%d RAspeed=%d", who->GetCWPP(), who->GetRunAnimSpeed()); } else { c->Message(0, "ERROR: target required"); diff --git a/zone/entity.cpp b/zone/entity.cpp index 2523c7d96..1ab6f214a 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -2655,49 +2655,49 @@ void EntityList::RemoveDebuffs(Mob *caster) // all updates into one packet. void EntityList::SendPositionUpdates(Client *client, uint32 cLastUpdate, float update_range, Entity *always_send, bool iSendEvenIfNotChanged) { - update_range = (update_range * update_range); - - EQApplicationPacket *outapp = 0; - PlayerPositionUpdateServer_Struct *ppu = 0; - Mob *mob = 0; - - auto it = mob_list.begin(); - while (it != mob_list.end()) { - - mob = it->second; - - if ( - mob && !mob->IsCorpse() - && (it->second != client) - && (mob->IsClient() || iSendEvenIfNotChanged || (mob->LastChange() >= cLastUpdate)) - && (it->second->ShouldISpawnFor(client)) - ) { - if ( - update_range == 0 - || (it->second == always_send) - || mob->IsClient() - || (DistanceSquared(mob->GetPosition(), client->GetPosition()) <= update_range) - ) { - if (mob && mob->IsClient() && mob->GetID() > 0) { - client->QueuePacket(outapp, false, Client::CLIENT_CONNECTED); - - if (outapp == 0) { - outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); - ppu = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer; - } - - mob->MakeSpawnUpdate(ppu); - - safe_delete(outapp); - outapp = 0; - } - } - } - - ++it; - } - - safe_delete(outapp); +// update_range = (update_range * update_range); +// +// EQApplicationPacket *outapp = 0; +// PlayerPositionUpdateServer_Struct *ppu = 0; +// Mob *mob = 0; +// +// auto it = mob_list.begin(); +// while (it != mob_list.end()) { +// +// mob = it->second; +// +// if ( +// mob && !mob->IsCorpse() +// && (it->second != client) +// && (mob->IsClient() || iSendEvenIfNotChanged || (mob->LastChange() >= cLastUpdate)) +// && (it->second->ShouldISpawnFor(client)) +// ) { +// if ( +// update_range == 0 +// || (it->second == always_send) +// || mob->IsClient() +// || (DistanceSquared(mob->GetPosition(), client->GetPosition()) <= update_range) +// ) { +// if (mob && mob->IsClient() && mob->GetID() > 0) { +// client->QueuePacket(outapp, false, Client::CLIENT_CONNECTED); +// +// if (outapp == 0) { +// outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); +// ppu = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer; +// } +// +// mob->MakeSpawnUpdate(ppu); +// +// safe_delete(outapp); +// outapp = 0; +// } +// } +// } +// +// ++it; +// } +// +// safe_delete(outapp); } char *EntityList::MakeNameUnique(char *name) diff --git a/zone/merc.cpp b/zone/merc.cpp index 42a7f0290..2f0cae947 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1490,9 +1490,6 @@ void Merc::AI_Process() { NodeReached ); - if (WaypointChanged) - tar_ndx = 20; - CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetRunspeed()); } else { @@ -1784,9 +1781,6 @@ void Merc::AI_Process() { glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(), speed, WaypointChanged, NodeReached); - if (WaypointChanged) - tar_ndx = 20; - CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed); } else { @@ -1825,7 +1819,6 @@ void Merc::AI_Start(int32 iMoveDelay) { } SendTo(GetX(), GetY(), GetZ()); - SetChanged(); SaveGuardSpot(); } @@ -4397,7 +4390,6 @@ void Merc::Sit() { // SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY())); SendPosition(); SetMoving(false); - tar_ndx = 0; } SetAppearance(eaSitting); diff --git a/zone/mob.cpp b/zone/mob.cpp index 9764ba099..a4e7dbff8 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -105,8 +105,6 @@ Mob::Mob(const char* in_name, gravity_timer(1000), viral_timer(0), m_FearWalkTarget(-999999.0f, -999999.0f, -999999.0f), - m_TargetLocation(glm::vec3()), - m_TargetV(glm::vec3()), flee_timer(FLEE_CHECK_TIMER), m_Position(position), tmHidden(-1), @@ -119,8 +117,6 @@ Mob::Mob(const char* in_name, hate_list_cleanup_timer(6000) { targeted = 0; - tar_ndx = 0; - tar_vector = 0; currently_fleeing = false; last_major_update_position = m_Position; @@ -131,7 +127,6 @@ Mob::Mob(const char* in_name, moved = false; m_RewindLocation = glm::vec3(); - _egnode = nullptr; name[0] = 0; orig_name[0] = 0; clean_name[0] = 0; @@ -348,7 +343,6 @@ Mob::Mob(const char* in_name, memset(&aabonuses, 0, sizeof(StatBonuses)); spellbonuses.AggroRange = -1; spellbonuses.AssistRange = -1; - pLastChange = 0; SetPetID(0); SetOwnerID(0); typeofpet = petNone; // default to not a pet @@ -1456,57 +1450,59 @@ void Mob::StopMoving(float new_heading) { /* 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); - - /* When an NPC has made a large distance change - we should update all clients to prevent "ghosts" */ - if (DistanceSquared(last_major_update_position, m_Position) >= (100 * 100)) { - entity_list.QueueClients(this, app, true, true); - last_major_update_position = m_Position; - is_distance_roamer = true; - } - else { - entity_list.QueueCloseClients(this, app, true, RuleI(Range, MobPositionUpdates), nullptr, false); - } - - safe_delete(app); + //auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); + //PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer; + //MakeSpawnUpdateNoDelta(spu); + // + //entity_list.QueueCloseClients(this, app, true, 200.0f, nullptr, false); + // + ///* When an NPC has made a large distance change - we should update all clients to prevent "ghosts" */ + //if (DistanceSquared(last_major_update_position, m_Position) >= (100 * 100)) { + // entity_list.QueueClients(this, app, true, true); + // last_major_update_position = m_Position; + // is_distance_roamer = true; + //} + //else { + // entity_list.QueueCloseClients(this, app, true, RuleI(Range, MobPositionUpdates), nullptr, false); + //} + // + //safe_delete(app); } void Mob::SendPositionUpdateToClient(Client *client) { - auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); - PlayerPositionUpdateServer_Struct* spawn_update = (PlayerPositionUpdateServer_Struct*)app->pBuffer; - - if(this->IsMoving()) - MakeSpawnUpdate(spawn_update); - else - MakeSpawnUpdateNoDelta(spawn_update); - - client->QueuePacket(app, false); - - safe_delete(app); + //auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); + //PlayerPositionUpdateServer_Struct* spawn_update = (PlayerPositionUpdateServer_Struct*)app->pBuffer; + // + //if(this->IsMoving()) + // MakeSpawnUpdate(spawn_update); + //else + // MakeSpawnUpdateNoDelta(spawn_update); + // + //client->QueuePacket(app, false); + // + //safe_delete(app); } /* 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; - MakeSpawnUpdate(spu); - - if (iSendToSelf == 2) { - if (IsClient()) { - CastToClient()->FastQueuePacket(&app, false); - } - } - else if (DistanceSquared(last_major_update_position, m_Position) >= (100 * 100)) { - entity_list.QueueClients(this, app, true, true); - last_major_update_position = m_Position; - is_distance_roamer = true; - } - else { - entity_list.QueueCloseClients(this, app, (iSendToSelf == 0), RuleI(Range, MobPositionUpdates), nullptr, false); - } - safe_delete(app); + //auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); + //PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer; + //MakeSpawnUpdate(spu); + // + //if (iSendToSelf == 2) { + // if (IsClient()) { + // CastToClient()->FastQueuePacket(&app, false); + // } + //} + //else if (DistanceSquared(last_major_update_position, m_Position) >= (100 * 100)) { + // entity_list.QueueClients(this, app, true, true); + // last_major_update_position = m_Position; + // is_distance_roamer = true; + //} + //else { + // entity_list.QueueCloseClients(this, app, (iSendToSelf == 0), RuleI(Range, MobPositionUpdates), nullptr, false); + //} + //safe_delete(app); } // this is for SendPosition() @@ -5864,7 +5860,6 @@ void Mob::SetCurrentSpeed(int in){ if (current_speed != in) { current_speed = in; - tar_ndx = 20; if (in == 0) { SetRunAnimSpeed(0); SetMoving(false); diff --git a/zone/mob.h b/zone/mob.h index 4dafe2bf9..e01c5c66f 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -530,14 +530,6 @@ public: inline const float GetHeading() const { return m_Position.w; } inline const float GetSize() const { return size; } inline const float GetBaseSize() const { return base_size; } - inline const float GetTarX() const { return m_TargetLocation.x; } - inline const float GetTarY() const { return m_TargetLocation.y; } - inline const float GetTarZ() const { return m_TargetLocation.z; } - inline const float GetTarVX() const { return m_TargetV.x; } - inline const float GetTarVY() const { return m_TargetV.y; } - inline const float GetTarVZ() const { return m_TargetV.z; } - inline const float GetTarVector() const { return tar_vector; } - inline const uint8 GetTarNDX() const { return tar_ndx; } inline const int8 GetFlyMode() const { return static_cast(flymode); } bool IsBoat() const; @@ -567,7 +559,6 @@ public: void SetRunning(bool val) { m_is_running = val; } virtual void GMMove(float x, float y, float z, float heading = 0.01, bool SendUpdate = true); void SetDelta(const glm::vec4& delta); - void SetTargetDestSteps(uint8 target_steps) { tar_ndx = target_steps; } void SendPositionUpdateToClient(Client *client); void SendPositionUpdate(uint8 iSendToSelf = 0); void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); @@ -613,8 +604,7 @@ public: void SetAssistAggro(bool value) { AssistAggro = value; if (PrimaryAggro) AssistAggro = false; } bool HateSummon(); void FaceTarget(Mob* mob_to_face = 0); - void SetHeading(float iHeading) { if(m_Position.w != iHeading) { pLastChange = Timer::GetCurrentTime(); - m_Position.w = iHeading; } } + void SetHeading(float iHeading) { if(m_Position.w != iHeading) { m_Position.w = iHeading; } } void WipeHateList(); void AddFeignMemory(Client* attacker); void RemoveFromFeignMemory(Client* attacker); @@ -625,8 +615,6 @@ public: bool CheckLosFN(Mob* other); bool CheckLosFN(float posX, float posY, float posZ, float mobSize); static bool CheckLosFN(glm::vec3 posWatcher, float sizeWatcher, glm::vec3 posTarget, float sizeTarget); - inline void SetChanged() { pLastChange = Timer::GetCurrentTime(); } - inline const uint32 LastChange() const { return pLastChange; } inline void SetLastLosState(bool value) { last_los_check = value; } inline bool CheckLastLosState() const { return last_los_check; } @@ -815,7 +803,7 @@ public: void SetAppearance(EmuAppearance app, bool iIgnoreSelf = true); inline EmuAppearance GetAppearance() const { return _appearance; } inline const uint8 GetRunAnimSpeed() const { return pRunAnimSpeed; } - inline void SetRunAnimSpeed(int8 in) { if (pRunAnimSpeed != in) { pRunAnimSpeed = in; pLastChange = Timer::GetCurrentTime(); } } + inline void SetRunAnimSpeed(int8 in) { if (pRunAnimSpeed != in) { pRunAnimSpeed = in; } } bool IsDestructibleObject() { return destructibleobject; } void SetDestructibleObject(bool in) { destructibleobject = in; } @@ -1274,7 +1262,6 @@ protected: int current_speed; eSpecialAttacks m_specialattacks; - uint32 pLastChange; bool held; bool gheld; bool nocast; @@ -1521,13 +1508,6 @@ protected: bool pet_owner_client; //Flags regular and pets as belonging to a client uint32 pet_targetlock_id; - EGNode *_egnode; //the EG node we are in - glm::vec3 m_TargetLocation; - uint8 tar_ndx; - float tar_vector; - glm::vec3 m_TargetV; - float test_vector; - glm::vec3 m_TargetRing; // we might want to do this differently, we gotta do max NPC buffs ... which is 97 diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 766929c97..dd61a3112 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -515,7 +515,6 @@ void Mob::AI_Start(uint32 iMoveDelay) { m_Delta = glm::vec4(); pRunAnimSpeed = 0; - pLastChange = Timer::GetCurrentTime(); } void Client::AI_Start(uint32 iMoveDelay) { @@ -551,7 +550,6 @@ void NPC::AI_Start(uint32 iMoveDelay) { } SendTo(GetX(), GetY(), GetZ()); - SetChanged(); SaveGuardSpot(); } @@ -823,9 +821,6 @@ void Client::AI_Process() node_reached ); - if (waypoint_changed) - tar_ndx = 20; - CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed); } } @@ -905,9 +900,6 @@ void Client::AI_Process() glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetRunspeed(), WaypointChanged, NodeReached); - if(WaypointChanged) - tar_ndx = 20; - CalculateNewPosition(Goal.x, Goal.y, Goal.z, newspeed); } } @@ -1039,7 +1031,6 @@ void Mob::ProcessForcedMovement() Teleport(m_Position + m_Delta); m_Delta = glm::vec4(); SendPositionUpdate(); - pLastChange = Timer::GetCurrentTime(); FixZ(); // 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 @@ -1151,9 +1142,6 @@ void Mob::AI_Process() { NodeReached ); - if (WaypointChanged) - tar_ndx = 20; - CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetFearSpeed()); } } @@ -1484,9 +1472,6 @@ void Mob::AI_Process() { GetRunspeed(), WaypointChanged, NodeReached ); - if (WaypointChanged) - tar_ndx = 20; - CalculateNewPosition(Goal.x, Goal.y, Goal.z, GetRunspeed()); } @@ -1877,8 +1862,6 @@ void NPC::AI_DoMovement() { WaypointChanged, NodeReached ); - if (WaypointChanged) - tar_ndx = 20; if (NodeReached) entity_list.OpenDoorsNear(CastToNPC()); @@ -1921,9 +1904,6 @@ void NPC::AI_DoMovement() { WaypointChanged, NodeReached ); - if (WaypointChanged) { - tar_ndx = 20; - } if (NodeReached) { entity_list.OpenDoorsNear(CastToNPC()); diff --git a/zone/pathing.cpp b/zone/pathing.cpp index 4829bcc83..ff1963720 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -86,27 +86,27 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa } if (!IsRooted()) { - bool AtPrevNode = DistanceSquared(From, PathingLastPosition) < 1.0f; - if (AtPrevNode) { - PathingLoopCount++; - auto front = (*Route.begin()).pos; - - if (PathingLoopCount > 5) { - Teleport(front); - SendPosition(); - Route.pop_front(); - - WaypointChanged = true; - NodeReached = true; - PathingLoopCount = 0; - } - - return front; - } - else { + //bool AtPrevNode = DistanceSquared(From, PathingLastPosition) < 1.0f; + //if (AtPrevNode) { + // PathingLoopCount++; + // auto front = (*Route.begin()).pos; + // + // if (PathingLoopCount > 5) { + // Teleport(front); + // SendPosition(); + // Route.pop_front(); + // + // WaypointChanged = true; + // NodeReached = true; + // PathingLoopCount = 0; + // } + // + // return front; + //} + //else { PathingLastPosition = From; PathingLoopCount = 0; - } + //} } else { PathingLastPosition = From; diff --git a/zone/perl_mob.cpp b/zone/perl_mob.cpp index 0a6275169..ea3ba40b4 100644 --- a/zone/perl_mob.cpp +++ b/zone/perl_mob.cpp @@ -7275,28 +7275,6 @@ XS(XS_Mob_SetLD) { XSRETURN_EMPTY; } -XS(XS_Mob_SetTargetDestSteps); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Mob_SetTargetDestSteps) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetTargetDestSteps(THIS, uint8 target_steps)"); - { - Mob *THIS; - uint8 target_steps = (uint8) SvIV(ST(1)); - - if (sv_derived_from(ST(0), "Mob")) { - IV tmp = SvIV((SV *) SvRV(ST(0))); - THIS = INT2PTR(Mob *, tmp); - } else - Perl_croak(aTHX_ "THIS is not of type Mob"); - if (THIS == nullptr) - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - - THIS->SetTargetDestSteps(target_steps); - } - XSRETURN_EMPTY; -} - XS(XS_Mob_SetTargetable); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetTargetable) { dXSARGS; @@ -8781,7 +8759,6 @@ XS(boot_Mob) { newXSproto(strcpy(buf, "SetBodyType"), XS_Mob_SetBodyType, file, "$$;$"); newXSproto(strcpy(buf, "SetDeltas"), XS_Mob_SetDeltas, file, "$$$$$"); newXSproto(strcpy(buf, "SetLD"), XS_Mob_SetLD, file, "$$"); - newXSproto(strcpy(buf, "SetTargetDestSteps"), XS_Mob_SetTargetDestSteps, file, "$$"); newXSproto(strcpy(buf, "SetTargetable"), XS_Mob_SetTargetable, file, "$$"); newXSproto(strcpy(buf, "MakeTempPet"), XS_Mob_MakeTempPet, file, "$$;$$$$"); newXSproto(strcpy(buf, "ModSkillDmgTaken"), XS_Mob_ModSkillDmgTaken, file, "$$$"); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 36c996ce8..0c1e4d11d 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include extern FastMath g_Math; +extern uint64_t frame_time; struct wp_distance { @@ -332,8 +333,6 @@ void NPC::CalculateNewWaypoint() } } - tar_ndx = 52; - // Preserve waypoint setting for quest controlled NPCs if (cur_wp < 0) cur_wp = old_wp; @@ -455,64 +454,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b return true; } - if ((m_Position.x - x == 0) && (m_Position.y - y == 0)) { //spawn is at target coords - return false; - } - else if ((std::abs(m_Position.x - x) < 0.1) && (std::abs(m_Position.y - y) < 0.1)) { - if (IsNPC()) { - entity_list.ProcessMove(CastToNPC(), x, y, z); - } - - m_Position.x = x; - m_Position.y = y; - m_Position.z = z; - - return true; - } - - int compare_steps = 20; - if (tar_ndx < compare_steps && m_TargetLocation.x == x && m_TargetLocation.y == y) { - - float new_x = m_Position.x + m_TargetV.x * tar_vector; - float new_y = m_Position.y + m_TargetV.y * tar_vector; - float new_z = m_Position.z + m_TargetV.z * tar_vector; - - if (IsNPC()) { - entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); - } - - m_Position.x = new_x; - m_Position.y = new_y; - m_Position.z = new_z; - - if (check_z && fix_z_timer.Check() && (!this->IsEngaged() || flee_mode || currently_fleeing)) { - this->FixZ(); - } - - tar_ndx++; - - return true; - } - - if (tar_ndx > 50) { - tar_ndx--; - } - else { - tar_ndx = 0; - } - - m_TargetLocation = glm::vec3(x, y, z); - - float nx = this->m_Position.x; - float ny = this->m_Position.y; - float nz = this->m_Position.z; - // float nh = this->heading; - - m_TargetV.x = x - nx; - m_TargetV.y = y - ny; - m_TargetV.z = z - nz; - SetCurrentSpeed((int8)speed); + SetCurrentSpeed(static_cast(speed)); pRunAnimSpeed = speed; + #ifdef BOTS if (IsClient() || IsBot()) #else @@ -522,88 +466,48 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b animation = speed / 2; } - // -------------------------------------------------------------------------- - // 2: get unit vector - // -------------------------------------------------------------------------- - float mag = sqrtf(m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z); - tar_vector = (float)speed / mag; - - // mob move fix - int numsteps = (int)(mag * 13.5f / (float)speed + 0.5f); - - - // mob move fix - - if (numsteps < 20) { - if (numsteps > 1) { - tar_vector = 1.0f; - m_TargetV.x = m_TargetV.x / (float) numsteps; - m_TargetV.y = m_TargetV.y / (float) numsteps; - m_TargetV.z = m_TargetV.z / (float) numsteps; - - float new_x = m_Position.x + m_TargetV.x; - float new_y = m_Position.y + m_TargetV.y; - float new_z = m_Position.z + m_TargetV.z; - if (IsNPC()) { - entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); - } - - m_Position.x = new_x; - m_Position.y = new_y; - m_Position.z = new_z; - if (calculate_heading) { - m_Position.w = CalculateHeadingToTarget(x, y); - } - tar_ndx = 20 - numsteps; - } - else { - if (IsNPC()) { - entity_list.ProcessMove(CastToNPC(), x, y, z); - } - - m_Position.x = x; - m_Position.y = y; - m_Position.z = z; - } + //Setup Vectors + glm::vec3 tar(x, y, z); + glm::vec3 pos(m_Position.x, m_Position.y, m_Position.z); + double len = glm::distance(pos, tar); + if (len == 0) { + return true; } + glm::vec3 dir = tar - pos; + glm::vec3 ndir = glm::normalize(dir); + if (calculate_heading) { + m_Position.w = CalculateHeadingToTarget(x, y); + } + + double time_since_last = static_cast(frame_time) / 1000.0; + double distance_moved = time_since_last * (speed + 100.0f); + + if (distance_moved > len) { + m_Position.x = x; + m_Position.y = y; + m_Position.z = z; + + if (IsNPC()) { + entity_list.ProcessMove(CastToNPC(), x, y, z); + } + + return true; + } else { - tar_vector /= 13.5f; - float dur = Timer::GetCurrentTime() - pLastChange; - if (dur < 0.0f) { - dur = 0.0f; - } - - if (dur > 100.f) { - dur = 100.f; - } - - tar_vector *= (dur / 100.0f); - - float new_x = m_Position.x + m_TargetV.x * tar_vector; - float new_y = m_Position.y + m_TargetV.y * tar_vector; - float new_z = m_Position.z + m_TargetV.z * tar_vector; + glm::vec3 npos = pos + (ndir * static_cast(distance_moved)); + m_Position.x = npos.x; + m_Position.y = npos.y; + m_Position.z = npos.z; if (IsNPC()) { - entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); - } - - m_Position.x = new_x; - m_Position.y = new_y; - m_Position.z = new_z; - if (calculate_heading) { - m_Position.w = CalculateHeadingToTarget(x, y); + entity_list.ProcessMove(CastToNPC(), x, y, z); } } - if (check_z && fix_z_timer.Check() && !this->IsEngaged()) - this->FixZ(); - SetMoving(true); - moved = true; - - m_Delta = glm::vec4(m_Position.x - nx, m_Position.y - ny, m_Position.z - nz, 0.0f); - + m_Delta = glm::vec4(m_Position.x - pos.x, m_Position.y - pos.y, m_Position.z - pos.z, 0.0f); + if (IsClient()) { SendPositionUpdate(1); CastToClient()->ResetPositionTimer(); @@ -613,7 +517,6 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b SetAppearance(eaStanding, false); } - pLastChange = Timer::GetCurrentTime(); return true; }