Scripts/Commands: New command: .debug threatinfo

# Conflicts:
#	sql/base/auth_database.sql
#	sql/old/4.3.4/auth/19_2017_06_18/2018_01_09_00_auth.sql
#	sql/old/4.3.4/world/23_2017_11_15/2018_01_09_00_world.sql
#	src/server/game/Accounts/RBAC.h
#	src/server/game/Combat/ThreatManager.h
This commit is contained in:
Treeston authored and Ovahlord committed 2020-07-22 17:02:48 +02:00
1 parent 4411a5389c
commit cbec08f2b5
3 files changed
+224 -152

No files matched your search

+75
View File
@@ -39,6 +39,7 @@ EndScriptData */
#include "PoolMgr.h"
#include "QuestPools.h"
#include "RBAC.h"
#include "SpellMgr.h"
#include "Transport.h"
#include "WorldSession.h"
#include <fstream>
@@ -78,6 +79,7 @@ public:
{
{ "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" },
{ "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, "" },
@@ -916,6 +918,79 @@ 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);
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*/)
{
Unit* target = handler->getSelectedUnit();