From 7309d8f3c9fb14cb5665b5b496a97bdb60a969e2 Mon Sep 17 00:00:00 2001 From: Revision Date: Thu, 11 Jul 2024 23:46:59 +0200 Subject: [PATCH] Add config options for the new summon conditions --- conf/playerbots.conf.dist | 14 +++++++- src/PlayerbotAIConfig.cpp | 3 ++ src/PlayerbotAIConfig.h | 3 ++ .../actions/UseMeetingStoneAction.cpp | 35 +++++++++---------- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 8e91ec1d..b81cc222 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -127,7 +127,19 @@ AiPlayerbot.EquipmentPersistenceLevel = 80 # default: 1 (accept based on level) AiPlayerbot.GroupInvitationPermission = 1 -# Enable/Disable bot revive when summon (0 = never, 1 = enable when non-combat and alive, 2 = enable always) +# Enable/Disable summoning bots when the master is in combat +# default: 1 (enabled) +AiPlayerbot.AllowSummonInCombat = 1 + +# Enable/Disable summoning bots when the master is dead +# default: 1 (enabled) +AiPlayerbot.AllowSummonWhenMasterIsDead = 1 + +# Enable/Disable summoning bots when they are dead (0 = only when the bots are ghosts, 1 = always) +# default: 1 (enabled) +AiPlayerbot.AllowSummonWhenBotIsDead = 1 + +# Enable/Disable bot revive when summon (0 = never, 1 = enable when non-combat, 2 = enable always) # default: 1 (enable for non-combat) AiPlayerbot.BotReviveWhenSummon = 1 diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 85ee2d56..79531200 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -273,6 +273,9 @@ bool PlayerbotAIConfig::Initialize() equipmentPersistence = sConfigMgr->GetOption("AiPlayerbot.EquipmentPersistence", false); equipmentPersistenceLevel = sConfigMgr->GetOption("AiPlayerbot.EquipmentPersistenceLevel", 80); groupInvitationPermission = sConfigMgr->GetOption("AiPlayerbot.GroupInvitationPermission", 1); + allowSummonInCombat = sConfigMgr->GetOption("AiPlayerbot.AllowSummonInCombat", true); + allowSummonWhenMasterIsDead = sConfigMgr->GetOption("AiPlayerbot.AllowSummonWhenMasterIsDead", true); + allowSummonWhenBotIsDead = sConfigMgr->GetOption("AiPlayerbot.AllowSummonWhenBotIsDead", true); botReviveWhenSummon = sConfigMgr->GetOption("AiPlayerbot.BotReviveWhenSummon", 1); botRepairWhenSummon = sConfigMgr->GetOption("AiPlayerbot.BotRepairWhenSummon", true); autoInitOnly = sConfigMgr->GetOption("AiPlayerbot.AutoInitOnly", false); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 5e63c745..3fb31410 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -214,6 +214,9 @@ class PlayerbotAIConfig bool equipmentPersistence; int32 equipmentPersistenceLevel; int32 groupInvitationPermission; + bool allowSummonInCombat; + bool allowSummonWhenMasterIsDead; + bool allowSummonWhenBotIsDead; int32 botReviveWhenSummon; bool botRepairWhenSummon; bool autoInitOnly; diff --git a/src/strategy/actions/UseMeetingStoneAction.cpp b/src/strategy/actions/UseMeetingStoneAction.cpp index 0f908530..f07ca217 100644 --- a/src/strategy/actions/UseMeetingStoneAction.cpp +++ b/src/strategy/actions/UseMeetingStoneAction.cpp @@ -179,28 +179,25 @@ bool SummonAction::Teleport(Player* summoner, Player* player) if (sPlayerbotAIConfig->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on bot->DurabilityRepairAll(false, 1.0f, false); - if (sPlayerbotAIConfig->botReviveWhenSummon < 2) + if (master->IsInCombat() && !sPlayerbotAIConfig->allowSummonInCombat) { - if (master->IsInCombat()) - { - botAI->TellError("You cannot summon me while you're in combat"); - return false; - } - - if (!master->IsAlive()) - { - botAI->TellError("You cannot summon me while you're dead"); - return false; - } - - if (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST)) - { - botAI->TellError("You cannot summon me while I'm dead, you need to release my spirit first"); - return false; - } + botAI->TellError("You cannot summon me while you're in combat"); + return false; } - if (sPlayerbotAIConfig->botReviveWhenSummon > 0 && bot->isDead()) + if (!master->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead) + { + botAI->TellError("You cannot summon me while you're dead"); + return false; + } + + if (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST) && !sPlayerbotAIConfig->allowSummonWhenBotIsDead) + { + botAI->TellError("You cannot summon me while I'm dead, you need to release my spirit first"); + return false; + } + + if (sPlayerbotAIConfig->botReviveWhenSummon == 2 || (sPlayerbotAIConfig->botReviveWhenSummon == 1 && !master->IsInCombat() && master->IsAlive())) { bot->ResurrectPlayer(1.0f, false); botAI->TellMasterNoFacing("I live, again!");