Skip to content

Commit

Permalink
feat: make it working (azerothcore#7)
Browse files Browse the repository at this point in the history
* wip

* chore: restore 6 players as min required

* chore: make FilterTalents optional conf

* chore: clean code
  • Loading branch information
Helias authored Apr 17, 2024
1 parent ec59b0c commit b8f988e
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 19 deletions.
8 changes: 4 additions & 4 deletions conf/arena_3v3_solo_queue.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Solo.3v3.Enable = 1
Solo.3v3.MinLevel = 80
Solo.3v3.Cost = 45
Solo.3v3.ArenaPointsMulti = 0.8
Solo.3v3.FilterTalents = 1
Solo.3v3.FilterTalents = 0
Solo.3v3.VendorRating = 1
Arena.3v3.BlockForbiddenTalents = 0
Arena.CheckEquipAndTalents = 1
Arena.CheckEquipAndTalents = 0
Solo.3v3.CastDeserterOnAfk = 1
Solo.3v3.CastDeserterOnLeave = 1
Solo.3v3.StopGameIncomplete = 1
Solo.3v3.CastDeserterOnLeave = 0
Solo.3v3.StopGameIncomplete = 0
37 changes: 27 additions & 10 deletions src/solo3v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,21 @@ bool Solo3v3::CheckSolo3v3Arena(BattlegroundQueue* queue, BattlegroundBracketId
if (!filterTalents && queue->m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() + queue->m_SelectionPools[TEAM_HORDE].GetPlayerCount() == MinPlayersPerTeam * 2)
return true;

Solo3v3TalentCat plrCat = GetTalentCatForSolo3v3(plr); // get talent cat
if (!plr)
return false;

Solo3v3TalentCat playerSlotIndex;
if (sConfigMgr->GetOption<bool>("Solo.3v3.FilterTalents", false))
playerSlotIndex = GetTalentCatForSolo3v3(plr);
else
playerSlotIndex = GetFirstAvailableSlot(soloTeam);

// is slot free in alliance team?
if ((filterTalents && soloTeam[TEAM_ALLIANCE][plrCat] == false) || (!filterTalents && queue->m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() != MinPlayersPerTeam))
if ((filterTalents && soloTeam[TEAM_ALLIANCE][playerSlotIndex] == false) || (!filterTalents && queue->m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() != MinPlayersPerTeam))
{
if (queue->m_SelectionPools[TEAM_ALLIANCE].AddGroup((*itr), MinPlayersPerTeam)) // added successfully?
{
soloTeam[TEAM_ALLIANCE][plrCat] = true; // okay take this slot
soloTeam[TEAM_ALLIANCE][playerSlotIndex] = true; // okay take this slot

if ((*itr)->teamId != TEAM_ALLIANCE) // move to other team
{
Expand All @@ -254,11 +261,11 @@ bool Solo3v3::CheckSolo3v3Arena(BattlegroundQueue* queue, BattlegroundBracketId
}
}
}
else if ((filterTalents && soloTeam[TEAM_HORDE][plrCat] == false) || !filterTalents) // nope? and in horde team?
else if ((filterTalents && soloTeam[TEAM_HORDE][playerSlotIndex] == false) || !filterTalents) // nope? and in horde team?
{
if (queue->m_SelectionPools[TEAM_HORDE].AddGroup((*itr), MinPlayersPerTeam))
{
soloTeam[TEAM_HORDE][plrCat] = true;
soloTeam[TEAM_HORDE][playerSlotIndex] = true;

if ((*itr)->teamId != TEAM_HORDE) // move to other team
{
Expand Down Expand Up @@ -354,15 +361,12 @@ bool Solo3v3::Arena3v3CheckTalents(Player* player)
ChatHandler(player->GetSession()).SendSysMessage("You can't join, because you have invested to much points in a forbidden talent. Please edit your talents.");
return false;
}
else
return true;

return true;
}

Solo3v3TalentCat Solo3v3::GetTalentCatForSolo3v3(Player* player)
{
if (!player || !sConfigMgr->GetOption<bool>("Solo.3v3.FilterTalents", false))
return MELEE;

uint32 count[MAX_TALENT_CAT];

for (int i = 0; i < MAX_TALENT_CAT; i++)
Expand Down Expand Up @@ -412,3 +416,16 @@ Solo3v3TalentCat Solo3v3::GetTalentCatForSolo3v3(Player* player)

return talCat;
}

Solo3v3TalentCat Solo3v3::GetFirstAvailableSlot(bool soloTeam[][MAX_TALENT_CAT]) {
if (!soloTeam[0][MELEE] || !soloTeam[1][MELEE])
return MELEE;

if (!soloTeam[0][RANGE] || !soloTeam[1][RANGE])
return RANGE;

if (!soloTeam[0][HEALER] || !soloTeam[1][HEALER])
return HEALER;

return MELEE;
}
18 changes: 14 additions & 4 deletions src/solo3v3.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,21 @@
#include "BattlegroundMgr.h"
#include "Player.h"

constexpr uint32 ARENA_TEAM_SOLO_3v3 = 3;
constexpr uint32 ARENA_TYPE_3v3_SOLO = 3;
constexpr uint32 ARENA_SLOT_SOLO_3v3 = 3;
constexpr uint32 BATTLEGROUND_QUEUE_3v3_SOLO = 11;
// Custom 1v1 Arena Rated
constexpr uint32 ARENA_TYPE_1v1 = 1;
constexpr uint32 ARENA_TEAM_1v1 = 1;
constexpr uint32 ARENA_SLOT_1v1 = 3;
constexpr uint32 BATTLEGROUND_QUEUE_1v1 = 11;
constexpr BattlegroundQueueTypeId bgQueueTypeId1v1 = (BattlegroundQueueTypeId)((int)BATTLEGROUND_QUEUE_5v5 + 1);

// custom 3v3 Arena
constexpr uint32 ARENA_TEAM_SOLO_3v3 = 4;
constexpr uint32 ARENA_TYPE_3v3_SOLO = 4;
constexpr uint32 ARENA_SLOT_SOLO_3v3 = 4;
constexpr uint32 BATTLEGROUND_QUEUE_3v3_SOLO = 12;
constexpr BattlegroundQueueTypeId bgQueueTypeId = (BattlegroundQueueTypeId)((int)BATTLEGROUND_QUEUE_3v3);


const uint32 FORBIDDEN_TALENTS_IN_1V1_ARENA[] =
{
// Healer
Expand Down Expand Up @@ -115,6 +124,7 @@ class Solo3v3

// Returns MELEE, RANGE or HEALER (depends on talent builds)
Solo3v3TalentCat GetTalentCatForSolo3v3(Player* player);
Solo3v3TalentCat GetFirstAvailableSlot(bool soloTeam[][MAX_TALENT_CAT]);
};

#define sSolo Solo3v3::instance()
Expand Down
3 changes: 2 additions & 1 deletion src/solo3v3_sc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ bool NpcSolo3v3::ArenaCheckFullEquipAndTalents(Player* player)
ChatHandler(player->GetSession()).SendSysMessage(err.str().c_str());
return false;
}

return true;
}

Expand Down Expand Up @@ -263,7 +264,7 @@ bool NpcSolo3v3::JoinQueueArena(Player* player, Creature* creature, bool isRated

// check if already in queue
if (player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
return false; // //player is already in this queue
return false; // player is already in this queue

// check if has free queue slots
if (!player->HasFreeBattlegroundQueueId())
Expand Down
35 changes: 35 additions & 0 deletions src/solo3v3_sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,41 @@ class PlayerScript3v3Arena : public PlayerScript

void AddSC_Solo_3v3_Arena()
{
// ArenaSlotByType
if (!ArenaTeam::ArenaSlotByType.count(ARENA_TEAM_1v1))
ArenaTeam::ArenaSlotByType[ARENA_TEAM_1v1] = ARENA_SLOT_1v1;

if (!ArenaTeam::ArenaSlotByType.count(ARENA_TEAM_SOLO_3v3))
ArenaTeam::ArenaSlotByType[ARENA_TEAM_SOLO_3v3] = ARENA_SLOT_SOLO_3v3;

// ArenaReqPlayersForType
if (!ArenaTeam::ArenaReqPlayersForType.count(ARENA_TYPE_1v1))
ArenaTeam::ArenaReqPlayersForType[ARENA_TYPE_1v1] = 2;

if (!ArenaTeam::ArenaReqPlayersForType.count(ARENA_TYPE_3v3_SOLO))
ArenaTeam::ArenaReqPlayersForType[ARENA_TYPE_3v3_SOLO] = 6;

// queueToBg
if (!BattlegroundMgr::queueToBg.count(BATTLEGROUND_QUEUE_1v1))
BattlegroundMgr::queueToBg[BATTLEGROUND_QUEUE_1v1] = BATTLEGROUND_AA;

if (!BattlegroundMgr::queueToBg.count(BATTLEGROUND_QUEUE_3v3_SOLO))
BattlegroundMgr::queueToBg[BATTLEGROUND_QUEUE_3v3_SOLO] = BATTLEGROUND_AA;

// ArenaTypeToQueue
if (!BattlegroundMgr::ArenaTypeToQueue.count(ARENA_TYPE_1v1))
BattlegroundMgr::ArenaTypeToQueue[ARENA_TYPE_1v1] = (BattlegroundQueueTypeId)BATTLEGROUND_QUEUE_1v1;

if (!BattlegroundMgr::ArenaTypeToQueue.count(ARENA_TYPE_3v3_SOLO))
BattlegroundMgr::ArenaTypeToQueue[ARENA_TYPE_3v3_SOLO] = (BattlegroundQueueTypeId)BATTLEGROUND_QUEUE_3v3_SOLO;

// QueueToArenaType
if (!BattlegroundMgr::QueueToArenaType.count(BATTLEGROUND_QUEUE_1v1))
BattlegroundMgr::QueueToArenaType[BATTLEGROUND_QUEUE_1v1] = (ArenaType)ARENA_TYPE_1v1;

if (!BattlegroundMgr::QueueToArenaType.count(BATTLEGROUND_QUEUE_3v3_SOLO))
BattlegroundMgr::QueueToArenaType[BATTLEGROUND_QUEUE_3v3_SOLO] = (ArenaType)ARENA_TYPE_3v3_SOLO;

new NpcSolo3v3();
new Solo3v3BG();
new Team3v3arena();
Expand Down

0 comments on commit b8f988e

Please sign in to comment.