Skip to content

Instantly share code, notes, and snippets.

@SeTM
Created May 19, 2011 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeTM/980888 to your computer and use it in GitHub Desktop.
Save SeTM/980888 to your computer and use it in GitHub Desktop.
void Unit::CalculateAuraPeriodicTime(SpellEntry const* spellProto, uint32* periodicTime)
{
bool applyHaste = (spellProto->AttributesEx5 & SPELL_ATTR_EX5_AFFECTED_BY_HASTE) != 0;
if (!applyHaste)
{
Unit::AuraList const& mModByHaste = GetAurasByType(SPELL_AURA_MOD_PERIODIC_HASTE);
for (Unit::AuraList::const_iterator itr = mModByHaste.begin(); itr != mModByHaste.end(); ++itr)
{
if ((*itr)->isAffectedOnSpell(spellProto))
{
applyHaste = true;
break;
}
}
}
Player* modOwner = GetSpellModOwner();
uint32 _periodicTime = periodicTime ? *periodicTime : 0;
if (_periodicTime)
{
int32 ticks = GetSpellDuration(spellProto) / _periodicTime;
if (modOwner)
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_ACTIVATION_TIME, _periodicTime);
// Calculate new periodic timer
if (applyHaste)
_periodicTime = ticks == 0 ? _periodicTime : CalculateSpellDuration(spellProto, this) / ticks;
*periodicTime = _periodicTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment