Merge pull request #323 from noisiver/amend-summon-requirements

Add config options for the new summon conditions
This commit is contained in:
Yunfan Li
2024-07-12 13:19:19 +08:00
committed by GitHub
4 changed files with 35 additions and 20 deletions

View File

@@ -127,7 +127,19 @@ AiPlayerbot.EquipmentPersistenceLevel = 80
# default: 1 (accept based on level) # default: 1 (accept based on level)
AiPlayerbot.GroupInvitationPermission = 1 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 (always)
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) # default: 1 (enable for non-combat)
AiPlayerbot.BotReviveWhenSummon = 1 AiPlayerbot.BotReviveWhenSummon = 1

View File

@@ -273,6 +273,9 @@ bool PlayerbotAIConfig::Initialize()
equipmentPersistence = sConfigMgr->GetOption<bool>("AiPlayerbot.EquipmentPersistence", false); equipmentPersistence = sConfigMgr->GetOption<bool>("AiPlayerbot.EquipmentPersistence", false);
equipmentPersistenceLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.EquipmentPersistenceLevel", 80); equipmentPersistenceLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.EquipmentPersistenceLevel", 80);
groupInvitationPermission = sConfigMgr->GetOption<int32>("AiPlayerbot.GroupInvitationPermission", 1); groupInvitationPermission = sConfigMgr->GetOption<int32>("AiPlayerbot.GroupInvitationPermission", 1);
allowSummonInCombat = sConfigMgr->GetOption<bool>("AiPlayerbot.AllowSummonInCombat", true);
allowSummonWhenMasterIsDead = sConfigMgr->GetOption<bool>("AiPlayerbot.AllowSummonWhenMasterIsDead", true);
allowSummonWhenBotIsDead = sConfigMgr->GetOption<bool>("AiPlayerbot.AllowSummonWhenBotIsDead", true);
botReviveWhenSummon = sConfigMgr->GetOption<int>("AiPlayerbot.BotReviveWhenSummon", 1); botReviveWhenSummon = sConfigMgr->GetOption<int>("AiPlayerbot.BotReviveWhenSummon", 1);
botRepairWhenSummon = sConfigMgr->GetOption<bool>("AiPlayerbot.BotRepairWhenSummon", true); botRepairWhenSummon = sConfigMgr->GetOption<bool>("AiPlayerbot.BotRepairWhenSummon", true);
autoInitOnly = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoInitOnly", false); autoInitOnly = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoInitOnly", false);

View File

@@ -214,6 +214,9 @@ class PlayerbotAIConfig
bool equipmentPersistence; bool equipmentPersistence;
int32 equipmentPersistenceLevel; int32 equipmentPersistenceLevel;
int32 groupInvitationPermission; int32 groupInvitationPermission;
bool allowSummonInCombat;
bool allowSummonWhenMasterIsDead;
bool allowSummonWhenBotIsDead;
int32 botReviveWhenSummon; int32 botReviveWhenSummon;
bool botRepairWhenSummon; bool botRepairWhenSummon;
bool autoInitOnly; bool autoInitOnly;

View File

@@ -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 if (sPlayerbotAIConfig->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
bot->DurabilityRepairAll(false, 1.0f, false); 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;
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;
}
} }
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); bot->ResurrectPlayer(1.0f, false);
botAI->TellMasterNoFacing("I live, again!"); botAI->TellMasterNoFacing("I live, again!");