Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ffd51e4
fix: Resolved a wrong bot percentile calculation algorithm.
SmashingQuasar Feb 9, 2026
39f9f98
refactor: Refactored InterruptSpell to make it more readable.
SmashingQuasar Feb 10, 2026
a498322
refactor: Refactored several methods in PlayerbotAI.
SmashingQuasar Feb 10, 2026
f2509ef
refactor: Refactored PlayerbotMgr::checkTellErrors.
SmashingQuasar Feb 10, 2026
88f2821
refactor: Refactored several chat reply handling systems.
SmashingQuasar Feb 11, 2026
6363b55
refactor: Refactoeed ChatReplyAction::HandleWTBItemsReply.
SmashingQuasar Feb 11, 2026
1206145
refactor: Refactored ChatHelper to eliminate the need for the botAI p…
SmashingQuasar Feb 11, 2026
50a4311
refactor: Removed the botAI property from ChatHelper.
SmashingQuasar Feb 11, 2026
12884fd
refactor: Made ChatHelper purely static.
SmashingQuasar Feb 11, 2026
62e0b46
refactor: ChatHelper is now never instantiated.
SmashingQuasar Feb 12, 2026
75f697f
refactor: Deleted all constructors, destructors and operators of Chat…
SmashingQuasar Feb 12, 2026
93fdf26
refactor: Refactored ChatReplyAction entirely to improve performance,…
SmashingQuasar Feb 12, 2026
7648d7b
refactor: Minor syntax improvements in ExternalEventHelper.
SmashingQuasar Feb 12, 2026
0d8d11a
fix: Resolved a possible dangling pointer situation that would lead t…
SmashingQuasar Feb 13, 2026
18bfecf
refactor: Refactored the Engine iterations.
SmashingQuasar Feb 14, 2026
ed9b9dd
refactor: Minor refactor of ChangeChatAction.
SmashingQuasar Mar 12, 2026
4b337c7
fix: Resolved a wrong condition resulting in all spells constantly be…
SmashingQuasar Apr 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Ai/Base/Actions/BankAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool BankAction::Withdraw(uint32 itemid)
bot->StoreItem(dest, pItem, true);

std::ostringstream out;
out << "got " << chat->FormatItem(pItem->GetTemplate(), pItem->GetCount()) << " from bank";
out << "got " << ChatHelper::FormatItem(pItem->GetTemplate(), pItem->GetCount()) << " from bank";
botAI->TellMaster(out.str());
return true;
}
Expand All @@ -102,7 +102,7 @@ bool BankAction::Deposit(Item* pItem)
bot->RemoveItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
bot->BankItem(dest, pItem, true);

out << "put " << chat->FormatItem(pItem->GetTemplate(), pItem->GetCount()) << " to bank";
out << "put " << ChatHelper::FormatItem(pItem->GetTemplate(), pItem->GetCount()) << " to bank";
botAI->TellMaster(out.str());
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/BuffAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ bool BuffAction::Execute(Event event)
{
Item* item = *j;
std::ostringstream out;
out << chat->FormatItem(item->GetTemplate(), item->GetCount());
out << ChatHelper::FormatItem(item->GetTemplate(), item->GetCount());
botAI->TellMaster(out);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/BuyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool BuyAction::Execute(Event event)
buyUseful = true;
else
{
itemIds = chat->parseItems(link);
itemIds = ChatHelper::parseItems(link);
}

GuidVector vendors = botAI->GetAiObjectContext()->GetValue<GuidVector>("nearest npcs")->Get();
Expand Down
14 changes: 7 additions & 7 deletions src/Ai/Base/Actions/CastCustomSpellAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool CastCustomSpellAction::Execute(Event event)
Unit* target = nullptr;
std::string text = event.getParam();

GuidVector gos = chat->parseGameobjects(text);
GuidVector gos = ChatHelper::parseGameobjects(text);
if (!gos.empty())
{
for (auto go : gos)
Expand All @@ -51,7 +51,7 @@ bool CastCustomSpellAction::Execute(Event event)
if (!botAI->GetUnit(go) || !botAI->GetUnit(go)->IsInWorld())
continue;

chat->eraseAllSubStr(text, chat->FormatWorldobject(botAI->GetUnit(go)));
ChatHelper::EraseAllSubStr(text, ChatHelper::FormatWorldobject(botAI->GetUnit(go)));
}

ltrim(text);
Expand Down Expand Up @@ -146,7 +146,7 @@ bool CastCustomSpellAction::Execute(Event event)
if (bot->GetTrader())
spellName << "trade item";
else if (itemTarget)
spellName << chat->FormatItem(itemTarget->GetTemplate());
spellName << ChatHelper::FormatItem(itemTarget->GetTemplate());
else if (target == bot)
spellName << "self";
else
Expand Down Expand Up @@ -187,7 +187,7 @@ bool CastCustomNcSpellAction::isUseful() { return !bot->IsInCombat(); }

std::string const CastCustomNcSpellAction::castString(WorldObject* target)
{
return "castnc " + chat->FormatWorldobject(target);
return "castnc " + ChatHelper::FormatWorldobject(target);
}

bool CastRandomSpellAction::AcceptSpell(SpellInfo const* spellInfo)
Expand All @@ -209,7 +209,7 @@ bool CastRandomSpellAction::Execute(Event event)
if (name.empty())
name = getName();

GuidVector wos = chat->parseGameobjects(name);
GuidVector wos = ChatHelper::parseGameobjects(name);
for (auto wo : wos)
{
target = botAI->GetUnit(wo);
Expand Down Expand Up @@ -289,7 +289,7 @@ bool CastRandomSpellAction::Execute(Event event)
if (MultiCast && ((wo && bot->HasInArc(CAST_ANGLE_IN_FRONT, wo, sPlayerbotAIConfig.sightDistance))))
{
std::ostringstream cmd;
cmd << "castnc " << chat->FormatWorldobject(wo) + " " << spellId << " " << 19;
cmd << "castnc " << ChatHelper::FormatWorldobject(wo) + " " << spellId << " " << 19;
botAI->HandleCommand(CHAT_MSG_WHISPER, cmd.str(), bot);
}
return true;
Expand Down Expand Up @@ -348,7 +348,7 @@ bool DisEnchantRandomItemAction::Execute(Event)
return false;

if (CastCustomSpellAction::Execute(
Event("disenchant random item", "13262 " + chat->FormatQItem(item->GetEntry()))))
Event("disenchant random item", "13262 " + ChatHelper::FormatQItem(item->GetEntry()))))
return true;
}

Expand Down
30 changes: 15 additions & 15 deletions src/Ai/Base/Actions/ChangeChatAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@

#include "ChangeChatAction.h"

#include "AiObjectContext.h"
#include "Event.h"
#include "Playerbots.h"
#include "ChatHelper.h"
#include "PlayerbotAI.h"

bool ChangeChatAction::Execute(Event event)
{
std::string const text = event.getParam();
ChatMsg parsed = chat->parseChat(text);
const std::string text = event.getParam();
const ChatMsg parsed = ChatHelper::parseChat(text);

std::ostringstream out{};

if (parsed == CHAT_MSG_SYSTEM)
{
std::ostringstream out;
out << "Current chat is " << chat->FormatChat(*context->GetValue<ChatMsg>("chat"));
botAI->TellMaster(out);
out << "Current chat is " << ChatHelper::FormatChat(*this->context->GetValue<ChatMsg>("chat"));
return this->botAI->TellMaster(out);
}
else
{
context->GetValue<ChatMsg>("chat")->Set(parsed);

std::ostringstream out;
out << "Chat set to " << chat->FormatChat(parsed);
botAI->TellMaster(out);
}
this->context->GetValue<ChatMsg>("chat")->Set(parsed);

out << "Chat set to " << ChatHelper::FormatChat(parsed);
return this->botAI->TellMaster(out);

return true;
}
};
4 changes: 2 additions & 2 deletions src/Ai/Base/Actions/ChangeTalentsAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool ChangeTalentsAction::Execute(Event event)
uint32 tab = AiFactory::GetPlayerSpecTab(bot);
out << "My current talent spec is: "
<< "|h|cffffffff";
out << chat->FormatClass(bot, tab) << "\n";
out << ChatHelper::FormatClass(bot, tab) << "\n";
out << TalentsHelp();
}

Expand Down Expand Up @@ -294,7 +294,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// if (newSpec.GetTalentPoints() > 0)
// {
// *out << "Upgrading saved spec "
// << "|h|cffffffff" << chat->FormatClass(bot, newSpec.highestTree()) << " (" <<
// << "|h|cffffffff" << ChatHelper::FormatClass(bot, newSpec.highestTree()) << " (" <<
// newSpec.FormatSpec(bot) << ")";
// }
// }
Expand Down
6 changes: 3 additions & 3 deletions src/Ai/Base/Actions/ChooseRpgTargetAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool ChooseRpgTargetAction::HasSameTarget(ObjectGuid guid, uint32 max, GuidVecto
if (!botAI)
continue;

if (!botAI->AllowActivity(GRIND_ACTIVITY))
if (!botAI->allowActivity(GRIND_ACTIVITY))
continue;

if (PAI_VALUE(GuidPosition, "rpg target") != guid)
Expand Down Expand Up @@ -255,7 +255,7 @@ bool ChooseRpgTargetAction::Execute(Event)
{
std::ostringstream out;
out << "found: ";
out << chat->FormatWorldobject(guidP.GetWorldObject());
out << ChatHelper::FormatWorldobject(guidP.GetWorldObject());
out << " " << relevances.front();

botAI->TellMasterNoFacing(out);
Expand All @@ -268,7 +268,7 @@ bool ChooseRpgTargetAction::Execute(Event)

bool ChooseRpgTargetAction::isUseful()
{
if (!botAI->AllowActivity(RPG_ACTIVITY))
if (!botAI->allowActivity(RPG_ACTIVITY))
return false;

GuidPosition guidP = AI_VALUE(GuidPosition, "rpg target");
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/ChooseTargetActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool AttackAnythingAction::isUseful()
if (!bot || !botAI) // Prevents invalid accesses
return false;

if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot cannot be active
if (!botAI->allowActivity(GRIND_ACTIVITY)) // Bot cannot be active
return false;

if (botAI->HasStrategy("stay", BOT_STATE_NON_COMBAT))
Expand Down
4 changes: 2 additions & 2 deletions src/Ai/Base/Actions/ChooseTravelTargetAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void ChooseTravelTargetAction::ReportTravelTarget(TravelTarget* newTarget, Trave

out << round(newTarget->getDestination()->distanceTo(&botLocation)) << "y";

out << " for " << chat->FormatQuest(quest);
out << " for " << ChatHelper::FormatQuest(quest);

out << " to " << QuestDestination->getTitle();

Expand Down Expand Up @@ -880,7 +880,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s

bool ChooseTravelTargetAction::isUseful()
{
if (!botAI->AllowActivity(TRAVEL_ACTIVITY))
if (!botAI->allowActivity(TRAVEL_ACTIVITY))
return false;

return !context->GetValue<TravelTarget*>("travel target")->Get()->isActive() &&
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/DelayAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ bool DelayAction::Execute(Event)

bool DelayAction::isUseful()
{
return !botAI->AllowActivity(ALL_ACTIVITY);
return !botAI->allowActivity(ALL_ACTIVITY);
}
4 changes: 2 additions & 2 deletions src/Ai/Base/Actions/DestroyItemAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
bool DestroyItemAction::Execute(Event event)
{
std::string const text = event.getParam();
ItemIds ids = chat->parseItems(text);
ItemIds ids = ChatHelper::parseItems(text);

for (ItemIds::iterator i = ids.begin(); i != ids.end(); i++)
{
Expand All @@ -30,7 +30,7 @@ void DestroyItemAction::DestroyItem(FindItemVisitor* visitor)
for (Item* item : items)
{
std::ostringstream out;
out << chat->FormatItem(item->GetTemplate()) << " destroyed";
out << ChatHelper::FormatItem(item->GetTemplate()) << " destroyed";
botAI->TellMaster(out);

bot->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/DropQuestAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void CleanQuestLogAction::DropQuestType(uint8& numQuest, uint8 wantNum, bool isG
LOG_INFO("playerbots", "{} => Quest [ {} ] removed", bot->GetName(), quest->GetTitle());
bot->Say("Quest [ " + text_quest + " ] removed", LANG_UNIVERSAL);
}
botAI->TellMaster("Quest removed" + chat->FormatQuest(quest));
botAI->TellMaster("Quest removed" + ChatHelper::FormatQuest(quest));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/EmoteAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ bool EmoteAction::Execute(Event event)

bool EmoteAction::isUseful()
{
if (!botAI->AllowActivity())
if (!botAI->allowActivity())
return false;

time_t lastEmote = AI_VALUE2(time_t, "last emote", qualifier);
Expand Down
14 changes: 7 additions & 7 deletions src/Ai/Base/Actions/EquipAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
bool EquipAction::Execute(Event event)
{
std::string const text = event.getParam();
ItemIds ids = chat->parseItems(text);
ItemIds ids = ChatHelper::parseItems(text);
EquipItems(ids);
return true;
}
Expand Down Expand Up @@ -77,7 +77,7 @@ void EquipAction::EquipItem(Item* item)
{
bot->SetAmmo(itemId);
std::ostringstream out;
out << "equipping " << chat->FormatItem(itemProto);
out << "equipping " << ChatHelper::FormatItem(itemProto);
botAI->TellMaster(out);
return;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ void EquipAction::EquipItem(Item* item)
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);

std::ostringstream out;
out << "Equipping " << chat->FormatItem(itemProto) << " in ranged slot";
out << "Equipping " << ChatHelper::FormatItem(itemProto) << " in ranged slot";
botAI->TellMaster(out);
return;
}
Expand Down Expand Up @@ -224,12 +224,12 @@ void EquipAction::EquipItem(Item* item)
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);

std::ostringstream moveMsg;
moveMsg << "Main hand upgrade found. Moving " << chat->FormatItem(oldMHProto) << " to offhand";
moveMsg << "Main hand upgrade found. Moving " << ChatHelper::FormatItem(oldMHProto) << " to offhand";
botAI->TellMaster(moveMsg);
}

std::ostringstream out;
out << "Equipping " << chat->FormatItem(itemProto) << " in main hand";
out << "Equipping " << ChatHelper::FormatItem(itemProto) << " in main hand";
botAI->TellMaster(out);
return;
}
Expand All @@ -246,7 +246,7 @@ void EquipAction::EquipItem(Item* item)
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);

std::ostringstream out;
out << "Equipping " << chat->FormatItem(itemProto) << " in offhand";
out << "Equipping " << ChatHelper::FormatItem(itemProto) << " in offhand";
botAI->TellMaster(out);
return;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ void EquipAction::EquipItem(Item* item)
}

std::ostringstream out;
out << "Equipping " << chat->FormatItem(itemProto);
out << "Equipping " << ChatHelper::FormatItem(itemProto);
botAI->TellMaster(out);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Ai/Base/Actions/FlagAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool FlagAction::Execute(Event event)
bot->SetPvP(!bot->IsPvP());

std::ostringstream out;
out << ss[0] << " flag is " << chat->FormatBoolean(bot->IsPvP());
out << ss[0] << " flag is " << ChatHelper::FormatBoolean(bot->IsPvP());
botAI->TellMaster(out.str());
return true;
}
Expand All @@ -56,7 +56,7 @@ bool FlagAction::Execute(Event event)
bot->SetFlag(PLAYER_FLAGS, playerFlags);

std::ostringstream out;
out << ss[0] << " flag is " << chat->FormatBoolean(!bot->HasFlag(PLAYER_FLAGS, playerFlags));
out << ss[0] << " flag is " << ChatHelper::FormatBoolean(!bot->HasFlag(PLAYER_FLAGS, playerFlags));
botAI->TellMaster(out.str());
return true;
}
4 changes: 2 additions & 2 deletions src/Ai/Base/Actions/GiveItemAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ bool GiveItemAction::Execute(Event)
receiver->MoveItemToInventory(dest, item, true);

std::ostringstream out;
out << "Got " << chat->FormatItem(item->GetTemplate(), item->GetCount()) << " from " << bot->GetName();
out << "Got " << ChatHelper::FormatItem(item->GetTemplate(), item->GetCount()) << " from " << bot->GetName();
receiverAi->TellMasterNoFacing(out.str());
}
else
{
std::ostringstream out;
out << "Cannot get " << chat->FormatItem(item->GetTemplate(), item->GetCount()) << " from "
out << "Cannot get " << ChatHelper::FormatItem(item->GetTemplate(), item->GetCount()) << " from "
<< bot->GetName() << "- my bags are full";
receiverAi->TellError(out.str());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Ai/Base/Actions/GuildBankAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ bool GuildBankAction::MoveFromCharToBank(Item* item, GameObject*)

// check source pos rights (item moved to bank)
if (!guild->MemberHasTabRights(bot->GetGUID(), 0, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
out << "I can't put " << chat->FormatItem(item->GetTemplate())
out << "I can't put " << ChatHelper::FormatItem(item->GetTemplate())
<< " to guild bank. I have no rights to put items in the first guild bank tab";
else
{
out << chat->FormatItem(item->GetTemplate()) << " put to guild bank";
out << ChatHelper::FormatItem(item->GetTemplate()) << " put to guild bank";
guild->SwapItemsWithInventory(bot, false, 0, 255, playerBag, playerSlot, 0);
}

Expand Down
Loading