mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 23:49:25 +02:00
## Pull Request Description
These changes I originally made for myself because as a person who
really likes to raid with bots, I felt like the current group buff
system is fundamentally broken, and I needed something more consistent
and optimal. I debated a lot whether to PR this because it's such an
extensive overhaul that was almost entirely reliant on AI, and I know
that wishmaster still has a PR open regarding the greater blessings. I
decided to after a couple of conversations so at least people can look
at it and see if it's something that they want.
The tl;dr version is that this PR overhauls buff handling in two related
areas:
1. It adds a dedicated greater blessing assignment system.
2. It generalizes party/raid reagent-buff handling for Paladins, Druids,
Mages, and Priests.
Under this PR, greater blessings are determined by assignments for the
current group, and those assignments are determined based on:
1. a hardcoded priority list of blessings for each spec;
2. the number of Paladins in the group; and
3. whether any Paladins have talents for Blessing of Sanctuary, Improved
Blessing of Might, or Improved Blessing of Wisdom.
Assignment determinations are cached in a value to avoid constant
reevaluation.
The exact priority list is:
- All casters: Kings, Wisdom, Sanctuary, Might
- Physical-only DPS (Rogues, Warriors, DKs): Might, Kings, Sanctuary,
N/A
- Hybrid DPS (Enh, Ret, Hunters, Cats): Might, Kings, Wisdom, Sanctuary
- Druid tanks: Kings, Might, Sanctuary, Wisdom
- Warrior and DK tanks: Kings, Might, Sanctuary, N/A
- Paladin tank: Sanctuary, Might, Wisdom, Kings
Note that Sanctuary is preferred over Kings for Paladin tanks because of
the mana regen component but deprioritized for other tanks because Kings
provides Agility. The extra 3% damage reduction from Sanctuary does not
stack with Disc Priests’ Renewed Hope, which will have 100% uptime.
For group buffs, logic is centralized so that class triggers use the
same gating and upgrade rules for Gift of the Wild, Arcane Brilliance,
Prayer of Fortitude, Prayer of Spirit, and Prayer of Shadow Protection.
Also, Shadow Protection is now a default strategy for Priests (rshadow,
which existed before but wasn’t added by default).
I’ve added a config setting for the greater blessing system and adjusted
the current config setting for group buffs. In each case, you can pick
whether to disable the feature entirely, use it in all groups, or use it
only in raid groups. The default is raid only for greater blessings and
all groups for group buffs. Note that for group buffs, even if the
config is enabled, they will be used only if at least 3 group/raid
members on the same map are missing the buff family. This is mainly to
stop group buff spamming during wipe recovery as bots are revived
one-by-one.
I renamed the Paladin buff strategies to align them with the actual
blessing names:
- `bhealth` -> `bsanc`
- `bmana` -> `bwisdom`
- `bdps` -> `bmight`
- `bstats` -> `bkings`
This is an intentional breaking change for saved strategy strings. Bots
will need a one-time strategy reset after update.
I removed bots telling you when they are out of reagents for greater
blessings. If people like that though, I can add it back.
A small cleanup is also included in TankPaladinStrategy: Holy Shield was
subject to three overlapping health triggers with the same priority; I
removed the two lower health thresholds which have no purpose.
## Feature Evaluation
- Describe the **minimum logic** required to achieve the intended
behavior.
I’m going to let the AI answer this one.
> The minimum logic is:
> - a shared config-gated check for whether group/raid buff variants are
allowed
> - a shared way to treat single and group variants as equivalent aura
families
> - a shared upgrade path from single-target buff to group buff when the
group variant is appropriate
> - a Paladin-only cached assignment model that decides which blessing
family each Paladin should cover for the current group
> - trigger/action wiring that only attempts casts when a group member
is actually missing the assigned buff
>
> This avoids scattering separate per-class heuristics across many
triggers and actions.
- Describe the **processing cost** when this logic executes across many
bots.
Processing cost should be minimal but non-zero. The general party buff
changes are limited to existing buff trigger paths and mostly replace
duplicated checks with shared helpers. They do not add expensive default
per-tick behavior outside those existing trigger evaluations.
The Paladin greater blessing logic does add extra decision-making, but
it is limited to Paladins, gated by config and group eligibility,
subject to a delayed trigger evaluation of only once per 4s, and cached
per group assignment set instead of recomputing the full assignment
model on every action attempt.
This PR also increases the throttle duration for group buff triggers to
limit performance impact; I’m open to adjustments to these durations:
- Mark of the Wild triggers were increased from 4s to 8s
- Arcane Intellect triggers were increased from 4s to 8s
- Priest buff triggers were increased to 8s (previously, Fortitude was
6s, Spirit was 4s, and Shadow Protection had no throttle)
- There is now a 5s delay on buffing (greater blessings and group buffs)
after bots log in—I was getting bots spamming buffs as soon as they
logged in even when it was not necessary
I’ve tested with pmon, and the impact is minimal—these are very cheap
triggers even compared to standard bot rotational ability triggers.
## How to Test the Changes
1. Try different config settings to confirm that they work to
enable/disable greater blessings/group buffs in the configured scenarios
2. For greater blessing changes:
- test with one Paladin in a party/raid
- test with multiple Paladins in a party/raid
- confirm the Paladins divide blessing coverage instead of repeatedly
overwriting each other
- include at least one Paladin with Improved Blessing of Might and make
sure it casts Might over Paladins without the talent; check the same
with a Paladin with Improved Blessing of Wisdom
- do not include a Paladin that knows Sanctuary, confirm any Paladin
tank receives Kings instead (you’ll need a low-level Paladin for this
since Sanctuary is a prot talent)
- confirm bots cast blessings only when a member is actually missing the
relevant blessing family
- confirm there is a 5s delay on buffing when bots log in
3. For group buff changes:
- confirm there is a 5s delay on buffing when bots log in
- confirm that single buffs are used when there aren’t at least three
unbuffed members in the same map, even if group buffs are enabled in the
config
4. For all buffs, test with reagents missing to confirm fallback to
single-target buffs and single blessings
5. Confirm the Paladin buff strategy names are changed after resetting
AI
## Impact Assessment
- Does this change increase per-bot/per-tick processing or risk scaling
poorly with thousands of bots?
- - [ ] No, not at all
- - [x] Minimal impact (**explain below**)
- - [ ] Moderate impact (**explain below**)
Discussed above in processing costs.
- Does this change modify default bot behavior?
- - [ ] No
- - [x] Yes (**explain why**)
Yes—that is the purpose of this PR, to change default buffing behavior.
- Does this change add new decision branches or increase maintenance
complexity?
- - [ ] No
- - [x] Yes (**explain below**)
Yes, but I think it’s inevitable to add complexity to get greater
blessings to function consistently, given the challenges brought by
their mechanic of applying across each class.
## AI Assistance
Was AI assistance used while working on this change?
- - [ ] No
- - [x] Yes (**explain below**)
I used GPT-5.4 extensively for this overhaul. It’s much more complicated
than I could handle on my own. I’ve done a lot of testing and have
reviewed the code and provided plenty of revisions, but I cannot say I
can perfectly explain each addition and how it works, not even close.
## Final Checklist
- - [x] Stability is not compromised.
- - [x] Performance impact is understood, tested, and acceptable.
- - [x] Added logic complexity is justified and explained.
- - [x] Any new bot dialogue lines are translated.
- - [x] Documentation updated if needed (Conf comments, WiKi commands).
## Notes for Reviewers
---------
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
Co-authored-by: bash <hermensb@gmail.com>
Co-authored-by: Revision <tkn963@gmail.com>
Co-authored-by: kadeshar <kadeshar@gmail.com>
656 lines
21 KiB
C++
656 lines
21 KiB
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
|
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
|
*/
|
|
|
|
#ifndef _PLAYERBOT_PLAYERBOTAI_H
|
|
#define _PLAYERBOT_PLAYERBOTAI_H
|
|
|
|
#include <stack>
|
|
|
|
#include "Chat.h"
|
|
#include "ChatFilter.h"
|
|
#include "ChatHelper.h"
|
|
#include "CreatureData.h"
|
|
#include "Event.h"
|
|
#include "Item.h"
|
|
#include "NewRpgInfo.h"
|
|
#include "NewRpgStrategy.h"
|
|
#include "PlayerbotAIBase.h"
|
|
#include "PlayerbotAIConfig.h"
|
|
#include "PlayerbotSecurity.h"
|
|
#include "PlayerbotTextMgr.h"
|
|
#include "SpellAuras.h"
|
|
#include "Util.h"
|
|
#include "WorldPacket.h"
|
|
|
|
class AiObjectContext;
|
|
class Creature;
|
|
class Engine;
|
|
class ExternalEventHelper;
|
|
class Gameobject;
|
|
class Item;
|
|
class ObjectGuid;
|
|
class Player;
|
|
class PlayerbotMgr;
|
|
class Spell;
|
|
class SpellInfo;
|
|
class Unit;
|
|
class WorldObject;
|
|
class WorldPosition;
|
|
|
|
struct CreatureData;
|
|
struct GameObjectData;
|
|
|
|
enum StrategyType : uint32;
|
|
|
|
enum HealingItemId
|
|
{
|
|
HEALTHSTONE = 5512,
|
|
MAJOR_HEALING_POTION = 13446,
|
|
WHIPPER_ROOT_TUBER = 11951,
|
|
NIGHT_DRAGON_BREATH = 11952,
|
|
LIMITED_INVULNERABILITY_POTION = 3387,
|
|
GREATER_DREAMLESS_SLEEP_POTION = 22886,
|
|
SUPERIOR_HEALING_POTION = 3928,
|
|
CRYSTAL_RESTORE = 11564,
|
|
DREAMLESS_SLEEP_POTION = 12190,
|
|
GREATER_HEALING_POTION = 1710,
|
|
HEALING_POTION = 929,
|
|
LESSER_HEALING_POTION = 858,
|
|
DISCOLORED_HEALING_POTION = 3391,
|
|
MINOR_HEALING_POTION = 118,
|
|
VOLATILE_HEALING_POTION = 28100,
|
|
SUPER_HEALING_POTION = 22829,
|
|
CRYSTAL_HEALING_POTION = 13462,
|
|
FEL_REGENERATION_POTION = 28101,
|
|
MAJOR_DREAMLESS_SLEEP_POTION = 20002
|
|
};
|
|
|
|
enum BotState
|
|
{
|
|
BOT_STATE_COMBAT = 0,
|
|
BOT_STATE_NON_COMBAT = 1,
|
|
BOT_STATE_DEAD = 2,
|
|
|
|
BOT_STATE_MAX
|
|
};
|
|
|
|
bool IsAlliance(uint8 race);
|
|
|
|
class PlayerbotChatHandler : protected ChatHandler
|
|
{
|
|
public:
|
|
explicit PlayerbotChatHandler(Player* pMasterPlayer);
|
|
void sysmessage(std::string const str) { SendSysMessage(str.c_str()); }
|
|
uint32 extractQuestId(std::string const str);
|
|
uint32 extractSpellId(std::string const str)
|
|
{
|
|
char* source = (char*)str.c_str();
|
|
return extractSpellIdFromLink(source);
|
|
}
|
|
};
|
|
|
|
class MinValueCalculator
|
|
{
|
|
public:
|
|
MinValueCalculator(float def = 0.0f) : param(nullptr), minValue(def) {}
|
|
|
|
void probe(float value, void* p)
|
|
{
|
|
if (!param || minValue >= value)
|
|
{
|
|
minValue = value;
|
|
param = p;
|
|
}
|
|
}
|
|
|
|
void* param;
|
|
float minValue;
|
|
};
|
|
enum ChatChannelSource
|
|
{
|
|
SRC_GUILD,
|
|
SRC_WORLD,
|
|
SRC_GENERAL,
|
|
SRC_TRADE,
|
|
SRC_LOOKING_FOR_GROUP,
|
|
SRC_LOCAL_DEFENSE,
|
|
SRC_WORLD_DEFENSE,
|
|
SRC_GUILD_RECRUITMENT,
|
|
|
|
SRC_SAY,
|
|
SRC_WHISPER,
|
|
SRC_EMOTE,
|
|
SRC_TEXT_EMOTE,
|
|
SRC_YELL,
|
|
|
|
SRC_PARTY,
|
|
SRC_RAID,
|
|
|
|
SRC_UNDEFINED
|
|
};
|
|
static std::map<ChatChannelSource, std::string> ChatChannelSourceStr = {
|
|
{SRC_GUILD, "SRC_GUILD"},
|
|
{SRC_WORLD, "SRC_WORLD"},
|
|
{SRC_GENERAL, "SRC_GENERAL"},
|
|
{SRC_TRADE, "SRC_TRADE"},
|
|
{SRC_LOOKING_FOR_GROUP, "SRC_LOOKING_FOR_GROUP"},
|
|
{SRC_LOCAL_DEFENSE, "SRC_LOCAL_DEFENSE"},
|
|
{SRC_WORLD_DEFENSE, "SRC_WORLD_DEFENSE"},
|
|
{SRC_GUILD_RECRUITMENT, "SRC_GUILD_RECRUITMENT"},
|
|
|
|
{SRC_SAY, "SRC_SAY"},
|
|
{SRC_WHISPER, "SRC_WHISPER"},
|
|
{SRC_EMOTE, "SRC_EMOTE"},
|
|
{SRC_TEXT_EMOTE, "SRC_TEXT_EMOTE"},
|
|
{SRC_YELL, "SRC_YELL"},
|
|
|
|
{SRC_PARTY, "SRC_PARTY"},
|
|
{SRC_RAID, "SRC_RAID"},
|
|
|
|
{SRC_UNDEFINED, "SRC_UNDEFINED"}};
|
|
|
|
enum ChatChannelId
|
|
{
|
|
GENERAL = 1,
|
|
TRADE = 2,
|
|
LOCAL_DEFENSE = 22,
|
|
WORLD_DEFENSE = 23,
|
|
LOOKING_FOR_GROUP = 26,
|
|
GUILD_RECRUITMENT = 25,
|
|
};
|
|
|
|
enum RoguePoisonId
|
|
{
|
|
INSTANT_POISON = 6947,
|
|
INSTANT_POISON_II = 6949,
|
|
INSTANT_POISON_III = 6950,
|
|
INSTANT_POISON_IV = 8926,
|
|
INSTANT_POISON_V = 8927,
|
|
INSTANT_POISON_VI = 8928,
|
|
INSTANT_POISON_VII = 21927,
|
|
INSTANT_POISON_VIII = 43230,
|
|
INSTANT_POISON_IX = 43231,
|
|
DEADLY_POISON = 2892,
|
|
DEADLY_POISON_II = 2893,
|
|
DEADLY_POISON_III = 8984,
|
|
DEADLY_POISON_IV = 8985,
|
|
DEADLY_POISON_V = 20844,
|
|
DEADLY_POISON_VI = 22053,
|
|
DEADLY_POISON_VII = 22054,
|
|
DEADLY_POISON_VIII = 43232,
|
|
DEADLY_POISON_IX = 43233
|
|
};
|
|
|
|
enum SharpeningStoneId
|
|
{
|
|
ROUGH_SHARPENING_STONE = 2862,
|
|
COARSE_SHARPENING_STONE = 2863,
|
|
HEAVY_SHARPENING_STONE = 2871,
|
|
SOLID_SHARPENING_STONE = 7964,
|
|
DENSE_SHARPENING_STONE = 12404,
|
|
ELEMENTAL_SHARPENING_STONE = 18262,
|
|
FEL_SHARPENING_STONE = 23528,
|
|
ADAMANTITE_SHARPENING_STONE = 23529
|
|
};
|
|
|
|
enum WeightstoneId
|
|
{
|
|
ROUGH_WEIGHTSTONE = 3239,
|
|
COARSE_WEIGHTSTONE = 3240,
|
|
HEAVY_WEIGHTSTONE = 3241,
|
|
SOLID_WEIGHTSTONE = 7965,
|
|
DENSE_WEIGHTSTONE = 12643,
|
|
FEL_WEIGHTSTONE = 28420,
|
|
ADAMANTITE_WEIGHTSTONE = 28421
|
|
};
|
|
|
|
enum WizardOilId
|
|
{
|
|
MINOR_WIZARD_OIL = 20744,
|
|
LESSER_WIZARD_OIL = 20746,
|
|
WIZARD_OIL = 20750,
|
|
BRILLIANT_WIZARD_OIL = 20749,
|
|
SUPERIOR_WIZARD_OIL = 22522
|
|
};
|
|
|
|
enum ManaOilId
|
|
{
|
|
MINOR_MANA_OIL = 20745,
|
|
LESSER_MANA_OIL = 20747,
|
|
BRILLIANT_MANA_OIL = 20748,
|
|
SUPERIOR_MANA_OIL = 22521
|
|
};
|
|
|
|
enum class BotTypeNumber : uint8
|
|
{
|
|
ACTIVITY_TYPE_NUMBER = 1,
|
|
GROUPER_TYPE_NUMBER = 2,
|
|
GUILDER_TYPE_NUMBER = 3,
|
|
};
|
|
|
|
enum class GrouperType : uint8
|
|
{
|
|
SOLO = 0,
|
|
MEMBER = 1,
|
|
LEADER_2 = 2,
|
|
LEADER_3 = 3,
|
|
LEADER_4 = 4,
|
|
LEADER_5 = 5
|
|
};
|
|
|
|
enum class GuilderType : uint8
|
|
{
|
|
SOLO = 0,
|
|
TINY = 30,
|
|
SMALL = 50,
|
|
MEDIUM = 70,
|
|
LARGE = 120,
|
|
VERY_LARGE = 250
|
|
};
|
|
|
|
enum ActivityType
|
|
{
|
|
GRIND_ACTIVITY = 1,
|
|
RPG_ACTIVITY = 2,
|
|
TRAVEL_ACTIVITY = 3,
|
|
OUT_OF_PARTY_ACTIVITY = 4,
|
|
PACKET_ACTIVITY = 5,
|
|
DETAILED_MOVE_ACTIVITY = 6,
|
|
PARTY_ACTIVITY = 7,
|
|
ALL_ACTIVITY = 8,
|
|
|
|
MAX_ACTIVITY_TYPE
|
|
};
|
|
|
|
enum BotRoles : uint8
|
|
{
|
|
BOT_ROLE_NONE = 0x00,
|
|
BOT_ROLE_TANK = 0x01,
|
|
BOT_ROLE_HEALER = 0x02,
|
|
BOT_ROLE_DPS = 0x04
|
|
};
|
|
|
|
enum HUNTER_TABS
|
|
{
|
|
HUNTER_TAB_BEAST_MASTERY,
|
|
HUNTER_TAB_MARKSMANSHIP,
|
|
HUNTER_TAB_SURVIVAL,
|
|
};
|
|
|
|
enum ROGUE_TABS
|
|
{
|
|
ROGUE_TAB_ASSASSINATION,
|
|
ROGUE_TAB_COMBAT,
|
|
ROGUE_TAB_SUBTLETY,
|
|
};
|
|
|
|
enum PRIEST_TABS
|
|
{
|
|
PRIEST_TAB_DISCIPLINE,
|
|
PRIEST_TAB_HOLY,
|
|
PRIEST_TAB_SHADOW,
|
|
};
|
|
|
|
enum DEATH_KNIGHT_TABS
|
|
{
|
|
DEATH_KNIGHT_TAB_BLOOD,
|
|
DEATH_KNIGHT_TAB_FROST,
|
|
DEATH_KNIGHT_TAB_UNHOLY,
|
|
};
|
|
|
|
enum DRUID_TABS
|
|
{
|
|
DRUID_TAB_BALANCE,
|
|
DRUID_TAB_FERAL,
|
|
DRUID_TAB_RESTORATION,
|
|
};
|
|
|
|
enum MAGE_TABS
|
|
{
|
|
MAGE_TAB_ARCANE,
|
|
MAGE_TAB_FIRE,
|
|
MAGE_TAB_FROST,
|
|
};
|
|
|
|
enum SHAMAN_TABS
|
|
{
|
|
SHAMAN_TAB_ELEMENTAL,
|
|
SHAMAN_TAB_ENHANCEMENT,
|
|
SHAMAN_TAB_RESTORATION,
|
|
};
|
|
|
|
enum PALADIN_TABS
|
|
{
|
|
PALADIN_TAB_HOLY,
|
|
PALADIN_TAB_PROTECTION,
|
|
PALADIN_TAB_RETRIBUTION,
|
|
};
|
|
|
|
enum WARLOCK_TABS
|
|
{
|
|
WARLOCK_TAB_AFFLICTION,
|
|
WARLOCK_TAB_DEMONOLOGY,
|
|
WARLOCK_TAB_DESTRUCTION,
|
|
};
|
|
|
|
enum WARRIOR_TABS
|
|
{
|
|
WARRIOR_TAB_ARMS,
|
|
WARRIOR_TAB_FURY,
|
|
WARRIOR_TAB_PROTECTION,
|
|
};
|
|
|
|
class PacketHandlingHelper
|
|
{
|
|
public:
|
|
void AddHandler(uint16 opcode, std::string const handler);
|
|
void Handle(ExternalEventHelper& helper);
|
|
void AddPacket(WorldPacket const& packet);
|
|
|
|
private:
|
|
std::map<uint16, std::string> handlers;
|
|
std::stack<WorldPacket> queue;
|
|
};
|
|
|
|
class ChatCommandHolder
|
|
{
|
|
public:
|
|
ChatCommandHolder(std::string const command, Player* owner = nullptr, uint32 type = CHAT_MSG_WHISPER,
|
|
time_t time = 0)
|
|
: command(command), owner(owner), type(type), time(time)
|
|
{
|
|
}
|
|
ChatCommandHolder(ChatCommandHolder const& other)
|
|
: command(other.command), owner(other.owner), type(other.type), time(other.time)
|
|
{
|
|
}
|
|
|
|
const std::string& GetCommand() { return command; }
|
|
Player* GetOwner() { return owner; }
|
|
uint32& GetType() { return type; }
|
|
time_t& GetTime() { return time; }
|
|
|
|
private:
|
|
std::string const command;
|
|
Player* owner;
|
|
uint32 type;
|
|
time_t time;
|
|
};
|
|
|
|
class PlayerbotAI : public PlayerbotAIBase
|
|
{
|
|
public:
|
|
PlayerbotAI();
|
|
PlayerbotAI(Player* bot);
|
|
virtual ~PlayerbotAI();
|
|
|
|
void UpdateAI(uint32 elapsed, bool minimal = false) override;
|
|
void UpdateAIInternal(uint32 elapsed, bool minimal = false) override;
|
|
|
|
std::string const HandleRemoteCommand(std::string const command);
|
|
void HandleCommand(uint32 type, std::string const text, Player* fromPlayer);
|
|
void QueueChatResponse(const ChatQueuedReply reply);
|
|
void HandleBotOutgoingPacket(WorldPacket const& packet);
|
|
void HandleMasterIncomingPacket(WorldPacket const& packet);
|
|
void HandleMasterOutgoingPacket(WorldPacket const& packet);
|
|
void HandleTeleportAck();
|
|
void ChangeEngine(BotState type);
|
|
void ChangeEngineOnCombat();
|
|
void ChangeEngineOnNonCombat();
|
|
void DoNextAction(bool minimal = false);
|
|
virtual bool DoSpecificAction(std::string const name, Event event = Event(), bool silent = false,
|
|
std::string const qualifier = "");
|
|
void ChangeStrategy(std::string const name, BotState type);
|
|
void ClearStrategies(BotState type);
|
|
void SelectiveResetStrategies(BotState type);
|
|
std::vector<std::string> GetStrategies(BotState type);
|
|
Strategy* GetStrategy(std::string const name, BotState type);
|
|
void ApplyInstanceStrategies(uint32 mapId, bool tellMaster = false);
|
|
void EvaluateHealerDpsStrategy();
|
|
bool ContainsStrategy(StrategyType type);
|
|
bool HasStrategy(std::string const name, BotState type);
|
|
BotState GetState() { return currentState; };
|
|
void ResetStrategies(bool load = false);
|
|
void ReInitCurrentEngine();
|
|
void Reset(bool full = false);
|
|
void LeaveOrDisbandGroup();
|
|
static bool IsTank(Player* player, bool bySpec = false);
|
|
static bool IsHeal(Player* player, bool bySpec = false);
|
|
static bool IsDps(Player* player, bool bySpec = false);
|
|
static bool IsRanged(Player* player, bool bySpec = false);
|
|
static bool IsMelee(Player* player, bool bySpec = false);
|
|
static bool IsCaster(Player* player, bool bySpec = false);
|
|
static bool IsRangedDps(Player* player, bool bySpec = false);
|
|
static bool IsCombo(Player* player);
|
|
static bool IsBotMainTank(Player* player);
|
|
static bool IsMainTank(Player* player, bool ignoreMemberFlag = false);
|
|
static uint32 GetGroupTankNum(Player* player);
|
|
static bool IsAssistTank(Player* player);
|
|
static bool IsAssistTankOfIndex(Player* player, uint8 index, bool ignoreDeadPlayers = false);
|
|
static bool IsAssistHealOfIndex(Player* player, uint8 index, bool ignoreDeadPlayers = false);
|
|
static bool IsAssistRangedDpsOfIndex(Player* player, uint8 index, bool ignoreDeadPlayers = false);
|
|
bool HasAggro(Unit* unit);
|
|
bool IsMovementImpaired(Unit* unit);
|
|
static int32 GetAssistTankIndex(Player* player);
|
|
int32 GetGroupSlotIndex(Player* player);
|
|
int32 GetRangedIndex(Player* player);
|
|
int32 GetClassIndex(Player* player, uint8 cls);
|
|
int32 GetRangedDpsIndex(Player* player);
|
|
int32 GetMeleeIndex(Player* player);
|
|
|
|
Creature* GetCreature(ObjectGuid guid);
|
|
Unit* GetUnit(ObjectGuid guid);
|
|
Player* GetPlayer(ObjectGuid guid);
|
|
static Unit* GetUnit(CreatureData const* creatureData);
|
|
GameObject* GetGameObject(ObjectGuid guid);
|
|
// static GameObject* GetGameObject(GameObjectData const* gameObjectData);
|
|
WorldObject* GetWorldObject(ObjectGuid guid);
|
|
std::vector<Player*> GetAllPlayersInGroup();
|
|
std::vector<Player*> GetRealPlayersInGroup();
|
|
const AreaTableEntry* GetCurrentArea();
|
|
const AreaTableEntry* GetCurrentZone();
|
|
static std::string GetLocalizedAreaName(const AreaTableEntry* entry);
|
|
static std::string GetLocalizedCreatureName(uint32 entry);
|
|
static std::string GetLocalizedGameObjectName(uint32 entry);
|
|
bool TellMaster(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
|
bool TellMaster(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
|
bool TellMasterNoFacing(std::ostringstream& stream,
|
|
PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
|
bool TellMasterNoFacing(std::string const text,
|
|
PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
|
bool TellError(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
|
bool SayToGuild(const std::string& msg);
|
|
bool SayToWorld(const std::string& msg);
|
|
bool SayToChannel(const std::string& msg, const ChatChannelId& chanId);
|
|
bool SayToParty(const std::string& msg);
|
|
bool SayToRaid(const std::string& msg);
|
|
bool Yell(const std::string& msg);
|
|
bool Say(const std::string& msg);
|
|
bool Whisper(const std::string& msg, const std::string& receiverName);
|
|
|
|
void SpellInterrupted(uint32 spellid);
|
|
int32 CalculateGlobalCooldown(uint32 spellid);
|
|
void InterruptSpell();
|
|
void RequestSpellInterrupt();
|
|
void RemoveAura(std::string const name);
|
|
void RemoveShapeshift();
|
|
void WaitForSpellCast(Spell* spell);
|
|
bool PlaySound(uint32 emote);
|
|
bool PlayEmote(uint32 emote);
|
|
void Ping(float x, float y);
|
|
Item* FindPoison() const;
|
|
Item* FindAmmo() const;
|
|
Item* FindBandage() const;
|
|
Item* FindOpenableItem() const;
|
|
Item* FindLockedItem() const;
|
|
Item* FindConsumable(uint32 itemId) const;
|
|
Item* FindStoneFor(Item* weapon) const;
|
|
Item* FindOilFor(Item* weapon) const;
|
|
void ImbueItem(Item* item, uint32 targetFlag, ObjectGuid targetGUID);
|
|
void ImbueItem(Item* item, uint8 targetInventorySlot);
|
|
void ImbueItem(Item* item, Unit* target);
|
|
void ImbueItem(Item* item);
|
|
void EnchantItemT(uint32 spellid, uint8 slot);
|
|
int32 GetNearGroupMemberCount(float dis = sPlayerbotAIConfig.sightDistance);
|
|
|
|
virtual bool CanCastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr);
|
|
virtual bool CastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr);
|
|
virtual bool HasAura(std::string const spellName, Unit* player, bool maxStack = false, bool checkIsOwner = false,
|
|
int maxAmount = -1, bool checkDuration = false);
|
|
virtual bool HasAnyAuraOf(Unit* player, ...);
|
|
|
|
virtual bool IsInterruptableSpellCasting(Unit* player, std::string const spell);
|
|
virtual bool HasAuraToDispel(Unit* player, uint32 dispelType);
|
|
bool CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell = true, Item* itemTarget = nullptr,
|
|
Item* castItem = nullptr);
|
|
bool CanCastSpell(uint32 spellid, GameObject* goTarget, bool checkHasSpell = true);
|
|
bool CanCastSpell(uint32 spellid, float x, float y, float z, bool checkHasSpell = true,
|
|
Item* itemTarget = nullptr);
|
|
|
|
bool HasAura(uint32 spellId, Unit const* player);
|
|
Aura* GetAura(std::string const spellName, Unit* unit, bool checkIsOwner = false, bool checkDuration = false,
|
|
int checkStack = -1);
|
|
bool CastSpell(uint32 spellId, Unit* target, Item* itemTarget = nullptr);
|
|
bool CastSpell(uint32 spellId, float x, float y, float z, Item* itemTarget = nullptr);
|
|
bool canDispel(SpellInfo const* spellInfo, uint32 dispelType);
|
|
|
|
bool CanCastVehicleSpell(uint32 spellid, Unit* target);
|
|
bool CastVehicleSpell(uint32 spellId, Unit* target);
|
|
bool CastVehicleSpell(uint32 spellId, float x, float y, float z);
|
|
bool IsInVehicle(bool canControl = false, bool canCast = false, bool canAttack = false, bool canTurn = false,
|
|
bool fixed = false);
|
|
|
|
uint32 GetEquipGearScore(Player* player);
|
|
//uint32 GetEquipGearScore(Player* player, bool withBags, bool withBank);
|
|
static uint32 GetMixedGearScore(Player* player, bool withBags, bool withBank, uint32 topN = 0);
|
|
bool HasSkill(SkillType skill);
|
|
bool IsAllowedCommand(std::string const text);
|
|
float GetRange(std::string const type);
|
|
|
|
Player* GetBot() { return bot; }
|
|
Player* GetMaster() { return master; }
|
|
Player* FindNewMaster();
|
|
|
|
// Checks if the bot is really a player. Players always have themselves as master.
|
|
bool IsRealPlayer() { return master ? (master == bot) : false; }
|
|
// Bot has a master that is a player.
|
|
bool HasRealPlayerMaster();
|
|
// Bot has a master that is activly playing.
|
|
bool HasActivePlayerMaster();
|
|
// Get the group leader or the master of the bot.
|
|
// Checks if the bot is summoned as alt of a player
|
|
bool IsAlt();
|
|
Player* GetGroupLeader();
|
|
uint32 GetFixedBotNumber(uint32 maxNum = 100);
|
|
GrouperType GetGrouperType();
|
|
GuilderType GetGuilderType();
|
|
bool HasPlayerNearby(WorldPosition* pos, float range = sPlayerbotAIConfig.reactDistance);
|
|
bool HasPlayerNearby(float range = sPlayerbotAIConfig.reactDistance);
|
|
bool AllowActive(ActivityType activityType);
|
|
bool AllowActivity(ActivityType activityType = ALL_ACTIVITY, bool checkNow = false);
|
|
uint32 AutoScaleActivity(uint32 mod);
|
|
|
|
// Check if player is safe to use.
|
|
bool IsSafe(Player* player);
|
|
bool IsSafe(WorldObject* obj);
|
|
ChatChannelSource GetChatChannelSource(Player* bot, uint32 type, std::string channelName);
|
|
|
|
bool StarterLevelDistanceCheck(Player* player, const WorldLocation &loc, bool fromStartUp = false);
|
|
|
|
bool HasCheat(BotCheatMask mask)
|
|
{
|
|
return ((uint32)mask & (uint32)cheatMask) != 0 ||
|
|
((uint32)mask & (uint32)sPlayerbotAIConfig.botCheatMask) != 0;
|
|
}
|
|
BotCheatMask GetCheat() { return cheatMask; }
|
|
void SetCheat(BotCheatMask mask) { cheatMask = mask; }
|
|
|
|
void SetMaster(Player* newMaster) { master = newMaster; }
|
|
AiObjectContext* GetAiObjectContext() { return aiObjectContext; }
|
|
ChatHelper* GetChatHelper() { return &chatHelper; }
|
|
bool IsOpposing(Player* player);
|
|
static bool IsOpposing(uint8 race1, uint8 race2);
|
|
PlayerbotSecurity* GetSecurity() { return &security; }
|
|
|
|
Position GetJumpDestination() { return jumpDestination; }
|
|
void SetJumpDestination(Position pos) { jumpDestination = pos; }
|
|
void ResetJumpDestination() { jumpDestination = Position(); }
|
|
|
|
bool CanMove();
|
|
bool IsInRealGuild();
|
|
static std::vector<std::string> dispel_whitelist;
|
|
bool EqualLowercaseName(std::string s1, std::string s2);
|
|
InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const;
|
|
uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const;
|
|
std::vector<Item*> GetInventoryAndEquippedItems();
|
|
std::vector<Item*> GetInventoryItems();
|
|
uint32 GetInventoryItemsCountWithId(uint32 itemId);
|
|
bool HasItemInInventory(uint32 itemId);
|
|
std::vector<std::pair<const Quest*, uint32>> GetCurrentQuestsRequiringItemId(uint32 itemId);
|
|
uint32 GetReactDelay();
|
|
|
|
std::vector<const Quest*> GetAllCurrentQuests();
|
|
std::vector<const Quest*> GetCurrentIncompleteQuests();
|
|
std::set<uint32> GetAllCurrentQuestIds();
|
|
std::set<uint32> GetCurrentIncompleteQuestIds();
|
|
void PetFollow();
|
|
static float GetItemScoreMultiplier(ItemQualities quality);
|
|
static bool IsHealingSpell(uint32 spellFamilyName, flag96 spelFalimyFlags);
|
|
static SpellFamilyNames Class2SpellFamilyName(uint8 cls);
|
|
NewRpgInfo rpgInfo;
|
|
NewRpgStatistic rpgStatistic;
|
|
std::unordered_set<uint32> lowPriorityQuest;
|
|
time_t bgReleaseAttemptTime = 0;
|
|
|
|
// Schedules a callback to run once after <delayMs> milliseconds.
|
|
void AddTimedEvent(std::function<void()> callback, uint32 delayMs);
|
|
|
|
private:
|
|
static void _fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore,
|
|
bool mixed = false);
|
|
bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
|
void UpdateAIGroupMaster();
|
|
Item* FindItemInInventory(std::function<bool(ItemTemplate const*)> checkItem) const;
|
|
void HandleCommands();
|
|
void HandleCommand(uint32 type, const std::string& text, Player& fromPlayer, const uint32 lang = LANG_UNIVERSAL);
|
|
inline bool IsValidUnit(const Unit* unit) const
|
|
{
|
|
return unit && unit->IsInWorld() && !unit->IsDuringRemoveFromWorld();
|
|
}
|
|
inline bool IsValidPlayer(const Player* player) const
|
|
{
|
|
return player && player->GetSession() && player->IsInWorld() && !player->IsDuringRemoveFromWorld() &&
|
|
!player->IsBeingTeleported();
|
|
}
|
|
protected:
|
|
Player* bot;
|
|
Player* master;
|
|
uint32 accountId;
|
|
AiObjectContext* aiObjectContext;
|
|
Engine* currentEngine;
|
|
Engine* engines[BOT_STATE_MAX];
|
|
BotState currentState;
|
|
ChatHelper chatHelper;
|
|
std::list<ChatCommandHolder> chatCommands;
|
|
std::list<ChatQueuedReply> chatReplies;
|
|
PacketHandlingHelper botOutgoingPacketHandlers;
|
|
PacketHandlingHelper masterIncomingPacketHandlers;
|
|
PacketHandlingHelper masterOutgoingPacketHandlers;
|
|
CompositeChatFilter chatFilter;
|
|
PlayerbotSecurity security;
|
|
std::map<std::string, time_t> whispers;
|
|
std::pair<ChatMsg, time_t> currentChat;
|
|
static std::set<std::string> unsecuredCommands;
|
|
bool allowActive[MAX_ACTIVITY_TYPE];
|
|
time_t allowActiveCheckTimer[MAX_ACTIVITY_TYPE];
|
|
bool inCombat = false;
|
|
BotCheatMask cheatMask = BotCheatMask::none;
|
|
Position jumpDestination = Position();
|
|
uint32 nextTransportCheck = 0;
|
|
bool spellInterruptRequested = false;
|
|
};
|
|
|
|
#endif
|