diff options
author | Peter Keresztes Schmidt <carbenium@outlook.com> | 2020-07-14 20:46:18 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-01-23 16:00:27 +0100 |
commit | d62b7c1e352e76f35490c22b2ab291ed299f4fa4 (patch) | |
tree | 7b53c5225e4830958d9f11d1880165181f3cb410 | |
parent | b27c70aff2ec6ec872fa149e7853d95876104dfe (diff) |
Core/CombatAI: Use std::chrono::duration overloads of EventMap (#25037)
Contributes to #25012
(cherry picked from commit bd837d4c3dc61e7817ccb14071108e97db86f1f5)
-rw-r--r-- | src/server/game/AI/CoreAI/CombatAI.cpp | 12 | ||||
-rw-r--r-- | src/server/game/AI/CoreAI/UnitAI.cpp | 6 | ||||
-rw-r--r-- | src/server/game/AI/CreatureAIImpl.h | 4 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 919215e91b4..982401db0dc 100644 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -84,7 +84,7 @@ void CombatAI::JustEngagedWith(Unit* who) if (info->condition == AICOND_AGGRO) me->CastSpell(who, spell, false); else if (info->condition == AICOND_COMBAT) - Events.ScheduleEvent(spell, info->cooldown + rand32() % info->cooldown); + Events.ScheduleEvent(spell, info->cooldown, info->cooldown * 2); } } } @@ -103,7 +103,7 @@ void CombatAI::UpdateAI(uint32 diff) { DoCast(spellId); if (AISpellInfoType const* info = GetAISpellInfo(spellId, me->GetMap()->GetDifficultyID())) - Events.ScheduleEvent(spellId, info->cooldown + rand32() % info->cooldown); + Events.ScheduleEvent(spellId, info->cooldown, info->cooldown * 2); } else DoMeleeAttackIfReady(); @@ -111,7 +111,7 @@ void CombatAI::UpdateAI(uint32 diff) void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) { - Events.RescheduleEvent(spellId, unTimeMs); + Events.RescheduleEvent(spellId, Milliseconds(unTimeMs)); } ///////////////// @@ -148,11 +148,11 @@ void CasterAI::JustEngagedWith(Unit* who) me->CastSpell(who, *itr, false); else if (info->condition == AICOND_COMBAT) { - uint32 cooldown = info->realCooldown; + Milliseconds cooldown = info->realCooldown; if (count == spell) { DoCast(Spells[spell]); - cooldown += me->GetCurrentSpellCastTime(*itr); + cooldown += Milliseconds(me->GetCurrentSpellCastTime(*itr)); } Events.ScheduleEvent(*itr, cooldown); } @@ -181,7 +181,7 @@ void CasterAI::UpdateAI(uint32 diff) DoCast(spellId); uint32 casttime = me->GetCurrentSpellCastTime(spellId); if (AISpellInfoType const* info = GetAISpellInfo(spellId, me->GetMap()->GetDifficultyID())) - Events.ScheduleEvent(spellId, (casttime ? casttime : 500) + info->realCooldown); + Events.ScheduleEvent(spellId, Milliseconds(casttime ? casttime : 500) + info->realCooldown); } } diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index ee019e4e0a9..bf4457caa86 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -198,8 +198,8 @@ void UnitAI::FillAISpellInfo() else AIInfo->condition = AICOND_COMBAT; - if (AIInfo->cooldown < spellInfo->RecoveryTime) - AIInfo->cooldown = spellInfo->RecoveryTime; + if (AIInfo->cooldown.count() < int32(spellInfo->RecoveryTime)) + AIInfo->cooldown = Milliseconds(spellInfo->RecoveryTime); if (!spellInfo->GetMaxRange(false)) UPDATE_TARGET(AITARGET_SELF) @@ -224,7 +224,7 @@ void UnitAI::FillAISpellInfo() } } } - AIInfo->realCooldown = spellInfo->RecoveryTime + spellInfo->StartRecoveryTime; + AIInfo->realCooldown = Milliseconds(spellInfo->RecoveryTime + spellInfo->StartRecoveryTime); AIInfo->maxRange = spellInfo->GetMaxRange(false) * 3 / 4; AIInfo->Effects = 0; diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index c8425fb08eb..c50d2a2eb33 100644 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -78,8 +78,8 @@ struct AISpellInfoType , cooldown(AI_DEFAULT_COOLDOWN), realCooldown(0), maxRange(0.0f){ } AITarget target; AICondition condition; - uint32 cooldown; - uint32 realCooldown; + Milliseconds cooldown; + Milliseconds realCooldown; float maxRange; uint8 Targets; // set of enum SelectTarget |