Skip to content

Commit

Permalink
NPCBots: Add combat ending beyound visibility range mechanic similar …
Browse files Browse the repository at this point in the history
…to players'
  • Loading branch information
trickerer committed Dec 17, 2024
1 parent f669eb8 commit 0355ccf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/NpcBots/bot_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0355ccf

Please sign in to comment.