mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Refactor close_npcs to close_mobs for future implementations
This commit is contained in:
parent
ec00daa5be
commit
59a2f0cdde
@ -358,7 +358,7 @@ Client::~Client() {
|
|||||||
m_tradeskill_object = nullptr;
|
m_tradeskill_object = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
close_npcs.clear();
|
close_mobs.clear();
|
||||||
|
|
||||||
if(IsDueling() && GetDuelTarget() != 0) {
|
if(IsDueling() && GetDuelTarget() != 0) {
|
||||||
Entity* entity = entity_list.GetID(GetDuelTarget());
|
Entity* entity = entity_list.GetID(GetDuelTarget());
|
||||||
|
|||||||
@ -222,7 +222,7 @@ public:
|
|||||||
Client(EQStreamInterface * ieqs);
|
Client(EQStreamInterface * ieqs);
|
||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
std::unordered_map<NPC *, float> close_npcs;
|
std::unordered_map<Mob *, float> close_mobs;
|
||||||
bool is_client_moving;
|
bool is_client_moving;
|
||||||
|
|
||||||
//abstract virtual function implementations required by base abstract class
|
//abstract virtual function implementations required by base abstract class
|
||||||
|
|||||||
@ -254,7 +254,7 @@ bool Client::Process() {
|
|||||||
/* Build a close range list of NPC's */
|
/* Build a close range list of NPC's */
|
||||||
if (npc_close_scan_timer.Check()) {
|
if (npc_close_scan_timer.Check()) {
|
||||||
|
|
||||||
close_npcs.clear();
|
close_mobs.clear();
|
||||||
|
|
||||||
auto &mob_list = entity_list.GetMobList();
|
auto &mob_list = entity_list.GetMobList();
|
||||||
float scan_range = (RuleI(Range, ClientNPCScan) * RuleI(Range, ClientNPCScan));
|
float scan_range = (RuleI(Range, ClientNPCScan) * RuleI(Range, ClientNPCScan));
|
||||||
@ -265,10 +265,10 @@ bool Client::Process() {
|
|||||||
float distance = DistanceSquared(m_Position, mob->GetPosition());
|
float distance = DistanceSquared(m_Position, mob->GetPosition());
|
||||||
if (mob->IsNPC()) {
|
if (mob->IsNPC()) {
|
||||||
if (distance <= scan_range) {
|
if (distance <= scan_range) {
|
||||||
close_npcs.insert(std::pair<NPC *, float>(mob->CastToNPC(), distance));
|
close_mobs.insert(std::pair<Mob *, float>(mob, distance));
|
||||||
}
|
}
|
||||||
else if (mob->GetAggroRange() > scan_range) {
|
else if (mob->GetAggroRange() > scan_range) {
|
||||||
close_npcs.insert(std::pair<NPC *, float>(mob->CastToNPC(), distance));
|
close_mobs.insert(std::pair<Mob *, float>(mob, distance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,11 +631,14 @@ bool Client::Process() {
|
|||||||
// only if client is not feigned
|
// only if client is not feigned
|
||||||
if (zone->CanDoCombat() && ret && !GetFeigned() && client_scan_npc_aggro_timer.Check()) {
|
if (zone->CanDoCombat() && ret && !GetFeigned() && client_scan_npc_aggro_timer.Check()) {
|
||||||
int npc_scan_count = 0;
|
int npc_scan_count = 0;
|
||||||
for (auto it = close_npcs.begin(); it != close_npcs.end(); ++it) {
|
for (auto it = close_mobs.begin(); it != close_mobs.end(); ++it) {
|
||||||
NPC *npc = it->first;
|
Mob *mob = it->first;
|
||||||
|
|
||||||
if (npc->CheckWillAggro(this) && !npc->CheckAggro(this)) {
|
if (mob->IsClient())
|
||||||
npc->AddToHateList(this, 25);
|
continue;
|
||||||
|
|
||||||
|
if (mob->CheckWillAggro(this) && !mob->CheckAggro(this)) {
|
||||||
|
mob->AddToHateList(this, 25);
|
||||||
}
|
}
|
||||||
npc_scan_count++;
|
npc_scan_count++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2323,11 +2323,10 @@ bool EntityList::RemoveNPC(uint16 delete_id)
|
|||||||
// make sure its proximity is removed
|
// make sure its proximity is removed
|
||||||
RemoveProximity(delete_id);
|
RemoveProximity(delete_id);
|
||||||
// remove from client close lists
|
// remove from client close lists
|
||||||
RemoveNPCFromClientCloseLists(npc);
|
RemoveMobFromClientCloseLists(npc->CastToMob());
|
||||||
// remove from the list
|
// remove from the list
|
||||||
npc_list.erase(it);
|
npc_list.erase(it);
|
||||||
|
|
||||||
|
|
||||||
// remove from limit list if needed
|
// remove from limit list if needed
|
||||||
if (npc_limit_list.count(delete_id))
|
if (npc_limit_list.count(delete_id))
|
||||||
npc_limit_list.erase(delete_id);
|
npc_limit_list.erase(delete_id);
|
||||||
@ -2336,11 +2335,11 @@ bool EntityList::RemoveNPC(uint16 delete_id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityList::RemoveNPCFromClientCloseLists(NPC *npc)
|
bool EntityList::RemoveMobFromClientCloseLists(Mob *mob)
|
||||||
{
|
{
|
||||||
auto it = client_list.begin();
|
auto it = client_list.begin();
|
||||||
while (it != client_list.end()) {
|
while (it != client_list.end()) {
|
||||||
it->second->close_npcs.erase(npc);
|
it->second->close_mobs.erase(mob);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -279,7 +279,7 @@ public:
|
|||||||
bool RemoveTrap(uint16 delete_id);
|
bool RemoveTrap(uint16 delete_id);
|
||||||
bool RemoveObject(uint16 delete_id);
|
bool RemoveObject(uint16 delete_id);
|
||||||
bool RemoveProximity(uint16 delete_npc_id);
|
bool RemoveProximity(uint16 delete_npc_id);
|
||||||
bool RemoveNPCFromClientCloseLists(NPC *npc);
|
bool RemoveMobFromClientCloseLists(Mob *mob);
|
||||||
void RemoveAllMobs();
|
void RemoveAllMobs();
|
||||||
void RemoveAllClients();
|
void RemoveAllClients();
|
||||||
void RemoveAllNPCs();
|
void RemoveAllNPCs();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user