mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Update LfgActions.cpp (#1225)
This commit is contained in:
@@ -198,65 +198,76 @@ bool LfgRoleCheckAction::Execute(Event event)
|
|||||||
|
|
||||||
bool LfgAcceptAction::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");
|
uint32 id = AI_VALUE(uint32, "lfg proposal");
|
||||||
|
|
||||||
|
// Try accept if already stored
|
||||||
if (id)
|
if (id)
|
||||||
{
|
{
|
||||||
// if (urand(0, 1 + 10 / sPlayerbotAIConfig->randomChangeMultiplier))
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
if (bot->IsInCombat() || bot->isDead())
|
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);
|
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
|
||||||
*packet << (uint32)id << (bool)false;
|
*packet << id << false;
|
||||||
bot->GetSession()->QueuePacket(packet);
|
bot->GetSession()->QueuePacket(packet);
|
||||||
// sLFGMgr->UpdateProposal(id, bot->GetGUID(), true);
|
|
||||||
return 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);
|
botAI->GetAiObjectContext()->GetValue<uint32>("lfg proposal")->Set(0);
|
||||||
|
|
||||||
bot->ClearUnitState(UNIT_STATE_ALL_STATE);
|
bot->ClearUnitState(UNIT_STATE_ALL_STATE);
|
||||||
|
|
||||||
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
|
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
|
||||||
*packet << (uint32)id << (bool)true;
|
*packet << id << true;
|
||||||
bot->GetSession()->QueuePacket(packet);
|
bot->GetSession()->QueuePacket(packet);
|
||||||
// sLFGMgr->UpdateProposal(id, bot->GetGUID(), true);
|
|
||||||
|
|
||||||
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())
|
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())
|
||||||
{
|
{
|
||||||
sRandomPlayerbotMgr->Refresh(bot);
|
sRandomPlayerbotMgr->Refresh(bot);
|
||||||
botAI->ResetStrategies();
|
botAI->ResetStrategies();
|
||||||
// bot->TeleportToHomebind();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
botAI->Reset();
|
botAI->Reset();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getPacket().empty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
WorldPacket p(event.getPacket());
|
// If we get the proposal packet, accept immediately
|
||||||
|
if (!event.getPacket().empty())
|
||||||
|
{
|
||||||
|
WorldPacket p(event.getPacket());
|
||||||
|
uint32 dungeonId;
|
||||||
|
uint8 state;
|
||||||
|
p >> dungeonId >> state >> id;
|
||||||
|
|
||||||
uint32 dungeon;
|
if (id)
|
||||||
uint8 state;
|
{
|
||||||
p >> dungeon >> state >> id;
|
if (bot->IsInCombat() || bot->isDead())
|
||||||
|
{
|
||||||
|
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
|
||||||
|
*packet << id << false;
|
||||||
|
bot->GetSession()->QueuePacket(packet);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
botAI->GetAiObjectContext()->GetValue<uint32>("lfg proposal")->Set(id);
|
botAI->GetAiObjectContext()->GetValue<uint32>("lfg proposal")->Set(0);
|
||||||
|
bot->ClearUnitState(UNIT_STATE_ALL_STATE);
|
||||||
|
|
||||||
return true;
|
WorldPacket* packet = new WorldPacket(CMSG_LFG_PROPOSAL_RESULT);
|
||||||
|
*packet << id << true;
|
||||||
|
bot->GetSession()->QueuePacket(packet);
|
||||||
|
|
||||||
|
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())
|
||||||
|
{
|
||||||
|
sRandomPlayerbotMgr->Refresh(bot);
|
||||||
|
botAI->ResetStrategies();
|
||||||
|
}
|
||||||
|
|
||||||
|
botAI->Reset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LfgLeaveAction::Execute(Event event)
|
bool LfgLeaveAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
// Don't leave if lfg strategy enabled
|
// Don't leave if lfg strategy enabled
|
||||||
|
|||||||
Reference in New Issue
Block a user