mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Scripts/Commands: New command: .debug threatinfo
(cherry picked from commit f45c211987)
This commit is contained in:
@@ -1195,6 +1195,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
|
||||
(196,869),
|
||||
(196,872),
|
||||
(196,881),
|
||||
(196,870),
|
||||
(197,232),
|
||||
(197,236),
|
||||
(197,237),
|
||||
@@ -2123,6 +2124,7 @@ INSERT INTO `rbac_permissions` VALUES
|
||||
(866,'Command: list spawnpoints'),
|
||||
(868,'Command: modify power'),
|
||||
(869,'Command: debug send playerchoice'),
|
||||
(870,'Command: debug threatinfo'),
|
||||
(872,'Command: server debug'),
|
||||
(881,'Command: reload vehicle_template');
|
||||
/*!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_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_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),
|
||||
|
||||
8
sql/old/8.x/auth/20061_2020_08_14/2018_01_09_00_auth.sql
Normal file
8
sql/old/8.x/auth/20061_2020_08_14/2018_01_09_00_auth.sql
Normal file
@@ -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.');
|
||||
@@ -775,7 +775,7 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING_LOCALE = 867, // reserved
|
||||
RBAC_PERM_COMMAND_MODIFY_POWER = 868,
|
||||
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869,
|
||||
RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870, // reserved
|
||||
RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870,
|
||||
RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871, // reserved
|
||||
RBAC_PERM_COMMAND_SERVER_DEBUG = 872,
|
||||
RBAC_PERM_COMMAND_RELOAD_CREATURE_MOVEMENT_OVERRIDE = 873,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ObjectGuid.h"
|
||||
#include "SharedDefines.h"
|
||||
#include <boost/heap/fibonacci_heap.hpp>
|
||||
#include <array>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -204,7 +205,7 @@ class TC_GAME_API ThreatManager
|
||||
void PutThreatenedByMeRef(ObjectGuid const& guid, ThreatReference* ref);
|
||||
void PurgeThreatenedByMeRef(ObjectGuid const& guid);
|
||||
std::unordered_map<ObjectGuid, ThreatReference*> _threatenedByMe; // these refs are entries for myself on other units' threat lists
|
||||
float _singleSchoolModifiers[MAX_SPELL_SCHOOL]; // most spells are single school - we pre-calculate these and store them
|
||||
std::array<float, MAX_SPELL_SCHOOL> _singleSchoolModifiers; // most spells are single school - we pre-calculate these and store them
|
||||
mutable std::unordered_map<std::underlying_type<SpellSchoolMask>::type, float> _multiSchoolModifiers; // these are calculated on demand
|
||||
|
||||
// redirect system (is kind of dumb, but that's because none of the redirection spells actually have any aura effect associated with them, so spellscript needs to deal with it)
|
||||
@@ -218,6 +219,7 @@ class TC_GAME_API ThreatManager
|
||||
|
||||
friend class ThreatReference;
|
||||
friend struct CompareThreatLessThan;
|
||||
friend class debug_commandscript;
|
||||
};
|
||||
|
||||
// Please check Game/Combat/ThreatManager.h for documentation on how this class works!
|
||||
|
||||
@@ -38,9 +38,11 @@ EndScriptData */
|
||||
#include "M2Stores.h"
|
||||
#include "MapManager.h"
|
||||
#include "MovementPackets.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PhasingHandler.h"
|
||||
#include "RBAC.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellPackets.h"
|
||||
#include "Transport.h"
|
||||
#include "World.h"
|
||||
@@ -81,6 +83,7 @@ public:
|
||||
static std::vector<ChatCommand> debugCommandTable =
|
||||
{
|
||||
{ "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "" },
|
||||
{ "threatinfo", rbac::RBAC_PERM_COMMAND_DEBUG_THREATINFO, false, &HandleDebugThreatInfoCommand, "" },
|
||||
{ "combat", rbac::RBAC_PERM_COMMAND_DEBUG_COMBAT, false, &HandleDebugCombatListCommand, "" },
|
||||
{ "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "" },
|
||||
{ "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, true, &HandleDebugArenaCommand, "" },
|
||||
@@ -849,7 +852,7 @@ public:
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (!target)
|
||||
target = handler->GetSession()->GetPlayer();
|
||||
|
||||
|
||||
ThreatManager& mgr = target->GetThreatManager();
|
||||
if (!target->IsAlive())
|
||||
{
|
||||
@@ -914,6 +917,81 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugThreatInfoCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("Threat info for %s (%s):", target->GetName(), target->GetGUID().ToString().c_str());
|
||||
|
||||
ThreatManager const& mgr = target->GetThreatManager();
|
||||
|
||||
// _singleSchoolModifiers
|
||||
{
|
||||
auto& mods = mgr._singleSchoolModifiers;
|
||||
handler->SendSysMessage(" - Single-school threat modifiers:");
|
||||
handler->PSendSysMessage(" |-- Physical: %.2f%%", mods[SPELL_SCHOOL_NORMAL] * 100.0f);
|
||||
handler->PSendSysMessage(" |-- Holy : %.2f%%", mods[SPELL_SCHOOL_HOLY] * 100.0f);
|
||||
handler->PSendSysMessage(" |-- Fire : %.2f%%", mods[SPELL_SCHOOL_FIRE] * 100.0f);
|
||||
handler->PSendSysMessage(" |-- Nature : %.2f%%", mods[SPELL_SCHOOL_NATURE] * 100.0f);
|
||||
handler->PSendSysMessage(" |-- Frost : %.2f%%", mods[SPELL_SCHOOL_FROST] * 100.0f);
|
||||
handler->PSendSysMessage(" |-- Shadow : %.2f%%", mods[SPELL_SCHOOL_SHADOW] * 100.0f);
|
||||
handler->PSendSysMessage(" |-- Arcane : %.2f%%", mods[SPELL_SCHOOL_ARCANE] * 100.0f);
|
||||
}
|
||||
|
||||
// _multiSchoolModifiers
|
||||
{
|
||||
auto& mods = mgr._multiSchoolModifiers;
|
||||
handler->PSendSysMessage("- Multi-school threat modifiers (%zu entries):", mods.size());
|
||||
for (auto const& pair : mods)
|
||||
handler->PSendSysMessage(" |-- Mask 0x%x: %.2f%%", uint32(pair.first), pair.second);
|
||||
}
|
||||
|
||||
// _redirectInfo
|
||||
{
|
||||
auto const& redirectInfo = mgr._redirectInfo;
|
||||
if (redirectInfo.empty())
|
||||
handler->SendSysMessage(" - No redirects being applied");
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(" - %02zu redirects being applied:", redirectInfo.size());
|
||||
for (auto const& pair : redirectInfo)
|
||||
{
|
||||
Unit* unit = ObjectAccessor::GetUnit(*target, pair.first);
|
||||
handler->PSendSysMessage(" |-- %02u%% to %s", pair.second, unit ? unit->GetName().c_str() : pair.first.ToString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// _redirectRegistry
|
||||
{
|
||||
auto const& redirectRegistry = mgr._redirectRegistry;
|
||||
if (redirectRegistry.empty())
|
||||
handler->SendSysMessage(" - No redirects are registered");
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(" - %02zu spells may have redirects registered", redirectRegistry.size());
|
||||
for (auto const& outerPair : redirectRegistry) // (spellId, (guid, pct))
|
||||
{
|
||||
SpellInfo const* const spell = sSpellMgr->GetSpellInfo(outerPair.first, DIFFICULTY_NONE);
|
||||
handler->PSendSysMessage(" |-- #%06u %s (%zu entries):", outerPair.first, spell ? (*spell->SpellName)[sWorld->GetDefaultDbcLocale()] : "<unknown>", outerPair.second.size());
|
||||
for (auto const& innerPair : outerPair.second) // (guid, pct)
|
||||
{
|
||||
Unit* unit = ObjectAccessor::GetUnit(*target, innerPair.first);
|
||||
handler->PSendSysMessage(" |-- %02u%% to %s", innerPair.second, unit ? unit->GetName().c_str() : innerPair.first.ToString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugCombatListCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
|
||||
Reference in New Issue
Block a user