Skip to content

Commit b5d1c07

Browse files
authored
Add partybot pull command. (#2588)
1 parent 998823e commit b5d1c07

File tree

3 files changed

+62
-7
lines changed

3 files changed

+62
-7
lines changed

src/game/Chat/Chat.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ ChatCommand * ChatHandler::getCommandTable()
9999
{ "setrole", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePartyBotSetRoleCommand, "", nullptr },
100100
{ "attackstart",SEC_ADMINISTRATOR, false, &ChatHandler::HandlePartyBotAttackStartCommand, "", nullptr },
101101
{ "attackstop", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePartyBotAttackStopCommand, "", nullptr },
102+
{ "pull", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePartyBotPullCommand, "", nullptr },
102103
{ "aoe", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePartyBotAoECommand, "", nullptr },
103104
{ "ccmark", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePartyBotControlMarkCommand, "", nullptr },
104105
{ "focusmark", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePartyBotFocusMarkCommand, "", nullptr },

src/game/Chat/Chat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class ChatHandler
273273
bool HandlePartyBotSetRoleCommand(char * args);
274274
bool HandlePartyBotAttackStartCommand(char * args);
275275
bool HandlePartyBotAttackStopCommand(char * args);
276+
bool HandlePartyBotPullCommand(char * args);
276277
bool HandlePartyBotAoECommand(char * args);
277278
bool HandlePartyBotControlMarkCommand(char * args);
278279
bool HandlePartyBotFocusMarkCommand(char * args);

src/game/PlayerBots/PlayerBotMgr.cpp

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void PlayerBotMgr::Update(uint32 diff)
340340
uint32 const minLevel = bg->GetMinLevel() + 10 * bracketId;
341341
ASSERT(minLevel <= PLAYER_MAX_LEVEL);
342342
uint32 const maxLevel = std::min<uint32>(minLevel + 9, PLAYER_MAX_LEVEL);
343-
343+
344344
for (uint32 i = queuedAllianceCount[bracketId]; i < bg->GetMinPlayersPerTeam(); ++i)
345345
{
346346
uint32 const botLevel = urand(minLevel, maxLevel);
@@ -1076,7 +1076,7 @@ bool ChatHandler::HandlePartyBotAttackStartCommand(char* args)
10761076
SetSentErrorMessage(true);
10771077
return false;
10781078
}
1079-
1079+
10801080
Group* pGroup = pPlayer->GetGroup();
10811081
if (!pGroup)
10821082
{
@@ -1099,10 +1099,10 @@ bool ChatHandler::HandlePartyBotAttackStartCommand(char* args)
10991099
if (pMember->IsValidAttackTarget(pTarget))
11001100
pAI->AttackStart(pTarget);
11011101
}
1102-
}
1102+
}
11031103
}
11041104
}
1105-
1105+
11061106
PSendSysMessage("All party bots are now attacking %s.", pTarget->GetName());
11071107
return true;
11081108
}
@@ -1304,7 +1304,7 @@ bool ChatHandler::HandlePartyBotFocusMarkCommand(char* args)
13041304
{
13051305
if (PartyBotAI* pAI = dynamic_cast<PartyBotAI*>(pTarget->AI()))
13061306
{
1307-
if (std::find(pAI->m_marksToFocus.begin(), pAI->m_marksToFocus.end(), itrMark->second) != pAI->m_marksToFocus.end())
1307+
if (std::find(pAI->m_marksToFocus.begin(), pAI->m_marksToFocus.end(), itrMark->second) != pAI->m_marksToFocus.end())
13081308
{
13091309
PSendSysMessage("%s already have focus %s.", pTarget->GetName(), args);
13101310
return false;
@@ -1339,7 +1339,7 @@ bool ChatHandler::HandlePartyBotFocusMarkCommand(char* args)
13391339
{
13401340
if (PartyBotAI* pAI = dynamic_cast<PartyBotAI*>(pMember->AI()))
13411341
{
1342-
if (std::find(pAI->m_marksToFocus.begin(), pAI->m_marksToFocus.end(), itrMark->second) != pAI->m_marksToFocus.end())
1342+
if (std::find(pAI->m_marksToFocus.begin(), pAI->m_marksToFocus.end(), itrMark->second) != pAI->m_marksToFocus.end())
13431343
{
13441344
// Already have focus mark
13451345
continue;
@@ -1620,7 +1620,7 @@ bool ChatHandler::HandlePartyBotPauseHelper(char* args, bool pause)
16201620
else
16211621
PSendSysMessage("%s unpaused.", pTarget->GetName());
16221622
}
1623-
1623+
16241624
else
16251625
SendSysMessage("Target is not a party bot.");
16261626
}
@@ -1638,6 +1638,59 @@ bool ChatHandler::HandlePartyBotUnpauseCommand(char* args)
16381638
return HandlePartyBotPauseHelper(args, false);
16391639
}
16401640

1641+
bool ChatHandler::HandlePartyBotPullCommand(char* args)
1642+
{
1643+
Player* pPlayer = GetSession()->GetPlayer();
1644+
Unit* pTarget = GetSelectedUnit();
1645+
if (!pTarget || !pPlayer->IsValidAttackTarget(pTarget, true))
1646+
{
1647+
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
1648+
SetSentErrorMessage(true);
1649+
return false;
1650+
}
1651+
1652+
Group* pGroup = pPlayer->GetGroup();
1653+
if (!pGroup)
1654+
{
1655+
SendSysMessage("You are not in a group.");
1656+
SetSentErrorMessage(true);
1657+
return false;
1658+
}
1659+
1660+
uint32 duration;
1661+
if (!ExtractUInt32(&args, duration))
1662+
duration = 10 * IN_MILLISECONDS;
1663+
1664+
for (GroupReference* itr = pGroup->GetFirstMember(); itr != nullptr; itr = itr->next())
1665+
{
1666+
if (Player* pMember = itr->getSource())
1667+
{
1668+
if (pMember == pPlayer)
1669+
continue;
1670+
1671+
if (pMember->AI())
1672+
{
1673+
if (PartyBotAI* pAI = dynamic_cast<PartyBotAI*>(pMember->AI()))
1674+
{
1675+
if (pAI->m_role == ROLE_MELEE_DPS || pAI->m_role == ROLE_RANGE_DPS)
1676+
{
1677+
HandlePartyBotPauseApplyHelper(pMember, duration);
1678+
continue;
1679+
}
1680+
else if (pAI->m_role == ROLE_TANK)
1681+
{
1682+
if (pMember->IsValidAttackTarget(pTarget))
1683+
pAI->AttackStart(pTarget);
1684+
}
1685+
}
1686+
}
1687+
}
1688+
}
1689+
1690+
PSendSysMessage("Tank party bots are pulling %s, DPS party bots are paused for %d seconds.", pTarget->GetName(), (duration / IN_MILLISECONDS));
1691+
return true;
1692+
}
1693+
16411694
bool ChatHandler::HandlePartyBotUnequipCommand(char* args)
16421695
{
16431696
Player* pTarget = GetSelectedPlayer();

0 commit comments

Comments
 (0)