diff --git a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp index cf12bb8e..8b3b331e 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp @@ -57,8 +57,14 @@ uint32 GrobbulusRotateAction::GetCurrWaypoint() return false; } EventMap* eventMap = &boss_ai->events; - const uint32 event_time = eventMap->GetNextEventTime(2); - return (event_time / 15000) % intervals; + + // avoids division/modulo by zero + if (!eventMap->HasTimeUntilEvent(2) || intervals == 0) + return 0; + + const Milliseconds event_time = eventMap->GetTimeUntilEvent(2); + uint32 event_ms = static_cast(event_time.count()); + return (event_ms / 15000) % intervals; } bool HeiganDanceAction::CalculateSafe() @@ -73,12 +79,17 @@ bool HeiganDanceAction::CalculateSafe() { return false; } + EventMap* eventMap = &boss_ai->events; uint32 curr_phase = boss_ai->currentPhase; - uint32 curr_erupt = eventMap->GetNextEventTime(3); - uint32 curr_dance = eventMap->GetNextEventTime(4); - uint32 curr_timer = eventMap->GetTimer(); - if ((curr_phase == 0 && curr_dance - curr_timer >= 85000) || (curr_phase == 1 && curr_dance - curr_timer >= 40000)) + + // Get remaining time until events + Milliseconds curr_erupt = eventMap->GetTimeUntilEvent(3); + Milliseconds curr_dance = eventMap->GetTimeUntilEvent(4); + + // Replace timer subtraction with the fact that GetTimeUntilEvent() already gives remaining time + if ((curr_phase == 0 && curr_dance >= Milliseconds(85000)) || + (curr_phase == 1 && curr_dance >= Milliseconds(40000))) { ResetSafe(); } @@ -86,8 +97,11 @@ bool HeiganDanceAction::CalculateSafe() { NextSafe(); } + + // Save previous values prev_phase = curr_phase; prev_erupt = curr_erupt; + return true; } @@ -1113,4 +1127,4 @@ bool LoathebChooseTargetAction::Execute(Event event) return false; } return Attack(target); -} \ No newline at end of file +} diff --git a/src/strategy/raids/naxxramas/RaidNaxxActions.h b/src/strategy/raids/naxxramas/RaidNaxxActions.h index 506fa626..3949094e 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxActions.h +++ b/src/strategy/raids/naxxramas/RaidNaxxActions.h @@ -9,6 +9,7 @@ #include "Playerbots.h" #include "RaidNaxxBossHelper.h" #include "RaidNaxxScripts.h" +#include "SharedDefines.h" // just for test // class TryToGetBossAIAction : public Action @@ -62,8 +63,8 @@ public: HeiganDanceAction(PlayerbotAI* ai) : MovementAction(ai, "heigan dance") { this->prev_phase = 0; - this->prev_erupt = 0; - this->prev_timer = 0; + this->prev_erupt = Milliseconds(0); + this->prev_timer = Milliseconds(0); ResetSafe(); waypoints.push_back(std::make_pair(2794.88f, -3668.12f)); waypoints.push_back(std::make_pair(2775.49f, -3674.43f)); @@ -86,7 +87,8 @@ protected: curr_dir = -curr_dir; } } - uint32 prev_phase, prev_erupt, prev_timer; + uint32 prev_phase; + Milliseconds prev_erupt, prev_timer; uint32 curr_safe, curr_dir; std::vector> waypoints; }; @@ -321,4 +323,4 @@ private: LoathebBossHelper helper; }; -#endif \ No newline at end of file +#endif diff --git a/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h b/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h index a5c781f9..83e48ddf 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h +++ b/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h @@ -60,7 +60,7 @@ public: { return false; } - _timer = 0; //_event_map->GetTimer(); TODO: change back, still testing + _timer = _event_map->GetTimer(); return true; } virtual void Reset() @@ -218,7 +218,7 @@ public: private: const uint32 POSITION_TIME_AFTER_LANDED = 5000; const uint32 EVENT_FLIGHT_INTERVAL = 45000; - Milliseconds lastEventGround = 0ms; + Milliseconds lastEventGround = Milliseconds(0); }; class GluthBossHelper : public GenericBossHelper @@ -298,7 +298,7 @@ public: lady = nullptr; ladyAI = nullptr; ladyEvent = nullptr; - lastEventVoidZone = 0ms; + lastEventVoidZone = Milliseconds(0); voidZoneCounter = 0; posToGo = 0; } @@ -367,7 +367,7 @@ protected: Unit* lady = nullptr; FourHorsemen::boss_four_horsemen::boss_four_horsemenAI* ladyAI = nullptr; EventMap* ladyEvent = nullptr; - Milliseconds lastEventVoidZone = 0ms; + Milliseconds lastEventVoidZone = Milliseconds(0); uint32 voidZoneCounter = 0; int posToGo = 0; }; diff --git a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp index 3b41ec0d..ec029b71 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp @@ -19,6 +19,7 @@ #include "ShamanActions.h" #include "UseMeetingStoneAction.h" #include "WarriorActions.h" +#include "SharedDefines.h" float GrobbulusMultiplier::GetValue(Action* action) { @@ -48,16 +49,20 @@ float HeiganDanceMultiplier::GetValue(Action* action) } EventMap* eventMap = &boss_ai->events; uint32 curr_phase = boss_ai->currentPhase; - uint32 curr_dance = eventMap->GetNextEventTime(4); - uint32 curr_timer = eventMap->GetTimer(); - uint32 curr_erupt = eventMap->GetNextEventTime(3); + + // Get remaining time until events + Milliseconds curr_dance = eventMap->GetTimeUntilEvent(4); + Milliseconds curr_erupt = eventMap->GetTimeUntilEvent(3); + if (dynamic_cast(action) || dynamic_cast(action) || - dynamic_cast(action) ) + dynamic_cast(action)) { return 0.0f; } - if (curr_phase != 1 && (int32)curr_dance - curr_timer >= 3000) + + // Replace old subtraction with direct comparison + if (curr_phase != 1 && curr_dance >= Milliseconds(3000)) { return 1.0f; } diff --git a/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp b/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp index f4575141..d2f3c2de 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp @@ -4,6 +4,7 @@ #include "Playerbots.h" #include "ScriptedCreature.h" #include "Trigger.h" +#include "SharedDefines.h" bool AuraRemovedTrigger::IsActive() { @@ -41,12 +42,16 @@ bool BossEventTrigger::IsActive() { return false; } - const uint32 event_time = eventMap->GetNextEventTime(event_id); - if (event_time != last_event_time) + Milliseconds event_time = eventMap->GetTimeUntilEvent(event_id); + if (event_time == Milliseconds::max()) + return false; + + if (last_event_time.count() == 0 || event_time != last_event_time) { last_event_time = event_time; return true; } + return false; } diff --git a/src/strategy/raids/naxxramas/RaidNaxxTriggers.h b/src/strategy/raids/naxxramas/RaidNaxxTriggers.h index ec10c5de..56a4e726 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxTriggers.h +++ b/src/strategy/raids/naxxramas/RaidNaxxTriggers.h @@ -41,12 +41,13 @@ public: { this->boss_entry = boss_entry; this->event_id = event_id; - this->last_event_time = -1; + this->last_event_time = Milliseconds(0); } virtual bool IsActive(); protected: - uint32 boss_entry, event_id, last_event_time; + uint32 boss_entry, event_id; + Milliseconds last_event_time; }; class GrobbulusCloudTrigger : public BossEventTrigger @@ -221,4 +222,4 @@ private: LoathebBossHelper helper; }; -#endif \ No newline at end of file +#endif