From 7790b2258bbaaec66490f3c69f259ba4b3132162 Mon Sep 17 00:00:00 2001 From: Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:28:11 -0400 Subject: [PATCH] feat(Core/Commands): Add debug command for applying a spell cooldown. (#20004) * Init. * Correct wrong query characters. --- .../pending_db_world/debug-cooldown.sql | 2 ++ src/server/scripts/Commands/cs_debug.cpp | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 data/sql/updates/pending_db_world/debug-cooldown.sql diff --git a/data/sql/updates/pending_db_world/debug-cooldown.sql b/data/sql/updates/pending_db_world/debug-cooldown.sql new file mode 100644 index 000000000..3768c7010 --- /dev/null +++ b/data/sql/updates/pending_db_world/debug-cooldown.sql @@ -0,0 +1,2 @@ +DELETE FROM `command` WHERE `name` = 'debug cooldown'; +INSERT INTO `command` (`name`, `security`, `help`) VALUES ('debug cooldown', 3, 'Syntax: .debug cooldown #spellID #cooldownTime #itemID\nApply a cooldown of the given duration (in milliseconds) for the given spell and item ID.'); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index b57ff6ccc..38dd93a2f 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -82,6 +82,7 @@ public: { "anim", HandleDebugAnimCommand, SEC_ADMINISTRATOR, Console::No }, { "arena", HandleDebugArenaCommand, SEC_ADMINISTRATOR, Console::No }, { "bg", HandleDebugBattlegroundCommand, SEC_ADMINISTRATOR, Console::No }, + { "cooldown", HandleDebugCooldownCommand, SEC_ADMINISTRATOR, Console::No }, { "getitemstate", HandleDebugGetItemStateCommand, SEC_ADMINISTRATOR, Console::No }, { "lootrecipient", HandleDebugGetLootRecipientCommand, SEC_ADMINISTRATOR, Console::No }, { "getvalue", HandleDebugGetValueCommand, SEC_ADMINISTRATOR, Console::No }, @@ -784,6 +785,33 @@ public: return true; } + static bool HandleDebugCooldownCommand(ChatHandler* handler, uint32 spell_id, uint32 end_time, Optional item_id) + { + Player* player = handler->GetPlayer(); + + if (!player || !spell_id || !end_time) + return false; + + if (!sSpellMgr->GetSpellInfo(spell_id)) + return false; + + if (!item_id) + item_id = 0; + else if (!sItemStore.LookupEntry(*item_id)) + return false; + + if (end_time < player->GetSpellCooldownDelay(spell_id)) + player->RemoveSpellCooldown(spell_id, true); + + player->AddSpellCooldown(spell_id, *item_id, end_time, true, false); + + WorldPacket data; + player->BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, spell_id, end_time); + player->SendDirectMessage(&data); + + return true; + } + static bool HandleDebugArenaCommand(ChatHandler* /*handler*/) { sBattlegroundMgr->ToggleArenaTesting();