Skip to content

Commit

Permalink
feat(Core/Commands): Add debug command for applying a spell cooldown. (
Browse files Browse the repository at this point in the history
…#20004)

* Init.

* Correct wrong query characters.
  • Loading branch information
heyitsbench committed Sep 21, 2024
1 parent 1802de9 commit 7790b22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/sql/updates/pending_db_world/debug-cooldown.sql
Original file line number Diff line number Diff line change
@@ -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.');
28 changes: 28 additions & 0 deletions src/server/scripts/Commands/cs_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class debug_commandscript : public CommandScript
{ "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 },
Expand Down Expand Up @@ -784,6 +785,33 @@ class debug_commandscript : public CommandScript
return true;
}

static bool HandleDebugCooldownCommand(ChatHandler* handler, uint32 spell_id, uint32 end_time, Optional<uint32> 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();
Expand Down

0 comments on commit 7790b22

Please sign in to comment.