Skip to content

Commit

Permalink
Merge pull request #60 from azerothcore/minlevel-disable-ap
Browse files Browse the repository at this point in the history
hackfix: restore arenapoints and honor points after arena create/disband & add min level arena points conf
  • Loading branch information
Nyeriah authored Oct 30, 2024
2 parents 4d7c233 + 9869a17 commit 8d398f1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
8 changes: 8 additions & 0 deletions conf/1v1arena.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ Arena1v1.VendorRating = 0

Arena1v1.ArenaPointsMulti = 0.64


#
# Arena1v1.ArenaPointsMinLevel
# Description: minlevel to get the arena points
# Default: 70

Arena1v1.ArenaPointsMinLevel = 70

#
# Arena1v1.PreventHealingTalents
# Description: If enabled, it prevents people from having healing talents.
Expand Down
36 changes: 28 additions & 8 deletions src/npc_arena1v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void deleteTeamArenaForPlayer(Player* player)
if (queryPlayerTeam)
{
CharacterDatabase.Execute("DELETE FROM `arena_team` WHERE `captainGuid`={} AND `type`=1", player->GetGUID().GetCounter());
CharacterDatabase.Execute("DELETE FROM `arena_team_member` WHERE `guid`={}", player->GetGUID().GetCounter());
CharacterDatabase.Execute("DELETE FROM `arena_team_member` WHERE `guid`={} AND `type`=1", player->GetGUID().GetCounter());
}
}

Expand Down Expand Up @@ -238,11 +238,19 @@ bool npc_1v1arena::OnGossipSelect(Player* player, Creature* creature, uint32 /*s

case NPC_ARENA_1V1_ACTION_DISBAND_ARENA_TEAM:
{
uint32 playerHonorPoints = player->GetHonorPoints();
uint32 playerArenaPoints = player->GetArenaPoints();

WorldPacket Data;
Data << player->GetArenaTeamId(ARENA_SLOT_1V1);
player->GetSession()->HandleArenaTeamLeaveOpcode(Data);
handler.SendSysMessage("Arenateam deleted!");
CloseGossipMenuFor(player);

// hackfix: restore points
player->SetHonorPoints(playerHonorPoints);
player->SetArenaPoints(playerArenaPoints);

return true;
}

Expand Down Expand Up @@ -352,19 +360,19 @@ bool npc_1v1arena::CreateArenateam(Player* player, Creature* /* me */)
if (slot == 0)
return false;

// This disaster is the result of changing the MAX_ARENA_SLOT from 3 to 4.
uint32 playerHonorPoints = player->GetHonorPoints();
uint32 playerArenaPoints = player->GetArenaPoints();
player->SetHonorPoints(0);
player->SetArenaPoints(0);

// Check if player is already in an arena team
if (player->GetArenaTeamId(slot))
{
player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "You are already in an arena team!", ERR_ALREADY_IN_ARENA_TEAM);
return false;
}

// This disaster is the result of changing the MAX_ARENA_SLOT from 3 to 4.
uint32 playerHonorPoints = player->GetHonorPoints();
uint32 playerArenaPoints = player->GetArenaPoints();
player->SetHonorPoints(0);
player->SetArenaPoints(0);

// This disaster is the result of changing the MAX_ARENA_SLOT from 3 to 4.
sArenaTeamMgr->RemoveArenaTeam(player->GetArenaTeamId(ARENA_SLOT_1V1));
deleteTeamArenaForPlayer(player);
Expand All @@ -374,6 +382,11 @@ bool npc_1v1arena::CreateArenateam(Player* player, Creature* /* me */)
if (!arenaTeam->Create(player->GetGUID(), ARENA_TEAM_1V1, player->GetName(), 4283124816, 45, 4294242303, 5, 4294705149))
{
delete arenaTeam;

// hackfix: restore points
player->SetHonorPoints(playerHonorPoints);
player->SetArenaPoints(playerArenaPoints);

return false;
}

Expand All @@ -383,6 +396,7 @@ bool npc_1v1arena::CreateArenateam(Player* player, Creature* /* me */)
ChatHandler(player->GetSession()).SendSysMessage("1v1 Arenateam successfully created!");

// This disaster is the result of changing the MAX_ARENA_SLOT from 3 to 4.
// hackfix: restore points
player->SetHonorPoints(playerHonorPoints);
player->SetArenaPoints(playerArenaPoints);

Expand Down Expand Up @@ -426,7 +440,13 @@ class team_1v1arena : public ArenaTeamScript
{
if (at->GetType() == ARENA_TEAM_1V1)
{
points *= sConfigMgr->GetOption<float>("Arena1v1.ArenaPointsMulti", 0.64f);
const auto Members = at->GetMembers();
uint8 playerLevel = sCharacterCache->GetCharacterLevelByGuid(Members.front().Guid);

if (playerLevel >= sConfigMgr->GetOption<uint32>("Arena1v1.ArenaPointsMinLevel", 70))
points *= sConfigMgr->GetOption<float>("Arena1v1.ArenaPointsMulti", 0.64f);
else
points *= 0;
}
}

Expand Down

0 comments on commit 8d398f1

Please sign in to comment.