Skip to content

Commit

Permalink
Merge branch 'celguar:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikely4r authored Feb 9, 2023
2 parents 259d89c + 0ab3ac9 commit bd4fdcb
Show file tree
Hide file tree
Showing 64 changed files with 756 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmangos-wotlk-windows-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/checkout@v2
with:
ref: ${{env.CORE_BRANCH}}
repository: ${{env.CORE_REPO_OWNER}}mangos-wotlk
repository: ${{env.CORE_REPO_OWNER}}/mangos-wotlk
path: ${{env.REPO_DIR}}
# submodules: recursive

Expand Down
2 changes: 1 addition & 1 deletion ahbot/AhBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ void AhBot::CheckSendMail(uint32 bidder, uint32 price, AuctionEntry *entry)
Item *item = sAuctionMgr.GetAItem(entry->itemGuidLow);
if (!item)
return;
body << "I see you posted " << ChatHelper::formatItem(item->GetProto(), item->GetCount());
body << "I see you posted " << ChatHelper::formatItem(item, item->GetCount());
body << " to the AH and I really need that at the moment. Could you lower your price at least to ";
body << ChatHelper::formatMoney(PricingStrategy::RoundPrice(price)) << "? I'll buy it then.\n";
body << "\n";
Expand Down
2 changes: 1 addition & 1 deletion playerbot/AiFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ Engine* AiFactory::createDeadEngine(Player* player, PlayerbotAI* const facade, A

void AiFactory::AddDefaultReactionStrategies(Player* player, PlayerbotAI* const facade, ReactionEngine* reactionEngine)
{
reactionEngine->addStrategies("react", "chat", "avoid aoe", "potions", NULL);
reactionEngine->addStrategies("react", "chat", "avoid aoe", "potions", "follow", NULL);
}

ReactionEngine* AiFactory::createReactionEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* AiObjectContext) {
Expand Down
28 changes: 14 additions & 14 deletions playerbot/ChatFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,12 @@ class UsageChatFilter : public ChatFilter
if (item.empty())
return message;

ItemIds ids = ChatHelper::parseItems(item);
set<string> qualifiers = ChatHelper::parseItemQualifiers(item);

if(ids.empty())
if(qualifiers.empty())
return message;

ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", *ids.begin());
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", ItemQualifier(*qualifiers.begin()).GetQualifier());

if (usage != ITEM_USAGE_NONE && usage != ITEM_USAGE_AH && usage != ITEM_USAGE_VENDOR)
{
Expand All @@ -786,12 +786,12 @@ class UsageChatFilter : public ChatFilter
if (item.empty())
return message;

ItemIds ids = ChatHelper::parseItems(item);
set<string> qualifiers = ChatHelper::parseItemQualifiers(item);

if (ids.empty())
if (qualifiers.empty())
return message;

ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", *ids.begin());
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", ItemQualifier(*qualifiers.begin()).GetQualifier());

if (usage == ITEM_USAGE_AH || usage == ITEM_USAGE_VENDOR)
{
Expand All @@ -807,14 +807,14 @@ class UsageChatFilter : public ChatFilter
if (item.empty())
return message;

ItemIds ids = ChatHelper::parseItems(item);
set<string> qualifiers = ChatHelper::parseItemQualifiers(item);

if (ids.empty())
if (qualifiers.empty())
return message;

ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", *ids.begin());
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", ItemQualifier(*qualifiers.begin()).GetQualifier());

if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_GUILD_TASK || usage == ITEM_USAGE_BAD_EQUIP || (usage == ITEM_USAGE_FORCE && AI_VALUE2(ForceItemUsage, "force item usage", *ids.begin()) == ForceItemUsage::FORCE_USAGE_NEED))
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_GUILD_TASK || usage == ITEM_USAGE_BAD_EQUIP || (usage == ITEM_USAGE_FORCE && AI_VALUE2(ForceItemUsage, "force item usage", ItemQualifier(*qualifiers.begin()).GetId()) == ForceItemUsage::FORCE_USAGE_NEED))
{
return FilterLink(message);
}
Expand All @@ -828,14 +828,14 @@ class UsageChatFilter : public ChatFilter
if (item.empty())
return message;

ItemIds ids = ChatHelper::parseItems(item);
set<string> qualifiers = ChatHelper::parseItemQualifiers(item);

if (ids.empty())
if (qualifiers.empty())
return message;

ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", *ids.begin());
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", ItemQualifier(*qualifiers.begin()).GetQualifier());

if (usage == ITEM_USAGE_SKILL || usage == ITEM_USAGE_USE || usage == ITEM_USAGE_DISENCHANT || usage == ITEM_USAGE_AH || usage == ITEM_USAGE_VENDOR || (usage == ITEM_USAGE_FORCE && AI_VALUE2(ForceItemUsage, "force item usage", *ids.begin()) == ForceItemUsage::FORCE_USAGE_GREED))
if (usage == ITEM_USAGE_SKILL || usage == ITEM_USAGE_USE || usage == ITEM_USAGE_DISENCHANT || usage == ITEM_USAGE_AH || usage == ITEM_USAGE_VENDOR || (usage == ITEM_USAGE_FORCE && AI_VALUE2(ForceItemUsage, "force item usage", ItemQualifier(*qualifiers.begin()).GetId()) == ForceItemUsage::FORCE_USAGE_GREED))
{
return FilterLink(message);
}
Expand Down
56 changes: 52 additions & 4 deletions playerbot/ChatHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "playerbot.h"
#include "ChatHelper.h"
#include "AiFactory.h"
#include "strategy/values/ItemUsageValue.h"

using namespace ai;
using namespace std;
Expand Down Expand Up @@ -274,6 +275,29 @@ ItemIds ChatHelper::parseItems(string& text)
return itemIds;
}

set<string> ChatHelper::parseItemQualifiers(string& text)
{
set<string> qualifiers;

uint8 pos = 0;
while (true)
{
int i = text.find("Hitem:", pos);
if (i == -1)
break;
pos = i + 6;
int endPos = text.find('|', pos);
if (endPos == -1)
break;

string qualifierString = text.substr(pos, endPos - pos);

qualifiers.insert(qualifierString);
}

return qualifiers;
}

string ChatHelper::formatQuest(Quest const* quest)
{
ostringstream out;
Expand Down Expand Up @@ -374,9 +398,10 @@ string ChatHelper::formatSpell(SpellEntry const *sInfo)
return out.str();
}

string ChatHelper::formatItem(ItemPrototype const * proto, int count, int total)
string ChatHelper::formatItem(ItemQualifier& itemQualifier, int count, int total)
{
char color[32];
ItemPrototype const* proto = itemQualifier.GetProto();
sprintf(color, "%x", ItemQualityColors[proto->Quality]);

ostringstream out;
Expand All @@ -385,12 +410,25 @@ string ChatHelper::formatItem(ItemPrototype const * proto, int count, int total)
if (loc_idx >= 0)
{
std::string tname;
sObjectMgr.GetItemLocaleStrings(proto->ItemId, loc_idx, &tname);
sObjectMgr.GetItemLocaleStrings(itemQualifier.GetId(), loc_idx, &tname);
if (!tname.empty())
name = tname;
}
out << "|c" << color << "|Hitem:" << proto->ItemId
<< ":0:0:0:0:0:0:0" << "|h[" << name

if (itemQualifier.GetRandomPropertyId())
{
ItemRandomPropertiesEntry const* item_rand = sItemRandomPropertiesStore.LookupEntry(abs(itemQualifier.GetRandomPropertyId()));

if (item_rand)
{
if (loc_idx < 0)
loc_idx = 0;
string suffix = item_rand->nameSuffix[loc_idx];
name += " " + suffix;
}
}

out << "|c" << color << "|Hitem:" << itemQualifier.GetLinkQualifier() << "|h[" << name
<< "]|h|r";

if (count > 1)
Expand All @@ -402,6 +440,16 @@ string ChatHelper::formatItem(ItemPrototype const * proto, int count, int total)
return out.str();
}

string ChatHelper::formatItem(ItemPrototype const* proto, int count, int total)
{
return formatItem(ItemQualifier(proto->ItemId), count, total);
}

string ChatHelper::formatItem(Item* item, int count, int total)
{
return formatItem(ItemQualifier(item), count, total);
}

string ChatHelper::formatQItem(uint32 itemId)
{
char color[32];
Expand Down
5 changes: 5 additions & 0 deletions playerbot/ChatHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ typedef set<uint32> SpellIds;

namespace ai
{
class ItemQualifier;

class ChatHelper : public PlayerbotAIAware
{
public:
Expand All @@ -18,9 +20,12 @@ namespace ai

static string formatQuest(Quest const* quest);

static string formatItem(ItemQualifier& itemQualifier, int count = 0, int total = 0);
static string formatItem(ItemPrototype const * proto, int count = 0, int total = 0);
static string formatItem(Item* item, int count = 0, int total = 0);
static string formatQItem(uint32 itemId);
static ItemIds parseItems(string& text);
static set<string> parseItemQualifiers(string& text);
static uint32 parseItemQuality(string text);
static bool parseItemClass(string text, uint32* itemClass, uint32* itemSubClass);
static uint32 parseSlot(string text);
Expand Down
4 changes: 3 additions & 1 deletion playerbot/LootObjectStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ using namespace std;

namespace ai
{
class ItemQualifier;

class LootStrategy
{
public:
LootStrategy() {}
virtual ~LootStrategy() {};
virtual bool CanLoot(ItemPrototype const *proto, AiObjectContext *context) = 0;
virtual bool CanLoot(ItemQualifier& itemQualifier, AiObjectContext *context) = 0;
virtual string GetName() = 0;
};

Expand Down
2 changes: 1 addition & 1 deletion playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ void PlayerbotAI::DoNextAction(bool min)

Group *group = bot->GetGroup();
// test BG master set
if ((!master || !HasActivePlayerMaster()) && group)
if ((!master || !HasActivePlayerMaster()) && group && !IsRealPlayer())
{
PlayerbotAI* ai = bot->GetPlayerbotAI();

Expand Down
Loading

0 comments on commit bd4fdcb

Please sign in to comment.