diff --git a/common/ruletypes.h b/common/ruletypes.h index 60a9bfa0e..99ff386a7 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -895,6 +895,10 @@ RULE_INT(Bots, CampTimer, 25, "Number of seconds after /camp has begun before bo RULE_BOOL(Bots, SendClassRaceOnHelp, true, "If enabled a reminder of how to check class/race IDs will be sent when using compatible commands.") RULE_BOOL(Bots, AllowCrossGroupRaidAssist, true, "If enabled bots will autodefend group or raid members set as main assist.") RULE_BOOL(Bots, AllowBotBlockedBuffs, true, "If enabled, you can create blocked buffs for each bot and for their pets.") +RULE_STRING(Bots, ZonesWithSpawnLimits, "", "Comma-delimited list of zones where different bot spawn limits apply. This is the max a zone allows.") +RULE_STRING(Bots, ZoneSpawnLimits, "", "Comma-delimited list of spawn limits for zones.") +RULE_STRING(Bots, ZonesWithForcedSpawnLimits, "", "Comma-delimited list of zones where bot spawn limits are forced. This will take priority over any other type of spawn limits.") +RULE_STRING(Bots, ZoneForcedSpawnLimits, "", "Comma-delimited list of forced spawn limits for zones.") RULE_CATEGORY_END() RULE_CATEGORY(Chat) diff --git a/zone/client_bot.cpp b/zone/client_bot.cpp index 2a4c5c0a8..7b0bfd7bb 100644 --- a/zone/client_bot.cpp +++ b/zone/client_bot.cpp @@ -103,8 +103,6 @@ int Client::GetBotSpawnLimit(uint8 class_id) if (!bucket_value.empty() && Strings::IsNumber(bucket_value)) { bot_spawn_limit = Strings::ToInt(bucket_value); - - return bot_spawn_limit; } if (RuleB(Bots, QuestableSpawnLimit)) { @@ -124,6 +122,52 @@ int Client::GetBotSpawnLimit(uint8 class_id) bot_spawn_limit = Strings::ToInt(row[0]); } + const auto& zones_list = Strings::Split(RuleS(Bots, ZonesWithSpawnLimits), ","); + const auto& zones_limits_list = Strings::Split(RuleS(Bots, ZoneSpawnLimits), ","); + int i = 0; + + for (const auto& result : zones_list) { + try { + if ( + std::stoul(result) == zone->GetZoneID() && + std::stoul(zones_limits_list[i]) < bot_spawn_limit + ) { + bot_spawn_limit = std::stoul(zones_limits_list[i]); + + break; + } + + ++i; + } + + catch (const std::exception& e) { + LogInfo("Invalid entry in Rule VegasScaling:SpecialScalingZones or SpecialScalingZonesVersions: [{}]", e.what()); + } + } + + const auto& zones_forced_list = Strings::Split(RuleS(Bots, ZonesWithForcedSpawnLimits), ","); + const auto& zones_forced_limits_list = Strings::Split(RuleS(Bots, ZoneForcedSpawnLimits), ","); + i = 0; + + for (const auto& result : zones_forced_list) { + try { + if ( + std::stoul(result) == zone->GetZoneID() && + std::stoul(zones_forced_limits_list[i]) != bot_spawn_limit + ) { + bot_spawn_limit = std::stoul(zones_forced_limits_list[i]); + + break; + } + + ++i; + } + + catch (const std::exception& e) { + LogInfo("Invalid entry in Rule VegasScaling:SpecialScalingZones or SpecialScalingZonesVersions: [{}]", e.what()); + } + } + return bot_spawn_limit; }