mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 09:17:21 +00:00
Allow using recipe produced items in ilevel check
This commit is contained in:
@@ -494,6 +494,11 @@ AuctionHouseBot.RandomStackRatio.Glyph = 0
|
||||
# The lowest item level that will show up in listings
|
||||
# Default: 0
|
||||
#
|
||||
# AuctionHouseBot.ListedItemLevelRestrict.UseCraftedItemForCalculation
|
||||
# If the item is a recipe, then this will use the item produced by it
|
||||
# for the determination if it will be excluded
|
||||
# Default: true
|
||||
#
|
||||
# AuctionHouseBot.ListedItemLevelRestrict.MaxItemLevel
|
||||
# The highest item level that will show up in listings
|
||||
# Default: 999
|
||||
@@ -503,10 +508,11 @@ AuctionHouseBot.RandomStackRatio.Glyph = 0
|
||||
# Ranges using a dash (-) can also be used
|
||||
# NOTE: Other filtering will still be honored even if it's listed here
|
||||
# Example: "100,150-200" would cause item level 100, and all item levels
|
||||
# between 150 and 200 (inclusively) to not be subjected to this restriction
|
||||
# between 150 and 200 (inclusively) to not be subjected to this restriction.
|
||||
###############################################################################
|
||||
|
||||
AuctionHouseBot.ListedItemLevelRestrict.Enabled = false
|
||||
AuctionHouseBot.ListedItemLevelRestrict.UseCraftedItemForCalculation = true
|
||||
AuctionHouseBot.ListedItemLevelRestrict.MinItemLevel = 0
|
||||
AuctionHouseBot.ListedItemLevelRestrict.MaxItemLevel = 999
|
||||
AuctionHouseBot.ListedItemLevelRestrict.ExceptionItemIDs =
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "ItemTemplate.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SpellMgr.h"
|
||||
#include <cmath>
|
||||
|
||||
#include <set>
|
||||
@@ -47,6 +48,7 @@ AuctionHouseBot::AuctionHouseBot() :
|
||||
ItemsPerCycle(75),
|
||||
DisabledItemTextFilter(true),
|
||||
ListedItemLevelRestrictedEnabled(false),
|
||||
ListedItemLevelRestrictedUseCraftedItemForCalculation(true),
|
||||
ListedItemLevelMax(999),
|
||||
ListedItemLevelMin(0),
|
||||
RandomStackRatioConsumable(1),
|
||||
@@ -429,6 +431,37 @@ void AuctionHouseBot::populateItemClassProportionList()
|
||||
populatetemClassSeedListForItemClass(ITEM_CLASS_GLYPH, ListProportionGlyph);
|
||||
}
|
||||
|
||||
ItemTemplate const* AuctionHouseBot::getProducedItemFromRecipe(ItemTemplate const* recipeItemTemplate)
|
||||
{
|
||||
if (!recipeItemTemplate)
|
||||
return nullptr;
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
{
|
||||
if (recipeItemTemplate->Spells[i].SpellId)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(recipeItemTemplate->Spells[i].SpellId);
|
||||
if (!spellInfo)
|
||||
continue;
|
||||
|
||||
for (auto const& effect : spellInfo->Effects)
|
||||
{
|
||||
if (effect.Effect == SPELL_EFFECT_CREATE_ITEM)
|
||||
{
|
||||
uint32 createdItemId = effect.ItemType;
|
||||
if (createdItemId)
|
||||
{
|
||||
ItemTemplate const* producedItem = sObjectMgr->GetItemTemplate(createdItemId);
|
||||
if (producedItem)
|
||||
return producedItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AuctionHouseBot::populateItemCandidateList()
|
||||
{
|
||||
// Clear old list and rebuild it
|
||||
@@ -475,13 +508,27 @@ void AuctionHouseBot::populateItemCandidateList()
|
||||
// Only test if it's not an exception
|
||||
if (ListedItemLevelExceptionItems.find(itr->second.ItemId) == ListedItemLevelExceptionItems.end())
|
||||
{
|
||||
if (itr->second.ItemLevel < ListedItemLevelMin)
|
||||
uint32 itemLevelToCompare = itr->second.ItemLevel;
|
||||
|
||||
// Recipes might need to consider produced items
|
||||
if (ListedItemLevelRestrictedUseCraftedItemForCalculation == true && itr->second.Class == ITEM_CLASS_RECIPE)
|
||||
{
|
||||
ItemTemplate const* producedItemTemplate = getProducedItemFromRecipe(&itr->second);
|
||||
if (producedItemTemplate != nullptr)
|
||||
{
|
||||
if (debug_Out_Filters)
|
||||
LOG_ERROR("module", "AuctionHouseBot: Using item {} for recipe {} for item level comparison since ListedItemLevelRestrictedUseCraftedItemForCalculation is true", producedItemTemplate->ItemId, itr->second.ItemId);
|
||||
itemLevelToCompare = producedItemTemplate->ItemLevel;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemLevelToCompare < ListedItemLevelMin)
|
||||
{
|
||||
if (debug_Out_Filters)
|
||||
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled since item level is lower than ListedItemLevelRestrict.MinItemLevel", itr->second.ItemId);
|
||||
continue;
|
||||
}
|
||||
if (itr->second.ItemLevel > ListedItemLevelMax)
|
||||
if (itemLevelToCompare > ListedItemLevelMax)
|
||||
{
|
||||
if (debug_Out_Filters)
|
||||
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled since item level is higher than ListedItemLevelRestrict.MaxItemLevel", itr->second.ItemId);
|
||||
@@ -1169,6 +1216,7 @@ void AuctionHouseBot::InitializeConfiguration()
|
||||
|
||||
// Item level Restrictions
|
||||
ListedItemLevelRestrictedEnabled = sConfigMgr->GetOption<bool>("AuctionHouseBot.ListedItemLevelRestrict.Enabled", false);
|
||||
ListedItemLevelRestrictedUseCraftedItemForCalculation = sConfigMgr->GetOption<bool>("AuctionHouseBot.ListedItemLevelRestrict.UseCraftedItemForCalculation", true);
|
||||
ListedItemLevelMin = sConfigMgr->GetOption("AuctionHouseBot.ListedItemLevelRestrict.MinItemLevel", 0);
|
||||
ListedItemLevelMax = sConfigMgr->GetOption("AuctionHouseBot.ListedItemLevelRestrict.MaxItemLevel", 999);
|
||||
ListedItemLevelExceptionItems.clear();
|
||||
|
||||
@@ -131,6 +131,7 @@ private:
|
||||
bool DisabledItemTextFilter;
|
||||
std::set<uint32> DisabledItems;
|
||||
bool ListedItemLevelRestrictedEnabled;
|
||||
bool ListedItemLevelRestrictedUseCraftedItemForCalculation;
|
||||
uint32 ListedItemLevelMax;
|
||||
uint32 ListedItemLevelMin;
|
||||
std::set<uint32> ListedItemLevelExceptionItems;
|
||||
@@ -238,6 +239,7 @@ private:
|
||||
void calculateItemValue(ItemTemplate const* itemProto, uint64& outBidPrice, uint64& outBuyoutPrice);
|
||||
void populatetemClassSeedListForItemClass(uint32 itemClass, uint32 itemClassSeedWeight);
|
||||
void populateItemClassProportionList();
|
||||
ItemTemplate const* getProducedItemFromRecipe(ItemTemplate const* recipeItemTemplate);
|
||||
void populateItemCandidateList();
|
||||
int getRandomValidItemClassForNewListing();
|
||||
void addNewAuctions(Player* AHBplayer, AHBConfig *config);
|
||||
|
||||
Reference in New Issue
Block a user