Skip to content

Commit

Permalink
added check if party members can join BG too to avoid wrong levels in…
Browse files Browse the repository at this point in the history
… BG (#59)
  • Loading branch information
Redbu11dev authored Aug 12, 2024
1 parent 8ad9176 commit a94253e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
34 changes: 27 additions & 7 deletions playerbot/strategy/actions/BattleGroundJoinAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)

if (member->GetLevel() < 70)
continue;

if (!member->GetPlayerbotAI())
continue;

Expand Down Expand Up @@ -317,25 +317,25 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
}
#endif

bool BGJoinAction::canJoinBg(BattleGroundQueueTypeId queueTypeId, BattleGroundBracketId bracketId)
bool BGJoinAction::canJoinBg(Player* player, BattleGroundQueueTypeId queueTypeId, BattleGroundBracketId bracketId)
{
// check if bot can join this bg/bracket

BattleGroundTypeId bgTypeId = sServerFacade.BgTemplateId(queueTypeId);

// check if already in queue
if (bot->InBattleGroundQueueForBattleGroundQueueType(queueTypeId))
if (player->InBattleGroundQueueForBattleGroundQueueType(queueTypeId))
return false;

// check too low/high level
if (!bot->GetBGAccessByLevel(bgTypeId))
if (!player->GetBGAccessByLevel(bgTypeId))
return false;

// check bracket
#ifdef MANGOSBOT_TWO
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
uint32 mapId = bg->GetMapId();
PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, bot->GetLevel());
PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, player->GetLevel());
if (!pvpDiff)
return false;

Expand All @@ -344,7 +344,7 @@ bool BGJoinAction::canJoinBg(BattleGroundQueueTypeId queueTypeId, BattleGroundBr
if (bracket_temp != bracketId)
return false;
#else
if (bot->GetBattleGroundBracketIdFromLevel(bgTypeId) != bracketId)
if (player->GetBattleGroundBracketIdFromLevel(bgTypeId) != bracketId)
return false;
#endif
return true;
Expand Down Expand Up @@ -600,7 +600,27 @@ bool BGJoinAction::isUseful()
BattleGroundTypeId bgTypeId = sServerFacade.BgTemplateId(queueTypeId);
BattleGroundBracketId bracketId = BattleGroundBracketId(i);

if (!canJoinBg(queueTypeId, bracketId))
Group* group = bot->GetGroup();
if (group)
{
bool partyMemberCanNotJoinBG = false;

for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{
Player* member = ref->getSource();

if (!canJoinBg(member, queueTypeId, bracketId))
{
partyMemberCanNotJoinBG = true;
break;
}
}

if (partyMemberCanNotJoinBG)
continue;

This comment has been minimized.

Copy link
@Exxenoz

Exxenoz Aug 12, 2024

Member

@Redbu11dev I didn't read the whole method body, but shouldn't this be return false;?

//EDIT: Everything fine. I just looked at the method.

}

if (!canJoinBg(bot, queueTypeId, bracketId))
continue;

if (shouldJoinBg(queueTypeId, bracketId))
Expand Down
2 changes: 1 addition & 1 deletion playerbot/strategy/actions/BattleGroundJoinAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BGJoinAction : public Action
BGJoinAction(PlayerbotAI* ai, std::string name = "bg join") : Action(ai, name) {}
virtual bool Execute(Event& event);
virtual bool isUseful();
virtual bool canJoinBg(BattleGroundQueueTypeId queueTypeId, BattleGroundBracketId bracketId);
virtual bool canJoinBg(Player* player, BattleGroundQueueTypeId queueTypeId, BattleGroundBracketId bracketId);
virtual bool shouldJoinBg(BattleGroundQueueTypeId queueTypeId, BattleGroundBracketId bracketId);
#ifndef MANGOSBOT_ZERO
virtual bool gatherArenaTeam(ArenaType type);
Expand Down

0 comments on commit a94253e

Please sign in to comment.