mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
[7363] Propertly set cooldown at server side for category spells at cooldown event send to client. Author: VladimirMangos
Also support item dependent cooldown set propetly at cooldown event send to client.
Last will used in follow potion cooldown delay in combat patch.
--HG--
branch : trunk
This commit is contained in:
@@ -2440,85 +2440,7 @@ void Spell::SendSpellCooldown()
|
||||
return;
|
||||
}
|
||||
|
||||
// init cooldown values
|
||||
uint32 cat = 0;
|
||||
int32 rec = -1;
|
||||
int32 catrec = -1;
|
||||
|
||||
// some special item spells without correct cooldown in SpellInfo
|
||||
// cooldown information stored in item prototype
|
||||
// This used in same way in WorldSession::HandleItemQuerySingleOpcode data sending to client.
|
||||
|
||||
if(m_CastItem)
|
||||
{
|
||||
ItemPrototype const* proto = m_CastItem->GetProto();
|
||||
if(proto)
|
||||
{
|
||||
for(int idx = 0; idx < MAX_ITEM_PROTO_SPELLS; ++idx)
|
||||
{
|
||||
if(proto->Spells[idx].SpellId == m_spellInfo->Id)
|
||||
{
|
||||
cat = proto->Spells[idx].SpellCategory;
|
||||
rec = proto->Spells[idx].SpellCooldown;
|
||||
catrec = proto->Spells[idx].SpellCategoryCooldown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no cooldown found above then base at DBC data
|
||||
if(rec < 0 && catrec < 0)
|
||||
{
|
||||
cat = m_spellInfo->Category;
|
||||
rec = m_spellInfo->RecoveryTime;
|
||||
catrec = m_spellInfo->CategoryRecoveryTime;
|
||||
}
|
||||
|
||||
// shoot spells used equipped item cooldown values already assigned in GetAttackTime(RANGED_ATTACK)
|
||||
// prevent 0 cooldowns set by another way
|
||||
if (rec <= 0 && catrec <= 0 && (cat == 76 || IsAutoRepeatRangedSpell(m_spellInfo) && m_spellInfo->Id != SPELL_ID_AUTOSHOT))
|
||||
rec = _player->GetAttackTime(RANGED_ATTACK);
|
||||
|
||||
// Now we have cooldown data (if found any), time to apply mods
|
||||
if(rec > 0)
|
||||
_player->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COOLDOWN, rec, this);
|
||||
|
||||
if(catrec > 0)
|
||||
_player->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COOLDOWN, catrec, this);
|
||||
|
||||
// replace negative cooldowns by 0
|
||||
if (rec < 0) rec = 0;
|
||||
if (catrec < 0) catrec = 0;
|
||||
|
||||
// no cooldown after applying spell mods
|
||||
if( rec == 0 && catrec == 0)
|
||||
return;
|
||||
|
||||
time_t curTime = time(NULL);
|
||||
|
||||
time_t catrecTime = catrec ? curTime+catrec/IN_MILISECONDS : 0;
|
||||
time_t recTime = rec ? curTime+rec/IN_MILISECONDS : catrecTime;
|
||||
|
||||
// self spell cooldown
|
||||
if(recTime > 0)
|
||||
_player->AddSpellCooldown(m_spellInfo->Id, m_CastItem ? m_CastItem->GetEntry() : 0, recTime);
|
||||
|
||||
// category spells
|
||||
if (catrec > 0)
|
||||
{
|
||||
SpellCategoryStore::const_iterator i_scstore = sSpellCategoryStore.find(cat);
|
||||
if(i_scstore != sSpellCategoryStore.end())
|
||||
{
|
||||
for(SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset)
|
||||
{
|
||||
if(*i_scset == m_spellInfo->Id) // skip main spell, already handled above
|
||||
continue;
|
||||
|
||||
_player->AddSpellCooldown(*i_scset, m_CastItem ? m_CastItem->GetEntry() : 0, catrecTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
_player->AddSpellAndCategoryCooldowns(m_spellInfo,m_CastItem ? m_CastItem->GetEntry() : 0, this);
|
||||
}
|
||||
|
||||
void Spell::update(uint32 difftime)
|
||||
|
||||
Reference in New Issue
Block a user