From 05ae8c8219d16c3bc26f5866e890e35a47191599 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Fri, 25 May 2018 22:41:46 -0500 Subject: [PATCH] Add rule Aggro:NPCAggroMaxDistanceEnabled - enabled by default If enabled, NPC's will drop aggro beyond 600 units or what is defined at the zone level --- common/ruletypes.h | 1 + zone/mob.cpp | 2 +- zone/mob.h | 2 +- zone/mob_ai.cpp | 6 +++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index 08adb5893..0233f0952 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -549,6 +549,7 @@ RULE_BOOL(Aggro, AllowTickPulling, false) // tick pulling is an exploit in an NP RULE_BOOL(Aggro, UseLevelAggro, true) // Level 18+ and Undead will aggro regardless of level difference. (this will disabled Rule:IntAggroThreshold if set to true) RULE_INT(Aggro, ClientAggroCheckInterval, 6) // Interval in which clients actually check for aggro - in seconds RULE_REAL(Aggro, PetAttackRange, 40000.0) // max squared range /pet attack works at default is 200 +RULE_BOOL(Aggro, NPCAggroMaxDistanceEnabled, true) /* If enabled, NPC's will drop aggro beyond 600 units or what is defined at the zone level */ RULE_CATEGORY_END() RULE_CATEGORY(TaskSystem) diff --git a/zone/mob.cpp b/zone/mob.cpp index 52f9059a9..c0130d5ae 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(500), - mHateListCleanup(6000) + hate_list_cleanup_timer(6000) { targeted = 0; tar_ndx = 0; diff --git a/zone/mob.h b/zone/mob.h index 8e7189696..5be772643 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1453,7 +1453,7 @@ protected: void AddItemFactionBonus(uint32 pFactionID,int32 bonus); int32 GetItemFactionBonus(uint32 pFactionID); void ClearItemFactionBonuses(); - Timer mHateListCleanup; + Timer hate_list_cleanup_timer; bool flee_mode; Timer flee_timer; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 2efb80cc7..3d9bb842a 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -487,6 +487,10 @@ void Mob::AI_Start(uint32 iMoveDelay) { AI_feign_remember_timer = std::unique_ptr(new Timer(AIfeignremember_delay)); AI_scan_door_open_timer = std::unique_ptr(new Timer(AI_scan_door_open_interval)); + if(!RuleB(Aggro, NPCAggroMaxDistanceEnabled)) { + hate_list_cleanup_timer.Disable(); + } + if (CastToNPC()->WillAggroNPCs()) AI_scan_area_timer = std::unique_ptr(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax)))); @@ -1163,7 +1167,7 @@ void Mob::AI_Process() { // NPCs will forget people after 10 mins of not interacting with them or out of range // both of these maybe zone specific, hardcoded for now - if (mHateListCleanup.Check()) { + if (hate_list_cleanup_timer.Check()) { hate_list.RemoveStaleEntries(600000, 600.0f); if (hate_list.IsHateListEmpty()) { AI_Event_NoLongerEngaged();