From 0355ccfe41c16d2813bd7243316f7cbc1bab454c Mon Sep 17 00:00:00 2001 From: trickerer Date: Tue, 17 Dec 2024 20:45:19 +0700 Subject: [PATCH] NPCBots: Add combat ending beyound visibility range mechanic similar to players' --- src/server/game/AI/NpcBots/bot_ai.cpp | 12 ++++++++++++ src/server/game/AI/NpcBots/bot_ai.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/server/game/AI/NpcBots/bot_ai.cpp b/src/server/game/AI/NpcBots/bot_ai.cpp index 10f69d1980a092..fa5e3c32e47df4 100644 --- a/src/server/game/AI/NpcBots/bot_ai.cpp +++ b/src/server/game/AI/NpcBots/bot_ai.cpp @@ -223,6 +223,7 @@ bot_ai::bot_ai(Creature* creature) : CreatureAI(creature), lastdiff = 0; _energyFraction = 0.f; _updateTimerMedium = 0; + _updateTimerLong = urand(15000, 25000); _updateTimerEx1 = urand(12000, 15000); _updateTimerEx2 = urand(8000, 12000); checkAurasTimer = 0; @@ -18030,6 +18031,16 @@ bool bot_ai::GlobalUpdate(uint32 diff) if (IsDuringTeleport()) return false; + if (_updateTimerLong <= diff) + { + _updateTimerLong = urand(15000, 25000); + + //Long-timed updates + + if (me->IsInWorld() && me->IsAlive() && me->IsInCombat() && !me->GetMap()->IsDungeon() && (IAmFree() || !master->IsInCombat())) + me->getHostileRefMgr().deleteReferencesOutOfRange(me->GetMap()->GetVisibilityRange()); + } + if (_updateTimerMedium <= diff) { _updateTimerMedium = 500; @@ -18785,6 +18796,7 @@ void bot_ai::CommonTimers(uint32 diff) else if (_groupUpdateTimer) _groupUpdateTimer = 0; if (_updateTimerMedium > diff) _updateTimerMedium -= diff; + if (_updateTimerLong > diff) _updateTimerLong -= diff; if (_updateTimerEx1 > diff) _updateTimerEx1 -= diff; if (_updateTimerEx2 > diff) _updateTimerEx2 -= diff; diff --git a/src/server/game/AI/NpcBots/bot_ai.h b/src/server/game/AI/NpcBots/bot_ai.h index eaed68230b2d20..cae5ed84a55108 100644 --- a/src/server/game/AI/NpcBots/bot_ai.h +++ b/src/server/game/AI/NpcBots/bot_ai.h @@ -711,7 +711,7 @@ class bot_ai : public CreatureAI //timers uint32 _reviveTimer, _powersTimer, _chaseTimer, _engageTimer, _potionTimer; - uint32 lastdiff, checkAurasTimer, checkMasterTimer, roleTimer, ordersTimer, regenTimer, _updateTimerMedium, _updateTimerEx1, _updateTimerEx2; + uint32 lastdiff, checkAurasTimer, checkMasterTimer, roleTimer, ordersTimer, regenTimer, _updateTimerLong, _updateTimerMedium, _updateTimerEx1, _updateTimerEx2; uint32 _checkOwershipTimer; uint32 _moveBehindTimer; uint32 _rentTimer;