Scripts/Commands: New command: .debug threatinfo
Port From (https://github.com/TrinityCore/TrinityCore/commit/e090c9a00eab7af40ba1b4090d5b5a456a3e4b33)
This commit is contained in:
@@ -775,7 +775,7 @@ namespace Framework.Constants
|
|||||||
CommandReloadQuestGreetingLocale = 867, // Reserved
|
CommandReloadQuestGreetingLocale = 867, // Reserved
|
||||||
CommandModifyPower = 868,
|
CommandModifyPower = 868,
|
||||||
CommandDebugSendPlayerChoice = 869,
|
CommandDebugSendPlayerChoice = 869,
|
||||||
CommandDebugThreatinfo = 870, // reserved
|
CommandDebugThreatinfo = 870,
|
||||||
CommandDebugInstancespawn = 871, // reserved
|
CommandDebugInstancespawn = 871, // reserved
|
||||||
CommandServerDebug = 872,
|
CommandServerDebug = 872,
|
||||||
CommandReloadCreatureMovementOverride = 873,
|
CommandReloadCreatureMovementOverride = 873,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using Game.DataStorage;
|
|||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Maps;
|
using Game.Maps;
|
||||||
using Game.Networking.Packets;
|
using Game.Networking.Packets;
|
||||||
|
using Game.Spells;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -495,7 +496,7 @@ namespace Game.Chat
|
|||||||
if (unit)
|
if (unit)
|
||||||
{
|
{
|
||||||
Player player = handler.GetSession().GetPlayer();
|
Player player = handler.GetSession().GetPlayer();
|
||||||
handler.SendSysMessage($"Checking LoS {player.GetName()} -> {unit.GetName()}:");
|
handler.SendSysMessage($"Checking LoS {player.GetName()} . {unit.GetName()}:");
|
||||||
handler.SendSysMessage($" VMAP LoS: {(player.IsWithinLOSInMap(unit, LineOfSightChecks.Vmap) ? "clear" : "obstructed")}");
|
handler.SendSysMessage($" VMAP LoS: {(player.IsWithinLOSInMap(unit, LineOfSightChecks.Vmap) ? "clear" : "obstructed")}");
|
||||||
handler.SendSysMessage($" GObj LoS: {(player.IsWithinLOSInMap(unit, LineOfSightChecks.Gobject) ? "clear" : "obstructed")}");
|
handler.SendSysMessage($" GObj LoS: {(player.IsWithinLOSInMap(unit, LineOfSightChecks.Gobject) ? "clear" : "obstructed")}");
|
||||||
handler.SendSysMessage($"{unit.GetName()} is {(player.IsWithinLOSInMap(unit) ? "" : "not ")}in line of sight of {player.GetName()}.");
|
handler.SendSysMessage($"{unit.GetName()} is {(player.IsWithinLOSInMap(unit) ? "" : "not ")}in line of sight of {player.GetName()}.");
|
||||||
@@ -832,6 +833,82 @@ namespace Game.Chat
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("threatinfo", RBACPermissions.CommandDebugThreatinfo)]
|
||||||
|
static bool HandleDebugThreatInfoCommand(StringArguments args, CommandHandler handler)
|
||||||
|
{
|
||||||
|
Unit target = handler.GetSelectedUnit();
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.SendSysMessage($"Threat info for {target.GetName()} ({target.GetGUID()}):");
|
||||||
|
|
||||||
|
ThreatManager mgr = target.GetThreatManager();
|
||||||
|
|
||||||
|
// _singleSchoolModifiers
|
||||||
|
{
|
||||||
|
var mods = mgr._singleSchoolModifiers;
|
||||||
|
handler.SendSysMessage(" - Single-school threat modifiers:");
|
||||||
|
handler.SendSysMessage($" |-- Physical: {mods[(int)SpellSchools.Normal] * 100.0f:0.##}");
|
||||||
|
handler.SendSysMessage($" |-- Holy : {mods[(int)SpellSchools.Holy] * 100.0f:0.##}");
|
||||||
|
handler.SendSysMessage($" |-- Fire : {mods[(int)SpellSchools.Fire] * 100.0f:0.##}");
|
||||||
|
handler.SendSysMessage($" |-- Nature : {mods[(int)SpellSchools.Nature] * 100.0f:0.##}");
|
||||||
|
handler.SendSysMessage($" |-- Frost : {mods[(int)SpellSchools.Frost] * 100.0f:0.##}");
|
||||||
|
handler.SendSysMessage($" |-- Shadow : {mods[(int)SpellSchools.Shadow] * 100.0f:0.##}");
|
||||||
|
handler.SendSysMessage($" |-- Arcane : {mods[(int)SpellSchools.Arcane] * 100.0f:0.##}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// _multiSchoolModifiers
|
||||||
|
{
|
||||||
|
var mods = mgr._multiSchoolModifiers;
|
||||||
|
handler.SendSysMessage($"- Multi-school threat modifiers ({mods.Count} entries):");
|
||||||
|
|
||||||
|
foreach (var pair in mods)
|
||||||
|
handler.SendSysMessage($" |-- Mask {pair.Key:X}: {pair.Value:0.XX}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// _redirectInfo
|
||||||
|
{
|
||||||
|
var redirectInfo = mgr._redirectInfo;
|
||||||
|
if (redirectInfo.Empty())
|
||||||
|
handler.SendSysMessage(" - No redirects being applied");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handler.SendSysMessage($" - {redirectInfo.Count} redirects being applied:");
|
||||||
|
foreach (var pair in redirectInfo)
|
||||||
|
{
|
||||||
|
Unit unit = Global.ObjAccessor.GetUnit(target, pair.Item1);
|
||||||
|
handler.SendSysMessage($" |-- {pair.Item2:D2} to {(unit != null ? unit.GetName() : pair.Item1)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _redirectRegistry
|
||||||
|
{
|
||||||
|
var redirectRegistry = mgr._redirectRegistry;
|
||||||
|
if (redirectRegistry.Empty())
|
||||||
|
handler.SendSysMessage(" - No redirects are registered");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handler.SendSysMessage($" - {redirectRegistry.Count} spells may have redirects registered");
|
||||||
|
foreach (var outerPair in redirectRegistry) // (spellId, (guid, pct))
|
||||||
|
{
|
||||||
|
SpellInfo spell = Global.SpellMgr.GetSpellInfo(outerPair.Key, Difficulty.None);
|
||||||
|
handler.SendSysMessage($" |-- #{outerPair.Key} {(spell != null ? spell.SpellName[Global.WorldMgr.GetDefaultDbcLocale()] : "<unknown>")} ({outerPair.Value.Count} entries):");
|
||||||
|
foreach (var innerPair in outerPair.Value) // (guid, pct)
|
||||||
|
{
|
||||||
|
Unit unit = Global.ObjAccessor.GetUnit(target, innerPair.Key);
|
||||||
|
handler.SendSysMessage($" |-- {innerPair.Value} to {(unit != null ? unit.GetName() : innerPair.Key)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
[Command("transport", RBACPermissions.CommandDebugTransport)]
|
[Command("transport", RBACPermissions.CommandDebugTransport)]
|
||||||
static bool HandleDebugTransportCommand(StringArguments args, CommandHandler handler)
|
static bool HandleDebugTransportCommand(StringArguments args, CommandHandler handler)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ namespace Game.Combat
|
|||||||
ThreatReference _currentVictimRef;
|
ThreatReference _currentVictimRef;
|
||||||
|
|
||||||
Dictionary<ObjectGuid, ThreatReference> _threatenedByMe = new(); // these refs are entries for myself on other units' threat lists
|
Dictionary<ObjectGuid, ThreatReference> _threatenedByMe = new(); // these refs are entries for myself on other units' threat lists
|
||||||
float[] _singleSchoolModifiers = new float[(int)SpellSchools.Max]; // most spells are single school - we pre-calculate these and store them
|
public float[] _singleSchoolModifiers = new float[(int)SpellSchools.Max]; // most spells are single school - we pre-calculate these and store them
|
||||||
volatile Dictionary<SpellSchoolMask, float> _multiSchoolModifiers = new(); // these are calculated on demand
|
public volatile Dictionary<SpellSchoolMask, float> _multiSchoolModifiers = new(); // these are calculated on demand
|
||||||
|
|
||||||
List<Tuple<ObjectGuid, uint>> _redirectInfo = new(); // current redirection targets and percentages (updated from registry in ThreatManager::UpdateRedirectInfo)
|
public List<Tuple<ObjectGuid, uint>> _redirectInfo = new(); // current redirection targets and percentages (updated from registry in ThreatManager::UpdateRedirectInfo)
|
||||||
Dictionary<uint, Dictionary<ObjectGuid, uint>> _redirectRegistry = new(); // spellid . (victim . pct); all redirection effects on us (removal individually managed by spell scripts because blizzard is dumb)
|
public Dictionary<uint, Dictionary<ObjectGuid, uint>> _redirectRegistry = new(); // spellid . (victim . pct); all redirection effects on us (removal individually managed by spell scripts because blizzard is dumb)
|
||||||
|
|
||||||
public static bool CanHaveThreatList(Unit who)
|
public static bool CanHaveThreatList(Unit who)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1195,6 +1195,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
|
|||||||
(196,869),
|
(196,869),
|
||||||
(196,872),
|
(196,872),
|
||||||
(196,881),
|
(196,881),
|
||||||
|
(196,870),
|
||||||
(197,232),
|
(197,232),
|
||||||
(197,236),
|
(197,236),
|
||||||
(197,237),
|
(197,237),
|
||||||
@@ -2123,6 +2124,7 @@ INSERT INTO `rbac_permissions` VALUES
|
|||||||
(866,'Command: list spawnpoints'),
|
(866,'Command: list spawnpoints'),
|
||||||
(868,'Command: modify power'),
|
(868,'Command: modify power'),
|
||||||
(869,'Command: debug send playerchoice'),
|
(869,'Command: debug send playerchoice'),
|
||||||
|
(870,'Command: debug threatinfo'),
|
||||||
(872,'Command: server debug'),
|
(872,'Command: server debug'),
|
||||||
(881,'Command: reload vehicle_template');
|
(881,'Command: reload vehicle_template');
|
||||||
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
||||||
@@ -2336,6 +2338,7 @@ INSERT INTO `updates` VALUES
|
|||||||
('2017_12_30_01_auth.sql','1E11C78BA6D1D8E8CED7423DF92D1D197D6061EE','ARCHIVED','2017-12-30 23:00:00',0),
|
('2017_12_30_01_auth.sql','1E11C78BA6D1D8E8CED7423DF92D1D197D6061EE','ARCHIVED','2017-12-30 23:00:00',0),
|
||||||
('2017_12_31_00_auth.sql','1721ACBD35EB95FAE33B9E95F8C4E4B1FB70A5E4','ARCHIVED','2017-12-31 20:15:23',0),
|
('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_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_02_18_00_auth.sql','8489DD3EFFE14A7486B593435F0BA2BC69B6EABF','ARCHIVED','2018-02-18 16:35:55',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_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),
|
('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`=870;
|
||||||
|
INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
|
||||||
|
(870, 'Command: debug threatinfo');
|
||||||
|
|
||||||
|
DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=870;
|
||||||
|
INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
|
||||||
|
(196,870);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
--
|
||||||
|
DELETE FROM `command` WHERE `name`="debug threatinfo";
|
||||||
|
INSERT INTO `command` (`name`,`permission`,`help`) VALUES
|
||||||
|
('debug threatinfo', 870, 'Syntax: .debug threatinfo
|
||||||
|
|
||||||
|
Displays various debug information about the target\'s threat state, modifiers, redirects and similar.');
|
||||||
Reference in New Issue
Block a user