TrinityCore/TrinityCore — Issue #5600: [PetAI] Improper check for spell cooldown + suggested fix
Author: MrSmite
Created: 2012-03-08 07:56:07+00:00
State: open

Rev:
OS: XP SP3
DB: TDB 46 + updates

Description

In PetAI::UpdateAI() there is a check for cooldown of autocast spells that checks the wrong thing which means the cooldown vs. duration always validates incorrectly.

This:

// allow only spell without cooldown > duration
int32 cooldown = spellInfo->GetRecoveryTime();
if (cooldown >= 0 && duration >= 0 && cooldown > duration)
continue;

Should be this:

// Check spell cooldown
if (me->HasSpellCooldown(spellInfo->Id))
continue;

Details

The reason being, duration is always going to equal recovery time. For example, using Furious Howl, the duration is 45 seconds and the recovery time is 45 seconds, therefore "cooldown" never evaluates properly in that context.

In order to find out if the spell is still in cooldown phase, you need to use the HasSpellCooldown() function istead.