diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Utilities/TaskScheduler.cpp | 11 | ||||
-rw-r--r-- | src/common/Utilities/TaskScheduler.h | 6 | ||||
-rw-r--r-- | src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp | 19 |
4 files changed, 24 insertions, 14 deletions
diff --git a/src/common/Utilities/TaskScheduler.cpp b/src/common/Utilities/TaskScheduler.cpp index 6f8978f3c8..8e07e0ed03 100644 --- a/src/common/Utilities/TaskScheduler.cpp +++ b/src/common/Utilities/TaskScheduler.cpp @@ -124,9 +124,9 @@ bool TaskScheduler::IsGroupScheduled(group_t const group) return _task_holder.IsGroupQueued(group); } -Milliseconds TaskScheduler::GetNextGroupOcurrence(group_t const group) const +Milliseconds TaskScheduler::GetNextGroupOccurrence(group_t const group) const { - return std::chrono::duration_cast<std::chrono::milliseconds>(_task_holder.GetNextGroupOcurrence(group) - clock_t::now()); + return std::chrono::duration_cast<std::chrono::milliseconds>(_task_holder.GetNextGroupOccurrence(group) - clock_t::now()); } void TaskScheduler::TaskQueue::Push(TaskContainer&& task) @@ -194,15 +194,12 @@ bool TaskScheduler::TaskQueue::IsGroupQueued(group_t const group) return false; } -TaskScheduler::timepoint_t TaskScheduler::TaskQueue::GetNextGroupOcurrence(group_t const group) const +TaskScheduler::timepoint_t TaskScheduler::TaskQueue::GetNextGroupOccurrence(group_t const group) const { TaskScheduler::timepoint_t next = TaskScheduler::timepoint_t::max(); for (auto const& task : container) - { if (task->IsInGroup(group) && task->_end < next) next = task->_end; - } - return next; } @@ -248,7 +245,7 @@ TaskScheduler::repeated_t TaskContext::GetRepeatCounter() const return _task->_repeated; } -TaskScheduler::timepoint_t TaskContext::GetNextOcurrence() const +TaskScheduler::timepoint_t TaskContext::GetNextOccurrence() const { return _task->_end; } diff --git a/src/common/Utilities/TaskScheduler.h b/src/common/Utilities/TaskScheduler.h index b85ad54978..4e422d6375 100644 --- a/src/common/Utilities/TaskScheduler.h +++ b/src/common/Utilities/TaskScheduler.h @@ -149,7 +149,7 @@ class TaskScheduler bool IsGroupQueued(group_t const group); // Returns the next group occurrence. - TaskScheduler::timepoint_t GetNextGroupOcurrence(group_t const group) const; + TaskScheduler::timepoint_t GetNextGroupOccurrence(group_t const group) const; bool IsEmpty() const; }; @@ -377,7 +377,7 @@ public: } // Returns the next group occurrence. - Milliseconds GetNextGroupOcurrence(group_t const group) const; + Milliseconds GetNextGroupOccurrence(group_t const group) const; private: /// Insert a new task to the enqueued tasks. @@ -483,7 +483,7 @@ public: /// Returns the repeat counter which increases every time the task is repeated. TaskScheduler::repeated_t GetRepeatCounter() const; - TaskScheduler::timepoint_t GetNextOcurrence() const; + TaskScheduler::timepoint_t GetNextOccurrence() const; /// Repeats the event and sets a new duration. /// std::chrono::seconds(5) for example. diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp index 11cf383a0f..d2b04f3184 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp @@ -98,7 +98,7 @@ struct boss_akilzon : public BossAI }); ScheduleTimedEvent(20s, 30s, [&] { - if (scheduler.GetNextGroupOcurrence(GROUP_ELECTRICAL_STORM) > 5s) + if (scheduler.GetNextGroupOccurrence(GROUP_ELECTRICAL_STORM) > 5s) DoCastRandomTarget(SPELL_GUST_OF_WIND, 1); }, 20s, 30s); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp index 5f5f05a341..9c9b1514df 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp @@ -135,7 +135,8 @@ enum Misc MAX_ADD_COUNT = 4, ADDITIONAL_CLASS_SPRIEST = 11, AURA_SHADOW_FORM = 15473, - GROUP_CLASS_ABILITY = 1 + GROUP_CLASS_ABILITY = 1, + GROUP_DRAIN_POWER = 2 }; enum AbilityTarget @@ -242,12 +243,15 @@ struct boss_hexlord_malacrass : public BossAI BossAI::Reset(); _currentClass = CLASS_NONE; _classAbilityTimer = 10000ms; + _timeUntilNextDrainPower = 0ms; SpawnAdds(); ScheduleHealthCheckEvent(80, [&] { - ScheduleTimedEvent(1s, [&] { + scheduler.Schedule(1s, GROUP_DRAIN_POWER, [this](TaskContext context) + { DoCastSelf(SPELL_DRAIN_POWER, true); Talk(SAY_DRAIN_POWER); - }, 30s); + context.Repeat(30s); + }); }); } @@ -282,6 +286,14 @@ struct boss_hexlord_malacrass : public BossAI ScheduleTimedEvent(30s, [&]{ scheduler.CancelGroup(GROUP_CLASS_ABILITY); DoCastSelf(SPELL_SPIRIT_BOLTS); + // Delay Drain Power if it's currently within 10s of being cast + // TODO: see what is wrong with GetNextGroupOccurrence as the timers don't seem correct on resets + _timeUntilNextDrainPower = scheduler.GetNextGroupOccurrence(GROUP_DRAIN_POWER); + if (_timeUntilNextDrainPower > 0s && _timeUntilNextDrainPower < 10s) + { + std::chrono::milliseconds delayTime = 10s - _timeUntilNextDrainPower + 1s; + scheduler.DelayGroup(GROUP_DRAIN_POWER, delayTime); + } scheduler.Schedule(10s, [this](TaskContext) { if (Creature* siphonTrigger = me->SummonCreature(NPC_TEMP_TRIGGER, me->GetPosition(), TEMPSUMMON_TIMED_DESPAWN, 30000)) @@ -354,6 +366,7 @@ struct boss_hexlord_malacrass : public BossAI private: uint8 _currentClass; std::chrono::milliseconds _classAbilityTimer; + std::chrono::milliseconds _timeUntilNextDrainPower; std::vector<uint8> _creatureIndex; }; |