mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 07:38:36 +00:00
Add hatelist removal for far distances and time
This commit is contained in:
@@ -107,6 +107,7 @@ void HateList::SetHateAmountOnEnt(Mob* other, uint32 in_hate, uint32 in_damage)
|
||||
entity->hatelist_damage = in_damage;
|
||||
if (in_hate > 0)
|
||||
entity->stored_hate_amount = in_hate;
|
||||
entity->last_modified = Timer::GetCurrentTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,6 +209,7 @@ void HateList::AddEntToHateList(Mob *in_entity, int32 in_hate, int32 in_damage,
|
||||
in_entity->CastToClient()->IncrementAggroCount();
|
||||
}
|
||||
}
|
||||
entity->last_modified = Timer::GetCurrentTime();
|
||||
}
|
||||
|
||||
bool HateList::RemoveEntFromHateList(Mob *in_entity)
|
||||
@@ -646,3 +648,31 @@ void HateList::SpellCast(Mob *caster, uint32 spell_id, float range, Mob* ae_cent
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void HateList::RemoveStaleEntries(int time_ms, float dist)
|
||||
{
|
||||
auto it = list.begin();
|
||||
|
||||
auto cur_time = Timer::GetCurrentTime();
|
||||
|
||||
while (it != list.end()) {
|
||||
auto m = (*it)->entity_on_hatelist;
|
||||
if (m) {
|
||||
// 10 mins or distance
|
||||
if ((cur_time - (*it)->last_modified > time_ms) || hate_owner->CalculateDistance(m->GetX(), m->GetY(), m->GetZ()) > dist) {
|
||||
parse->EventNPC(EVENT_HATE_LIST, hate_owner->CastToNPC(), m, "0", 0);
|
||||
|
||||
if (m->IsClient()) {
|
||||
m->CastToClient()->DecrementAggroCount();
|
||||
m->CastToClient()->RemoveXTarget(hate_owner, true);
|
||||
}
|
||||
|
||||
delete (*it);
|
||||
it = list.erase(it);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user