Skip to content

Commit 34c21a1

Browse files
committed
NPCBots: Add combat ending beyound visibility range mechanic similar to players'
1 parent 038db40 commit 34c21a1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/server/game/AI/NpcBots/bot_ai.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ bot_ai::bot_ai(Creature* creature) : CreatureAI(creature),
228228
lastdiff = 0;
229229
_energyFraction = 0.f;
230230
_updateTimerMedium = 0;
231+
_updateTimerLong = urand(15000, 25000);
231232
_updateTimerEx1 = urand(12000, 15000);
232233
_updateTimerEx2 = urand(8000, 12000);
233234
checkAurasTimer = 0;
@@ -18011,6 +18012,16 @@ bool bot_ai::GlobalUpdate(uint32 diff)
1801118012
if (IsDuringTeleport())
1801218013
return false;
1801318014

18015+
if (_updateTimerLong <= diff)
18016+
{
18017+
_updateTimerLong = urand(15000, 25000);
18018+
18019+
//Long-timed updates
18020+
18021+
if (me->IsInWorld() && me->IsAlive() && me->IsInCombat() && !me->GetMap()->IsDungeon() && (IAmFree() || !master->IsInCombat()))
18022+
me->GetCombatManager().EndCombatBeyondRange(me->GetMap()->GetVisibilityRange(), true);
18023+
}
18024+
1801418025
if (_updateTimerMedium <= diff)
1801518026
{
1801618027
_updateTimerMedium = 500;
@@ -18761,6 +18772,7 @@ void bot_ai::CommonTimers(uint32 diff)
1876118772
else if (_groupUpdateTimer) _groupUpdateTimer = 0;
1876218773

1876318774
if (_updateTimerMedium > diff) _updateTimerMedium -= diff;
18775+
if (_updateTimerLong > diff) _updateTimerLong -= diff;
1876418776
if (_updateTimerEx1 > diff) _updateTimerEx1 -= diff;
1876518777
if (_updateTimerEx2 > diff) _updateTimerEx2 -= diff;
1876618778

src/server/game/AI/NpcBots/bot_ai.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ class bot_ai : public CreatureAI
710710

711711
//timers
712712
uint32 _reviveTimer, _powersTimer, _chaseTimer, _engageTimer, _potionTimer;
713-
uint32 lastdiff, checkAurasTimer, checkMasterTimer, roleTimer, ordersTimer, regenTimer, _updateTimerMedium, _updateTimerEx1, _updateTimerEx2;
713+
uint32 lastdiff, checkAurasTimer, checkMasterTimer, roleTimer, ordersTimer, regenTimer, _updateTimerLong, _updateTimerMedium, _updateTimerEx1, _updateTimerEx2;
714714
uint32 _checkOwershipTimer;
715715
uint32 _moveBehindTimer;
716716
uint32 _rentTimer;

0 commit comments

Comments
 (0)