Skip to content
2 changes: 1 addition & 1 deletion conf/playerbots.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# LEVELS
# GEAR
# QUESTS
# ACTIVITIES
# ACTIVITY
# SPELLS
# STRATEGIES
# RPG STRATEGY
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/BattleGroundJoinAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool BGJoinAction::isUseful()
return false;

// check Deserter debuff
if (!bot->CanJoinToBattleground())
if (bot->IsDeserter())
return false;

// check if has free queue slots (pointless as already making sure not in queue)
Expand Down
8 changes: 1 addition & 7 deletions src/Ai/Base/Actions/BuyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,7 @@ bool BuyAction::Execute(Event event)
}
}

if (!vendored)
{
botAI->TellError("There are no vendors nearby");
return false;
}

return true;
return vendored;
}

bool BuyAction::BuyItem(VendorItemData const* tItems, ObjectGuid vendorguid, ItemTemplate const* proto)
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Actions/GuildCreateActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ bool PetitionTurnInAction::isUseful()

bool BuyTabardAction::Execute(Event /*event*/)
{
bool canBuy = botAI->DoSpecificAction("buy", Event("buy tabard", "Hitem:5976:"));
bool canBuy = botAI->DoSpecificAction("buy", Event("buy tabard", "Hitem:5976:"), true);
if (canBuy && AI_VALUE2(uint32, "item count", chat->FormatQItem(5976)))
return true;

Expand Down
39 changes: 39 additions & 0 deletions src/Ai/Base/Actions/TellEmblemsAction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.
*/

#include "TellEmblemsAction.h"

#include <array>

#include "Event.h"
#include "Playerbots.h"

bool TellEmblemsAction::Execute(Event /*event*/)
{
static std::array<uint32, 6> const emblemIds = {
29434, // Badge of Justice
40752, // Emblem of Heroism
40753, // Emblem of Valor
45624, // Emblem of Conquest
47241, // Emblem of Triumph
49426 // Emblem of Frost
};

botAI->TellMaster("=== Emblems ===");

for (uint32 itemId : emblemIds)
{
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
if (!proto)
continue;

uint32 count = bot->GetItemCount(itemId, false);
std::ostringstream out;
out << chat->FormatItem(proto, count);
botAI->TellMaster(out);
}

return true;
}
21 changes: 21 additions & 0 deletions src/Ai/Base/Actions/TellEmblemsAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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_TELLEMBLEMSACTION_H
#define _PLAYERBOT_TELLEMBLEMSACTION_H

#include "InventoryAction.h"

class PlayerbotAI;

class TellEmblemsAction : public InventoryAction
{
public:
TellEmblemsAction(PlayerbotAI* botAI) : InventoryAction(botAI, "emblems") {}

bool Execute(Event event) override;
};

#endif
89 changes: 68 additions & 21 deletions src/Ai/Base/Actions/TellReputationAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,23 @@

#include "TellReputationAction.h"

#include <algorithm>

#include "Event.h"
#include "PlayerbotAI.h"
#include "ReputationMgr.h"

bool TellReputationAction::Execute(Event /*event*/)
{
Player* master = GetMaster();
if (!master)
return false;

ObjectGuid selection = master->GetTarget();
if (selection.IsEmpty())
return false;
#include "SharedDefines.h"

Unit* unit = ObjectAccessor::GetUnit(*master, selection);
if (!unit)
return false;

FactionTemplateEntry const* factionTemplate = unit->GetFactionTemplateEntry();
uint32 faction = factionTemplate->faction;
FactionEntry const* entry = sFactionStore.LookupEntry(faction);
int32 reputation = bot->GetReputationMgr().GetReputation(faction);
std::string TellReputationAction::BuildReputationLine(FactionEntry const* entry)
{
ReputationMgr& repMgr = bot->GetReputationMgr();
ReputationRank rank = repMgr.GetRank(entry);
int32 reputation = repMgr.GetReputation(entry->ID);

std::ostringstream out;
out << entry->name[0] << ": ";
out << "|cff";
out << entry->name[0] << ": |cff";

ReputationRank rank = bot->GetReputationMgr().GetRank(entry);
switch (rank)
{
case REP_HATED:
Expand Down Expand Up @@ -71,7 +60,65 @@ bool TellReputationAction::Execute(Event /*event*/)
base -= ReputationMgr::PointsInRank[i];

out << " (" << (reputation - base) << "/" << ReputationMgr::PointsInRank[rank] << ")";
botAI->TellMaster(out);
return out.str();
}

bool TellReputationAction::Execute(Event event)
{
std::string const param = event.getParam();
if (param == "all")
{
ReputationMgr& repMgr = bot->GetReputationMgr();
std::vector<std::string> lines;

FactionStateList const& stateList = repMgr.GetStateList();
lines.reserve(stateList.size());

for (auto const& itr : stateList)
{
FactionState const& faction = itr.second;
if (!(faction.Flags & FACTION_FLAG_VISIBLE))
continue;

if (faction.Flags & (FACTION_FLAG_HIDDEN | FACTION_FLAG_INVISIBLE_FORCED) &&
!(faction.Flags & FACTION_FLAG_SPECIAL))
continue;

FactionEntry const* entry = sFactionStore.LookupEntry(faction.ID);
if (!entry)
continue;

lines.push_back(BuildReputationLine(entry));
}

std::sort(lines.begin(), lines.end());

botAI->TellMaster("=== Reputations ===");
for (auto const& line : lines)
botAI->TellMaster(line);

return true;
}

Player* master = GetMaster();
if (!master)
return false;

ObjectGuid selection = master->GetTarget();
if (selection.IsEmpty())
return false;

Unit* unit = ObjectAccessor::GetUnit(*master, selection);
if (!unit)
return false;

FactionTemplateEntry const* factionTemplate = unit->GetFactionTemplateEntry();

FactionEntry const* entry = sFactionStore.LookupEntry(factionTemplate->faction);
if (!entry)
return false;

botAI->TellMaster(BuildReputationLine(entry));

return true;
}
6 changes: 6 additions & 0 deletions src/Ai/Base/Actions/TellReputationAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
#ifndef _PLAYERBOT_TELLREPUTATIONACTION_H
#define _PLAYERBOT_TELLREPUTATIONACTION_H

#include <string>

#include "Action.h"

struct FactionEntry;
class PlayerbotAI;

class TellReputationAction : public Action
Expand All @@ -16,6 +19,9 @@ class TellReputationAction : public Action
TellReputationAction(PlayerbotAI* botAI) : Action(botAI, "reputation") {}

bool Execute(Event event) override;

private:
std::string BuildReputationLine(FactionEntry const* entry);
};

#endif
3 changes: 3 additions & 0 deletions src/Ai/Base/ChatActionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "TaxiAction.h"
#include "TeleportAction.h"
#include "TellCastFailedAction.h"
#include "TellEmblemsAction.h"
#include "TellItemCountAction.h"
#include "TellLosAction.h"
#include "TellReputationAction.h"
Expand Down Expand Up @@ -120,6 +121,7 @@ class ChatActionContext : public NamedObjectContext<Action>
creators["teleport"] = &ChatActionContext::teleport;
creators["taxi"] = &ChatActionContext::taxi;
creators["repair"] = &ChatActionContext::repair;
creators["emblems"] = &ChatActionContext::emblems;
creators["use"] = &ChatActionContext::use;
creators["item count"] = &ChatActionContext::item_count;
creators["equip"] = &ChatActionContext::equip;
Expand Down Expand Up @@ -276,6 +278,7 @@ class ChatActionContext : public NamedObjectContext<Action>
static Action* item_count(PlayerbotAI* botAI) { return new TellItemCountAction(botAI); }
static Action* use(PlayerbotAI* botAI) { return new UseItemAction(botAI); }
static Action* repair(PlayerbotAI* botAI) { return new RepairAllAction(botAI); }
static Action* emblems(PlayerbotAI* botAI) { return new TellEmblemsAction(botAI); }
static Action* taxi(PlayerbotAI* botAI) { return new TaxiAction(botAI); }
static Action* teleport(PlayerbotAI* botAI) { return new TeleportAction(botAI); }
static Action* release(PlayerbotAI* botAI) { return new ReleaseSpiritAction(botAI); }
Expand Down
2 changes: 2 additions & 0 deletions src/Ai/Base/ChatTriggerContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ChatTriggerContext : public NamedObjectContext<Trigger>
creators["teleport"] = &ChatTriggerContext::teleport;
creators["taxi"] = &ChatTriggerContext::taxi;
creators["repair"] = &ChatTriggerContext::repair;
creators["emblems"] = &ChatTriggerContext::emblems;
creators["u"] = &ChatTriggerContext::use;
creators["use"] = &ChatTriggerContext::use;
creators["c"] = &ChatTriggerContext::item_count;
Expand Down Expand Up @@ -235,6 +236,7 @@ class ChatTriggerContext : public NamedObjectContext<Trigger>
static Trigger* item_count(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "c"); }
static Trigger* use(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "use"); }
static Trigger* repair(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "repair"); }
static Trigger* emblems(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "emblems"); }
static Trigger* taxi(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "taxi"); }
static Trigger* teleport(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "teleport"); }
static Trigger* q(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "q"); }
Expand Down
6 changes: 4 additions & 2 deletions src/Ai/Base/Strategy/ChatCommandHandlerStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector<TriggerNode*>& trigger
triggers.push_back(new TriggerNode("pet attack", { NextAction("pet attack", relevance) }));
triggers.push_back(new TriggerNode("roll", { NextAction("roll", relevance) }));
triggers.push_back(new TriggerNode("focus heal", { NextAction("focus heal targets", relevance) }));
triggers.push_back(new TriggerNode("emblems", { NextAction("emblems", relevance) }));
}

ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI)
Expand All @@ -138,6 +139,7 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
supported.push_back("teleport");
supported.push_back("taxi");
supported.push_back("repair");
supported.push_back("emblems");
supported.push_back("talents");
supported.push_back("spells");
supported.push_back("co");
Expand Down Expand Up @@ -202,8 +204,8 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
supported.push_back("unlock items");
supported.push_back("unlock traded item");
supported.push_back("tame");
supported.push_back("glyphs"); // Added for custom Glyphs
supported.push_back("glyph equip"); // Added for custom Glyphs
supported.push_back("glyphs");
supported.push_back("glyph equip");
supported.push_back("pet");
supported.push_back("pet attack");
supported.push_back("wait for attack time");
Expand Down
2 changes: 1 addition & 1 deletion src/Ai/Base/Trigger/PvpTriggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ bool PlayerWantsInBattlegroundTrigger::IsActive()
if (bot->GetBattleground() && bot->GetBattleground()->GetStatus() == STATUS_IN_PROGRESS)
return false;

if (!bot->CanJoinToBattleground())
if (bot->IsDeserter())
return false;

return true;
Expand Down
Loading
Loading