[11299] Handle aura durations in SpellAuraHolder

- Unit::CalculateSpellDuration split into two functions
    - CalculateSpellDuration taking into account combo points and caster-side spell mods
    - Unit::CalculateAuraDuration taking into account target-side spell mods
- Diminishing is now applied before duration reduction mods
- Implement saving per-effect periodic timers to DB (required for auras affected by haste)
This commit is contained in:
zergtmn 2011-03-30 23:29:01 +06:00
parent 5833d74963
commit 4687fa8cb4
19 changed files with 388 additions and 379 deletions

View file

@ -3521,7 +3521,7 @@ void Spell::EffectApplyAura(SpellEffectIndex eff_idx)
Unit* caster = GetAffectiveCaster();
if(!caster)
{
// FIXME: currently we can't have auras applied explIcitly by gameobjects
// FIXME: currently we can't have auras applied explicitly by gameobjects
// so for auras from wild gameobjects (no owner) target used
if (m_originalCasterGUID.IsGameObject())
caster = unitTarget;
@ -3531,28 +3531,8 @@ void Spell::EffectApplyAura(SpellEffectIndex eff_idx)
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell: Aura is: %u", m_spellInfo->EffectApplyAuraName[eff_idx]);
Aura* Aur = CreateAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], spellAuraHolder, unitTarget, caster, m_CastItem);
// Now Reduce spell duration using data received at spell hit
int32 duration = Aur->GetAuraMaxDuration();
int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup,m_spellInfo);
unitTarget->ApplyDiminishingToDuration(m_diminishGroup, duration, m_caster, m_diminishLevel,limitduration);
spellAuraHolder->setDiminishGroup(m_diminishGroup);
// if Aura removed and deleted, do not continue.
if(duration== 0 && !(spellAuraHolder->IsPermanent()))
{
delete Aur;
return;
}
if(duration != Aur->GetAuraMaxDuration())
{
Aur->SetAuraMaxDuration(duration);
Aur->SetAuraDuration(duration);
}
spellAuraHolder->AddAura(Aur, eff_idx);
Aura* aur = CreateAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], m_spellAuraHolder, unitTarget, caster, m_CastItem);
m_spellAuraHolder->AddAura(aur, eff_idx);
}
void Spell::EffectUnlearnSpecialization(SpellEffectIndex eff_idx)
@ -4383,8 +4363,8 @@ void Spell::EffectApplyAreaAura(SpellEffectIndex eff_idx)
if (!unitTarget->isAlive())
return;
AreaAura* Aur = new AreaAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], spellAuraHolder, unitTarget, m_caster, m_CastItem);
spellAuraHolder->AddAura(Aur, eff_idx);
AreaAura* Aur = new AreaAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], m_spellAuraHolder, unitTarget, m_caster, m_CastItem);
m_spellAuraHolder->AddAura(Aur, eff_idx);
}
void Spell::EffectSummonType(SpellEffectIndex eff_idx)
@ -4525,10 +4505,7 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
uint32 level = m_caster->getLevel();
Pet* spawnCreature = new Pet(SUMMON_PET);
int32 duration = GetSpellDuration(m_spellInfo);
if (duration > 0)
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
int32 duration = CalculateSpellDuration(m_spellInfo, m_caster);
if (m_caster->GetTypeId()==TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster,pet_entry))
{
@ -4980,10 +4957,7 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
float center_z = m_targets.m_destZ;
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx]));
int32 duration = GetSpellDuration(m_spellInfo);
if (duration > 0)
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
int32 duration = CalculateSpellDuration(m_spellInfo, m_caster);
int32 amount = damage > 0 ? damage : 1;
@ -7654,10 +7628,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
pTotem->SetOwner(m_caster);
pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initialized
int32 duration=GetSpellDuration(m_spellInfo);
if (duration > 0)
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
int32 duration = CalculateSpellDuration(m_spellInfo, m_caster);
pTotem->SetDuration(duration);
if (damage) // if not spell info, DB values used