Core/Commands: Allow .cooldown command to work on player pets

This commit is contained in:
Shauren
2016-07-16 11:15:23 +02:00
parent 236547435a
commit 9509aac38b
2 changed files with 13 additions and 4 deletions

View File

@@ -0,0 +1 @@
UPDATE `command` SET `help`='Syntax: .cooldown [#spell_id]\r\n\r\nRemove all (if spell_id not provided) or #spel_id spell cooldown from selected character or their pet or you (if no selection).' WHERE `name`='cooldown';

View File

@@ -703,7 +703,7 @@ public:
static bool HandleCooldownCommand(ChatHandler* handler, char const* args)
{
Player* target = handler->getSelectedPlayerOrSelf();
Unit* target = handler->getSelectedUnit();
if (!target)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
@@ -711,7 +711,15 @@ public:
return false;
}
std::string nameLink = handler->GetNameLink(target);
Player* owner = target->GetCharmerOrOwnerPlayerOrPlayerItself();
if (!owner)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
return false;
}
std::string nameLink = handler->GetNameLink(owner);
if (!*args)
{
@@ -728,13 +736,13 @@ public:
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellIid);
if (!spellInfo)
{
handler->PSendSysMessage(LANG_UNKNOWN_SPELL, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
handler->PSendSysMessage(LANG_UNKNOWN_SPELL, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
handler->SetSentErrorMessage(true);
return false;
}
target->GetSpellHistory()->ResetCooldown(spellIid, true);
handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
}
return true;
}