Skip to content

Commit

Permalink
[Playerbot] Start of Cross Core work
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1arm committed Aug 27, 2024
1 parent 6a7ae14 commit 821445d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/modules/Bots/ahbot/Category.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ namespace ahbot
public:
virtual bool Contains(ItemPrototype const* proto)
{
#if defined(CLASSIC)
return proto->Class == ITEM_CLASS_TRADE_GOODS;
#else
return proto->Class == ITEM_CLASS_TRADE_GOODS ||
proto->Class == ITEM_CLASS_MISC ||
proto->Class == ITEM_CLASS_REAGENT;
#endif
}
virtual string GetName() { return "trade"; }

Expand Down
2 changes: 2 additions & 0 deletions src/modules/Bots/playerbot/ChatHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ ChatHelper::ChatHelper(PlayerbotAI* ai) : PlayerbotAIAware(ai)
races[RACE_ORC] = "Orc";
races[RACE_TAUREN] = "Tauren";
races[RACE_TROLL] = "Troll";
#if !defined(CLASSIC)
races[RACE_DRAENEI] = "Draenei";
races[RACE_BLOODELF] = "Blood Elf";
#endif
races[RACE_UNDEAD] = "Undead";
}

Expand Down
7 changes: 5 additions & 2 deletions src/modules/Bots/playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1311,8 +1311,11 @@ bool PlayerbotAI::canDispel(const SpellEntry* entry, uint32 dispelType)

bool IsAlliance(uint8 race)
{
return race == RACE_HUMAN || race == RACE_DWARF || race == RACE_NIGHTELF || race == RACE_DRAENEI ||
race == RACE_GNOME;
return race == RACE_HUMAN || race == RACE_DWARF || race == RACE_NIGHTELF
#if !defined(CLASSIC)
|| race == RACE_DRAENEI
#endif
|| race == RACE_GNOME;
}

bool PlayerbotAI::IsOpposing(Player* player)
Expand Down
6 changes: 6 additions & 0 deletions src/modules/Bots/playerbot/PlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ uint32 PlayerbotFactory::tradeSkills[] =
SKILL_ENCHANTING,
SKILL_SKINNING,
SKILL_TAILORING,
#if !defined(CLASSIC)
SKILL_JEWELCRAFTING,
#endif
SKILL_LEATHERWORKING,
SKILL_ENGINEERING,
SKILL_HERBALISM,
Expand Down Expand Up @@ -1128,7 +1130,9 @@ void PlayerbotFactory::InitTradeSkills()
break;
case 2:
SetRandomSkill(SKILL_MINING);
#if !defined(CLASSIC)
SetRandomSkill(SKILL_JEWELCRAFTING);
#endif
break;
case 3:
SetRandomSkill(firstSkills[urand(0, firstSkills.size() - 1)]);
Expand Down Expand Up @@ -1750,11 +1754,13 @@ void PlayerbotFactory::InitInventorySkill()
{
StoreItem(2901, 1); // Mining Pick
}
#if !defined(CLASSIC)
if (bot->HasSkill(SKILL_JEWELCRAFTING))
{
StoreItem(20815, 1); // Jeweler's Kit
StoreItem(20824, 1); // Simple Grinder
}
#endif
if (bot->HasSkill(SKILL_BLACKSMITHING) || bot->HasSkill(SKILL_ENGINEERING))
{
StoreItem(5956, 1); // Blacksmith Hammer
Expand Down
28 changes: 25 additions & 3 deletions src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,72 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc
availableRaces[CLASS_WARRIOR].push_back(RACE_UNDEAD);
availableRaces[CLASS_WARRIOR].push_back(RACE_TAUREN);
availableRaces[CLASS_WARRIOR].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_WARRIOR].push_back(RACE_DRAENEI);
#endif

availableRaces[CLASS_PALADIN].push_back(RACE_HUMAN);
availableRaces[CLASS_PALADIN].push_back(RACE_DWARF);
#if !defined(CLASSIC)
availableRaces[CLASS_PALADIN].push_back(RACE_DRAENEI);
availableRaces[CLASS_PALADIN].push_back(RACE_BLOODELF);
#endif

availableRaces[CLASS_ROGUE].push_back(RACE_HUMAN);
availableRaces[CLASS_ROGUE].push_back(RACE_DWARF);
availableRaces[CLASS_ROGUE].push_back(RACE_NIGHTELF);
availableRaces[CLASS_ROGUE].push_back(RACE_GNOME);
availableRaces[CLASS_ROGUE].push_back(RACE_ORC);
availableRaces[CLASS_ROGUE].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_ROGUE].push_back(RACE_BLOODELF);

#endif
availableRaces[CLASS_PRIEST].push_back(RACE_HUMAN);
availableRaces[CLASS_PRIEST].push_back(RACE_DWARF);
availableRaces[CLASS_PRIEST].push_back(RACE_NIGHTELF);
#if !defined(CLASSIC)
availableRaces[CLASS_PRIEST].push_back(RACE_DRAENEI);
#endif
availableRaces[CLASS_PRIEST].push_back(RACE_TROLL);
availableRaces[CLASS_PRIEST].push_back(RACE_UNDEAD);
#if !defined(CLASSIC)
availableRaces[CLASS_PRIEST].push_back(RACE_BLOODELF);

#endif
availableRaces[CLASS_MAGE].push_back(RACE_HUMAN);
availableRaces[CLASS_MAGE].push_back(RACE_GNOME);
#if !defined(CLASSIC)
availableRaces[CLASS_MAGE].push_back(RACE_DRAENEI);
#endif
availableRaces[CLASS_MAGE].push_back(RACE_UNDEAD);
availableRaces[CLASS_MAGE].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_MAGE].push_back(RACE_BLOODELF);
#endif

availableRaces[CLASS_WARLOCK].push_back(RACE_HUMAN);
availableRaces[CLASS_WARLOCK].push_back(RACE_GNOME);
availableRaces[CLASS_WARLOCK].push_back(RACE_UNDEAD);
availableRaces[CLASS_WARLOCK].push_back(RACE_ORC);
#if !defined(CLASSIC)
availableRaces[CLASS_WARLOCK].push_back(RACE_BLOODELF);
#endif

#if !defined(CLASSIC)
availableRaces[CLASS_SHAMAN].push_back(RACE_DRAENEI);
#endif
availableRaces[CLASS_SHAMAN].push_back(RACE_ORC);
availableRaces[CLASS_SHAMAN].push_back(RACE_TAUREN);
availableRaces[CLASS_SHAMAN].push_back(RACE_TROLL);

availableRaces[CLASS_HUNTER].push_back(RACE_DWARF);
availableRaces[CLASS_HUNTER].push_back(RACE_NIGHTELF);
availableRaces[CLASS_HUNTER].push_back(RACE_DRAENEI);
availableRaces[CLASS_HUNTER].push_back(RACE_ORC);
availableRaces[CLASS_HUNTER].push_back(RACE_TAUREN);
availableRaces[CLASS_HUNTER].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_HUNTER].push_back(RACE_DRAENEI);
availableRaces[CLASS_HUNTER].push_back(RACE_BLOODELF);
#endif

availableRaces[CLASS_DRUID].push_back(RACE_NIGHTELF);
availableRaces[CLASS_DRUID].push_back(RACE_TAUREN);
Expand All @@ -97,7 +115,11 @@ bool RandomPlayerbotFactory::CreateRandomBot(uint8 cls)
uint8 facialHair = urand(0, 7);
uint8 outfitId = 0;

#if !defined(CLASSIC)
WorldSession* session = new WorldSession(accountId, NULL, SEC_PLAYER, MAX_EXPANSION, 0, LOCALE_enUS);
#else
WorldSession* session = new WorldSession(accountId, NULL, SEC_PLAYER, 0, LOCALE_enUS);
#endif
if (!session)
{
sLog.outError("Couldn't create session for random bot account %d", accountId);
Expand Down
24 changes: 23 additions & 1 deletion src/modules/Bots/playerbot/strategy/actions/LootRollAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ bool LootRollAction::Execute(Event event)
}

RollVote vote = ROLL_PASS;
#if defined(CLASSIC)
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(guid.GetEntry());
if (proto)
{
switch (proto->Class)
{
case ITEM_CLASS_WEAPON:
case ITEM_CLASS_ARMOR:
if (QueryItemUsage(proto))
{
vote = ROLL_NEED;
}
break;
default:
if (IsLootAllowed(guid.GetEntry()))
{
vote = ROLL_NEED;
}
break;
}
}
#else
for (vector<Roll*>::iterator i = group->GetRolls().begin(); i != group->GetRolls().end(); ++i)
{
if ((*i)->isValid() && (*i)->lootedTargetGUID == guid && (*i)->itemSlot == slot)
Expand All @@ -43,7 +65,7 @@ bool LootRollAction::Execute(Event event)
}
}
}

#endif
switch (group->GetLootMethod())
{
case MASTER_LOOT:
Expand Down
6 changes: 4 additions & 2 deletions src/modules/Bots/playerbot/strategy/actions/UseItemAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget)

if (itemTarget)
{
#if !defined(CLASSIC)
if (item->GetProto()->Class == ITEM_CLASS_GEM)
{
bool fit = SocketItem(itemTarget, item) || SocketItem(itemTarget, item, true);
Expand All @@ -148,6 +149,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget)
return fit;
}
else
#endif
{
uint32 targetFlag = TARGET_FLAG_ITEM;
*packet << targetFlag << itemTarget->GetPackGUID();
Expand Down Expand Up @@ -279,6 +281,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget)
bot->GetSession()->QueuePacket(packet);
return true;
}
#if !defined(CLASSIC)
bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
{
WorldPacket* const packet = new WorldPacket(CMSG_SOCKET_GEMS);
Expand Down Expand Up @@ -335,8 +338,7 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
}
return fits;
}


#endif

bool UseItemAction::isPossible()
{
Expand Down

0 comments on commit 821445d

Please sign in to comment.