Skip to content

Commit

Permalink
TimerAI: Do not reset timers on evade for TIMER_ALWAYS
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Sep 25, 2023
1 parent 954645f commit e512fc1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/game/AI/BaseAI/CreatureAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CreatureAI::CreatureAI(Creature* creature, uint32 combatActions) :

void CreatureAI::Reset()
{
ResetAllTimers();
ResetTimersOnEvade();
m_currentRangedMode = m_rangedMode;
m_attackDistance = m_chaseDistance;
}
Expand Down
22 changes: 22 additions & 0 deletions src/game/AI/ScriptDevAI/base/TimerAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ void TimerManager::ResetAllTimers()
data.second.ResetTimer();
}

void TimerManager::ResetTimersOnEvade()
{
for (auto& data : m_timers)
if (data.second.combatSetting != TIMER_ALWAYS)
data.second.ResetTimer();
}

void TimerManager::GetAIInformation(ChatHandler& reader)
{
reader.PSendSysMessage("TimerAI: Timers:");
Expand Down Expand Up @@ -187,6 +194,21 @@ void CombatActions::ResetAllTimers()
TimerManager::ResetAllTimers();
}

void CombatActions::ResetTimersOnEvade()
{
for (uint32 i = 0; i < m_actionReadyStatus.size(); ++i)
{
auto itr = m_timerlessActionSettings.find(i);
if (itr == m_timerlessActionSettings.end())
m_actionReadyStatus[i] = false;
else
m_actionReadyStatus[i] = (*itr).second;
}
for (auto& data : m_combatActions)
data.second.ResetTimer();
TimerManager::ResetTimersOnEvade();
}

void CombatActions::AddCombatAction(uint32 id, bool disabled)
{
m_combatActions.emplace(id, Timer(id, [&, id] { m_actionReadyStatus[id] = true; }, 0, 0, TIMER_COMBAT_COMBAT, disabled));
Expand Down
8 changes: 5 additions & 3 deletions src/game/AI/ScriptDevAI/base/TimerAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class ChatHandler;

enum TimerCombat
{
TIMER_COMBAT_OOC = 0,
TIMER_COMBAT_COMBAT = 1,
TIMER_ALWAYS = 2
TIMER_COMBAT_OOC = 0, // reset on evade
TIMER_COMBAT_COMBAT = 1, // reset on evade
TIMER_ALWAYS = 2, // reset on spawn
};

/*
Expand Down Expand Up @@ -104,6 +104,7 @@ class TimerManager
virtual void UpdateTimers(const uint32 diff);
virtual void UpdateTimers(const uint32 diff, bool combat);
virtual void ResetAllTimers();
virtual void ResetTimersOnEvade();

virtual void GetAIInformation(ChatHandler& reader);

Expand Down Expand Up @@ -191,6 +192,7 @@ class CombatActions : public TimerManager
virtual void UpdateTimers(const uint32 diff, bool combat) override;
virtual void ExecuteActions() = 0;
virtual void ResetAllTimers() override;
virtual void ResetTimersOnEvade() override;

virtual void GetAIInformation(ChatHandler& reader) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,6 @@ struct mob_water_globuleAI : public ScriptedAI

bool m_initialAggro;

void Reset() override
{
ResetAllTimers();
}

void JustRespawned() override
{
ScriptedAI::JustRespawned();
Expand Down

0 comments on commit e512fc1

Please sign in to comment.