mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
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
This commit is contained in:
parent
e5e801dad5
commit
d7dfc18c54
@ -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...");
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)))
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -479,18 +479,18 @@ void Mob::AI_Start(uint32 iMoveDelay) {
|
||||
AI_movement_timer = std::unique_ptr<Timer>(new Timer(AImovement_duration));
|
||||
AI_target_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration));
|
||||
AI_feign_remember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay));
|
||||
AI_scan_area_timer = std::unique_ptr<Timer>(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax))));
|
||||
|
||||
if(CastToNPC()->WillAggroNPCs())
|
||||
AI_scan_area_timer = std::unique_ptr<Timer>(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax))));
|
||||
|
||||
AI_check_signal_timer = std::unique_ptr<Timer>(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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user