[7029] Some work vs aura charges

Move to protected: need use SetAuraCharges, GetAuraCharges, DropAuraCharge
Now m_procCharges == 0 if infinite charges, and > 0 for limit
Remove not need UpdateAuraCharges()

Signed-off-by: DiSlord <dislord@nomail.com>
This commit is contained in:
DiSlord 2009-01-05 04:08:40 +03:00
parent 791c54dd0b
commit daf24ce90c
6 changed files with 43 additions and 49 deletions

View file

@ -1221,7 +1221,7 @@ void Pet::_SaveAuras()
{
CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
"VALUES ('%u', '" I64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d')",
m_charmInfo->GetPetNumber(), itr2->second->GetCasterGUID(),(uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges));
m_charmInfo->GetPetNumber(), itr2->second->GetCasterGUID(),(uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->GetAuraCharges()));
}
}
}

View file

@ -14421,7 +14421,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
remaincharges = spellproto->procCharges;
}
else
remaincharges = -1;
remaincharges = 0;
//do not load single target auras (unless they were cast by the player)
if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
@ -15512,7 +15512,7 @@ void Player::_SaveAuras()
{
CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
"VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')",
GetGUIDLow(), itr2->second->GetCasterGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges));
GetGUIDLow(), itr2->second->GetCasterGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->GetAuraCharges()));
}
}
}
@ -18097,7 +18097,7 @@ void Player::SendAurasForTarget(Unit *target)
// level
data << uint8(aura->GetAuraLevel());
// charges
data << uint8(aura->m_procCharges >= 0 ? aura->m_procCharges : 0 );
data << uint8(aura->GetAuraCharges());
if(!(auraFlags & AFLAG_NOT_CASTER))
{

View file

@ -415,15 +415,9 @@ m_periodicTimer(0), m_PeriodicEventId(0), m_AuraDRGroup(DIMINISHING_NONE)
m_isDeathPersist = IsDeathPersistentSpell(m_spellProto);
if(m_spellProto->procCharges)
{
m_procCharges = m_spellProto->procCharges;
if(modOwner)
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
}
else
m_procCharges = -1;
m_procCharges = m_spellProto->procCharges;
if(modOwner)
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() && m_spellProto->Stances &&
!(m_spellProto->AttributesEx2 & 0x80000) && !(m_spellProto->Attributes & 0x10000));
@ -971,7 +965,6 @@ void Aura::_AddAura()
SetAura(false);
SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE));
SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
UpdateAuraCharges();
SendAuraUpdate(false);
// update for out of range group members
@ -1124,7 +1117,7 @@ void Aura::SendAuraUpdate(bool remove)
uint8 auraFlags = GetAuraFlags();
data << uint8(auraFlags);
data << uint8(GetAuraLevel());
data << uint8(m_procCharges >= 0 ? m_procCharges : 0);
data << uint8(GetAuraCharges());
if(!(auraFlags & AFLAG_NOT_CASTER))
{
@ -1208,7 +1201,7 @@ void Aura::HandleAddModifier(bool apply, bool Real)
case 34754: // Clearcasting
case 34936: // Backlash
case 48108: // Hot Streak
m_procCharges = 1;
SetAuraCharges(1);
break;
}
@ -1236,11 +1229,7 @@ void Aura::HandleAddModifier(bool apply, bool Real)
mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
mod->mask2= (uint64)ptr[2];
if (m_procCharges > 0)
mod->charges = m_procCharges;
else
mod->charges = 0;
mod->charges = m_procCharges;
m_spellmod = mod;
}
@ -4005,8 +3994,7 @@ void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
switch (GetId())
{
case 28200: // Ascendance (Talisman of Ascendance trinket)
m_procCharges = 6;
UpdateAuraCharges();
SetAuraCharges(6);
break;
default: break;
}

View file

@ -256,15 +256,24 @@ class MANGOS_DLL_SPEC Aura
uint8 GetAuraLevel() const { return m_auraLevel; }
void SetAuraLevel(uint8 level) { m_auraLevel = level; }
uint8 GetAuraCharges() const { return m_procCharges; }
void SetAuraCharges(uint8 charges) { m_procCharges = charges; }
void SetAuraCharges(uint8 charges)
{
if (m_procCharges == charges)
return;
m_procCharges = charges;
SendAuraUpdate(false);
}
bool DropAuraCharge() // return true if last charge dropped
{
if (m_procCharges == 0)
return false;
m_procCharges--;
SendAuraUpdate(false);
return m_procCharges == 0;
}
void SetAura(bool remove) { m_target->SetVisibleAura(m_auraSlot, remove ? 0 : GetId()); }
void SendAuraUpdate(bool remove);
void UpdateAuraCharges()
{
// only aura in slot with charges and without stack limitation
if (m_auraSlot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0)
SendAuraUpdate(false);
}
bool IsPositive() { return m_positive; }
void SetNegative() { m_positive = false; }
@ -292,8 +301,6 @@ class MANGOS_DLL_SPEC Aura
void SetUpdated(bool val) { m_updated = val; }
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
int32 m_procCharges;
virtual Unit* GetTriggerTarget() const { return m_target; }
// add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras
@ -329,6 +336,7 @@ class MANGOS_DLL_SPEC Aura
uint8 m_auraSlot;
uint8 m_auraFlags;
uint8 m_auraLevel;
int8 m_procCharges;
bool m_positive:1;
bool m_permanent:1;

View file

@ -4354,7 +4354,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
case 33493:
{
// Cast finish spell at last charge
if (triggeredByAura->m_procCharges > 1)
if (triggeredByAura->GetAuraCharges() > 1)
return false;
target = this;
@ -4624,7 +4624,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
case 11129:
{
//last charge and crit
if (triggeredByAura->m_procCharges <= 1 && (procEx & PROC_EX_CRITICAL_HIT) )
if (triggeredByAura->GetAuraCharges() <= 1 && (procEx & PROC_EX_CRITICAL_HIT) )
{
RemoveAurasDueToSpell(28682); //-> remove Combustion auras
return true; // charge counting (will removed)
@ -9743,6 +9743,11 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
procTriggered.push_back( ProcTriggeredData(spellProcEvent, itr->second) );
}
// Nothing found
if (procTriggered.empty())
return;
// Handle effects proceed this time
for(ProcTriggeredList::iterator i = procTriggered.begin(); i != procTriggered.end(); ++i)
{
@ -9777,7 +9782,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
Modifier *auraModifier = triggeredByAura->GetModifier();
SpellEntry const *spellInfo = triggeredByAura->GetSpellProto();
uint32 effIndex = triggeredByAura->GetEffIndex();
bool useCharges = triggeredByAura->m_procCharges > 0;
bool useCharges = triggeredByAura->GetAuraCharges() > 0;
// For players set spell cooldown if need
uint32 cooldown = 0;
if (GetTypeId() == TYPEID_PLAYER && spellProcEvent && spellProcEvent->cooldown)
@ -9840,11 +9845,6 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
continue;
break;
}
case SPELL_AURA_MOD_STUN:
// Remove by default, but if charge exist drop it
if (triggeredByAura->m_procCharges == 0)
removedSpells.push_back(triggeredByAura->GetId());
break;
case SPELL_AURA_MOD_CASTING_SPEED:
// Skip melee hits or instant cast spells
if (procSpell == NULL || GetSpellCastTime(procSpell) == 0)
@ -9885,18 +9885,16 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair);
for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr)
{
if(itr->second == i->triggeredByAura)
// If last charge dropped add spell to remove list
if(itr->second == i->triggeredByAura && triggeredByAura->DropAuraCharge())
{
triggeredByAura->m_procCharges -=1;
triggeredByAura->UpdateAuraCharges();
if (triggeredByAura->m_procCharges <= 0)
removedSpells.push_back(triggeredByAura->GetId());
removedSpells.push_back(triggeredByAura->GetId());
break;
}
}
}
}
if (removedSpells.size())
if (!removedSpells.empty())
{
// Sort spells and remove dublicates
removedSpells.sort();
@ -10618,10 +10616,10 @@ bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura )
uint64 caster_guid = triggeredByAura->GetCasterGUID();
// jumps
int32 jumps = triggeredByAura->m_procCharges-1;
int32 jumps = triggeredByAura->GetAuraCharges()-1;
// current aura expire
triggeredByAura->m_procCharges = 1; // will removed at next charges decrease
triggeredByAura->SetAuraCharges(1); // will removed at next charges decrease
// next target selection
if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid))

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7028"
#define REVISION_NR "7029"
#endif // __REVISION_NR_H__