This commit is contained in:
Bobblybook
2024-10-20 16:18:27 +11:00
14 changed files with 411 additions and 194 deletions

View File

@@ -234,16 +234,15 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
return false;
TeamId teamId = bot->GetTeamId();
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty()
? sPlayerbotAIConfig->diffEmpty
: sPlayerbotAIConfig->diffWithPlayer) *
1.1;
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ?
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer) * 1.1;
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
uint32 TeamSize = bg->GetMaxPlayersPerTeam();
// If performance diff is enabled, only queue if there is no lag
if (sPlayerbotAIConfig->enablePrototypePerformanceDiff && !noLag)
if (sPlayerbotAIConfig->botActiveAloneSmartScale && !noLag)
return false;
// If the bot is in a group, only the leader can queue
@@ -578,16 +577,15 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
return false;
TeamId teamId = bot->GetTeamId();
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty()
? sPlayerbotAIConfig->diffEmpty
: sPlayerbotAIConfig->diffWithPlayer) *
1.1;
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ?
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer) * 1.1;
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
uint32 TeamSize = bg->GetMaxPlayersPerTeam();
// If performance diff is enabled, only queue if there is no lag
if (sPlayerbotAIConfig->enablePrototypePerformanceDiff && !noLag)
if (sPlayerbotAIConfig->botActiveAloneSmartScale && !noLag)
return false;
// If the bot is in a group, only the leader can queue

View File

@@ -58,55 +58,92 @@ bool DropQuestAction::Execute(Event event)
return true;
}
bool CleanQuestLogAction::Execute(Event event)
{
Player* requester = event.getOwner() ? event.getOwner() : GetMaster();
std::string link = event.getParam();
if (botAI->HasActivePlayerMaster() || !sRandomPlayerbotMgr->IsRandomBot(bot))
if (!requester)
{
botAI->TellMaster("No event owner detected");
return false;
uint8 totalQuests = 0;
// Count the total quests
DropQuestType(totalQuests);
if (MAX_QUEST_LOG_SIZE - totalQuests > 6)
{
// Drop failed quests
DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE, true, true);
return true;
}
// Only drop gray quests when able to fight proper lvl quests.
if (AI_VALUE(bool, "can fight equal"))
// Only output this message if "debug rpg" strategy is enabled
if (botAI->HasStrategy("debug rpg", BotState::BOT_STATE_COMBAT))
{
// Drop gray/red quests.
DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6);
// Drop gray/red quests with progress.
DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6, false, true);
// Drop gray/red completed quests.
DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6, false, true, true);
botAI->TellMaster("Clean Quest Log command received, removing grey/trivial quests...");
}
if (MAX_QUEST_LOG_SIZE - totalQuests > 4)
return true;
uint8 botLevel = bot->GetLevel(); // Get bot's level
uint8 numQuest = 0;
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
if (bot->GetQuestSlotQuestId(slot))
{
numQuest++;
}
}
DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 4, true); // Drop quests without progress.
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
uint32 questId = bot->GetQuestSlotQuestId(slot);
if (!questId)
continue;
if (MAX_QUEST_LOG_SIZE - totalQuests > 2)
return true;
const Quest* quest = sObjectMgr->GetQuestTemplate(questId);
if (!quest)
continue;
DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 2, true, true); // Drop quests with progress.
// Determine if quest is trivial by comparing levels
int32 questLevel = quest->GetQuestLevel();
if (questLevel == -1) // For scaling quests, default to bot level
{
questLevel = botLevel;
}
if (MAX_QUEST_LOG_SIZE - totalQuests > 0)
return true;
// Check if the quest is trivial (grey) for the bot
if ((botLevel - questLevel) >= 5)
{
// Output only if "debug rpg" strategy is enabled
if (botAI->HasStrategy("debug rpg", BotState::BOT_STATE_COMBAT))
{
botAI->TellMaster("Quest [ " + quest->GetTitle() + " ] will be removed because it is trivial (grey).");
}
DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 1, true, true, true); // Drop completed quests.
// Remove quest
bot->SetQuestSlot(slot, 0);
bot->TakeQuestSourceItem(questId, false);
bot->SetQuestStatus(questId, QUEST_STATUS_NONE);
bot->RemoveRewardedQuest(questId);
if (MAX_QUEST_LOG_SIZE - totalQuests > 0)
return true;
numQuest--;
return false;
if (botAI->HasStrategy("debug rpg", BotState::BOT_STATE_COMBAT))
{
const std::string text_quest = ChatHelper::FormatQuest(quest);
LOG_INFO("playerbots", "{} => Quest [ {} ] removed", bot->GetName(), quest->GetTitle());
bot->Say("Quest [ " + text_quest + " ] removed", LANG_UNIVERSAL);
}
if (botAI->HasStrategy("debug rpg", BotState::BOT_STATE_COMBAT))
{
botAI->TellMaster("Quest [ " + quest->GetTitle() + " ] has been removed.");
}
}
else
{
// Only output if "debug rpg" strategy is enabled
if (botAI->HasStrategy("debug rpg", BotState::BOT_STATE_COMBAT))
{
botAI->TellMaster("Quest [ " + quest->GetTitle() + " ] is not trivial and will be kept.");
}
}
}
return true;
}
void CleanQuestLogAction::DropQuestType(uint8& numQuest, uint8 wantNum, bool isGreen, bool hasProgress, bool isComplete)
{
std::vector<uint8> slots;

View File

@@ -30,6 +30,8 @@ bool PartyCommandAction::Execute(Event event)
Player* master = GetMaster();
if (master && member == master->GetName())
return Leave(bot);
botAI->Reset();
return false;
}
@@ -62,6 +64,8 @@ bool UninviteAction::Execute(Event event)
if (bot->GetGUID() == guid)
return Leave(bot);
}
botAI->Reset();
return false;
}
@@ -160,6 +164,8 @@ bool LeaveFarAwayAction::isUseful()
{
return true;
}
botAI->Reset();
return false;
}

View File

@@ -79,7 +79,7 @@ bool RpgAction::SetNextRpgAction()
{
NextAction* nextAction = nextActions[i];
if (nextAction->getRelevance() > 2.0f)
if (nextAction->getRelevance() > 5.0f)
continue;
if (!isChecked && !trigger->IsActive())
@@ -92,7 +92,7 @@ bool RpgAction::SetNextRpgAction()
continue;
actions.push_back(action);
relevances.push_back((nextAction->getRelevance() - 1) * 1000);
relevances.push_back((nextAction->getRelevance() - 1) * 500);
}
NextAction::destroy(nextActions);
}