Scripts/Commands: new command '.debug instancespawn'
Port From (https://github.com/TrinityCore/TrinityCore/commit/386ec582334818bb46582290e9daecb19f453897)
This commit is contained in:
@@ -776,7 +776,7 @@ namespace Framework.Constants
|
||||
CommandModifyPower = 868,
|
||||
CommandDebugSendPlayerChoice = 869,
|
||||
CommandDebugThreatinfo = 870,
|
||||
CommandDebugInstancespawn = 871, // reserved
|
||||
CommandDebugInstancespawn = 871,
|
||||
CommandServerDebug = 872,
|
||||
CommandReloadCreatureMovementOverride = 873,
|
||||
// 874 previously used, do not reuse
|
||||
|
||||
@@ -458,6 +458,115 @@ namespace Game.Chat
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("instancespawn", RBACPermissions.CommandDebugInstancespawn)]
|
||||
static bool HandleDebugInstanceSpawns(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
string explainOrGroupId = args.NextString();
|
||||
|
||||
bool explain = false;
|
||||
uint groupID = 0;
|
||||
if (explainOrGroupId.Equals("explain"))
|
||||
explain = true;
|
||||
else
|
||||
groupID = uint.Parse(explainOrGroupId);
|
||||
|
||||
if (groupID != 0 && Global.ObjectMgr.GetSpawnGroupData(groupID) == null)
|
||||
{
|
||||
handler.SendSysMessage($"There is no spawn group with ID {groupID}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Map map = player.GetMap();
|
||||
string mapName = map.GetMapName();
|
||||
InstanceScript instance = player.GetInstanceScript();
|
||||
if (instance == null)
|
||||
{
|
||||
handler.SendSysMessage($"{mapName} has no instance script.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var spawnGroups = instance.GetInstanceSpawnGroups();
|
||||
if (spawnGroups.Empty())
|
||||
{
|
||||
handler.SendSysMessage($"{mapName}'s instance script does not manage any spawn groups.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MultiMap<uint, Tuple<bool, byte, byte>> store = new();
|
||||
foreach (InstanceSpawnGroupInfo info in spawnGroups)
|
||||
{
|
||||
if (groupID != 0 && info.SpawnGroupId != groupID)
|
||||
continue;
|
||||
|
||||
bool isSpawn;
|
||||
if (info.Flags.HasFlag(InstanceSpawnGroupFlags.BlockSpawn))
|
||||
isSpawn = false;
|
||||
else if (info.Flags.HasFlag(InstanceSpawnGroupFlags.ActivateSpawn))
|
||||
isSpawn = true;
|
||||
else
|
||||
continue;
|
||||
|
||||
store.Add(info.SpawnGroupId, Tuple.Create(isSpawn, info.BossStateId, info.BossStates));
|
||||
}
|
||||
|
||||
if (groupID != 0 && !store.ContainsKey(groupID))
|
||||
{
|
||||
handler.SendSysMessage($"{mapName}'s instance script does not manage group '{Global.ObjectMgr.GetSpawnGroupData(groupID).name}'.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (groupID == 0)
|
||||
handler.SendSysMessage($"Spawn groups managed by {mapName} ({map.GetId()}):");
|
||||
|
||||
foreach (var key in store.Keys)
|
||||
{
|
||||
SpawnGroupTemplateData groupData = Global.ObjectMgr.GetSpawnGroupData(key);
|
||||
Cypher.Assert(groupData != null); // checked by objectmgr on load
|
||||
if (explain)
|
||||
{
|
||||
handler.SendSysMessage(" |-- '{}' ({})", groupData.name, key);
|
||||
bool isBlocked = false, isSpawned = false;
|
||||
foreach (var tuple in store[key])
|
||||
{
|
||||
bool isSpawn = tuple.Item1;
|
||||
byte bossStateId = tuple.Item2;
|
||||
EncounterState actualState = instance.GetBossState(bossStateId);
|
||||
if ((tuple.Item3 & (1 << (int)actualState)) != 0)
|
||||
{
|
||||
if (isSpawn)
|
||||
{
|
||||
isSpawned = true;
|
||||
if (isBlocked)
|
||||
handler.SendSysMessage($" | |-- '{groupData.name}' would be allowed to spawn by boss state {bossStateId} being {(EncounterState)actualState}, but this is overruled");
|
||||
else
|
||||
handler.SendSysMessage($" | |-- '{groupData.name}' is allowed to spawn because boss state {bossStateId} is {(EncounterState)bossStateId}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
isBlocked = true;
|
||||
handler.SendSysMessage($" | |-- '{groupData.name}' is blocked from spawning because boss state {bossStateId} is {(EncounterState)bossStateId}.");
|
||||
}
|
||||
}
|
||||
else
|
||||
handler.SendSysMessage($" | |-- '{groupData.name}' could've been {(isSpawn ? "allowed to spawn" : "blocked from spawning")} if boss state {bossStateId} matched mask {tuple.Item3}; but it is {(EncounterState)actualState} . {(1 << (int)actualState)}, which does not match.");
|
||||
}
|
||||
if (isBlocked)
|
||||
handler.SendSysMessage($" | |=> '{groupData.name}' is not active due to a blocking rule being matched");
|
||||
else if (isSpawned)
|
||||
handler.SendSysMessage($" | |=> '{groupData.name}' is active due to a spawn rule being matched");
|
||||
else
|
||||
handler.SendSysMessage($" | |=> '{groupData.name}' is not active due to none of its rules being matched");
|
||||
}
|
||||
else
|
||||
handler.SendSysMessage($" - '{groupData.name}' ({key}) is {(map.IsSpawnGroupActive(key) ? "" : "not ")}active");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("itemexpire", RBACPermissions.CommandDebugItemexpire)]
|
||||
static bool HandleDebugItemExpireCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
@@ -477,6 +586,29 @@ namespace Game.Chat
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("loadcells", RBACPermissions.CommandDebugLoadcells)]
|
||||
static bool HandleDebugLoadCellsCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
Map map = null;
|
||||
|
||||
if (!args.Empty())
|
||||
{
|
||||
uint mapId = args.NextUInt32();
|
||||
map = Global.MapMgr.FindBaseNonInstanceMap(mapId);
|
||||
}
|
||||
if (!map)
|
||||
map = player.GetMap();
|
||||
|
||||
map.LoadAllCells();
|
||||
|
||||
handler.SendSysMessage("Cells loaded (mapId: {0})", map.GetId());
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("lootrecipient", RBACPermissions.CommandDebugLootrecipient)]
|
||||
static bool HandleDebugGetLootRecipientCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
@@ -603,29 +735,6 @@ namespace Game.Chat
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("loadcells", RBACPermissions.CommandDebugLoadcells)]
|
||||
static bool HandleDebugLoadCellsCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
Map map = null;
|
||||
|
||||
if (!args.Empty())
|
||||
{
|
||||
uint mapId = args.NextUInt32();
|
||||
map = Global.MapMgr.FindBaseNonInstanceMap(mapId);
|
||||
}
|
||||
if (!map)
|
||||
map = player.GetMap();
|
||||
|
||||
map.LoadAllCells();
|
||||
|
||||
handler.SendSysMessage("Cells loaded (mapId: {0})", map.GetId());
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("phase", RBACPermissions.CommandDebugPhase)]
|
||||
static bool HandleDebugPhaseCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
|
||||
@@ -904,6 +904,8 @@ namespace Game.Maps
|
||||
|
||||
public virtual void WriteSaveDataMore(StringBuilder data) { }
|
||||
|
||||
public List<InstanceSpawnGroupInfo> GetInstanceSpawnGroups() { return _instanceSpawnGroups; }
|
||||
|
||||
public InstanceMap instance;
|
||||
List<char> headers = new();
|
||||
Dictionary<uint, BossInfo> bosses = new();
|
||||
|
||||
@@ -1196,6 +1196,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
|
||||
(196,872),
|
||||
(196,881),
|
||||
(196,870),
|
||||
(196,871),
|
||||
(197,232),
|
||||
(197,236),
|
||||
(197,237),
|
||||
@@ -2125,6 +2126,7 @@ INSERT INTO `rbac_permissions` VALUES
|
||||
(868,'Command: modify power'),
|
||||
(869,'Command: debug send playerchoice'),
|
||||
(870,'Command: debug threatinfo'),
|
||||
(871,'Command: debug instancespawn'),
|
||||
(872,'Command: server debug'),
|
||||
(881,'Command: reload vehicle_template');
|
||||
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
||||
@@ -2339,6 +2341,7 @@ INSERT INTO `updates` VALUES
|
||||
('2017_12_31_00_auth.sql','1721ACBD35EB95FAE33B9E95F8C4E4B1FB70A5E4','ARCHIVED','2017-12-31 20:15:23',0),
|
||||
('2018_01_02_00_auth.sql','CD9B826B9D95697DC412DEF780E814FA3991D6CD','ARCHIVED','2018-01-02 20:40:37',0),
|
||||
('2018_01_09_00_auth.sql','A5D4EC8FCFAB4F2DCE70EDCAD1ACBFB484FD68D5','RELEASED','2018-01-09 00:00:00',0),
|
||||
('2018_01_24_00_auth.sql','167B17D8A253D62A8112F8A7EB21C6E99CAEF1E4','RELEASED','2018-01-24 00:00:00',0),
|
||||
('2018_02_18_00_auth.sql','8489DD3EFFE14A7486B593435F0BA2BC69B6EABF','ARCHIVED','2018-02-18 16:35:55',0),
|
||||
('2018_02_19_00_auth.sql','07CE658C5EF88693D3C047EF8E724F94ADA74C15','ARCHIVED','2018-02-19 22:33:32',0),
|
||||
('2018_02_28_00_auth.sql','E92EF4ABF7FA0C66649E1633DD0459F44C09EB83','ARCHIVED','2018-02-28 23:07:59',0),
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
--
|
||||
DELETE FROM `rbac_permissions` WHERE `id`=871;
|
||||
INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
|
||||
(871, 'Command: debug instancespawn');
|
||||
|
||||
DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=871;
|
||||
INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
|
||||
(196,871);
|
||||
@@ -0,0 +1,6 @@
|
||||
--
|
||||
DELETE FROM `command` WHERE `name`="debug instancespawn";
|
||||
INSERT INTO `command`(`name`,`permission`,`help`) VALUES
|
||||
('debug instancespawn',871,'Syntax: .debug instancespawn [<groupID>/explain]
|
||||
|
||||
Displays information about the spawn groups being managed by the current instance script. If groupID is specified, additionally explains why that spawn group is in the listed state. If "explain" is specified, explains all spawn groups.');
|
||||
Reference in New Issue
Block a user