From 0cd1fa4db3d75e59bda889e84f5db84f4e2ed276 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 31 Jul 2023 12:49:27 +0800 Subject: [PATCH] grind, teleport, move random for rndbot --- conf/playerbots.conf.dist | 26 ++-- src/AiFactory.cpp | 8 +- src/PlayerbotAIConfig.cpp | 5 +- src/PlayerbotAIConfig.h | 3 +- src/PlayerbotFactory.cpp | 22 ++-- src/RandomPlayerbotMgr.cpp | 143 +++++++++++----------- src/strategy/StrategyContext.h | 2 + src/strategy/actions/MovementActions.cpp | 2 +- src/strategy/generic/GrindingStrategy.cpp | 6 + src/strategy/generic/GrindingStrategy.h | 7 ++ src/strategy/values/AttackersValue.cpp | 7 +- src/strategy/values/GrindTargetValue.cpp | 13 +- 12 files changed, 145 insertions(+), 99 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 6352e7c5..53c7c5dc 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -61,13 +61,13 @@ AiPlayerbot.RandomBotArenaTeamCount = 20 AiPlayerbot.DeleteRandomBotArenaTeams = 0 # Change random bot has lower gear -AiPlayerbot.RandomGearLoweringChance = 0.15 +AiPlayerbot.RandomGearLoweringChance = 0 # Chance random bot has max level on first randomize (default 0.15) -AiPlayerbot.RandomBotMaxLevelChance = 0.15 +AiPlayerbot.RandomBotMaxLevelChance = 0 # Chance bot chooses RPG (Teleport to random camp for their level) instead of grinding -AiPlayerbot.RandomBotRpgChance = 0.20 +AiPlayerbot.RandomBotRpgChance = 0.20 #unused now # Set randombots movement speed to walking anywhere AiPlayerbot.RandombotsWalkingRPG = 0 @@ -100,7 +100,7 @@ AiPlayerbot.BotActiveAlone = 100 # Set minimum level of randombots where gets enchants on items (Maxlevel + 1 to disable) # Default: 60 -AiPlayerbot.MinEnchantingBotLevel = 60 +AiPlayerbot.MinEnchantingBotLevel = 60 # unused now # Randombots checking players gear score level and deny the group invite if it's too low # Default: 1 (enabled) @@ -138,13 +138,13 @@ AiPlayerbot.SyncLevelWithPlayers = 0 # Give free food to random bots # Default: 1 (enabled) -AiPlayerbot.FreeFood = 0 +AiPlayerbot.FreeFood = 1 # Bot automatically trains spells when talking to trainer (yes = train all available spells as long as the bot has the money, free = auto trains with no money cost, no = only list spells) AiPlayerbot.AutoTrainSpells = yes # Bot automatically picks talent points based on current spec (full = pick spec based on probability if multiple are like current spec, semi = only apply points if 1 spec looks like current spec, no = no auto talent points) -AiPlayerbot.AutoPickTalents = full +AiPlayerbot.AutoPickTalents = no # Bots automatically learn trainable spells on levelup # Default: 0 (disabled) @@ -156,7 +156,7 @@ AiPlayerbot.AutoLearnQuestSpells = 0 # Random Bots will pick quests on their own and try to complete # Default: 0 (disabled) -AiPlayerbot.AutoDoQuests = 0 +AiPlayerbot.AutoDoQuests = 1 ################################################################################## # # @@ -543,7 +543,7 @@ AiPlayerbot.RandomBotMaps = 0,1,530,571 AiPlayerbot.RandomBotQuestItems = "6948,5175,5176,5177,5178,16309,12382,13704,11000" # PvP Restricted Zones (bots don't pvp) -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" +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,3703" # Spells every random bot will learn on randomize (54197 - cold weather flying) AiPlayerbot.RandomBotSpellIds = "54197" @@ -562,13 +562,15 @@ AiPlayerbot.MinRandomBotInWorldTime = 3600 AiPlayerbot.MaxRandomBotInWorldTime = 1209600 AiPlayerbot.MinRandomBotRandomizeTime = 302400 AiPlayerbot.MaxRandomRandomizeTime = 1209600 -AiPlayerbot.RandomBotsPerInterval = 50 +AiPlayerbot.RandomBotsPerInterval = 500 AiPlayerbot.MinRandomBotsPriceChangeInterval = 7200 AiPlayerbot.MaxRandomBotsPriceChangeInterval = 172800 AiPlayerbot.MinRandomBotChangeStrategyTime = 180 AiPlayerbot.MaxRandomBotChangeStrategyTime = 720 AiPlayerbot.MinRandomBotReviveTime = 60 AiPlayerbot.MaxRandomBotReviveTime = 300 +AiPlayerbot.MinRandomBotTeleportInterval = 3600 +AiPlayerbot.MaxRandomBotTeleportInterval = 18000 # How far random bots are teleported after death AiPlayerbot.RandomBotTeleportDistance = 100 @@ -605,6 +607,9 @@ AiPlayerbot.BotCheats = "taxi" # Enables/Disables password to bot account AiPlayerbot.RandomBotRandomPassword = 0 +# Set RandomBotMaxLevel bots to RandomBotMinLevel or not +AiPlayerbot.DowngradeMaxLevelBot = 1 + ################################################################################## # # # Database Stuff # @@ -746,4 +751,5 @@ AiPlayerbot.DefaultTalentsOrder.10.0 = AiPlayerbot.RandomClassSpecProbability.10.1 = 33 AiPlayerbot.DefaultTalentsOrder.10.1 = AiPlayerbot.RandomClassSpecProbability.10.2 = 33 -AiPlayerbot.DefaultTalentsOrder.10.2 = \ No newline at end of file +AiPlayerbot.DefaultTalentsOrder.10.2 = + diff --git a/src/AiFactory.cpp b/src/AiFactory.cpp index 5675da24..ac1c7139 100644 --- a/src/AiFactory.cpp +++ b/src/AiFactory.cpp @@ -547,13 +547,15 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->addStrategy("pvp"); // nonCombatEngine->addStrategy("collision"); nonCombatEngine->addStrategy("grind"); - // nonCombatEngine->addStrategy("group"); + nonCombatEngine->addStrategy("group"); // nonCombatEngine->addStrategy("guild"); if (sPlayerbotAIConfig->autoDoQuests) { nonCombatEngine->addStrategy("travel"); nonCombatEngine->addStrategy("rpg"); + } else { + nonCombatEngine->addStrategy("move random"); } if (sPlayerbotAIConfig->randomBotJoinBG) @@ -576,13 +578,15 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->addStrategy("pvp"); // nonCombatEngine->addStrategy("collision"); nonCombatEngine->addStrategy("grind"); - // nonCombatEngine->addStrategy("group"); + nonCombatEngine->addStrategy("group"); // nonCombatEngine->addStrategy("guild"); if (sPlayerbotAIConfig->autoDoQuests) { nonCombatEngine->addStrategy("travel"); nonCombatEngine->addStrategy("rpg"); + } else { + nonCombatEngine->addStrategy("move random"); } if (masterBotAI) diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 950befcf..4b11969e 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -101,7 +101,7 @@ bool PlayerbotAIConfig::Initialize() LoadList>(randomBotMapsAsString, randomBotMaps); LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestItems", "6948,5175,5176,5177,5178,16309,12382,13704,11000"), randomBotQuestItems); LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotSpellIds", "54197"), randomBotSpellIds); - LoadList>(sConfigMgr->GetOption("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"), pvpProhibitedZoneIds); + LoadList>(sConfigMgr->GetOption("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"), pvpProhibitedZoneIds); LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestIds", "7848,3802,5505,6502,7761"), randomBotQuestIds); botAutologin = sConfigMgr->GetOption("AiPlayerbot.BotAutologin", false); @@ -119,6 +119,8 @@ bool PlayerbotAIConfig::Initialize() maxRandomBotChangeStrategyTime = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotChangeStrategyTime", 2 * HOUR); minRandomBotReviveTime = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotReviveTime", MINUTE); maxRandomBotReviveTime = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotReviveTime", 5 * MINUTE); + minRandomBotTeleportInterval = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotTeleportInterval", 1 * HOUR); + maxRandomBotTeleportInterval = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotTeleportInterval", 5 * HOUR); randomBotTeleportDistance = sConfigMgr->GetOption("AiPlayerbot.RandomBotTeleportDistance", 100); randomBotsPerInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotsPerInterval", MINUTE); minRandomBotsPriceChangeInterval = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotsPriceChangeInterval", 2 * HOUR); @@ -292,6 +294,7 @@ bool PlayerbotAIConfig::Initialize() enableGreet = sConfigMgr->GetOption("AiPlayerbot.EnableGreet", true); disableRandomLevels = sConfigMgr->GetOption("AiPlayerbot.DisableRandomLevels", false); randomBotRandomPassword = sConfigMgr->GetOption("AiPlayerbot.RandomBotRandomPassword", true); + downgradeMaxLevelBot = sConfigMgr->GetOption("AiPlayerbot.DowngradeMaxLevelBot", true); playerbotsXPrate = sConfigMgr->GetOption("AiPlayerbot.KillXPRate", 1); botActiveAlone = sConfigMgr->GetOption("AiPlayerbot.BotActiveAlone", 10); randombotsWalkingRPG = sConfigMgr->GetOption("AiPlayerbot.RandombotsWalkingRPG", false); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index d372108c..73971eec 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -66,6 +66,7 @@ class PlayerbotAIConfig uint32 minRandomBotRandomizeTime, maxRandomBotRandomizeTime; uint32 minRandomBotChangeStrategyTime, maxRandomBotChangeStrategyTime; uint32 minRandomBotReviveTime, maxRandomBotReviveTime; + uint32 minRandomBotTeleportInterval, maxRandomBotTeleportInterval; uint32 minRandomBotPvpTime, maxRandomBotPvpTime; uint32 randomBotsPerInterval; uint32 minRandomBotsPriceChangeInterval, maxRandomBotsPriceChangeInterval; @@ -162,7 +163,7 @@ class PlayerbotAIConfig std::vector randomBotArenaTeams; uint32 selfBotLevel; - + bool downgradeMaxLevelBot; 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"); diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index 1c39e862..b2dd86fc 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -80,11 +80,11 @@ void PlayerbotFactory::Prepare() { if (!itemQuality) { - if (level < 80) { - itemQuality = ITEM_QUALITY_RARE; - } else { - itemQuality = ITEM_QUALITY_EPIC; - } + // if (level < 80) { + itemQuality = ITEM_QUALITY_RARE; + // } else { + // itemQuality = ITEM_QUALITY_EPIC; + // } } if (bot->isDead()) @@ -115,10 +115,10 @@ void PlayerbotFactory::Prepare() void PlayerbotFactory::Randomize(bool incremental) { - if (sPlayerbotAIConfig->disableRandomLevels) - { - return; - } + // if (sPlayerbotAIConfig->disableRandomLevels) + // { + // return; + // } LOG_INFO("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full")); Prepare(); @@ -1206,7 +1206,9 @@ void PlayerbotFactory::InitEquipment(bool incremental) continue; uint32 desiredQuality = itemQuality; - + if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && desiredQuality > ITEM_QUALITY_NORMAL) { + desiredQuality--; + } do { ItemTemplateContainer const* itemTemplates = sObjectMgr->GetItemTemplateStore(); diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 1e133870..0559f9e2 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -18,11 +18,14 @@ #include "LFGMgr.h" #include "MapMgr.h" #include "PerformanceMonitor.h" +#include "PlayerbotAIConfig.h" #include "Playerbots.h" #include "PlayerbotCommandServer.h" #include "PlayerbotFactory.h" +#include "Random.h" #include "ServerFacade.h" #include "ChannelMgr.h" +#include "World.h" #include #include @@ -871,80 +874,70 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) //GET_PLAYERBOT_AI(player)->GetAiObjectContext()->GetValue("random bot update")->Set(false); - bool randomiser = true; - if (player->GetGuildId()) - { - if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId())) - { - if (guild->GetLeaderGUID() == player->GetGUID()) - { - for (std::vector::iterator i = players.begin(); i != players.end(); ++i) - sGuildTaskMgr->Update(*i, player); - } + // bool randomiser = true; + // if (player->GetGuildId()) + // { + // if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId())) + // { + // if (guild->GetLeaderGUID() == player->GetGUID()) + // { + // for (std::vector::iterator i = players.begin(); i != players.end(); ++i) + // sGuildTaskMgr->Update(*i, player); + // } - uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guild->GetLeaderGUID()); - if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId)) - { - uint8 rank = player->GetRank(); - randomiser = rank < 4 ? false : true; - } - } - } + // uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guild->GetLeaderGUID()); + // if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId)) + // { + // uint8 rank = player->GetRank(); + // randomiser = rank < 4 ? false : true; + // } + // } + // } uint32 randomize = GetEventValue(bot, "randomize"); if (!randomize) { - if (randomiser) - Randomize(player); - - if (randomiser) - { - LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->getLevel(), player->GetName()); - } - else - { - LOG_INFO("playerbots", "Bot #{} {}:{} {} <{}>: consumables refreshed", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->getLevel(), player->GetName(), sGuildMgr->GetGuildById(player->GetGuildId())->GetName()); - } - - if (sPlayerbotAIConfig->autoDoQuests) - ChangeStrategyOnce(player); - else - ChangeStrategy(player); - + // if (randomiser) + Randomize(player); + LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->getLevel(), player->GetName()); uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime); ScheduleRandomize(bot, randomTime); return true; + // if (randomiser) + // { + // } + // else + // { + // LOG_INFO("playerbots", "Bot #{} {}:{} {} <{}>: consumables refreshed", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->getLevel(), player->GetName(), sGuildMgr->GetGuildById(player->GetGuildId())->GetName()); + // } + // if (sPlayerbotAIConfig->autoDoQuests) + // ChangeStrategyOnce(player); + // else + // ChangeStrategy(player); } // enable random teleport logic if no auto traveling enabled - if (!sPlayerbotAIConfig->autoDoQuests) + // if (!sPlayerbotAIConfig->autoDoQuests) + // { + uint32 teleport = GetEventValue(bot, "teleport"); + if (!teleport) { - uint32 teleport = GetEventValue(bot, "teleport"); - if (!teleport) - { - LOG_INFO("players", "Bot #{} <{}>: sent to grind", bot, player->GetName()); - RandomTeleportForLevel(player); - Refresh(player); - SetEventValue(bot, "teleport", 1, sPlayerbotAIConfig->maxRandomBotInWorldTime); - return true; - } - - uint32 changeStrategy = GetEventValue(bot, "change_strategy"); - if (!changeStrategy) - { - LOG_INFO("playerbots", "Changing strategy for bot {} <{}>", bot, player->GetName()); - ChangeStrategy(player); - return true; - } - } - - uint32 changeStrategy = GetEventValue(bot, "change_strategy"); - if (!changeStrategy) - { - LOG_INFO("playerbots", "Changing strategy for bot #{} <{}>", bot, player->GetName().c_str()); - ChangeStrategy(player); + LOG_INFO("players", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName()); + RandomTeleportForLevel(player); + Refresh(player); + uint32 time = urand(sPlayerbotAIConfig->minRandomBotTeleportInterval, sPlayerbotAIConfig->maxRandomBotTeleportInterval); + ScheduleTeleport(bot, time); return true; } + // } + + // uint32 changeStrategy = GetEventValue(bot, "change_strategy"); + // if (!changeStrategy) + // { + // LOG_INFO("playerbots", "Changing strategy for bot #{} <{}>", bot, player->GetName().c_str()); + // ChangeStrategy(player); + // return true; + // } return false; } @@ -980,8 +973,8 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& // if (bot->getLevel() < 5) // return; - if (sPlayerbotAIConfig->randomBotRpgChance < 0) - return; + // if (sPlayerbotAIConfig->randomBotRpgChance < 0) + // return; if (locs.empty()) { @@ -1250,9 +1243,11 @@ void RandomPlayerbotMgr::Randomize(Player* bot) RandomizeFirst(bot); else if (bot->getLevel() < 57 && bot->getClass() == CLASS_DEATH_KNIGHT) RandomizeFirst(bot); - else + else if (bot->getLevel() < sPlayerbotAIConfig->randomBotMaxLevel || !sPlayerbotAIConfig->downgradeMaxLevelBot) IncreaseLevel(bot); - + else { + RandomizeFirst(bot); + } //RandomTeleportForRpg(bot); } @@ -1286,13 +1281,23 @@ void RandomPlayerbotMgr::RandomizeFirst(Player* bot) maxLevel = std::max(sPlayerbotAIConfig->randomBotMinLevel, std::min(playersLevel, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomizeFirst"); - uint32 level = urand(sPlayerbotAIConfig->randomBotMinLevel, maxLevel); + + uint32 level; - if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomBotMaxLevelChance) - level = maxLevel; + if (sPlayerbotAIConfig->downgradeMaxLevelBot && bot->GetLevel() == sPlayerbotAIConfig->randomBotMaxLevel) { + if (bot->getClass() == CLASS_DEATH_KNIGHT) { + level = sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL); + } else { + level = sPlayerbotAIConfig->randomBotMinLevel; + } + } else { + level = urand(sPlayerbotAIConfig->randomBotMinLevel, maxLevel); + if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomBotMaxLevelChance) + level = maxLevel; - if (bot->getClass() == CLASS_DEATH_KNIGHT) - level = urand(sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL), std::max(sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL), maxLevel)); + if (bot->getClass() == CLASS_DEATH_KNIGHT) + level = urand(sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL), std::max(sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL), maxLevel)); + } SetValue(bot, "level", level); diff --git a/src/strategy/StrategyContext.h b/src/strategy/StrategyContext.h index a8da6f61..649ddca9 100644 --- a/src/strategy/StrategyContext.h +++ b/src/strategy/StrategyContext.h @@ -110,6 +110,7 @@ class StrategyContext : public NamedObjectContext creators["guild"] = &StrategyContext::guild; creators["grind"] = &StrategyContext::grind; creators["avoid aoe"] = &StrategyContext::avoid_aoe; + creators["move random"] = &StrategyContext::move_random; } private: @@ -169,6 +170,7 @@ class StrategyContext : public NamedObjectContext static Strategy* guild (PlayerbotAI* botAI) { return new GuildStrategy(botAI); } static Strategy* grind(PlayerbotAI* botAI) { return new GrindingStrategy(botAI); } static Strategy* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeStrategy(botAI); } + static Strategy* move_random(PlayerbotAI* ai) { return new MoveRandomStrategy(ai); } }; class MovementStrategyContext : public NamedObjectContext diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index ca09cae7..4ac45841 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -1399,7 +1399,7 @@ bool MoveRandomAction::Execute(Event event) bool MoveRandomAction::isUseful() { - return !botAI->HasRealPlayerMaster() && botAI->GetAiObjectContext()->GetValue("nearest friendly players")->Get().size() > urand(25, 100); + return !botAI->HasRealPlayerMaster(); } bool MoveInsideAction::Execute(Event event) diff --git a/src/strategy/generic/GrindingStrategy.cpp b/src/strategy/generic/GrindingStrategy.cpp index 4a62de88..ceb746be 100644 --- a/src/strategy/generic/GrindingStrategy.cpp +++ b/src/strategy/generic/GrindingStrategy.cpp @@ -15,3 +15,9 @@ void GrindingStrategy::InitTriggers(std::vector& triggers) triggers.push_back(new TriggerNode("no target", NextAction::array(0, new NextAction("attack anything", 5.0f), nullptr))); } +void MoveRandomStrategy::InitTriggers(std::vector& triggers) +{ + triggers.push_back(new TriggerNode( + "often", + NextAction::array(0, new NextAction("move random", 1.5f), NULL))); +} \ No newline at end of file diff --git a/src/strategy/generic/GrindingStrategy.h b/src/strategy/generic/GrindingStrategy.h index ba5228d8..9821f84b 100644 --- a/src/strategy/generic/GrindingStrategy.h +++ b/src/strategy/generic/GrindingStrategy.h @@ -20,4 +20,11 @@ class GrindingStrategy : public NonCombatStrategy void InitTriggers(std::vector& triggers) override; }; +class MoveRandomStrategy : public NonCombatStrategy +{ +public: + MoveRandomStrategy(PlayerbotAI* ai) : NonCombatStrategy(botAI) {} + std::string const getName() override { return "move random"; } + void InitTriggers(std::vector& triggers) override; +}; #endif diff --git a/src/strategy/values/AttackersValue.cpp b/src/strategy/values/AttackersValue.cpp index e5eff0bd..2f223c40 100644 --- a/src/strategy/values/AttackersValue.cpp +++ b/src/strategy/values/AttackersValue.cpp @@ -7,6 +7,7 @@ #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "Playerbots.h" +#include "ReputationMgr.h" #include "ServerFacade.h" GuidVector AttackersValue::Calculate() @@ -126,7 +127,7 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range) rti = bot->GetGroup()->GetTargetIcon(7) == attacker->GetGUID(); PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - + bool leaderHasThreat = false; if (attacker && bot->GetGroup() && botAI->GetMaster()) leaderHasThreat = attacker->GetThreatMgr().GetThreat(botAI->GetMaster()); @@ -141,6 +142,7 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range) // bool inCannon = botAI->IsInVehicle(false, true); // bool enemy = botAI->GetAiObjectContext()->GetValue("enemy player target")->Get(); + return attacker && attacker->IsInWorld() && attacker->GetMapId() == bot->GetMapId() && @@ -155,7 +157,8 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range) !(attacker->GetCreatureType() == CREATURE_TYPE_CRITTER && !attacker->IsInCombat()) && !attacker->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) && !attacker->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) && - !(sPlayerbotAIConfig->IsInPvpProhibitedZone(attacker->GetAreaId()) && bot->CanSeeOrDetect(attacker) && (attacker->GetGUID().IsPlayer() || attacker->GetGUID().IsPet())) && + bot->CanSeeOrDetect(attacker) && + !(sPlayerbotAIConfig->IsInPvpProhibitedZone(attacker->GetZoneId()) && (attacker->GetGUID().IsPlayer() || attacker->GetGUID().IsPet())) && (!c || (!c->IsInEvadeMode() && ((!isMemberBotGroup && botAI->HasStrategy("attack tagged", BOT_STATE_NON_COMBAT)) || leaderHasThreat || (!c->hasLootRecipient() && (!c->GetVictim() || (c->GetVictim() && ((!c->GetVictim()->IsPlayer() || bot->IsInSameGroupWith(c->GetVictim()->ToPlayer())) || (botAI->GetMaster() && c->GetVictim() == botAI->GetMaster()))))) || c->isTappedBy(bot)))); diff --git a/src/strategy/values/GrindTargetValue.cpp b/src/strategy/values/GrindTargetValue.cpp index 48d13488..856184e4 100644 --- a/src/strategy/values/GrindTargetValue.cpp +++ b/src/strategy/values/GrindTargetValue.cpp @@ -4,6 +4,8 @@ #include "GrindTargetValue.h" #include "Playerbots.h" +#include "ReputationMgr.h" +#include "SharedDefines.h" Unit* GrindTargetValue::Calculate() { @@ -54,14 +56,19 @@ Unit* GrindTargetValue::FindTargetForGrinding(uint32 assistCount) if (!unit) continue; - // if (unit->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE)) { - // continue; - // } + auto &rep = bot->ToPlayer()->GetReputationMgr(); + if (unit->ToCreature() && !unit->ToCreature()->GetCreatureTemplate()->lootid && bot->GetReactionTo(unit) >= REP_NEUTRAL) { + continue; + } if (!bot->IsHostileTo(unit) && unit->GetNpcFlags() != UNIT_NPC_FLAG_NONE) { continue; } + if (!bot->isHonorOrXPTarget(unit)) { + continue; + } + if (abs(bot->GetPositionZ() - unit->GetPositionZ()) > sPlayerbotAIConfig->spellDistance) continue;