[9090] Implement tick counting in periodic auras.

This can be used for some tick number dependent aura effects.
Also in some cases impossible claculate tickes count pass,
for example for infinity duration auras.
This commit is contained in:
VladimirMangos 2009-12-31 17:14:20 +03:00
parent 9a6c248dec
commit e5dfeea31e
4 changed files with 18 additions and 12 deletions

View file

@ -363,7 +363,7 @@ static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_
Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) :
m_spellmod(NULL), m_caster_guid(0), m_target(target), m_castItemGuid(castItem?castItem->GetGUID():0),
m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
m_timeCla(1000), m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
m_effIndex(eff), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
@ -652,6 +652,7 @@ void Aura::Update(uint32 diff)
{
// update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
m_periodicTimer += m_modifier.periodictime;
++m_periodicTick; // for some infinity auras in some cases can overflow and reset
PeriodicTick();
}
}
@ -4539,7 +4540,7 @@ void Aura::HandlePeriodicEnergize(bool apply, bool Real)
case 54833: // Glyph of Innervate (value%/2 of casters base mana)
{
if (Unit* caster = GetCaster())
m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (200 * m_maxduration / m_periodicTimer));
m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (200 * GetAuraMaxTicks()));
break;
}
@ -4551,7 +4552,7 @@ void Aura::HandlePeriodicEnergize(bool apply, bool Real)
if (caster->HasAura(54832))
caster->CastSpell(caster,54833,true,NULL,this);
m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * m_maxduration / m_periodicTimer));
m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * GetAuraMaxTicks()));
}
break;
}
@ -6612,10 +6613,10 @@ void Aura::PeriodicTick()
if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000400)) && GetSpellProto()->SpellIconID==544)
{
// 1..4 ticks, 1/2 from normal tick damage
if (m_duration >= ((m_maxduration-m_modifier.periodictime) * 2 / 3))
if (GetAuraTicks() <= 4)
pdamage = pdamage/2;
// 9..12 ticks, 3/2 from normal tick damage
else if(m_duration < ((m_maxduration-m_modifier.periodictime) / 3))
else if(GetAuraTicks() >= 9)
pdamage += (pdamage + 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
// 5..8 ticks have normal tick damage
}
@ -6756,8 +6757,8 @@ void Aura::PeriodicTick()
// Wild Growth (1/7 - 6 + 2*ramainTicks) %
if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellIconID == 2864)
{
int32 ticks = m_maxduration/m_modifier.periodictime;
int32 remainingTicks = int32(float(m_duration) / m_modifier.periodictime + 0.5);
int32 ticks = GetAuraMaxTicks();
int32 remainingTicks = ticks - GetAuraTicks();
pdamage = int32(pdamage) + int32(amount)*ticks*(-6+2*remainingTicks)/100;
}
}