[Fix] Fix NPC ghosting at safe coordinates (#2823)

* [Fix] Fix NPC ghosting at safe coordinates

* Tweak order

* Handle another case
This commit is contained in:
Chris Miles 2023-02-06 17:23:29 -06:00 committed by GitHub
parent b385a4385f
commit 0348cb6b8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 1 deletions

View File

@ -2083,6 +2083,7 @@ private:
bool m_bot_precombat;
bool CanTradeFVNoDropItem();
void SendMobPositions();
};
#endif

View File

@ -778,6 +778,12 @@ void Client::CompleteConnect()
parse->EventPlayer(EVENT_ENTER_ZONE, this, "", 0);
// the way that the client deals with positions during the initial spawn struct
// is subtly different from how it deals with getting a position update
// if a mob is slightly in the wall or slightly clipping a floor they will be
// sent to a succor point
SendMobPositions();
SetLastPositionBeforeBulkUpdate(GetPosition());
/* This sub event is for if a player logs in for the first time since entering world. */
@ -15730,3 +15736,14 @@ bool Client::CanTradeFVNoDropItem()
return false;
}
void Client::SendMobPositions()
{
auto p = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
auto *s = (PlayerPositionUpdateServer_Struct *) p->pBuffer;
for (auto &m: entity_list.GetMobList()) {
m.second->MakeSpawnUpdate(s);
QueuePacket(p, false);
}
safe_delete(p);
}

View File

@ -718,6 +718,8 @@ void EntityList::AddNPC(NPC *npc, bool send_spawn_packet, bool dont_queue)
}
}
npc->SendPositionToClients();
entity_list.ScanCloseMobs(npc->close_mobs, npc, true);
npc->DispatchZoneControllerEvent(EVENT_SPAWN_ZONE, npc, "", 0, nullptr);
@ -844,8 +846,10 @@ void EntityList::CheckSpawnQueue()
NPC *pnpc = it->second;
pnpc->SendArmorAppearance();
pnpc->SetAppearance(pnpc->GetGuardPointAnim(), false);
if (!pnpc->IsTargetable())
if (!pnpc->IsTargetable()) {
pnpc->SendTargetable(false);
}
pnpc->SendPositionToClients();
}
safe_delete(outapp);
iterator.RemoveCurrent();

View File

@ -3783,3 +3783,14 @@ int NPC::GetRolledItemCount(uint32 item_id)
return rolled_count;
}
void NPC::SendPositionToClients()
{
auto p = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
auto *s = (PlayerPositionUpdateServer_Struct *) p->pBuffer;
for (auto &c: entity_list.GetClientList()) {
MakeSpawnUpdate(s);
c.second->QueuePacket(p, false);
}
safe_delete(p);
}

View File

@ -536,6 +536,8 @@ public:
void RecalculateSkills();
void ReloadSpells();
void SendPositionToClients();
static LootDropEntries_Struct NewLootDropEntry();
protected: