diff --git a/changelog.txt b/changelog.txt index 18d35029e..7386c7602 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- == 4/1/2017 == +Akkadius: Cleaned up some of the NPC to NPC aggro code, only do aggro checks to other NPC's when the NPC is flagged for it Akkadius: [Performance] Reworked how all log calls are made in the source - Before we used Log.Out, we will now use a macro Log( - Before: Log.Out(Logs::General, Logs::Status, "Importing Spells..."); diff --git a/common/features.h b/common/features.h index 863004666..7e347db6d 100644 --- a/common/features.h +++ b/common/features.h @@ -111,9 +111,6 @@ Zone extensions and features //path to where sql logs should be placed #define SQL_LOG_PATH "sql_logs/" -//New aggro system to reduce overhead. -#define REVERSE_AGGRO - //The highest you can #setskill / #setallskill #define HIGHEST_CAN_SET_SKILL 400 diff --git a/zone/aggro.cpp b/zone/aggro.cpp index f717c3bdf..0e9009072 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -408,25 +408,19 @@ bool Mob::CheckWillAggro(Mob *mob) { return(false); } -Mob* EntityList::AICheckCloseAggro(Mob* sender, float iAggroRange, float iAssistRange) { +Mob* EntityList::AICheckNPCtoNPCAggro(Mob* sender, float iAggroRange, float iAssistRange) { if (!sender || !sender->IsNPC()) return(nullptr); -#ifdef REVERSE_AGGRO - //with reverse aggro, npc->client is checked elsewhere, no need to check again auto it = npc_list.begin(); while (it != npc_list.end()) { -#else - auto it = mob_list.begin(); - while (it != mob_list.end()) { -#endif Mob *mob = it->second; if (sender->CheckWillAggro(mob)) return mob; ++it; } - //LogFile->write(EQEMuLog::Debug, "Check aggro for %s no target.", sender->GetName()); + return nullptr; } diff --git a/zone/client.cpp b/zone/client.cpp index 4173eda76..ca7df4643 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -134,9 +134,7 @@ Client::Client(EQStreamInterface* ieqs) endupkeep_timer(1000), forget_timer(0), autosave_timer(RuleI(Character, AutosaveIntervalS) * 1000), -#ifdef REVERSE_AGGRO client_scan_npc_aggro_timer(RuleI(Aggro, ClientAggroCheckInterval) * 1000), -#endif tribute_timer(Tribute_duration), proximity_timer(ClientProximity_interval), TaskPeriodic_Timer(RuleI(TaskSystem, PeriodicCheckTimer) * 1000), diff --git a/zone/client.h b/zone/client.h index 43af2a841..722df5f10 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1460,9 +1460,7 @@ private: Timer endupkeep_timer; Timer forget_timer; // our 2 min everybody forgets you timer Timer autosave_timer; -#ifdef REVERSE_AGGRO Timer client_scan_npc_aggro_timer; -#endif Timer tribute_timer; Timer proximity_timer; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 6cadc4be5..130c10c9d 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -614,7 +614,6 @@ bool Client::Process() { } } -#ifdef REVERSE_AGGRO //At this point, we are still connected, everything important has taken //place, now check to see if anybody wants to aggro us. // only if client is not feigned @@ -630,7 +629,6 @@ bool Client::Process() { } Log(Logs::General, Logs::Aggro, "Checking Reverse Aggro (client->npc) scanned_npcs (%i)", npc_scan_count); } -#endif if (client_state != CLIENT_LINKDEAD && (client_state == CLIENT_ERROR || client_state == DISCONNECTED || client_state == CLIENT_KICKED || !eqs->CheckState(ESTABLISHED))) { diff --git a/zone/entity.h b/zone/entity.h index 193a17b8d..2f2237283 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -412,7 +412,7 @@ public: bool LimitCheckName(const char* npc_name); void CheckClientAggro(Client *around); - Mob* AICheckCloseAggro(Mob* sender, float iAggroRange, float iAssistRange); + Mob* AICheckNPCtoNPCAggro(Mob* sender, float iAggroRange, float iAssistRange); int GetHatedCount(Mob *attacker, Mob *exclude); void AIYellForHelp(Mob* sender, Mob* attacker); bool AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float iRange, uint32 iSpellTypes); diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index c44d73c3e..3f58a0854 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -479,18 +479,18 @@ void Mob::AI_Start(uint32 iMoveDelay) { AI_movement_timer = std::unique_ptr(new Timer(AImovement_duration)); AI_target_check_timer = std::unique_ptr(new Timer(AItarget_check_duration)); AI_feign_remember_timer = std::unique_ptr(new Timer(AIfeignremember_delay)); - AI_scan_area_timer = std::unique_ptr(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax)))); + + if(CastToNPC()->WillAggroNPCs()) + AI_scan_area_timer = std::unique_ptr(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax)))); + AI_check_signal_timer = std::unique_ptr(new Timer(AI_check_signal_timer_delay)); -#ifdef REVERSE_AGGRO - if(IsNPC() && !CastToNPC()->WillAggroNPCs()) - AI_scan_area_timer->Disable(); -#endif if (GetAggroRange() == 0) pAggroRange = 70; if (GetAssistRange() == 0) pAssistRange = 70; + hate_list.WipeHateList(); m_Delta = glm::vec4(); @@ -1351,18 +1351,13 @@ void Mob::AI_Process() { { //we processed a spell action, so do nothing else. } - else if (zone->CanDoCombat() && AI_scan_area_timer->Check()) + else if (zone->CanDoCombat() && CastToNPC()->WillAggroNPCs() && AI_scan_area_timer->Check()) { /* - * This is where NPCs look around to see if they want to attack anybody. - * - * if REVERSE_AGGRO is enabled, then this timer is disabled unless they - * have the npc_aggro flag on them, and aggro against clients is checked - * by the clients. - * + * NPC to NPC aggro checking, npc needs npc_aggro flag */ - Mob* temp_target = entity_list.AICheckCloseAggro(this, GetAggroRange(), GetAssistRange()); + Mob* temp_target = entity_list.AICheckNPCtoNPCAggro(this, GetAggroRange(), GetAssistRange()); if (temp_target){ AddToHateList(temp_target); }