From a28d096befa7925f727f32ef21e1f45bb31af751 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sat, 28 Oct 2023 19:22:58 +0800 Subject: [PATCH] Pvp Prohibited Areas --- conf/playerbots.conf.dist | 5 ++++- src/PlayerbotAIConfig.cpp | 12 ++++++++++++ src/PlayerbotAIConfig.h | 3 +++ src/strategy/actions/ChooseTargetActions.cpp | 2 +- src/strategy/values/AttackersValue.cpp | 2 +- src/strategy/values/EnemyPlayerValue.cpp | 2 +- 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index cd3e47fc..98f8144d 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -311,7 +311,10 @@ AiPlayerbot.ProbTeleToBankers = 0.25 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,3703,33" +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" # 33(stranglethorn vale),440(tanaris) + +# PvP Restricted Areas (bots don't pvp) +AiPlayerbot.PvpProhibitedAreaIds = "976,35" # Spells every random bot will learn on randomize (54197 - cold weather flying) AiPlayerbot.RandomBotSpellIds = "54197" diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 58b515ff..460143d1 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -103,6 +103,8 @@ bool PlayerbotAIConfig::Initialize() 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,4395"), pvpProhibitedZoneIds); + LoadList>(sConfigMgr->GetOption("AiPlayerbot.PvpProhibitedAreaIds", "976,35"), pvpProhibitedAreaIds); + LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestIds", "7848,3802,5505,6502,7761"), randomBotQuestIds); botAutologin = sConfigMgr->GetOption("AiPlayerbot.BotAutologin", false); @@ -390,11 +392,21 @@ bool PlayerbotAIConfig::IsInRandomQuestItemList(uint32 id) return find(randomBotQuestItems.begin(), randomBotQuestItems.end(), id) != randomBotQuestItems.end(); } +bool PlayerbotAIConfig::IsPvpProhibited(uint32 zoneId, uint32 areaId) +{ + return IsInPvpProhibitedZone(zoneId) || IsInPvpProhibitedArea(areaId); +} + bool PlayerbotAIConfig::IsInPvpProhibitedZone(uint32 id) { return find(pvpProhibitedZoneIds.begin(), pvpProhibitedZoneIds.end(), id) != pvpProhibitedZoneIds.end(); } +bool PlayerbotAIConfig::IsInPvpProhibitedArea(uint32 id) +{ + return find(pvpProhibitedAreaIds.begin(), pvpProhibitedAreaIds.end(), id) != pvpProhibitedAreaIds.end(); +} + std::string const PlayerbotAIConfig::GetTimestampStr() { time_t t = time(nullptr); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 68482c57..d13d98d9 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -35,7 +35,9 @@ class PlayerbotAIConfig bool Initialize(); bool IsInRandomAccountList(uint32 id); bool IsInRandomQuestItemList(uint32 id); + bool IsPvpProhibited(uint32 zoneId, uint32 areaId); bool IsInPvpProhibitedZone(uint32 id); + bool IsInPvpProhibitedArea(uint32 id); bool enabled; bool allowGuildBots; @@ -100,6 +102,7 @@ class PlayerbotAIConfig bool deleteRandomBotGuilds; std::vector randomBotGuilds; std::vector pvpProhibitedZoneIds; + std::vector pvpProhibitedAreaIds; bool randombotsWalkingRPG; bool randombotsWalkingRPGInDoors; diff --git a/src/strategy/actions/ChooseTargetActions.cpp b/src/strategy/actions/ChooseTargetActions.cpp index 57e5a1a5..a9bc1a36 100644 --- a/src/strategy/actions/ChooseTargetActions.cpp +++ b/src/strategy/actions/ChooseTargetActions.cpp @@ -16,7 +16,7 @@ bool AttackEnemyPlayerAction::isUseful() if (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976)) return false; - return !sPlayerbotAIConfig->IsInPvpProhibitedZone(bot->GetZoneId()); + return !sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()); } bool AttackEnemyFlagCarrierAction::isUseful() diff --git a/src/strategy/values/AttackersValue.cpp b/src/strategy/values/AttackersValue.cpp index bfb6c5bd..e3748c1c 100644 --- a/src/strategy/values/AttackersValue.cpp +++ b/src/strategy/values/AttackersValue.cpp @@ -158,7 +158,7 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range) !attacker->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) && !attacker->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) && bot->CanSeeOrDetect(attacker) && - !(sPlayerbotAIConfig->IsInPvpProhibitedZone(attacker->GetZoneId()) && (attacker->GetGUID().IsPlayer() || attacker->GetGUID().IsPet())) && + !(sPlayerbotAIConfig->IsPvpProhibited(attacker->GetZoneId(), attacker->GetAreaId()) && (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/EnemyPlayerValue.cpp b/src/strategy/values/EnemyPlayerValue.cpp index 7dbb9202..4b412ce8 100644 --- a/src/strategy/values/EnemyPlayerValue.cpp +++ b/src/strategy/values/EnemyPlayerValue.cpp @@ -10,7 +10,7 @@ bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit) { bool inCannon = botAI->IsInVehicle(false, true); Player* enemy = dynamic_cast(unit); - if (enemy && botAI->IsOpposing(enemy) && enemy->IsPvP() && !sPlayerbotAIConfig->IsInPvpProhibitedZone(enemy->GetZoneId()) && + if (enemy && botAI->IsOpposing(enemy) && enemy->IsPvP() && !sPlayerbotAIConfig->IsPvpProhibited(enemy->GetZoneId(), enemy->GetAreaId()) && !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) && ((inCannon || !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) && /*!enemy->HasStealthAura() && !enemy->HasInvisibilityAura()*/ enemy->CanSeeOrDetect(bot) && !(enemy->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))) return true;