Permalink
Browse files

[10075] Attempt use more expected by result buffs downranking algo.

* In small rate more fast
* Not affect non-buff ranked spells like 10909
  • Loading branch information...
1 parent fc39dea commit aa2b8a5270650de2f0124260396892dcba49b2d4 VladimirMangos committed Jun 18, 2010
Showing with 45 additions and 31 deletions.
  1. +4 −14 src/game/Spell.cpp
  2. +1 −1 src/game/SpellAuras.cpp
  3. +2 −4 src/game/SpellHandler.cpp
  4. +17 −10 src/game/SpellMgr.cpp
  5. +20 −1 src/game/SpellMgr.h
  6. +1 −1 src/shared/revision_nr.h
View
@@ -4253,21 +4253,11 @@ SpellCastResult Spell::CheckCast(bool strict)
// auto selection spell rank implemented in WorldSession::HandleCastSpellOpcode
// this case can be triggered if rank not found (too low-level target for first rank)
- if (m_caster->GetTypeId() == TYPEID_PLAYER && !IsPassiveSpell(m_spellInfo) && !m_CastItem)
+ if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_CastItem && !m_IsTriggeredSpell)
{
- for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
- {
- // check only spell that apply positive auras
- if (m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA &&
- IsPositiveEffect(m_spellInfo->Id, SpellEffectIndex(i)) &&
- // at not self target
- !IsCasterSourceTarget(m_spellInfo->EffectImplicitTargetA[i]) &&
- // and target low level
- target->getLevel() + 10 < m_spellInfo->spellLevel)
- {
- return SPELL_FAILED_LOWLEVEL;
- }
- }
+ // spell expected to be auto-downranking in cast handle, so must be same
+ if (m_spellInfo != sSpellMgr.SelectAuraRankForLevel(m_spellInfo, target->getLevel()))
+ return SPELL_FAILED_LOWLEVEL;
}
}
else if (m_caster == target)
View
@@ -813,7 +813,7 @@ void AreaAura::Update(uint32 diff)
if(!apply)
continue;
- if(SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel()))
+ if(SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForLevel(GetSpellProto(), (*tIter)->getLevel()))
{
int32 actualBasePoints = m_currentBasePoints;
// recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
@@ -376,12 +376,10 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
}
// auto-selection buff level base at target level (in spellInfo)
- if (targets.getUnitTarget())
+ if (Unit* target = targets.getUnitTarget())
{
- SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForPlayerLevel(spellInfo,targets.getUnitTarget()->getLevel());
-
// if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message
- if(actualSpellInfo)
+ if (SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForLevel(spellInfo, target->getLevel()))
spellInfo = actualSpellInfo;
}
View
@@ -2216,37 +2216,44 @@ bool SpellMgr::IsSkillBonusSpell(uint32 spellId) const
return false;
}
-SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const
+SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo, uint32 level) const
{
- // ignore passive spells
- if(IsPassiveSpell(spellInfo))
+ // fast case
+ if (level + 10 >= spellInfo->spellLevel)
+ return spellInfo;
+
+ // ignore selection for passive spells
+ if (IsPassiveSpell(spellInfo))
return spellInfo;
bool needRankSelection = false;
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{
- if (IsPositiveEffect(spellInfo->Id, SpellEffectIndex(i)) && (
- spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA ||
+ // for simple aura in check apply to any non caster based targets, in rank search mode to any explicit targets
+ if (((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA &&
+ (IsExplicitPositiveTarget(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_RAID))
+ spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID) &&
+ IsPositiveEffect(spellInfo->Id, SpellEffectIndex(i)))
{
needRankSelection = true;
break;
}
}
- // not required
- if(!needRankSelection)
+ // not required (rank check more slow so check it here)
+ if (!needRankSelection || GetSpellRank(spellInfo->Id) == 0)
return spellInfo;
for(uint32 nextSpellId = spellInfo->Id; nextSpellId != 0; nextSpellId = GetPrevSpellInChain(nextSpellId))
{
SpellEntry const *nextSpellInfo = sSpellStore.LookupEntry(nextSpellId);
- if(!nextSpellInfo)
+ if (!nextSpellInfo)
break;
// if found appropriate level
- if(playerLevel + 10 >= nextSpellInfo->spellLevel)
+ if (level + 10 >= spellInfo->spellLevel)
return nextSpellInfo;
// one rank less then
View
@@ -320,6 +320,25 @@ inline bool IsPointEffectTarget( Targets target )
return false;
}
+inline bool IsAreaEffectPossitiveTarget( Targets target )
+{
+ switch (target )
+ {
+ case TARGET_ALL_PARTY_AROUND_CASTER:
+ case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER:
+ case TARGET_ALL_FRIENDLY_UNITS_IN_AREA:
+ case TARGET_ALL_PARTY:
+ case TARGET_ALL_PARTY_AROUND_CASTER_2:
+ case TARGET_AREAEFFECT_PARTY:
+ case TARGET_ALL_RAID_AROUND_CASTER:
+ case TARGET_AREAEFFECT_PARTY_AND_CLASS:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
inline bool IsAreaEffectTarget( Targets target )
{
switch (target )
@@ -904,7 +923,7 @@ class SpellMgr
static bool canStackSpellRanks(SpellEntry const *spellInfo);
bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const;
- SpellEntry const* SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const;
+ SpellEntry const* SelectAuraRankForLevel(SpellEntry const* spellInfo, uint32 Level) const;
// Spell learning
SpellLearnSkillNode const* GetSpellLearnSkill(uint32 spell_id) const
View
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "10074"
+ #define REVISION_NR "10075"
#endif // __REVISION_NR_H__

0 comments on commit aa2b8a5

Please sign in to comment.