Update LfgActions.cpp (#1225)

This commit is contained in:
NotCronky
2025-04-27 11:43:56 +01:00
committed by GitHub
parent 96d9b346c1
commit a5e0e6f5cf

View File

@@ -198,65 +198,76 @@ bool LfgRoleCheckAction::Execute(Event event)
bool LfgAcceptAction::Execute(Event event)
{
/*LfgState status = sLFGMgr->GetState(bot->GetGUID());
if (status != LFG_STATE_PROPOSAL)
return false;*/
uint32 id = AI_VALUE(uint32, "lfg proposal");
// Try accept if already stored
if (id)
{
// if (urand(0, 1 + 10 / sPlayerbotAIConfig->randomChangeMultiplier))
// return false;
if (bot->IsInCombat() || bot->isDead())
{
LOG_INFO("playerbots", "Bot {} {}:{} <{}> is in combat and refuses LFG proposal {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
bot->GetName().c_str(), id);
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
*packet << (uint32)id << (bool)false;
*packet << id << false;
bot->GetSession()->QueuePacket(packet);
// sLFGMgr->UpdateProposal(id, bot->GetGUID(), true);
return true;
}
LOG_INFO("playerbots", "Bot {} {}:{} <{}> accepts LFG proposal {}", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), id);
botAI->GetAiObjectContext()->GetValue<uint32>("lfg proposal")->Set(0);
bot->ClearUnitState(UNIT_STATE_ALL_STATE);
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
*packet << (uint32)id << (bool)true;
*packet << id << true;
bot->GetSession()->QueuePacket(packet);
// sLFGMgr->UpdateProposal(id, bot->GetGUID(), true);
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())
{
sRandomPlayerbotMgr->Refresh(bot);
botAI->ResetStrategies();
// bot->TeleportToHomebind();
}
botAI->Reset();
return true;
}
if (event.getPacket().empty())
return false;
// If we get the proposal packet, accept immediately
if (!event.getPacket().empty())
{
WorldPacket p(event.getPacket());
uint32 dungeonId;
uint8 state;
p >> dungeonId >> state >> id;
WorldPacket p(event.getPacket());
if (id)
{
if (bot->IsInCombat() || bot->isDead())
{
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
*packet << id << false;
bot->GetSession()->QueuePacket(packet);
return true;
}
uint32 dungeon;
uint8 state;
p >> dungeon >> state >> id;
botAI->GetAiObjectContext()->GetValue<uint32>("lfg proposal")->Set(0);
bot->ClearUnitState(UNIT_STATE_ALL_STATE);
botAI->GetAiObjectContext()->GetValue<uint32>("lfg proposal")->Set(id);
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
*packet << id << true;
bot->GetSession()->QueuePacket(packet);
return true;
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())
{
sRandomPlayerbotMgr->Refresh(bot);
botAI->ResetStrategies();
}
botAI->Reset();
return true;
}
}
return false;
}
bool LfgLeaveAction::Execute(Event event)
{
// Don't leave if lfg strategy enabled