Merge pull request #672 from LFTEC/master

Instance FOS strategy
This commit is contained in:
Bobblybook
2024-11-13 22:40:27 +11:00
committed by GitHub
16 changed files with 365 additions and 4 deletions

View File

@@ -62,6 +62,7 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI)
actionContexts.Add(new WotlkDungeonOccActionContext());
actionContexts.Add(new WotlkDungeonUPActionContext());
actionContexts.Add(new WotlkDungeonCoSActionContext());
actionContexts.Add(new WotlkDungeonFoSActionContext());
triggerContexts.Add(new TriggerContext());
triggerContexts.Add(new ChatTriggerContext());
@@ -84,6 +85,7 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI)
triggerContexts.Add(new WotlkDungeonOccTriggerContext());
triggerContexts.Add(new WotlkDungeonUPTriggerContext());
triggerContexts.Add(new WotlkDungeonCoSTriggerContext());
triggerContexts.Add(new WotlkDungeonFosTriggerContext());
valueContexts.Add(new ValueContext());

View File

@@ -14,6 +14,7 @@
#include "wotlk/oculus/OculusStrategy.h"
#include "wotlk/utgardepinnacle/UtgardePinnacleStrategy.h"
#include "wotlk/cullingofstratholme/CullingOfStratholmeStrategy.h"
#include "wotlk/forgeofsouls/ForgeOfSoulsStrategy.h"
/*
Full list/TODO:
@@ -76,11 +77,12 @@ class DungeonStrategyContext : public NamedObjectContext<Strategy>
static Strategy* wotlk_occ(PlayerbotAI* botAI) { return new WotlkDungeonOccStrategy(botAI); }
static Strategy* wotlk_up(PlayerbotAI* botAI) { return new WotlkDungeonUPStrategy(botAI); }
static Strategy* wotlk_cos(PlayerbotAI* botAI) { return new WotlkDungeonCoSStrategy(botAI); }
static Strategy* wotlk_fos(PlayerbotAI* botAI) { return new WotlkDungeonFoSStrategy(botAI); }
// NYI from here down
static Strategy* wotlk_toc(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); }
static Strategy* wotlk_hor(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); }
static Strategy* wotlk_pos(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); }
static Strategy* wotlk_fos(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); }
};
#endif

View File

@@ -1,7 +1,6 @@
#ifndef _PLAYERBOT_DUNGEONUTILS_H
#define _PLAYERBOT_DUNGEONUTILS_H
template<class T> inline
const T& DUNGEON_MODE(Player* bot, const T& normal5, const T& heroic10)
{

View File

@@ -13,9 +13,9 @@
#include "oculus/OculusActionContext.h"
#include "utgardepinnacle/UtgardePinnacleActionContext.h"
#include "cullingofstratholme/CullingOfStratholmeActionContext.h"
#include "forgeofsouls/ForgeOfSoulsActionContext.h"
// #include "trialofthechampion/TrialOfTheChampionActionContext.h"
// #include "hallsofreflection/HallsOfReflectionActionContext.h"
// #include "pitofsaron/PitOfSaronActionContext.h"
// #include "forgeofsouls/ForgeOfSoulsActionContext.h"
#endif

View File

@@ -13,9 +13,9 @@
#include "oculus/OculusTriggerContext.h"
#include "utgardepinnacle/UtgardePinnacleTriggerContext.h"
#include "cullingofstratholme/CullingOfStratholmeTriggerContext.h"
#include "forgeofsouls/ForgeOfSoulsTriggerContext.h"
// #include "trialofthechampion/TrialOfTheChampionTriggerContext.h"
// #include "hallsofreflection/HallsOfReflectionTriggerContext.h"
// #include "pitofsaron/PitOfSaronTriggerContext.h"
// #include "forgeofsouls/ForgeOfSoulsTriggerContext.h"
#endif

View File

@@ -0,0 +1,23 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONFOSACTIONCONTEXT_H
#define _PLAYERBOT_WOTLKDUNGEONFOSACTIONCONTEXT_H
#include "Action.h"
#include "NamedObjectContext.h"
#include "ForgeOfSoulsActions.h"
class WotlkDungeonFoSActionContext : public NamedObjectContext<Action>
{
public:
WotlkDungeonFoSActionContext()
{
creators["move from bronjahm"] = &WotlkDungeonFoSActionContext::move_from_bronjahm;
creators["attack corrupted soul fragment"] = &WotlkDungeonFoSActionContext::attack_corrupted_soul_fragment;
creators["bronjahm group position"] = &WotlkDungeonFoSActionContext::bronjahm_group_position;
}
private:
static Action* move_from_bronjahm(PlayerbotAI* ai) { return new MoveFromBronjahmAction(ai); }
static Action* attack_corrupted_soul_fragment(PlayerbotAI* ai) { return new AttackCorruptedSoulFragmentAction(ai); }
static Action* bronjahm_group_position(PlayerbotAI* ai) { return new BronjahmGroupPositionAction(ai); }
};
#endif

View File

@@ -0,0 +1,87 @@
#include "Playerbots.h"
#include "ForgeOfSoulsActions.h"
#include "ForgeOfSoulsStrategy.h"
bool MoveFromBronjahmAction::Execute(Event event)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "bronjahm");
if (!boss)
return false;
float distance = bot->GetExactDist2d(boss->GetPosition());
float targetDis = 20.0f;
if (distance >= targetDis)
return false;
return MoveAway(boss, targetDis - distance);
}
bool AttackCorruptedSoulFragmentAction::Execute(Event event)
{
Unit* fragment = nullptr;
GuidVector targets = AI_VALUE(GuidVector, "possible targets no los");
for (auto &target : targets)
{
Unit* unit = botAI->GetUnit(target);
if (unit && unit->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT)
{
fragment = unit;
break;
}
}
if (fragment && AI_VALUE(Unit*, "current target") != fragment)
return Attack(fragment);
return false;
}
bool BronjahmGroupPositionAction::Execute(Event event)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "bronjahm");
if (!boss)
return false;
if (botAI->IsTank(bot))
{
bot->SetTarget(boss->GetGUID());
if (AI_VALUE2(bool, "has aggro", "current target"))
if (bot->GetExactDist2d(BRONJAHM_TANK_POSITION) > 5.0f)
return MoveTo(bot->GetMapId(), BRONJAHM_TANK_POSITION.GetPositionX(),
BRONJAHM_TANK_POSITION.GetPositionY(), BRONJAHM_TANK_POSITION.GetPositionZ(), false,
false, false, true, MovementPriority::MOVEMENT_NORMAL);
else
return Attack(boss);
else
{
return Attack(boss);
}
}
else
{
float maxMovement = 10.0f;
if (bot->GetExactDist2d(boss) > maxMovement)
{
if (bot->getClass() == CLASS_HUNTER)
{
return Move(bot->GetAngle(boss), fmin(bot->GetExactDist2d(boss) - 6.5f, maxMovement));
}
else
{
return Move(bot->GetAngle(boss), fmin(bot->GetExactDist2d(boss) - 2.0f, maxMovement));
}
}
else
return false;
}
}
bool BronjahmGroupPositionAction::isUseful() { return true; }

View File

@@ -0,0 +1,37 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONFOSACTIONS_H
#define _PLAYERBOT_WOTLKDUNGEONFOSACTIONS_H
#include "Action.h"
#include "AttackAction.h"
#include "PlayerbotAI.h"
#include "Playerbots.h"
#include "ForgeOfSoulsTriggers.h"
const Position BRONJAHM_TANK_POSITION = Position(5297.920f, 2506.698f, 686.068f);
class MoveFromBronjahmAction : public MovementAction
{
public:
MoveFromBronjahmAction(PlayerbotAI* ai) : MovementAction(ai, "move from bronjahm") {}
bool Execute(Event event) override;
};
class AttackCorruptedSoulFragmentAction : public AttackAction
{
public:
AttackCorruptedSoulFragmentAction(PlayerbotAI* ai) : AttackAction(ai, "attack corrupted soul fragment") {}
bool Execute(Event event) override;
};
class BronjahmGroupPositionAction : public AttackAction
{
public:
BronjahmGroupPositionAction(PlayerbotAI* ai) : AttackAction(ai, "bronjahm group position") {}
bool Execute(Event event) override;
bool isUseful() override;
};
#endif

View File

@@ -0,0 +1,50 @@
#include "ForgeOfSoulsMultipliers.h"
#include "ForgeOfSoulsActions.h"
#include "GenericSpellActions.h"
#include "ChooseTargetActions.h"
#include "MovementActions.h"
#include "ForgeOfSoulsTriggers.h"
#include "ForgeOfSoulsActions.h"
float BronjahmMultiplier::GetValue(Action* action) {
Unit* boss = AI_VALUE2(Unit *, "find target", "bronjahm");
if (!boss)
return 1.0f;
if (dynamic_cast<TankAssistAction*>(action))
return 0.0f;
if (boss->FindCurrentSpellBySpellId(SPELL_CORRUPT_SOUL) &&
bot->HasAura(SPELL_CORRUPT_SOUL))
{
if (dynamic_cast<MovementAction*>(action) && !dynamic_cast<MoveFromBronjahmAction*>(action))
{
return 0.0f;
}
}
return 1.0f;
}
float AttackFragmentMultiplier::GetValue(Action* action)
{
Unit* fragment = nullptr;
GuidVector targets = AI_VALUE(GuidVector, "possible targets no los");
for (auto& target : targets)
{
Unit* unit = botAI->GetUnit(target);
if (unit && unit->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT)
{
fragment = unit;
break;
}
}
if (fragment && botAI->IsDps(bot) && dynamic_cast<BronjahmGroupPositionAction*>(action))
return 0.0f;
return 1.0f;
}

View File

@@ -0,0 +1,24 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONFOSMULTIPLIERS_H
#define _PLAYERBOT_WOTLKDUNGEONFOSMULTIPLIERS_H
#include "Multiplier.h"
class BronjahmMultiplier : public Multiplier
{
public:
BronjahmMultiplier(PlayerbotAI* ai) : Multiplier(ai, "bronjahm") {}
public:
virtual float GetValue(Action* action);
};
class AttackFragmentMultiplier : public Multiplier
{
public:
AttackFragmentMultiplier(PlayerbotAI* ai) : Multiplier(ai, "attack fragment") { }
float GetValue(Action* action) override;
};
#endif

View File

@@ -0,0 +1,18 @@
#include "ForgeOfSoulsStrategy.h"
#include "ForgeOfSoulsMultipliers.h"
void WotlkDungeonFoSStrategy::InitTriggers(std::vector<TriggerNode*>& triggers) {
triggers.push_back(
new TriggerNode("move from bronjahm",
NextAction::array(0, new NextAction("move from bronjahm", ACTION_MOVE + 5), nullptr)));
triggers.push_back(new TriggerNode(
"switch to soul fragment", NextAction::array(0, new NextAction("attack corrupted soul fragment", ACTION_RAID + 1), nullptr)));
triggers.push_back(new TriggerNode("bronjahm position",
NextAction::array(0, new NextAction("bronjahm group position", ACTION_RAID + 1), nullptr)));
}
void WotlkDungeonFoSStrategy::InitMultipliers(std::vector<Multiplier*>& multipliers)
{
multipliers.push_back(new BronjahmMultiplier(botAI));
multipliers.push_back(new AttackFragmentMultiplier(botAI));
}

View File

@@ -0,0 +1,16 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONFOSSTRATEGY_H
#define _PLAYERBOT_WOTLKDUNGEONFOSSTRATEGY_H
#include "Multiplier.h"
#include "Strategy.h"
class WotlkDungeonFoSStrategy : public Strategy
{
public:
WotlkDungeonFoSStrategy(PlayerbotAI* ai) : Strategy(ai) {}
std::string const getName() override { return "forge of souls"; }
void InitTriggers(std::vector<TriggerNode*> &triggers) override;
void InitMultipliers(std::vector<Multiplier*> &multipliers) override;
};
#endif // !_PLAYERBOT_WOTLKDUNGEONFOSSTRATEGY_H

View File

@@ -0,0 +1,24 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERCONTEXT_H
#define _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERCONTEXT_H
#include "NamedObjectContext.h"
#include "AiObjectContext.h"
#include "ForgeOfSoulsTriggers.h"
class WotlkDungeonFosTriggerContext : public NamedObjectContext<Trigger>
{
public:
WotlkDungeonFosTriggerContext()
{
creators["bronjahm position"] = &WotlkDungeonFosTriggerContext::bronjahm_position;
creators["move from bronjahm"] = &WotlkDungeonFosTriggerContext::move_from_bronjahm;
creators["switch to soul fragment"] = &WotlkDungeonFosTriggerContext::switch_to_soul_fragment;
}
private:
static Trigger* move_from_bronjahm(PlayerbotAI* ai) { return new MoveFromBronjahmTrigger(ai); }
static Trigger* switch_to_soul_fragment(PlayerbotAI* ai) { return new SwitchToSoulFragment(ai); }
static Trigger* bronjahm_position(PlayerbotAI* ai) { return new BronjahmPositionTrigger(ai); }
};
#endif // !_PLAYERBOT_WOTLKDUNGEONFOSTRIGGERCONTEXT_H

View File

@@ -0,0 +1,39 @@
#include "Playerbots.h"
#include "ForgeOfSoulsTriggers.h"
#include "AiObject.h"
#include "AiObjectContext.h"
bool MoveFromBronjahmTrigger::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", "bronjahm");
if (boss->FindCurrentSpellBySpellId(SPELL_CORRUPT_SOUL) && bot->HasAura(SPELL_CORRUPT_SOUL))
return true;
return false;
}
bool SwitchToSoulFragment::IsActive()
{
Unit* fragment = nullptr;
GuidVector targets = AI_VALUE(GuidVector, "possible targets no los");
for (auto& target : targets)
{
Unit* unit = botAI->GetUnit(target);
if (unit && unit->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT)
{
if (botAI->IsDps(bot))
return true;
}
}
return false;
}
bool BronjahmPositionTrigger::IsActive()
{
return bool(AI_VALUE2(Unit*, "find target", "bronjahm"));
}

View File

@@ -0,0 +1,40 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERS_H
#define _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERS_H
#include "Trigger.h"
#include "PlayerbotAIConfig.h"
#include "GenericTriggers.h"
#include "DungeonStrategyUtils.h"
enum ForgeOfSoulsBronjahmIDs
{
// Boss1
NPC_CORRUPTED_SOUL_FRAGMENT = 36535,
SPELL_CORRUPT_SOUL = 68839
};
class MoveFromBronjahmTrigger : public Trigger
{
public:
MoveFromBronjahmTrigger(PlayerbotAI* ai) : Trigger(ai, "move from bronjahm") {}
bool IsActive() override;
};
class SwitchToSoulFragment : public Trigger
{
public:
SwitchToSoulFragment(PlayerbotAI* ai) : Trigger(ai, "switch to soul fragment") {}
bool IsActive() override;
};
class BronjahmPositionTrigger : public Trigger
{
public:
BronjahmPositionTrigger(PlayerbotAI* ai) : Trigger(ai, "bronjahm position") {}
bool IsActive() override;
};
#endif