[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

@ -26,6 +26,7 @@
#include "Spell.h"
#include "BattleGroundMgr.h"
#include "MapManager.h"
#include "Unit.h"
SpellMgr::SpellMgr()
{
@ -61,6 +62,29 @@ int32 GetSpellMaxDuration(SpellEntry const *spellInfo)
return (du->Duration[2] == -1) ? -1 : abs(du->Duration[2]);
}
int32 CalculateSpellDuration(SpellEntry const *spellInfo, Unit const* caster)
{
int32 duration = GetSpellDuration(spellInfo);
if (duration != -1 && caster)
{
int32 maxduration = GetSpellMaxDuration(spellInfo);
if (duration != maxduration && caster->GetTypeId() == TYPEID_PLAYER)
duration += int32((maxduration - duration) * ((Player*)caster)->GetComboPoints() / 5);
if (Player* modOwner = caster->GetSpellModOwner())
{
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration);
if (duration < 0)
duration = 0;
}
}
return duration;
}
uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell)
{
if (spell)
@ -847,6 +871,11 @@ bool IsPositiveSpell(uint32 spellId)
if (!spellproto)
return false;
return IsPositiveSpell(spellproto);
}
bool IsPositiveSpell(SpellEntry const *spellproto)
{
// spells with at least one negative effect are considered negative
// some self-applied spells have negative effects but in self casting case negative check ignored.
for (int i = 0; i < MAX_EFFECT_INDEX; ++i)