diff options
author | Treeston <treeston.mmoc@gmail.com> | 2018-01-09 18:09:24 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-05-16 21:57:35 +0200 |
commit | e090c9a00eab7af40ba1b4090d5b5a456a3e4b33 (patch) | |
tree | 21fb6a7a7430008b8cae9a513e669e8adaad60b2 /src/server/scripts/Commands | |
parent | 0ce1e9d6522974e3186e8b5cf75b7c653a075862 (diff) |
Scripts/Commands: New command: .debug threatinfo
(cherry picked from commit f45c211987794ff7e4192e0d3d4ca6bf67335fb5)
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 8efbd353ed0..2d53688e2e5 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -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(); |