Adjust the behavior of out of range aggro removal

This is a bit more accurate
This commit is contained in:
Michael Cook (mackal) 2018-01-18 19:59:04 -05:00
parent a7310cba17
commit a440269c6b
3 changed files with 17 additions and 3 deletions

View File

@ -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()) {

View File

@ -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
};

View File

@ -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;