Scripts/Commands: Improve .debug arena
Port From (https://github.com/TrinityCore/TrinityCore/commit/16edee0b0ea805f5d8f0abf5eedb2c66a6edb23f)
This commit is contained in:
@@ -244,6 +244,15 @@ namespace Game.BattleGrounds
|
|||||||
return _battlegroundScriptTemplates.LookupByKey((mapId, BattlegroundTypeId.None));
|
return _battlegroundScriptTemplates.LookupByKey((mapId, BattlegroundTypeId.None));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void QueuePlayerForArena(Player player, byte teamSize, byte roles)
|
||||||
|
{
|
||||||
|
BattlemasterJoinArena packet = new(new Networking.WorldPacket(ClientOpcodes.BattlemasterJoinArena));
|
||||||
|
packet.TeamSizeIndex = teamSize;
|
||||||
|
packet.Roles = roles;
|
||||||
|
|
||||||
|
player.GetSession().HandleBattlemasterJoinArena(packet);
|
||||||
|
}
|
||||||
|
|
||||||
uint CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
|
uint CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
|
||||||
{
|
{
|
||||||
if (IsArenaType(bgTypeId))
|
if (IsArenaType(bgTypeId))
|
||||||
@@ -448,10 +457,24 @@ namespace Game.BattleGrounds
|
|||||||
Global.WorldMgr.SendWorldText(m_Testing ? CypherStrings.DebugBgOn : CypherStrings.DebugBgOff);
|
Global.WorldMgr.SendWorldText(m_Testing ? CypherStrings.DebugBgOn : CypherStrings.DebugBgOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleArenaTesting()
|
// Return whether toggling was successful. In case of a non-existing battlemasterListId, or this battlemasterListId is not an arena, this would return false.
|
||||||
|
public bool ToggleArenaTesting(uint battlemasterListId)
|
||||||
{
|
{
|
||||||
m_ArenaTesting = !m_ArenaTesting;
|
if (battlemasterListId != 0)
|
||||||
Global.WorldMgr.SendWorldText(m_ArenaTesting ? CypherStrings.DebugArenaOn : CypherStrings.DebugArenaOff);
|
{
|
||||||
|
BattlegroundTemplate bgTemplate = GetBattlegroundTemplateByTypeId((BattlegroundTypeId)battlemasterListId);
|
||||||
|
if (bgTemplate == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!bgTemplate.IsArena())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ArenaTesting != battlemasterListId)
|
||||||
|
Global.WorldMgr.SendWorldText((battlemasterListId != 0) ? CypherStrings.DebugArenaOn : CypherStrings.DebugArenaOff);
|
||||||
|
|
||||||
|
m_ArenaTesting = battlemasterListId;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId)
|
public bool IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId)
|
||||||
@@ -642,6 +665,9 @@ namespace Game.BattleGrounds
|
|||||||
BattlegroundTemplate bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId);
|
BattlegroundTemplate bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId);
|
||||||
if (bgTemplate != null)
|
if (bgTemplate != null)
|
||||||
{
|
{
|
||||||
|
if (bgTemplate.IsArena() && IsArenaTesting())
|
||||||
|
return (BattlegroundTypeId)m_ArenaTesting;
|
||||||
|
|
||||||
List<BattlegroundTemplate> ids = new();
|
List<BattlegroundTemplate> ids = new();
|
||||||
foreach (var mapId in bgTemplate.MapIDs)
|
foreach (var mapId in bgTemplate.MapIDs)
|
||||||
{
|
{
|
||||||
@@ -698,7 +724,7 @@ namespace Game.BattleGrounds
|
|||||||
return m_BattlegroundQueues[bgQueueTypeId];
|
return m_BattlegroundQueues[bgQueueTypeId];
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsArenaTesting() { return m_ArenaTesting; }
|
public bool IsArenaTesting() { return m_ArenaTesting != 0; }
|
||||||
public bool IsTesting() { return m_Testing; }
|
public bool IsTesting() { return m_Testing; }
|
||||||
|
|
||||||
public BattlegroundTypeId GetBattleMasterBG(uint entry)
|
public BattlegroundTypeId GetBattleMasterBG(uint entry)
|
||||||
@@ -760,7 +786,7 @@ namespace Game.BattleGrounds
|
|||||||
List<ScheduledQueueUpdate> m_QueueUpdateScheduler = new();
|
List<ScheduledQueueUpdate> m_QueueUpdateScheduler = new();
|
||||||
uint m_NextRatedArenaUpdate;
|
uint m_NextRatedArenaUpdate;
|
||||||
uint m_UpdateTimer;
|
uint m_UpdateTimer;
|
||||||
bool m_ArenaTesting;
|
uint m_ArenaTesting;
|
||||||
bool m_Testing;
|
bool m_Testing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,19 @@ namespace Game.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Command("arena", RBACPermissions.CommandDebug, true)]
|
[Command("arena", RBACPermissions.CommandDebug, true)]
|
||||||
static bool HandleDebugArenaCommand(CommandHandler handler)
|
static bool HandleDebugArenaCommand(CommandHandler handler, uint battlemasterListId)
|
||||||
{
|
{
|
||||||
Global.BattlegroundMgr.ToggleArenaTesting();
|
bool successful = Global.BattlegroundMgr.ToggleArenaTesting(battlemasterListId);
|
||||||
|
if (!successful)
|
||||||
|
{
|
||||||
|
handler.SendSysMessage("BattlemasterListId %u does not exist or is not an arena.", battlemasterListId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (battlemasterListId == 0 || handler == null || handler.GetSession() == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
BattlegroundManager.QueuePlayerForArena(handler.GetSession().GetPlayer(), 0, (byte)LfgRoles.Damage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
[WorldPacketHandler(ClientOpcodes.BattlemasterJoinArena)]
|
[WorldPacketHandler(ClientOpcodes.BattlemasterJoinArena)]
|
||||||
void HandleBattlemasterJoinArena(BattlemasterJoinArena packet)
|
public void HandleBattlemasterJoinArena(BattlemasterJoinArena packet)
|
||||||
{
|
{
|
||||||
// ignore if we already in BG or BG queue
|
// ignore if we already in BG or BG queue
|
||||||
if (GetPlayer().InBattleground())
|
if (GetPlayer().InBattleground())
|
||||||
@@ -508,9 +508,16 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Group group = GetPlayer().GetGroup();
|
Group group = GetPlayer().GetGroup();
|
||||||
|
if (group == null)
|
||||||
|
{
|
||||||
|
group = new Group();
|
||||||
|
group.Create(_player);
|
||||||
|
}
|
||||||
|
|
||||||
// no group found, error
|
// no group found, error
|
||||||
if (group == null)
|
if (group == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (group.GetLeaderGUID() != GetPlayer().GetGUID())
|
if (group.GetLeaderGUID() != GetPlayer().GetGUID())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -534,7 +541,9 @@ namespace Game
|
|||||||
GroupQueueInfo ginfo = null;
|
GroupQueueInfo ginfo = null;
|
||||||
|
|
||||||
ObjectGuid errorGuid;
|
ObjectGuid errorGuid;
|
||||||
var err = group.CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, (uint)arenatype, (uint)arenatype, true, packet.TeamSizeIndex, out errorGuid);
|
GroupJoinBattlegroundResult err = GroupJoinBattlegroundResult.None;
|
||||||
|
if (!Global.BattlegroundMgr.IsArenaTesting())
|
||||||
|
err = group.CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, (uint)arenatype, (uint)arenatype, true, packet.TeamSizeIndex, out errorGuid);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.Battleground, "Battleground: arena team id {0}, leader {1} queued with matchmaker rating {2} for type {3}", GetPlayer().GetArenaTeamId(packet.TeamSizeIndex), GetPlayer().GetName(), matchmakerRating, arenatype);
|
Log.outDebug(LogFilter.Battleground, "Battleground: arena team id {0}, leader {1} queued with matchmaker rating {2} for type {3}", GetPlayer().GetArenaTeamId(packet.TeamSizeIndex), GetPlayer().GetName(), matchmakerRating, arenatype);
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ namespace Game.Networking
|
|||||||
this.opcode = (uint)opcode;
|
this.opcode = (uint)opcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WorldPacket(ClientOpcodes opcode)
|
||||||
|
{
|
||||||
|
this.opcode = (uint)opcode;
|
||||||
|
}
|
||||||
|
|
||||||
public WorldPacket(byte[] data) : base(data)
|
public WorldPacket(byte[] data) : base(data)
|
||||||
{
|
{
|
||||||
opcode = ReadUInt32();
|
opcode = ReadUInt32();
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ namespace Game.Networking.Packets
|
|||||||
public int[] BlacklistMap = new int[2];
|
public int[] BlacklistMap = new int[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
class BattlemasterJoinArena : ClientPacket
|
public class BattlemasterJoinArena : ClientPacket
|
||||||
{
|
{
|
||||||
public BattlemasterJoinArena(WorldPacket packet) : base(packet) { }
|
public BattlemasterJoinArena(WorldPacket packet) : base(packet) { }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user