equipmentPersistence

This commit is contained in:
Yunfan Li
2023-09-15 00:06:45 +08:00
parent 0ea649340e
commit be13e0e189
5 changed files with 24 additions and 7 deletions

View File

@@ -623,6 +623,13 @@ AiPlayerbot.RandomBotRandomPassword = 0
# Set RandomBotMaxLevel bots to RandomBotMinLevel or not
AiPlayerbot.DowngradeMaxLevelBot = 0
# Enable/Disable bot equipments persistence (stop random initialization) after certain level (EquipmentPersistenceLevel)
# default: 0 (disable)
AiPlayerbot.EquipmentPersistence = 0
# default: 80
AiPlayerbot.EquipmentPersistenceLevel = 80
##################################################################################
# #
# Database Stuff #

View File

@@ -296,6 +296,8 @@ bool PlayerbotAIConfig::Initialize()
disableRandomLevels = sConfigMgr->GetOption<bool>("AiPlayerbot.DisableRandomLevels", false);
randomBotRandomPassword = sConfigMgr->GetOption<bool>("AiPlayerbot.RandomBotRandomPassword", true);
downgradeMaxLevelBot = sConfigMgr->GetOption<bool>("AiPlayerbot.DowngradeMaxLevelBot", true);
equipmentPersistence = sConfigMgr->GetOption<bool>("AiPlayerbot.EquipmentPersistence", false);
equipmentPersistenceLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.EquipmentPersistenceLevel", 80);
playerbotsXPrate = sConfigMgr->GetOption<int32>("AiPlayerbot.KillXPRate", 1);
botActiveAlone = sConfigMgr->GetOption<int32>("AiPlayerbot.BotActiveAlone", 10);
randombotsWalkingRPG = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG", false);

View File

@@ -167,6 +167,8 @@ class PlayerbotAIConfig
uint32 selfBotLevel;
bool downgradeMaxLevelBot;
bool equipmentPersistence;
int32 equipmentPersistenceLevel;
std::string const GetTimestampStr();
bool hasLog(std::string const fileName) { return std::find(allowedLogFiles.begin(), allowedLogFiles.end(), fileName) != allowedLogFiles.end(); };
bool openLog(std::string const fileName, char const* mode = "a");

View File

@@ -130,7 +130,9 @@ void PlayerbotFactory::Randomize(bool incremental)
{
ResetQuests();
}
ClearAllItems();
if (!sPlayerbotAIConfig->equipmentPersistence || level < sPlayerbotAIConfig->equipmentPersistenceLevel) {
ClearAllItems();
}
bot->SaveToDB(false, false);
bot->GiveLevel(level);
@@ -222,7 +224,9 @@ void PlayerbotFactory::Randomize(bool incremental)
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Equip");
LOG_INFO("playerbots", "Initializing equipmemt...");
InitEquipment(incremental);
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) {
InitEquipment(incremental);
}
// bot->SaveToDB(false, false);
if (pmo)
pmo->finish();
@@ -342,7 +346,9 @@ void PlayerbotFactory::Randomize(bool incremental)
void PlayerbotFactory::Refresh()
{
// Prepare();
InitEquipment(true);
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) {
InitEquipment(true);
}
ClearInventory();
InitAmmo();
InitFood();
@@ -1153,9 +1159,7 @@ void Shuffle(std::vector<uint32>& items)
void PlayerbotFactory::InitEquipment(bool incremental)
{
// todo(yunfan): to be refactored, too much time overhead
std::map<uint8, std::vector<uint32> > items;
std::unordered_map<uint8, std::vector<uint32> > items;
int tab = AiFactory::GetPlayerSpecTab(bot);
uint32 blevel = bot->getLevel();

View File

@@ -20,6 +20,8 @@ void AutoTeleportForLevelAction::AutoUpgradeEquip() {
return;
}
PlayerbotFactory factory(bot, bot->GetLevel(), ITEM_QUALITY_RARE);
factory.InitEquipment(true);
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) {
factory.InitEquipment(true);
}
factory.InitAmmo();
}