[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) " 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')", "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; remaincharges = spellproto->procCharges;
} }
else else
remaincharges = -1; remaincharges = 0;
//do not load single target auras (unless they were cast by the player) //do not load single target auras (unless they were cast by the player)
if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) 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) " 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')", "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 // level
data << uint8(aura->GetAuraLevel()); data << uint8(aura->GetAuraLevel());
// charges // charges
data << uint8(aura->m_procCharges >= 0 ? aura->m_procCharges : 0 ); data << uint8(aura->GetAuraCharges());
if(!(auraFlags & AFLAG_NOT_CASTER)) 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); m_isDeathPersist = IsDeathPersistentSpell(m_spellProto);
if(m_spellProto->procCharges) m_procCharges = m_spellProto->procCharges;
{ if(modOwner)
m_procCharges = m_spellProto->procCharges; modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
if(modOwner)
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
}
else
m_procCharges = -1;
m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() && m_spellProto->Stances && m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() && m_spellProto->Stances &&
!(m_spellProto->AttributesEx2 & 0x80000) && !(m_spellProto->Attributes & 0x10000)); !(m_spellProto->AttributesEx2 & 0x80000) && !(m_spellProto->Attributes & 0x10000));
@ -971,7 +965,6 @@ void Aura::_AddAura()
SetAura(false); SetAura(false);
SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE)); 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)); SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
UpdateAuraCharges();
SendAuraUpdate(false); SendAuraUpdate(false);
// update for out of range group members // update for out of range group members
@ -1124,7 +1117,7 @@ void Aura::SendAuraUpdate(bool remove)
uint8 auraFlags = GetAuraFlags(); uint8 auraFlags = GetAuraFlags();
data << uint8(auraFlags); data << uint8(auraFlags);
data << uint8(GetAuraLevel()); data << uint8(GetAuraLevel());
data << uint8(m_procCharges >= 0 ? m_procCharges : 0); data << uint8(GetAuraCharges());
if(!(auraFlags & AFLAG_NOT_CASTER)) if(!(auraFlags & AFLAG_NOT_CASTER))
{ {
@ -1208,7 +1201,7 @@ void Aura::HandleAddModifier(bool apply, bool Real)
case 34754: // Clearcasting case 34754: // Clearcasting
case 34936: // Backlash case 34936: // Backlash
case 48108: // Hot Streak case 48108: // Hot Streak
m_procCharges = 1; SetAuraCharges(1);
break; break;
} }
@ -1236,11 +1229,7 @@ void Aura::HandleAddModifier(bool apply, bool Real)
mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32; mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
mod->mask2= (uint64)ptr[2]; mod->mask2= (uint64)ptr[2];
mod->charges = m_procCharges;
if (m_procCharges > 0)
mod->charges = m_procCharges;
else
mod->charges = 0;
m_spellmod = mod; m_spellmod = mod;
} }
@ -4005,8 +3994,7 @@ void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
switch (GetId()) switch (GetId())
{ {
case 28200: // Ascendance (Talisman of Ascendance trinket) case 28200: // Ascendance (Talisman of Ascendance trinket)
m_procCharges = 6; SetAuraCharges(6);
UpdateAuraCharges();
break; break;
default: break; default: break;
} }

View file

@ -256,15 +256,24 @@ class MANGOS_DLL_SPEC Aura
uint8 GetAuraLevel() const { return m_auraLevel; } uint8 GetAuraLevel() const { return m_auraLevel; }
void SetAuraLevel(uint8 level) { m_auraLevel = level; } void SetAuraLevel(uint8 level) { m_auraLevel = level; }
uint8 GetAuraCharges() const { return m_procCharges; } 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 SetAura(bool remove) { m_target->SetVisibleAura(m_auraSlot, remove ? 0 : GetId()); }
void SendAuraUpdate(bool remove); 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; } bool IsPositive() { return m_positive; }
void SetNegative() { m_positive = false; } void SetNegative() { m_positive = false; }
@ -292,8 +301,6 @@ class MANGOS_DLL_SPEC Aura
void SetUpdated(bool val) { m_updated = val; } void SetUpdated(bool val) { m_updated = val; }
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; } void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
int32 m_procCharges;
virtual Unit* GetTriggerTarget() const { return m_target; } virtual Unit* GetTriggerTarget() const { return m_target; }
// add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras // add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras
@ -329,6 +336,7 @@ class MANGOS_DLL_SPEC Aura
uint8 m_auraSlot; uint8 m_auraSlot;
uint8 m_auraFlags; uint8 m_auraFlags;
uint8 m_auraLevel; uint8 m_auraLevel;
int8 m_procCharges;
bool m_positive:1; bool m_positive:1;
bool m_permanent:1; bool m_permanent:1;

View file

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

View file

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