mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Scripts/Commands: New command: .debug threatinfo
This commit is contained in:
@@ -817,6 +817,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
|
|||||||
(196,843),
|
(196,843),
|
||||||
(196,866),
|
(196,866),
|
||||||
(196,867),
|
(196,867),
|
||||||
|
(196,870),
|
||||||
(197,232),
|
(197,232),
|
||||||
(197,236),
|
(197,236),
|
||||||
(197,237),
|
(197,237),
|
||||||
@@ -1707,7 +1708,8 @@ INSERT INTO `rbac_permissions` VALUES
|
|||||||
(864,'Command: group set mainassist'),
|
(864,'Command: group set mainassist'),
|
||||||
(865,'Command: npc showloot'),
|
(865,'Command: npc showloot'),
|
||||||
(866,'Command: list spawnpoints'),
|
(866,'Command: list spawnpoints'),
|
||||||
(867,'Command: reload quest_greeting_locale');
|
(867,'Command: reload quest_greeting_locale'),
|
||||||
|
(870,'Command: debug threatinfo');
|
||||||
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
|
|||||||
8
sql/updates/auth/3.3.5/2018_01_09_00_auth.sql
Normal file
8
sql/updates/auth/3.3.5/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);
|
||||||
6
sql/updates/world/3.3.5/2018_01_09_00_world.sql
Normal file
6
sql/updates/world/3.3.5/2018_01_09_00_world.sql
Normal file
@@ -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,6 +775,7 @@ enum RBACPermissions
|
|||||||
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING_LOCALE = 867,
|
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING_LOCALE = 867,
|
||||||
RBAC_PERM_COMMAND_MODIFY_POWER = 868, // reserved
|
RBAC_PERM_COMMAND_MODIFY_POWER = 868, // reserved
|
||||||
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869, // reserved
|
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869, // reserved
|
||||||
|
RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870,
|
||||||
//
|
//
|
||||||
// IF YOU ADD NEW PERMISSIONS, ADD THEM IN MASTER BRANCH AS WELL!
|
// IF YOU ADD NEW PERMISSIONS, ADD THEM IN MASTER BRANCH AS WELL!
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "IteratorPair.h"
|
#include "IteratorPair.h"
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
|
#include <array>
|
||||||
#include <boost/heap/fibonacci_heap.hpp>
|
#include <boost/heap/fibonacci_heap.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -204,7 +205,7 @@ class TC_GAME_API ThreatManager
|
|||||||
void PutThreatenedByMeRef(ObjectGuid const& guid, ThreatReference* ref);
|
void PutThreatenedByMeRef(ObjectGuid const& guid, ThreatReference* ref);
|
||||||
void PurgeThreatenedByMeRef(ObjectGuid const& guid);
|
void PurgeThreatenedByMeRef(ObjectGuid const& guid);
|
||||||
std::unordered_map<ObjectGuid, ThreatReference*> _threatenedByMe; // these refs are entries for myself on other units' threat lists
|
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
|
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)
|
// 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 class ThreatReference;
|
||||||
friend struct CompareThreatLessThan;
|
friend struct CompareThreatLessThan;
|
||||||
|
friend class debug_commandscript;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Please check Game/Combat/ThreatManager.h for documentation on how this class works!
|
// Please check Game/Combat/ThreatManager.h for documentation on how this class works!
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ EndScriptData */
|
|||||||
#include "MapManager.h"
|
#include "MapManager.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "RBAC.h"
|
#include "RBAC.h"
|
||||||
|
#include "SpellMgr.h"
|
||||||
#include "Transport.h"
|
#include "Transport.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -72,6 +73,7 @@ public:
|
|||||||
{
|
{
|
||||||
{ "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" },
|
{ "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" },
|
||||||
{ "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "" },
|
{ "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, "" },
|
{ "combat", rbac::RBAC_PERM_COMMAND_DEBUG_COMBAT, false, &HandleDebugCombatListCommand, "" },
|
||||||
{ "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "" },
|
{ "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "" },
|
||||||
{ "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, true, &HandleDebugArenaCommand, "" },
|
{ "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, true, &HandleDebugArenaCommand, "" },
|
||||||
@@ -910,6 +912,79 @@ public:
|
|||||||
return true;
|
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);
|
||||||
|
handler->PSendSysMessage(" |-- #%06u %s (%zu entries):", outerPair.first, spell ? spell->SpellName[0] : "<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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool HandleDebugCombatListCommand(ChatHandler* handler, char const* /*args*/)
|
static bool HandleDebugCombatListCommand(ChatHandler* handler, char const* /*args*/)
|
||||||
{
|
{
|
||||||
Unit* target = handler->getSelectedUnit();
|
Unit* target = handler->getSelectedUnit();
|
||||||
|
|||||||
Reference in New Issue
Block a user