Skip to content

Commit

Permalink
[10345] Fix passive spells that are active without shapeshift and cer…
Browse files Browse the repository at this point in the history
…tain shapeshift forms only.

Currently, 63411 is the only affected spell, but implementation is hopefully generic enough to cover future cases.
  • Loading branch information
Lynx3d committed Aug 11, 2010
1 parent 70df7ff commit 4a18180
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3352,7 +3352,8 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const
{
// note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell
// talent dependent passives activated at form apply have proper stance data
bool need_cast = (!spellInfo->Stances || (m_form != 0 && (spellInfo->Stances & (1<<(m_form-1)))));
bool need_cast = (!spellInfo->Stances || (m_form != 0 && (spellInfo->Stances & (1<<(m_form-1)))) ||
(m_form == 0 && (spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT)));

//Check CasterAuraStates
return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState)));
Expand Down
53 changes: 41 additions & 12 deletions src/game/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ void AreaAura::Update(uint32 diff)
actualBasePoints = actualSpellInfo->CalculateSimpleValue(m_effIndex);

SpellAuraHolder *holder = (*tIter)->GetSpellAuraHolder(actualSpellInfo->Id, GetCasterGUID());

bool addedToExisting = true;
if (!holder)
{
Expand Down Expand Up @@ -3989,7 +3989,7 @@ void Aura::HandleInvisibility(bool apply, bool Real)
void Aura::HandleInvisibilityDetect(bool apply, bool Real)
{
Unit *target = GetTarget();

if(apply)
{
target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
Expand Down Expand Up @@ -4182,7 +4182,7 @@ void Aura::HandleModTaunt(bool apply, bool Real)
// only at real add/remove aura
if (!Real)
return;

Unit *target = GetTarget();

if (!target->isAlive() || !target->CanHaveThreatList())
Expand Down Expand Up @@ -5917,11 +5917,27 @@ void Aura::HandleShapeshiftBoosts(bool apply)
if (itr->second.state == PLAYERSPELL_REMOVED) continue;
if (itr->first==spellId1 || itr->first==spellId2) continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | (1<<7))))
if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | SPELL_ATTR_UNK7)))
continue;
if (spellInfo->Stances & (1<<(form-1)))
// passive spells with SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT are already active without shapeshift, do no recast!
if (spellInfo->Stances & (1<<(form-1)) && !(spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT))
target->CastSpell(target, itr->first, true, NULL, this);
}
// remove auras that do not require shapeshift, but are not active in this specific form (like Improved Barkskin)
Unit::SpellAuraHolderMap& tAuras = target->GetSpellAuraHolderMap();
for (Unit::SpellAuraHolderMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
{
SpellEntry const *spellInfo = itr->second->GetSpellProto();
if (itr->second->IsPassive() && (spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT)
&& (spellInfo->StancesNot & (1<<(form-1))))
{
target->RemoveAurasDueToSpell(itr->second->GetId());
itr = tAuras.begin();
}
else
++itr;
}


// Master Shapeshifter
if (MasterShaperSpellId)
Expand Down Expand Up @@ -6005,6 +6021,19 @@ void Aura::HandleShapeshiftBoosts(bool apply)
if(MasterShaperSpellId)
target->RemoveAurasDueToSpell(MasterShaperSpellId);

// re-apply passive spells that don't need shapeshift but were inactive in current form:
const PlayerSpellMap& sp_list = ((Player *)target)->GetSpellMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
{
if (itr->second.state == PLAYERSPELL_REMOVED) continue;
if (itr->first==spellId1 || itr->first==spellId2) continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (!spellInfo || !IsPassiveSpell(spellInfo))
continue;
if ((spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && spellInfo->StancesNot & (1<<(form-1)))
target->CastSpell(target, itr->first, true, NULL, this);
}

Unit::SpellAuraHolderMap& tAuras = target->GetSpellAuraHolderMap();
for (Unit::SpellAuraHolderMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
{
Expand Down Expand Up @@ -7542,7 +7571,7 @@ void Aura::HandlePhase(bool apply, bool Real)
return;

Unit *target = GetTarget();

// always non stackable
if(apply)
{
Expand Down Expand Up @@ -7699,12 +7728,12 @@ bool Aura::IsLastAuraOnHolder()

SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem) : m_caster_guid(0), m_target(target),
m_castItemGuid(castItem?castItem->GetGUID():0), m_permanent(false),
m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE), m_auraSlot(MAX_AURAS),
m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE), m_auraSlot(MAX_AURAS),
m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1)
{
ASSERT(target);
ASSERT(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");

if(!caster)
m_caster_guid = target->GetGUID();
else
Expand Down Expand Up @@ -7811,7 +7840,7 @@ void SpellAuraHolder::_AddSpellAuraHolder()
}
flags |= ((GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_NOT_CASTER : AFLAG_NONE) | ((GetSpellMaxDuration(m_spellProto) > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE);
SetAuraFlags(flags);

SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));

if (IsNeedVisibleSlot(caster))
Expand Down Expand Up @@ -7867,7 +7896,7 @@ void SpellAuraHolder::_AddSpellAuraHolder()
// Enrage aura state
if(m_spellProto->Dispel == DISPEL_ENRAGE)
m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);

}
}

Expand Down Expand Up @@ -8759,7 +8788,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply)
if (spellId4)
m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGUID());
}

SetInUse(false);
}

Expand Down Expand Up @@ -8877,4 +8906,4 @@ void SpellAuraHolder::UnregisterSingleCastHolder()
}
m_isSingleTarget = false;
}
}
}
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10344"
#define REVISION_NR "10345"
#endif // __REVISION_NR_H__

0 comments on commit 4a18180

Please sign in to comment.