feat(Core/Script): Hooks for custom arena teams/types (#3508)

This commit is contained in:
Petric
2020-11-29 21:04:38 +00:00
committed by GitHub
parent d503ba0d71
commit 5984e82f22
9 changed files with 225 additions and 29 deletions

View File

@@ -13,7 +13,7 @@
#include "Player.h"
#include "WorldSession.h"
#include "Opcodes.h"
#include <Config.h>
#include "ScriptMgr.h"
ArenaTeam::ArenaTeam()
: TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
@@ -473,7 +473,7 @@ void ArenaTeam::NotifyStatsChanged()
void ArenaTeam::Inspect(WorldSession* session, uint64 guid)
{
ArenaTeamMember* member = GetMember(guid);
if (!member)
if (!member || GetSlot() >= MAX_ARENA_SLOT)
return;
WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8 + 1 + 4 * 6);
@@ -495,7 +495,7 @@ void ArenaTeamMember::ModifyPersonalRating(Player* player, int32 mod, uint32 typ
else
PersonalRating += mod;
if (player)
if (player && ArenaTeam::GetSlotByType(type) < 3)
{
player->SetArenaTeamInfoField(ArenaTeam::GetSlotByType(type), ARENA_TEAM_PERSONAL_RATING, PersonalRating);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, PersonalRating, type);
@@ -579,17 +579,28 @@ void ArenaTeam::MassInviteToEvent(WorldSession* session)
uint8 ArenaTeam::GetSlotByType(uint32 type)
{
uint8 slot = 0xFF;
switch (type)
{
case ARENA_TEAM_2v2:
return 0;
slot = 0;
break;
case ARENA_TEAM_3v3:
return 1;
slot = 1;
break;
case ARENA_TEAM_5v5:
return 2;
slot = 2;
break;
default:
break;
}
//Get the changed slot type
sScriptMgr->OnGetSlotByType(type, slot);
if (slot != 0xFF)
{
return slot;
}
sLog->outError("FATAL: Unknown arena team type %u for some arena team", type);
return 0xFF;
}
@@ -626,6 +637,8 @@ uint32 ArenaTeam::GetPoints(uint32 memberRating)
else if (Type == ARENA_TEAM_3v3)
points *= 0.88f;
sScriptMgr->OnGetArenaPoints(this, points);
points *= sWorld->getRate(RATE_ARENA_POINTS);
return (uint32) points;