[11288] Check IsPositiveEffect in IsPositiveSpell only for existed effects.

Thanks to NoFantasy for problem research.

Also make IsPositiveEffect use SpellEntry* arg instead spell id.
This commit is contained in:
VladimirMangos 2011-03-26 03:05:48 +03:00
parent dae28ae93a
commit 989d229968
9 changed files with 24 additions and 21 deletions

View file

@ -92,11 +92,18 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellE
SetFloatValue(DYNAMICOBJECT_RADIUS, radius); SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
SetUInt32Value(DYNAMICOBJECT_CASTTIME, WorldTimer::getMSTime()); // new 2.4.0 SetUInt32Value(DYNAMICOBJECT_CASTTIME, WorldTimer::getMSTime()); // new 2.4.0
SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId);
if (!spellProto)
{
sLog.outError("DynamicObject (spell %u) not created. Spell not exist!", spellId, GetPositionX(), GetPositionY());
return false;
}
m_aliveDuration = duration; m_aliveDuration = duration;
m_radius = radius; m_radius = radius;
m_effIndex = effIndex; m_effIndex = effIndex;
m_spellId = spellId; m_spellId = spellId;
m_positive = IsPositiveEffect(m_spellId, m_effIndex); m_positive = IsPositiveEffect(spellProto, m_effIndex);
return true; return true;
} }

View file

@ -1301,7 +1301,7 @@ void Pet::_LoadAuras(uint32 timediff)
if ((effIndexMask & (1 << i)) == 0) if ((effIndexMask & (1 << i)) == 0)
continue; continue;
if (remaintime[i] != -1 && !IsPositiveEffect(spellid, SpellEffectIndex(i))) if (remaintime[i] != -1 && !IsPositiveEffect(spellproto, SpellEffectIndex(i)))
{ {
if (remaintime[i]/IN_MILLISECONDS <= int32(timediff)) if (remaintime[i]/IN_MILLISECONDS <= int32(timediff))
continue; continue;

View file

@ -15980,7 +15980,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
if ((effIndexMask & (1 << i)) == 0) if ((effIndexMask & (1 << i)) == 0)
continue; continue;
if (remaintime[i] != -1 && !IsPositiveEffect(spellid, SpellEffectIndex(i))) if (remaintime[i] != -1 && !IsPositiveEffect(spellproto, SpellEffectIndex(i)))
{ {
if (remaintime[i]/IN_MILLISECONDS <= int32(timediff)) if (remaintime[i]/IN_MILLISECONDS <= int32(timediff))
continue; continue;

View file

@ -783,7 +783,7 @@ void Spell::prepareDataForTriggerSystem()
// avoid triggering negative hit for only positive targets // avoid triggering negative hit for only positive targets
m_negativeEffectMask = 0x0; m_negativeEffectMask = 0x0;
for (int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
if (!IsPositiveEffect(m_spellInfo->Id, SpellEffectIndex(i))) if (!IsPositiveEffect(m_spellInfo, SpellEffectIndex(i)))
m_negativeEffectMask |= (1<<i); m_negativeEffectMask |= (1<<i);
// Hunter traps spells (for Entrapment trigger) // Hunter traps spells (for Entrapment trigger)
@ -1832,7 +1832,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
SpellTargets targetB = SPELL_TARGETS_AOE_DAMAGE; SpellTargets targetB = SPELL_TARGETS_AOE_DAMAGE;
// Select friendly targets for positive effect // Select friendly targets for positive effect
if (IsPositiveEffect(m_spellInfo->Id, effIndex)) if (IsPositiveEffect(m_spellInfo, effIndex))
targetB = SPELL_TARGETS_FRIENDLY; targetB = SPELL_TARGETS_FRIENDLY;
UnitList tempTargetUnitMap; UnitList tempTargetUnitMap;

View file

@ -385,7 +385,7 @@ m_isPersistent(false), m_in_use(0), m_spellAuraHolder(holder)
bool isPassive = IsPassiveSpell(GetSpellProto()); bool isPassive = IsPassiveSpell(GetSpellProto());
bool isPermanent = false; bool isPermanent = false;
m_positive = IsPositiveEffect(spellproto->Id, m_effIndex); m_positive = IsPositiveEffect(spellproto, m_effIndex);
m_applyTime = time(NULL); m_applyTime = time(NULL);

View file

@ -623,17 +623,13 @@ bool IsExplicitNegativeTarget(uint32 targetA)
return false; return false;
} }
bool IsPositiveEffect(uint32 spellId, SpellEffectIndex effIndex) bool IsPositiveEffect(SpellEntry const *spellproto, SpellEffectIndex effIndex)
{ {
SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId);
if (!spellproto)
return false;
switch(spellproto->Effect[effIndex]) switch(spellproto->Effect[effIndex])
{ {
case SPELL_EFFECT_DUMMY: case SPELL_EFFECT_DUMMY:
// some explicitly required dummy effect sets // some explicitly required dummy effect sets
switch(spellId) switch(spellproto->Id)
{ {
case 28441: // AB Effect 000 case 28441: // AB Effect 000
return false; return false;
@ -708,7 +704,7 @@ bool IsPositiveEffect(uint32 spellId, SpellEffectIndex effIndex)
case SPELL_AURA_ADD_TARGET_TRIGGER: case SPELL_AURA_ADD_TARGET_TRIGGER:
return true; return true;
case SPELL_AURA_PERIODIC_TRIGGER_SPELL: case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
if (spellId != spellproto->EffectTriggerSpell[effIndex]) if (spellproto->Id != spellproto->EffectTriggerSpell[effIndex])
{ {
uint32 spellTriggeredId = spellproto->EffectTriggerSpell[effIndex]; uint32 spellTriggeredId = spellproto->EffectTriggerSpell[effIndex];
SpellEntry const *spellTriggeredProto = sSpellStore.LookupEntry(spellTriggeredId); SpellEntry const *spellTriggeredProto = sSpellStore.LookupEntry(spellTriggeredId);
@ -720,8 +716,8 @@ bool IsPositiveEffect(uint32 spellId, SpellEffectIndex effIndex)
{ {
// if non-positive trigger cast targeted to positive target this main cast is non-positive // if non-positive trigger cast targeted to positive target this main cast is non-positive
// this will place this spell auras as debuffs // this will place this spell auras as debuffs
if (IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex],spellTriggeredProto->EffectImplicitTargetB[effIndex]) && if (IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex], spellTriggeredProto->EffectImplicitTargetB[effIndex]) &&
!IsPositiveEffect(spellTriggeredId,SpellEffectIndex(i))) !IsPositiveEffect(spellTriggeredProto, SpellEffectIndex(i)))
return false; return false;
} }
} }
@ -854,7 +850,7 @@ bool IsPositiveSpell(uint32 spellId)
// spells with at least one negative effect are considered negative // 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. // some self-applied spells have negative effects but in self casting case negative check ignored.
for (int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
if (!IsPositiveEffect(spellId, SpellEffectIndex(i))) if (spellproto->Effect[i] && !IsPositiveEffect(spellproto, SpellEffectIndex(i)))
return false; return false;
return true; return true;
} }
@ -2405,7 +2401,7 @@ SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo,
IsAreaEffectPossitiveTarget(Targets(spellInfo->EffectImplicitTargetA[i])))) || IsAreaEffectPossitiveTarget(Targets(spellInfo->EffectImplicitTargetA[i])))) ||
spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY || spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY ||
spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID) && spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID) &&
IsPositiveEffect(spellInfo->Id, SpellEffectIndex(i))) IsPositiveEffect(spellInfo, SpellEffectIndex(i)))
{ {
needRankSelection = true; needRankSelection = true;
break; break;

View file

@ -240,7 +240,7 @@ inline bool IsNonCombatSpell(SpellEntry const *spellInfo)
} }
bool IsPositiveSpell(uint32 spellId); bool IsPositiveSpell(uint32 spellId);
bool IsPositiveEffect(uint32 spellId, SpellEffectIndex effIndex); bool IsPositiveEffect(SpellEntry const *spellInfo, SpellEffectIndex effIndex);
bool IsPositiveTarget(uint32 targetA, uint32 targetB); bool IsPositiveTarget(uint32 targetA, uint32 targetB);
bool IsExplicitPositiveTarget(uint32 targetA); bool IsExplicitPositiveTarget(uint32 targetA);

View file

@ -7195,7 +7195,7 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i
for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter)
if (spellInfo->Dispel == DISPEL_MAGIC && // Magic debuff if (spellInfo->Dispel == DISPEL_MAGIC && // Magic debuff
((*iter)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellInfo)) && // Check school ((*iter)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellInfo)) && // Check school
!IsPositiveEffect(spellInfo->Id, index)) // Harmful !IsPositiveEffect(spellInfo, index)) // Harmful
return true; return true;
} }
@ -8751,7 +8751,7 @@ int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, SpellEffectInde
// Find total mod value (negative bonus) // Find total mod value (negative bonus)
int32 durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, mechanic); int32 durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, mechanic);
// Modify from SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL aura for negative effects (stack always ?) // Modify from SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL aura for negative effects (stack always ?)
if (!IsPositiveEffect(spellProto->Id, effect_index)) if (!IsPositiveEffect(spellProto, effect_index))
durationMod_always+=target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL, spellProto->Dispel); durationMod_always+=target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL, spellProto->Dispel);
// Find max mod (negative bonus) // Find max mod (negative bonus)
int32 durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, mechanic); int32 durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, mechanic);

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 "11287" #define REVISION_NR "11288"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__