configuration and duplicate name

This commit is contained in:
Yunfan Li
2023-05-27 23:58:28 +08:00
parent eb90822755
commit 33ef77c4fa
4 changed files with 65 additions and 43 deletions

View File

@@ -510,7 +510,8 @@ AiPlayerbot.MediumMana = 40
# Random bot default strategies (applied after defaults)
AiPlayerbot.RandomBotCombatStrategies = "+dps,+dps assist,-threat"
AiPlayerbot.RandomBotNonCombatStrategies = "+grind,+loot,+rpg,+custom::say"
# AiPlayerbot.RandomBotNonCombatStrategies = "+grind,+loot,+rpg,+custom::say"
AiPlayerbot.RandomBotNonCombatStrategies = "+grind,+loot,+custom::say"
AiPlayerbot.CombatStrategies = "+custom::say"
AiPlayerbot.NonCombatStrategies = "+custom::say,+return"
@@ -545,7 +546,7 @@ AiPlayerbot.RandomBotQuestItems = "6948,5175,5176,5177,5178,16309,12382,13704,11
AiPlayerbot.PvpProhibitedZoneIds = "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565,3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395"
# Spells every random bot will learn on randomize (54197 - cold weather flying)
AiPlayerbot.RandomBotSpellIds = "1"
AiPlayerbot.RandomBotSpellIds = "54197"
# Level diff between random bots and nearby creatures for random teleports
AiPlayerbot.RandomBotTeleLevel = 3
@@ -554,7 +555,7 @@ AiPlayerbot.RandomBotTeleLevel = 3
AiPlayerbot.OpenGoSpell = 6477
# Intervals
AiPlayerbot.RandomBotUpdateInterval = 60
AiPlayerbot.RandomBotUpdateInterval = 20
AiPlayerbot.RandomBotCountChangeMinInterval = 1800
AiPlayerbot.RandomBotCountChangeMaxInterval = 7200
AiPlayerbot.MinRandomBotInWorldTime = 3600
@@ -602,7 +603,7 @@ AiPlayerbot.SelfBotLevel = 1
AiPlayerbot.BotCheats = "taxi"
# Enables/Disables password to bot account
AiPlayerbot.RandomBotRandomPassword = 1
AiPlayerbot.RandomBotRandomPassword = 0
##################################################################################
# #

View File

@@ -10689,3 +10689,5 @@ INSERT INTO `playerbots_names` VALUES
DELETE FROM `playerbots_names` WHERE LENGTH(`name`) > 12;
ALTER TABLE `playerbots_names` MODIFY `name` varchar(12);
ALTER TABLE `playerbots_names` ADD in_use BIT default 0;

View File

@@ -279,7 +279,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
else
engine->addStrategies("heal", "threat", nullptr);
engine->addStrategies("dps assist", "flee", "cure", "ranged", "cc", nullptr);
engine->addStrategies("dps assist", "flee", "cure", "ranged", nullptr);
break;
case CLASS_MAGE:
if (tab == 0)
@@ -289,7 +289,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
else
engine->addStrategies("frost", "frost aoe", "threat", "dps aoe", nullptr);
engine->addStrategies("dps", "dps assist", "flee", "cure", "ranged", "cc", nullptr);
engine->addStrategies("dps", "dps assist", "flee", "cure", "ranged", nullptr);
break;
case CLASS_WARRIOR:
if (tab == 2)
@@ -311,11 +311,11 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
break;
case CLASS_PALADIN:
if (tab == 1)
engine->addStrategies("tank", "tank assist", "bthreat", "cure", "baoe", "bstats", "close", "cc", nullptr);
engine->addStrategies("tank", "tank assist", "bthreat", "cure", "baoe", "bstats", "close", nullptr);
else if (tab == 0)
engine->addStrategies("heal", "bmana", "dps assist", "cure", "flee", "cc", nullptr);
engine->addStrategies("heal", "bmana", "dps assist", "cure", "flee", nullptr);
else
engine->addStrategies("dps", "bdps", "dps assist", "cure", "close", "cc", nullptr);
engine->addStrategies("dps", "bdps", "dps assist", "cure", "close", nullptr);
if (player->getLevel() < 14)
{
@@ -330,31 +330,32 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
case CLASS_DRUID:
if (tab == 0)
{
engine->addStrategies("caster", "cure", "caster aoe", "threat", "flee", "dps assist", "ranged", "cc", nullptr);
engine->addStrategies("caster", "cure", "caster aoe", "threat", "flee", "dps assist", "ranged", nullptr);
if (player->getLevel() > 19)
engine->addStrategy("caster debuff");
}
else if (tab == 2)
engine->addStrategies("heal", "cure", "flee", "dps assist", "ranged", "cc", nullptr);
engine->addStrategies("heal", "cure", "flee", "dps assist", "ranged", nullptr);
else
{
engine->removeStrategy("ranged");
engine->removeStrategy("flee");
engine->addStrategies("bear", "tank assist", "flee", "close", nullptr);
}
break;
case CLASS_HUNTER:
engine->addStrategies("dps", "bdps", "threat", "dps assist", "ranged", "pet", "cc", nullptr);
engine->addStrategies("dps", "bdps", "threat", "dps assist", "ranged", "pet", nullptr);
if (player->getLevel() > 19)
engine->addStrategy("dps debuff");
break;
case CLASS_ROGUE:
engine->addStrategies("dps", "threat", "dps assist", "aoe", "close", "cc", "behind", "stealth", nullptr);
engine->addStrategies("dps", "threat", "dps assist", "aoe", "close", "behind", "stealth", nullptr);
break;
case CLASS_WARLOCK:
if (player->getLevel() > 19)
engine->addStrategy("dps debuff");
engine->addStrategies("dps assist", "dps", "flee", "ranged", "cc", "pet", "threat", nullptr);
engine->addStrategies("dps assist", "dps", "flee", "ranged", "pet", "threat", nullptr);
break;
case CLASS_DEATH_KNIGHT:
if (tab == 0)
@@ -364,7 +365,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
else
engine->addStrategies("unholy", "unholy aoe", "dps assist", "threat", nullptr);
engine->addStrategies("dps assist", "flee", "close", "cc", nullptr);
engine->addStrategies("dps assist", "flee", "close", nullptr);
break;
}

View File

@@ -120,10 +120,14 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls
LOG_DEBUG("playerbots", "Creating new random bot for class {}", cls);
uint8 gender = rand() % 2 ? GENDER_MALE : GENDER_FEMALE;
uint32 const randomRaceIndex = urand(0, availableRaces[cls].size() - 1);
uint8 race = availableRaces[cls][randomRaceIndex];
uint8 alliance = rand() % 2;
uint8 race;
for (int attempt = 0; attempt < 15; attempt++) {
race = availableRaces[cls][urand(0, availableRaces[cls].size() - 1)];
if ((alliance && IsAlliance(race)) || (!alliance && !IsAlliance(race))) {
break;
}
}
std::string name;
if (names.empty())
name = CreateRandomBotName(gender);
@@ -188,6 +192,10 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls
player->setCinematic(2);
player->SetAtLoginFlag(AT_LOGIN_NONE);
if (player->getClass() == CLASS_DEATH_KNIGHT)
{
player->learnSpell(50977, false);
}
LOG_DEBUG("playerbots", "Random bot created for account {} - name: \"{}\"; race: {}; class: {}", accountId, name.c_str(), race, cls);
return player;
@@ -207,17 +215,27 @@ std::string const RandomPlayerbotFactory::CreateRandomBotName(uint8 gender)
Field* fields = result->Fetch();
uint32 maxId = fields[0].Get<uint32>();
int tries = 10;
while(--tries) {
uint32 id = urand(0, maxId / 2);
result = CharacterDatabase.Query("SELECT n.name FROM playerbots_names n "
"LEFT OUTER JOIN characters e ON e.name = n.name WHERE e.guid IS NULL AND n.gender = {} ORDER BY RAND() LIMIT 1", gender);
"LEFT OUTER JOIN characters e ON e.name = n.name "
"WHERE e.guid IS NULL AND n.name_id >= '{}' AND n.in_use=0 LIMIT 1", id);
if (!result)
{
LOG_ERROR("playerbots", "No more names left for random bots");
return std::move(botName);
continue;
}
fields = result->Fetch();
botName = fields[0].Get<std::string>();
std::string ret = fields[0].Get<std::string>();
if (ret.size()) {
CharacterDatabase.DirectExecute("UPDATE playerbots_names SET in_use=1 WHERE name='{}'", ret);
}
return ret;
}
LOG_ERROR("playerbots", "No more names left for random bots. Simply random.");
for (uint8 i = 0; i < 10; i++) {
botName += (i == 0 ? 'A' : 'a') + rand() % 26;
}
return std::move(botName);
}
@@ -340,7 +358,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
uint32 totalAccCount = sPlayerbotAIConfig->randomBotAccountCount;
LOG_INFO("server.loading", "Creating random bot accounts...");
LOG_INFO("playerbots", "Creating random bot accounts...");
std::vector<std::future<void>> account_creations;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
@@ -385,20 +403,20 @@ void RandomPlayerbotFactory::CreateRandomBots()
LOG_INFO("server.loading", "Loading available names...");
std::unordered_map<uint8,std::vector<std::string>> names;
QueryResult result = CharacterDatabase.Query("SELECT n.gender, n.name FROM playerbots_names n LEFT OUTER JOIN characters e ON e.name = n.name WHERE e.guid IS NULL");
if (!result)
{
LOG_ERROR("server.loading", "No more names left for random bots");
return;
}
// QueryResult result = CharacterDatabase.Query("SELECT n.gender, n.name FROM playerbots_names n LEFT OUTER JOIN characters e ON e.name = n.name WHERE e.guid IS NULL");
// if (!result)
// {
// LOG_ERROR("server.loading", "No more names left for random bots");
// return;
// }
do
{
Field* fields = result->Fetch();
uint8 gender = fields[0].Get<uint8>();
std::string const bname = fields[1].Get<std::string>();
names[gender].push_back(bname);
} while (result->NextRow());
// do
// {
// Field* fields = result->Fetch();
// uint8 gender = fields[0].Get<uint8>();
// std::string const bname = fields[1].Get<std::string>();
// names[gender].push_back(bname);
// } while (result->NextRow());
LOG_INFO("playerbots", "Creating random bot characters...");
uint32 totalRandomBotChars = 0;