Skip to content

Commit

Permalink
NPCBots: Make NpcBot.GearBank.EquipmentSets actually affect player'…
Browse files Browse the repository at this point in the history
…s ability to use / create new sets

(cherry picked from commit b9d97b940f22872eb2f38d631bffd9182af81422)
  • Loading branch information
trickerer committed Nov 14, 2024
1 parent da3fbac commit 9334f8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10022,7 +10022,8 @@ bool bot_ai::OnGossipSelect(Player* player, Creature* creature/* == me*/, uint32

AddGossipItemFor(player, GOSSIP_ICON_TALK, LocalizedNpcText(player, BOT_TEXT_DEPOSIT_ITEMS), GOSSIP_SENDER_EQUIPMENT_BANK_DEPOSIT, GOSSIP_ACTION_INFO_DEF + 0);
AddGossipItemFor(player, GOSSIP_ICON_TALK, LocalizedNpcText(player, BOT_TEXT_WITHDRAW_ITEMS), GOSSIP_SENDER_EQUIPMENT_BANK_WITHDRAW, GOSSIP_ACTION_INFO_DEF + 0);
AddGossipItemFor(player, GOSSIP_ICON_TALK, LocalizedNpcText(player, BOT_TEXT_EQUIPMENT_SETS) + "...", GOSSIP_SENDER_EQUIPMENT_BANK_SETS_MENU, GOSSIP_ACTION_INFO_DEF + 0);
if (BotMgr::GetGearBankEquipmentSetsCount() > 0)
AddGossipItemFor(player, GOSSIP_ICON_TALK, LocalizedNpcText(player, BOT_TEXT_EQUIPMENT_SETS) + "...", GOSSIP_SENDER_EQUIPMENT_BANK_SETS_MENU, GOSSIP_ACTION_INFO_DEF + 0);
AddGossipItemFor(player, GOSSIP_ICON_CHAT, LocalizedNpcText(player, BOT_TEXT_BACK), GOSSIP_SENDER_EQUIPMENT, GOSSIP_ACTION_INFO_DEF + 1);
break;
}
Expand Down Expand Up @@ -10118,7 +10119,8 @@ bool bot_ai::OnGossipSelect(Player* player, Creature* creature/* == me*/, uint32
{
subMenu = true;

AddGossipItemFor(player, GOSSIP_ICON_CHAT, LocalizedNpcText(player, BOT_TEXT_CREATE) + "...", GOSSIP_SENDER_EQUIPMENT_BANK_SET_CREATE, GOSSIP_ACTION_INFO_DEF + 0, "", 0, true);
if (BotDataMgr::GetBotItemSetsCount(player->GetGUID()) < BotMgr::GetGearBankEquipmentSetsCount())
AddGossipItemFor(player, GOSSIP_ICON_CHAT, LocalizedNpcText(player, BOT_TEXT_CREATE) + "...", GOSSIP_SENDER_EQUIPMENT_BANK_SET_CREATE, GOSSIP_ACTION_INFO_DEF + 0, "", 0, true);

//list existing sets
if (BotItemSetsArray const* itemSets = BotDataMgr::GetBotItemSets(player->GetGUID()))
Expand Down
7 changes: 7 additions & 0 deletions src/server/game/AI/NpcBots/botdatamgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3261,6 +3261,13 @@ void BotDataMgr::SaveNpcBotStoredGear(ObjectGuid playerGuid, CharacterDatabaseTr
}
}

uint32 BotDataMgr::GetBotItemSetsCount(ObjectGuid playerGuid)
{
if (BotItemSetsArray const* item_sets = GetBotItemSets(playerGuid))
return std::ranges::count_if(NPCBots::index_array<uint8, MAX_BOT_EQUIPMENT_SETS>, [=](uint8 i) { return !!item_sets->at(i); });
return 0;
}

BotItemSetsArray const* BotDataMgr::GetBotItemSets(ObjectGuid playerGuid)
{
decltype(_botStoredGearSetMap)::const_iterator sci = _botStoredGearSetMap.find(playerGuid);
Expand Down
1 change: 1 addition & 0 deletions src/server/game/AI/NpcBots/botdatamgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class BotDataMgr
static void DepositBotBankItem(ObjectGuid playerGuid, Item* item);
static void SaveNpcBotStoredGear(ObjectGuid playerGuid, CharacterDatabaseTransaction trans);

static uint32 GetBotItemSetsCount(ObjectGuid playerGuid);
static BotItemSetsArray const* GetBotItemSets(ObjectGuid playerGuid);
static NpcBotItemSet const* GetBotItemSet(ObjectGuid playerGuid, uint8 set_id);
static NpcBotItemSet& CreateNewBotItemSet(ObjectGuid playerGuid);
Expand Down

0 comments on commit 9334f8a

Please sign in to comment.