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
|
||||
CommandModifyPower = 868,
|
||||
CommandDebugSendPlayerChoice = 869,
|
||||
CommandDebugThreatinfo = 870, // reserved
|
||||
CommandDebugThreatinfo = 870,
|
||||
CommandDebugInstancespawn = 871, // reserved
|
||||
CommandServerDebug = 872,
|
||||
CommandReloadCreatureMovementOverride = 873,
|
||||
|
||||
@@ -24,6 +24,7 @@ using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Maps;
|
||||
using Game.Networking.Packets;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@@ -495,7 +496,7 @@ namespace Game.Chat
|
||||
if (unit)
|
||||
{
|
||||
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($" 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()}.");
|
||||
@@ -832,6 +833,82 @@ namespace Game.Chat
|
||||
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)]
|
||||
static bool HandleDebugTransportCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
|
||||
@@ -40,11 +40,11 @@ namespace Game.Combat
|
||||
ThreatReference _currentVictimRef;
|
||||
|
||||
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
|
||||
volatile Dictionary<SpellSchoolMask, float> _multiSchoolModifiers = new(); // these are calculated on demand
|
||||
public float[] _singleSchoolModifiers = new float[(int)SpellSchools.Max]; // most spells are single school - we pre-calculate these and store them
|
||||
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)
|
||||
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 List<Tuple<ObjectGuid, uint>> _redirectInfo = new(); // current redirection targets and percentages (updated from registry in ThreatManager::UpdateRedirectInfo)
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user