Skip to content

Commit

Permalink
Fix use action adding cooldown on item spells before the spell has fi…
Browse files Browse the repository at this point in the history
…nished casting
  • Loading branch information
davidonete committed May 22, 2024
1 parent 2ad028a commit f89cd80
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions playerbot/strategy/actions/UseItemAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ bool UseAction::UseItemInternal(Player* requester, uint32 itemId, Unit* unit, Ga
}
}

if (spellTargets & TARGET_FLAG_GAMEOBJECT && !validTarget)
if ((spellTargets & TARGET_FLAG_GAMEOBJECT || spellTargets & TARGET_FLAG_LOCKED) && !validTarget)
{
if (gameObject && gameObject->IsSpawned())
{
Expand Down Expand Up @@ -506,8 +506,12 @@ bool UseAction::UseItemInternal(Player* requester, uint32 itemId, Unit* unit, Ga

if (successCast)
{
bot->RemoveSpellCooldown(*spellInfo, false);
bot->AddCooldown(*spellInfo, proto, false);
// Only add cooldown if the spell doesn't use a real item
if (itemUsed == nullptr)
{
bot->RemoveSpellCooldown(*spellInfo, false);
bot->AddCooldown(*spellInfo, proto, false);
}

if (IsFood(proto) || IsDrink(proto))
{
Expand Down Expand Up @@ -549,7 +553,7 @@ bool UseAction::UseItemInternal(Player* requester, uint32 itemId, Unit* unit, Ga
else if (gameObjectTarget)
{
replyArgs["%gameobject"] = chat->formatGameobject(gameObjectTarget);
replyStr << " " << BOT_TEXT("use_command_target_go");
replyStr << " " << BOT_TEXT("command_target_go");
}
else
{
Expand Down

0 comments on commit f89cd80

Please sign in to comment.