mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-17 09:04:36 +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>
368 lines
12 KiB
C++
368 lines
12 KiB
C++
#include "RaidKarazhanMultipliers.h"
|
|
#include "RaidKarazhanActions.h"
|
|
#include "RaidKarazhanHelpers.h"
|
|
#include "AttackAction.h"
|
|
#include "ChooseTargetActions.h"
|
|
#include "DruidActions.h"
|
|
#include "FollowActions.h"
|
|
#include "GenericActions.h"
|
|
#include "HunterActions.h"
|
|
#include "MageActions.h"
|
|
#include "Playerbots.h"
|
|
#include "PriestActions.h"
|
|
#include "RaidBossHelpers.h"
|
|
#include "ReachTargetActions.h"
|
|
#include "RogueActions.h"
|
|
#include "ShamanActions.h"
|
|
|
|
using namespace KarazhanHelpers;
|
|
|
|
// Keep tanks from jumping back and forth between Attumen and Midnight
|
|
float AttumenTheHuntsmanDisableTankAssistMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* midnight = AI_VALUE2(Unit*, "find target", "midnight");
|
|
if (!midnight)
|
|
return 1.0f;
|
|
|
|
Unit* attumen = AI_VALUE2(Unit*, "find target", "attumen the huntsman");
|
|
if (!attumen)
|
|
return 1.0f;
|
|
|
|
if (bot->GetVictim() != nullptr && dynamic_cast<TankAssistAction*>(action))
|
|
return 0.0f;
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Try to get rid of jittering when bots are stacked behind Attumen
|
|
float AttumenTheHuntsmanStayStackedMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* attumenMounted = GetFirstAliveUnitByEntry(botAI, NPC_ATTUMEN_THE_HUNTSMAN_MOUNTED);
|
|
if (!attumenMounted)
|
|
return 1.0f;
|
|
|
|
if (!botAI->IsMainTank(bot) && attumenMounted->GetVictim() != bot)
|
|
{
|
|
if (dynamic_cast<CombatFormationMoveAction*>(action) ||
|
|
dynamic_cast<FleeAction*>(action) ||
|
|
dynamic_cast<CastBlinkBackAction*>(action) ||
|
|
dynamic_cast<CastDisengageAction*>(action) ||
|
|
dynamic_cast<CastReachTargetSpellAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Give the main tank 8 seconds to grab aggro when Attumen mounts Midnight
|
|
// In reality it's shorter because it takes Attumen a few seconds to aggro after mounting
|
|
float AttumenTheHuntsmanWaitForDpsMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* attumenMounted = GetFirstAliveUnitByEntry(botAI, NPC_ATTUMEN_THE_HUNTSMAN_MOUNTED);
|
|
if (!attumenMounted)
|
|
return 1.0f;
|
|
|
|
const uint32 instanceId = attumenMounted->GetMap()->GetInstanceId();
|
|
const time_t now = std::time(nullptr);
|
|
const uint8 dpsWaitSeconds = 8;
|
|
|
|
auto it = attumenDpsWaitTimer.find(instanceId);
|
|
if (it == attumenDpsWaitTimer.end() || (now - it->second) < dpsWaitSeconds)
|
|
{
|
|
if (!botAI->IsMainTank(bot))
|
|
{
|
|
if (dynamic_cast<AttackAction*>(action) || (dynamic_cast<CastSpellAction*>(action) &&
|
|
!dynamic_cast<CastHealingSpellAction*>(action)))
|
|
return 0.0f;
|
|
}
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// The assist tank should stay on the boss to be 2nd on aggro and tank Hateful Bolts
|
|
float TheCuratorDisableTankAssistMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* curator = AI_VALUE2(Unit*, "find target", "the curator");
|
|
if (!curator)
|
|
return 1.0f;
|
|
|
|
if (bot->GetVictim() != nullptr && dynamic_cast<TankAssistAction*>(action))
|
|
return 0.0f;
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Save Bloodlust/Heroism for Evocation (100% increased damage)
|
|
float TheCuratorDelayBloodlustAndHeroismMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* curator = AI_VALUE2(Unit*, "find target", "the curator");
|
|
if (!curator)
|
|
return 1.0f;
|
|
|
|
if (!curator->HasAura(SPELL_CURATOR_EVOCATION))
|
|
{
|
|
if (dynamic_cast<CastBloodlustAction*>(action) ||
|
|
dynamic_cast<CastHeroismAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Don't charge back in when running from Arcane Explosion
|
|
float ShadeOfAranArcaneExplosionDisableChargeMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* aran = AI_VALUE2(Unit*, "find target", "shade of aran");
|
|
if (!aran)
|
|
return 1.0f;
|
|
|
|
if (aran->HasUnitState(UNIT_STATE_CASTING) &&
|
|
aran->FindCurrentSpellBySpellId(SPELL_ARCANE_EXPLOSION))
|
|
{
|
|
if (dynamic_cast<CastReachTargetSpellAction*>(action))
|
|
return 0.0f;
|
|
|
|
if (bot->GetDistance2d(aran) >= 20.0f)
|
|
{
|
|
if (dynamic_cast<CombatFormationMoveAction*>(action) ||
|
|
dynamic_cast<FleeAction*>(action) ||
|
|
dynamic_cast<FollowAction*>(action) ||
|
|
dynamic_cast<ReachTargetAction*>(action) ||
|
|
dynamic_cast<AvoidAoeAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// I will not move when Flame Wreath is cast or the raid blows up
|
|
float ShadeOfAranFlameWreathDisableMovementMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* aran = AI_VALUE2(Unit*, "find target", "shade of aran");
|
|
if (!aran)
|
|
return 1.0f;
|
|
|
|
if (IsFlameWreathActive(botAI, bot))
|
|
{
|
|
if (dynamic_cast<CombatFormationMoveAction*>(action) ||
|
|
dynamic_cast<FleeAction*>(action) ||
|
|
dynamic_cast<FollowAction*>(action) ||
|
|
dynamic_cast<ReachTargetAction*>(action) ||
|
|
dynamic_cast<AvoidAoeAction*>(action) ||
|
|
dynamic_cast<CastKillingSpreeAction*>(action) ||
|
|
dynamic_cast<CastBlinkBackAction*>(action) ||
|
|
dynamic_cast<CastDisengageAction*>(action) ||
|
|
dynamic_cast<CastReachTargetSpellAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Try to rid of the jittering when blocking beams
|
|
float NetherspiteKeepBlockingBeamMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* netherspite = AI_VALUE2(Unit*, "find target", "netherspite");
|
|
if (!netherspite || netherspite->HasAura(SPELL_NETHERSPITE_BANISHED))
|
|
return 1.0f;
|
|
|
|
auto [redBlocker, greenBlocker, blueBlocker] = GetCurrentBeamBlockers(botAI, bot);
|
|
|
|
if (bot == redBlocker)
|
|
{
|
|
if (dynamic_cast<CombatFormationMoveAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
if (bot == blueBlocker)
|
|
{
|
|
if (dynamic_cast<CombatFormationMoveAction*>(action) ||
|
|
dynamic_cast<ReachTargetAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
if (bot == greenBlocker)
|
|
{
|
|
if (dynamic_cast<CombatFormationMoveAction*>(action) ||
|
|
dynamic_cast<ReachTargetAction*>(action) ||
|
|
dynamic_cast<FleeAction*>(action) ||
|
|
dynamic_cast<CastKillingSpreeAction*>(action) ||
|
|
dynamic_cast<CastReachTargetSpellAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Give tanks 5 seconds to get aggro during phase transitions
|
|
float NetherspiteWaitForDpsMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* netherspite = AI_VALUE2(Unit*, "find target", "netherspite");
|
|
if (!netherspite || netherspite->HasAura(SPELL_NETHERSPITE_BANISHED))
|
|
return 1.0f;
|
|
|
|
const uint32 instanceId = netherspite->GetMap()->GetInstanceId();
|
|
const time_t now = std::time(nullptr);
|
|
const uint8 dpsWaitSeconds = 5;
|
|
|
|
auto it = netherspiteDpsWaitTimer.find(instanceId);
|
|
if (it == netherspiteDpsWaitTimer.end() || (now - it->second) < dpsWaitSeconds)
|
|
{
|
|
if (!botAI->IsTank(bot))
|
|
{
|
|
if (dynamic_cast<AttackAction*>(action) || (dynamic_cast<CastSpellAction*>(action) &&
|
|
!dynamic_cast<CastHealingSpellAction*>(action)))
|
|
return 0.0f;
|
|
}
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Disable standard "avoid aoe" strategy, which may interfere with scripted avoidance
|
|
float PrinceMalchezaarDisableAvoidAoeMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* malchezaar = AI_VALUE2(Unit*, "find target", "prince malchezaar");
|
|
if (!malchezaar)
|
|
return 1.0f;
|
|
|
|
if (dynamic_cast<AvoidAoeAction*>(action))
|
|
return 0.0f;
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Don't run back into Shadow Nova when Enfeebled
|
|
float PrinceMalchezaarEnfeebleKeepDistanceMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* malchezaar = AI_VALUE2(Unit*, "find target", "prince malchezaar");
|
|
if (!malchezaar)
|
|
return 1.0f;
|
|
|
|
if (bot->HasAura(SPELL_ENFEEBLE))
|
|
{
|
|
if (dynamic_cast<CastReachTargetSpellAction*>(action))
|
|
return 0.0f;
|
|
|
|
if (dynamic_cast<MovementAction*>(action) &&
|
|
!dynamic_cast<PrinceMalchezaarEnfeebledAvoidHazardAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Wait until Phase 3 to use Bloodlust/Heroism
|
|
float PrinceMalchezaarDelayBloodlustAndHeroismMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* malchezaar = AI_VALUE2(Unit*, "find target", "prince malchezaar");
|
|
if (!malchezaar)
|
|
return 1.0f;
|
|
|
|
if (malchezaar->GetHealthPct() > 30.0f)
|
|
{
|
|
if (dynamic_cast<CastBloodlustAction*>(action) ||
|
|
dynamic_cast<CastHeroismAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Pets tend to run out of bounds and cause skeletons to spawn off the map
|
|
// Pets also tend to pull adds from inside of the tower through the floor
|
|
// This multiplier DOES NOT impact Hunter and Warlock pets
|
|
// Hunter and Warlock pets are addressed in ControlPetAggressionAction
|
|
float NightbaneDisablePetsMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* nightbane = AI_VALUE2(Unit*, "find target", "nightbane");
|
|
if (!nightbane)
|
|
return 1.0f;
|
|
|
|
if (dynamic_cast<CastForceOfNatureAction*>(action) ||
|
|
dynamic_cast<CastFeralSpiritAction*>(action) ||
|
|
dynamic_cast<CastFireElementalTotemAction*>(action) ||
|
|
dynamic_cast<CastFireElementalTotemMeleeAction*>(action) ||
|
|
dynamic_cast<CastSummonWaterElementalAction*>(action) ||
|
|
dynamic_cast<CastShadowfiendAction*>(action))
|
|
return 0.0f;
|
|
|
|
if (nightbane->GetPositionZ() > NIGHTBANE_FLIGHT_Z)
|
|
{
|
|
if (dynamic_cast<PetAttackAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Give the main tank 8 seconds to get aggro during phase transitions
|
|
float NightbaneWaitForDpsMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* nightbane = AI_VALUE2(Unit*, "find target", "nightbane");
|
|
if (!nightbane || nightbane->GetPositionZ() > NIGHTBANE_FLIGHT_Z)
|
|
return 1.0f;
|
|
|
|
const uint32 instanceId = nightbane->GetMap()->GetInstanceId();
|
|
const time_t now = std::time(nullptr);
|
|
const uint8 dpsWaitSeconds = 8;
|
|
|
|
auto it = nightbaneDpsWaitTimer.find(instanceId);
|
|
if (it == nightbaneDpsWaitTimer.end() || (now - it->second) < dpsWaitSeconds)
|
|
{
|
|
if (!botAI->IsMainTank(bot))
|
|
{
|
|
if (dynamic_cast<AttackAction*>(action) || (dynamic_cast<CastSpellAction*>(action) &&
|
|
!dynamic_cast<CastHealingSpellAction*>(action)))
|
|
return 0.0f;
|
|
}
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// The "avoid aoe" strategy must be disabled for the main tank
|
|
// Otherwise, the main tank will spin Nightbane to avoid Charred Earth and wipe the raid
|
|
// It is also disabled for all bots during the flight phase
|
|
float NightbaneDisableAvoidAoeMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* nightbane = AI_VALUE2(Unit*, "find target", "nightbane");
|
|
if (!nightbane)
|
|
return 1.0f;
|
|
|
|
if (nightbane->GetPositionZ() > NIGHTBANE_FLIGHT_Z || botAI->IsMainTank(bot))
|
|
{
|
|
if (dynamic_cast<AvoidAoeAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
// Disable some movement actions that conflict with the strategies
|
|
float NightbaneDisableMovementMultiplier::GetValue(Action* action)
|
|
{
|
|
Unit* nightbane = AI_VALUE2(Unit*, "find target", "nightbane");
|
|
if (!nightbane)
|
|
return 1.0f;
|
|
|
|
if (dynamic_cast<CastBlinkBackAction*>(action) ||
|
|
dynamic_cast<CastDisengageAction*>(action) ||
|
|
dynamic_cast<FleeAction*>(action))
|
|
return 0.0f;
|
|
|
|
// Disable CombatFormationMoveAction for all bots except:
|
|
// (1) main tank and (2) only during the ground phase, other melee
|
|
if (botAI->IsRanged(bot) ||
|
|
(botAI->IsMelee(bot) && !botAI->IsMainTank(bot) &&
|
|
nightbane->GetPositionZ() > NIGHTBANE_FLIGHT_Z))
|
|
{
|
|
if (dynamic_cast<CombatFormationMoveAction*>(action))
|
|
return 0.0f;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|