mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-07 20:51:09 +00:00
# Pull Request The purposes of this PR are to (1) establish a general raid helper framework for the benefit of future raid strategies and (2) make some improvements to problematic areas of the raid strategy code. List of changes: 1. Added new RaidBossHelpers.cpp and RaidBossHelpers.h files in the Raid folder. 3. Moved reused helpers from Karazhan, Gruul, and Magtheridon strategies to the new helper files. 4. Modified the prior function that assigned a DPS bot to store and erase timers and trackers in associative containers--the function now includes parameters for mapId (so a bot that is not in the instance will not be assigned) and for the ability to exclude a bot (useful for excluding particular important roles, such as a Warlock tank, so they are not bogged down by these extra tasks at critical moments). I also renamed it from IsInstanceTimerManager to IsMechanicTrackerBot. 5. Moved all helper files in raid strategies to Util folders (was needed for ICC, MC, and Ulduar). 6. Renamed and reordered includes of Ulduar files in AiObjectContext.cpp to match other raid strategies. a. This initially caused compile errors which made me realize that the existing code had several problems with missing includes and was compiling only due to the prior ordering in AiObjectContext.cpp. Therefore, I added the missing includes to Molten Core, Ulduar, and Vault of Archavon strategies. b. Ulduar and Old Kingdom were also using the same constant name for a spell--the reordering caused a compile error here as well, which just highlighted an existing problem that was being hidden. I renamed the constant for Ulduar to fix this, but I think the better approach going forward would be to use a namespace or enum class. But that is for another time and probably another person. 7. Several changes with respect to Ulduar files: a. The position constants and enums for spells and NPCs and such were in the trigger header file. I did not think that made sense so moved them to existing helper files. b. Since the strategy does not use multipliers, I removed all files and references to multipliers in it. c. I removed some unneeded includes. I did not do a detailed review to determine what else could be removed--I just took some out that I could tell right away were not needed. d. I renamed the ingame strategy name from "uld" to "ulduar," which I think is clearer and is still plenty short. 8. Partial refactor of Gruul and Magtheridon strategies: a. I did not due a full refactoring but made some quick changes to things I did previously that were rather stupid like repeating calculations, having useless logic like pointless IsAlive() checks for creatures already on the hostile references list, and not using the existing Position class for coordinates. b. There were a few substantive changes, such as allowing players to pick Maulgar mage and moonkin tanks with the assistant flag, but a greater refactoring of the strategies themselves is beyond this PR. c. I was clearing some containers used for Gruul and Magtheridon strategies; the methods are now fixed to erase only the applicable keys so that in the unlikely event that one server has multiple groups running Gruul or Magtheridon at the same time, there won't be timer or position tracker conflicts. ## How to Test the Changes 1. Enter any raid instance that has any code impacted by this PR 2. Engage bosses and observe if any strategies are now broken I personally tested Maulgar, Gruul, and Magtheridon and confirmed that they still work as intended. ## Complexity & Impact I do not expect this PR to have any relevant changes to in-game performance, but I will defer to those more knowledgeable than I if there are concerns in this area. As I've mentioned before, you can consider me to be like a person who has taken half an intro C++ course at best. ## AI Assistance None beyond autocomplete of repetitive changes. --------- Co-authored-by: bashermens <31279994+hermensbas@users.noreply.github.com>
76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
#include <unordered_map>
|
|
#include <ctime>
|
|
|
|
#include "RaidMagtheridonMultipliers.h"
|
|
#include "RaidMagtheridonActions.h"
|
|
#include "RaidMagtheridonHelpers.h"
|
|
#include "ChooseTargetActions.h"
|
|
#include "GenericSpellActions.h"
|
|
#include "Playerbots.h"
|
|
#include "WarlockActions.h"
|
|
#include "WipeAction.h"
|
|
|
|
using namespace MagtheridonHelpers;
|
|
|
|
// Don't do anything other than clicking cubes when Magtheridon is casting Blast Nova
|
|
float MagtheridonUseManticronCubeMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* magtheridon = AI_VALUE2(Unit*, "find target", "magtheridon");
|
|
if (!magtheridon)
|
|
return 1.0f;
|
|
|
|
if (magtheridon->HasUnitState(UNIT_STATE_CASTING) &&
|
|
magtheridon->FindCurrentSpellBySpellId(SPELL_BLAST_NOVA))
|
|
{
|
|
auto it = botToCubeAssignment.find(bot->GetGUID());
|
|
if (it != botToCubeAssignment.end())
|
|
{
|
|
if (dynamic_cast<WipeAction*>(action))
|
|
return 1.0f;
|
|
else if (!dynamic_cast<MagtheridonUseManticronCubeAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Bots will wait for 6 seconds after Magtheridon becomes attackable before engaging
|
|
float MagtheridonWaitToAttackMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* magtheridon = AI_VALUE2(Unit*, "find target", "magtheridon");
|
|
if (!magtheridon || magtheridon->HasAura(SPELL_SHADOW_CAGE))
|
|
return 1.0f;
|
|
|
|
if (botAI->IsMainTank(bot))
|
|
return 1.0f;
|
|
|
|
const uint8 dpsWaitSeconds = 6;
|
|
auto it = dpsWaitTimer.find(magtheridon->GetMap()->GetInstanceId());
|
|
if (it == dpsWaitTimer.end() ||
|
|
(time(nullptr) - it->second) < dpsWaitSeconds)
|
|
{
|
|
if (dynamic_cast<AttackAction*>(action) ||
|
|
(!botAI->IsHeal(bot) && dynamic_cast<CastSpellAction*>(action)))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
float MagtheridonDisableOffTankAssistMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* magtheridon = AI_VALUE2(Unit*, "find target", "magtheridon");
|
|
if (!magtheridon)
|
|
return 1.0f;
|
|
|
|
if (bot->GetVictim() == nullptr)
|
|
return 1.0f;
|
|
|
|
if ((botAI->IsAssistTankOfIndex(bot, 0) || botAI->IsAssistTankOfIndex(bot, 1)) &&
|
|
dynamic_cast<TankAssistAction*>(action))
|
|
return 0.0f;
|
|
|
|
return 1.0f;
|
|
}
|