diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 01507174f..8da223b04 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -200,6 +200,7 @@ void HateList::AddEntToHateList(Mob *in_entity, int32 in_hate, int32 in_damage, entity->hatelist_damage = (in_damage >= 0) ? in_damage : 0; entity->stored_hate_amount = in_hate; entity->is_entity_frenzy = in_is_entity_frenzied; + entity->oor_count = 0; list.push_back(entity); parse->EventNPC(EVENT_HATE_LIST, hate_owner->CastToNPC(), in_entity, "1", 0); @@ -658,8 +659,20 @@ void HateList::RemoveStaleEntries(int time_ms, float dist) 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) { + bool remove = false; + + if (cur_time - (*it)->last_modified > time_ms) + remove = true; + + if (!remove && hate_owner->CalculateDistance(m->GetX(), m->GetY(), m->GetZ()) > dist) { + (*it)->oor_count++; + if ((*it)->oor_count == 2) + remove = true; + } else if ((*it)->oor_count != 0) { + (*it)->oor_count = 0; + } + + if (remove) { parse->EventNPC(EVENT_HATE_LIST, hate_owner->CastToNPC(), m, "0", 0); if (m->IsClient()) { diff --git a/zone/hate_list.h b/zone/hate_list.h index 1ffb1eaf8..0ac1840ac 100644 --- a/zone/hate_list.h +++ b/zone/hate_list.h @@ -31,6 +31,7 @@ struct struct_HateList int32 hatelist_damage; uint32 stored_hate_amount; bool is_entity_frenzy; + int8 oor_count; // count on how long we've been out of range uint32 last_modified; // we need to remove this if it gets higher than 10 mins }; diff --git a/zone/mob.cpp b/zone/mob.cpp index 150469da4..39efb1d3d 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -116,7 +116,7 @@ Mob::Mob(const char* in_name, fix_z_timer_engaged(100), attack_anim_timer(1000), position_update_melee_push_timer(1000), - mHateListCleanup(3000) + mHateListCleanup(6000) { targeted = 0; tar_ndx = 0;