Core/Spells: Unify spell effect access api in both branches

This commit is contained in:
Shauren
2021-09-04 15:13:15 +02:00
parent 16ed458eee
commit 8a4e1119ac
90 changed files with 1485 additions and 1675 deletions
+38 -44
View File
@@ -202,12 +202,9 @@ void UnitAI::FillAISpellInfo()
UPDATE_TARGET(AITARGET_SELF)
else
{
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& effect : spellInfo->GetEffects())
{
if (!effect)
continue;
uint32 targetType = effect->TargetA.GetTarget();
uint32 targetType = effect.TargetA.GetTarget();
if (targetType == TARGET_UNIT_TARGET_ENEMY
|| targetType == TARGET_DEST_TARGET_ENEMY)
@@ -215,7 +212,7 @@ void UnitAI::FillAISpellInfo()
else if (targetType == TARGET_UNIT_DEST_AREA_ENEMY)
UPDATE_TARGET(AITARGET_ENEMY)
if (effect->Effect == SPELL_EFFECT_APPLY_AURA)
if (effect.Effect == SPELL_EFFECT_APPLY_AURA)
{
if (targetType == TARGET_UNIT_TARGET_ENEMY)
UPDATE_TARGET(AITARGET_DEBUFF)
@@ -230,73 +227,70 @@ void UnitAI::FillAISpellInfo()
AIInfo->Effects = 0;
AIInfo->Targets = 0;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effect)
continue;
// Spell targets self.
if (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER)
AIInfo->Targets |= 1 << (SELECT_TARGET_SELF - 1);
// Spell targets a single enemy.
if (effect->TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
effect->TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY)
AIInfo->Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY - 1);
// Spell targets AoE at enemy.
if (effect->TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
effect->TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
effect->TargetA.GetTarget() == TARGET_SRC_CASTER ||
effect->TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_SRC_CASTER ||
spellEffectInfo.TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
AIInfo->Targets |= 1 << (SELECT_TARGET_AOE_ENEMY - 1);
// Spell targets an enemy.
if (effect->TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
effect->TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY ||
effect->TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
effect->TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
effect->TargetA.GetTarget() == TARGET_SRC_CASTER ||
effect->TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_SRC_CASTER ||
spellEffectInfo.TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
AIInfo->Targets |= 1 << (SELECT_TARGET_ANY_ENEMY - 1);
// Spell targets a single friend (or self).
if (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER ||
effect->TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
effect->TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY)
AIInfo->Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND - 1);
// Spell targets AoE friends.
if (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
effect->TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
effect->TargetA.GetTarget() == TARGET_SRC_CASTER)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_SRC_CASTER)
AIInfo->Targets |= 1 << (SELECT_TARGET_AOE_FRIEND - 1);
// Spell targets any friend (or self).
if (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER ||
effect->TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
effect->TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY ||
effect->TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
effect->TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
effect->TargetA.GetTarget() == TARGET_SRC_CASTER)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
spellEffectInfo.TargetA.GetTarget() == TARGET_SRC_CASTER)
AIInfo->Targets |= 1 << (SELECT_TARGET_ANY_FRIEND - 1);
// Make sure that this spell includes a damage effect.
if (effect->Effect == SPELL_EFFECT_SCHOOL_DAMAGE ||
effect->Effect == SPELL_EFFECT_INSTAKILL ||
effect->Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
effect->Effect == SPELL_EFFECT_HEALTH_LEECH)
if (spellEffectInfo.Effect == SPELL_EFFECT_SCHOOL_DAMAGE ||
spellEffectInfo.Effect == SPELL_EFFECT_INSTAKILL ||
spellEffectInfo.Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
spellEffectInfo.Effect == SPELL_EFFECT_HEALTH_LEECH)
AIInfo->Effects |= 1 << (SELECT_EFFECT_DAMAGE - 1);
// Make sure that this spell includes a healing effect (or an apply aura with a periodic heal).
if (effect->Effect == SPELL_EFFECT_HEAL ||
effect->Effect == SPELL_EFFECT_HEAL_MAX_HEALTH ||
effect->Effect == SPELL_EFFECT_HEAL_MECHANICAL ||
(effect->Effect == SPELL_EFFECT_APPLY_AURA && effect->ApplyAuraName == 8))
if (spellEffectInfo.Effect == SPELL_EFFECT_HEAL ||
spellEffectInfo.Effect == SPELL_EFFECT_HEAL_MAX_HEALTH ||
spellEffectInfo.Effect == SPELL_EFFECT_HEAL_MECHANICAL ||
(spellEffectInfo.Effect == SPELL_EFFECT_APPLY_AURA && spellEffectInfo.ApplyAuraName == 8))
AIInfo->Effects |= 1 << (SELECT_EFFECT_HEALING - 1);
// Make sure that this spell applies an aura.
if (effect->Effect == SPELL_EFFECT_APPLY_AURA)
if (spellEffectInfo.Effect == SPELL_EFFECT_APPLY_AURA)
AIInfo->Effects |= 1 << (SELECT_EFFECT_AURA - 1);
}
});
@@ -1265,14 +1265,13 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
if (!IsSpellValid(e, e.action.cast.spell))
return false;
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(e.action.cast.spell, DIFFICULTY_NONE);
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : sSpellMgr->AssertSpellInfo(e.action.cast.spell, DIFFICULTY_NONE)->GetEffects())
{
if (effect && (effect->IsEffect(SPELL_EFFECT_KILL_CREDIT) || effect->IsEffect(SPELL_EFFECT_KILL_CREDIT2)))
if (spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT) || spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT2))
{
if (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER)
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER)
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u Effect: SPELL_EFFECT_KILL_CREDIT: (SpellId: %u targetA: %u - targetB: %u) has invalid target for this Action",
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.cast.spell, effect->TargetA.GetTarget(), effect->TargetB.GetTarget());
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.cast.spell, spellEffectInfo.TargetA.GetTarget(), spellEffectInfo.TargetB.GetTarget());
}
}
break;
@@ -1821,19 +1820,16 @@ void SmartAIMgr::LoadHelperStores()
sSpellMgr->ForEachSpellInfo([this](SpellInfo const* spellInfo)
{
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effect)
continue;
if (effect->IsEffect(SPELL_EFFECT_SUMMON))
SummonCreatureSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex))));
else if (effect->IsEffect(SPELL_EFFECT_SUMMON_OBJECT_WILD))
SummonGameObjectSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex))));
else if (effect->IsEffect(SPELL_EFFECT_KILL_CREDIT) || effect->IsEffect(SPELL_EFFECT_KILL_CREDIT2))
KillCreditSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex))));
else if (effect->IsEffect(SPELL_EFFECT_CREATE_ITEM))
CreateItemSpellStore.insert(std::make_pair(uint32(effect->ItemType), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex))));
if (spellEffectInfo.IsEffect(SPELL_EFFECT_SUMMON))
SummonCreatureSpellStore.insert(std::make_pair(uint32(spellEffectInfo.MiscValue), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex)));
else if (spellEffectInfo.IsEffect(SPELL_EFFECT_SUMMON_OBJECT_WILD))
SummonGameObjectSpellStore.insert(std::make_pair(uint32(spellEffectInfo.MiscValue), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex)));
else if (spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT) || spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT2))
KillCreditSpellStore.insert(std::make_pair(uint32(spellEffectInfo.MiscValue), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex)));
else if (spellEffectInfo.IsEffect(SPELL_EFFECT_CREATE_ITEM))
CreateItemSpellStore.insert(std::make_pair(uint32(spellEffectInfo.ItemType), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex)));
}
});
@@ -147,14 +147,13 @@ bool CriteriaData::IsValid(Criteria const* criteria)
criteria->ID, criteria->Entry->Type, (DataType == CRITERIA_DATA_TYPE_S_AURA ? "CRITERIA_DATA_TYPE_S_AURA" : "CRITERIA_DATA_TYPE_T_AURA"), DataType, Aura.SpellId);
return false;
}
SpellEffectInfo const* effect = spellEntry->GetEffect(Aura.EffectIndex);
if (!effect)
if (spellEntry->GetEffects().size() <= Aura.EffectIndex)
{
TC_LOG_ERROR("sql.sql", "Table `criteria_data` (Entry: %u Type: %u) for data type %s (%u) contains a wrong spell effect index in value2 (%u), ignored.",
criteria->ID, criteria->Entry->Type, (DataType == CRITERIA_DATA_TYPE_S_AURA ? "CRITERIA_DATA_TYPE_S_AURA" : "CRITERIA_DATA_TYPE_T_AURA"), DataType, Aura.EffectIndex);
return false;
}
if (!effect->ApplyAuraName)
if (!spellEntry->GetEffect(SpellEffIndex(Aura.EffectIndex)).ApplyAuraName)
{
TC_LOG_ERROR("sql.sql", "Table `criteria_data` (Entry: %u Type: %u) for data type %s (%u) contains a non-aura spell effect (ID: %u Effect: %u), ignored.",
criteria->ID, criteria->Entry->Type, (DataType == CRITERIA_DATA_TYPE_S_AURA ? "CRITERIA_DATA_TYPE_S_AURA" : "CRITERIA_DATA_TYPE_T_AURA"), DataType, Aura.SpellId, Aura.EffectIndex);
+24 -46
View File
@@ -1372,38 +1372,34 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const
{
uint32 conditionEffMask = cond->SourceGroup;
std::list<uint32> sharedMasks;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
SpellEffectInfo const* effect = spellInfo->GetEffect(i);
if (!effect)
continue;
// additional checks by condition type
if (conditionEffMask & (1 << i))
if (conditionEffMask & (1 << spellEffectInfo.EffectIndex))
{
switch (cond->ConditionType)
{
case CONDITION_OBJECT_ENTRY_GUID:
{
uint32 implicitTargetMask = GetTargetFlagMask(effect->TargetA.GetObjectType()) | GetTargetFlagMask(effect->TargetB.GetObjectType());
uint32 implicitTargetMask = GetTargetFlagMask(spellEffectInfo.TargetA.GetObjectType()) | GetTargetFlagMask(spellEffectInfo.TargetB.GetObjectType());
if ((implicitTargetMask & TARGET_FLAG_UNIT_MASK) && cond->ConditionValue1 != TYPEID_UNIT && cond->ConditionValue1 != TYPEID_PLAYER)
{
TC_LOG_ERROR("sql.sql", "%s in `condition` table - spell %u EFFECT_%u - "
"target requires ConditionValue1 to be either TYPEID_UNIT (%u) or TYPEID_PLAYER (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(i), uint32(TYPEID_UNIT), uint32(TYPEID_PLAYER));
"target requires ConditionValue1 to be either TYPEID_UNIT (%u) or TYPEID_PLAYER (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(spellEffectInfo.EffectIndex), uint32(TYPEID_UNIT), uint32(TYPEID_PLAYER));
return;
}
if ((implicitTargetMask & TARGET_FLAG_GAMEOBJECT_MASK) && cond->ConditionValue1 != TYPEID_GAMEOBJECT)
{
TC_LOG_ERROR("sql.sql", "%s in `condition` table - spell %u EFFECT_%u - "
"target requires ConditionValue1 to be TYPEID_GAMEOBJECT (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(i), uint32(TYPEID_GAMEOBJECT));
"target requires ConditionValue1 to be TYPEID_GAMEOBJECT (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(spellEffectInfo.EffectIndex), uint32(TYPEID_GAMEOBJECT));
return;
}
if ((implicitTargetMask & TARGET_FLAG_CORPSE_MASK) && cond->ConditionValue1 != TYPEID_CORPSE)
{
TC_LOG_ERROR("sql.sql", "%s in `condition` table - spell %u EFFECT_%u - "
"target requires ConditionValue1 to be TYPEID_CORPSE (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(i), uint32(TYPEID_CORPSE));
"target requires ConditionValue1 to be TYPEID_CORPSE (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(spellEffectInfo.EffectIndex), uint32(TYPEID_CORPSE));
return;
}
break;
@@ -1414,22 +1410,16 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const
}
// check if effect is already a part of some shared mask
auto itr = std::find_if(sharedMasks.begin(), sharedMasks.end(), [i](uint32 mask) { return !!(mask & (1 << i)); });
auto itr = std::find_if(sharedMasks.begin(), sharedMasks.end(), [&](uint32 mask) { return !!(mask & (1 << spellEffectInfo.EffectIndex)); });
if (itr != sharedMasks.end())
continue;
// build new shared mask with found effect
uint32 sharedMask = 1 << i;
ConditionContainer* cmp = effect->ImplicitTargetConditions;
for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
{
SpellEffectInfo const* inner = spellInfo->GetEffect(effIndex);
if (!inner)
continue;
if (inner->ImplicitTargetConditions == cmp)
uint32 sharedMask = 1 << spellEffectInfo.EffectIndex;
ConditionContainer* cmp = spellEffectInfo.ImplicitTargetConditions;
for (size_t effIndex = spellEffectInfo.EffectIndex + 1; effIndex < spellInfo->GetEffects().size(); ++effIndex)
if (spellInfo->GetEffect(SpellEffIndex(effIndex)).ImplicitTargetConditions == cmp)
sharedMask |= 1 << effIndex;
}
sharedMasks.push_back(sharedMask);
}
@@ -1439,20 +1429,16 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const
// some effect indexes should have same data
if (uint32 commonMask = effectMask & conditionEffMask)
{
uint8 firstEffIndex = 0;
for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
size_t firstEffIndex = 0;
for (; firstEffIndex < spellInfo->GetEffects().size(); ++firstEffIndex)
if ((1 << firstEffIndex) & effectMask)
break;
if (firstEffIndex >= MAX_SPELL_EFFECTS)
if (firstEffIndex >= spellInfo->GetEffects().size())
return;
SpellEffectInfo const* effect = spellInfo->GetEffect(firstEffIndex);
if (!effect)
continue;
// get shared data
ConditionContainer* sharedList = effect->ImplicitTargetConditions;
ConditionContainer* sharedList = spellInfo->GetEffect(SpellEffIndex(firstEffIndex)).ImplicitTargetConditions;
// there's already data entry for that sharedMask
if (sharedList)
@@ -1472,15 +1458,11 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const
// add new list, create new shared mask
sharedList = new ConditionContainer();
bool assigned = false;
for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
for (size_t i = firstEffIndex; i < spellInfo->GetEffects().size(); ++i)
{
SpellEffectInfo const* eff = spellInfo->GetEffect(i);
if (!eff)
continue;
if ((1 << i) & commonMask)
{
const_cast<SpellEffectInfo*>(eff)->ImplicitTargetConditions = sharedList;
const_cast<SpellEffectInfo&>(spellInfo->GetEffect(SpellEffIndex(i))).ImplicitTargetConditions = sharedList;
assigned = true;
}
}
@@ -1767,19 +1749,15 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
uint32 origGroup = cond->SourceGroup;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!((1 << i) & cond->SourceGroup))
if (!((1 << spellEffectInfo.EffectIndex) & cond->SourceGroup))
continue;
SpellEffectInfo const* effect = spellInfo->GetEffect(i);
if (!effect)
if (spellEffectInfo.ChainTargets > 0)
continue;
if (effect->ChainTargets > 0)
continue;
switch (effect->TargetA.GetSelectionCategory())
switch (spellEffectInfo.TargetA.GetSelectionCategory())
{
case TARGET_SELECT_CATEGORY_NEARBY:
case TARGET_SELECT_CATEGORY_CONE:
@@ -1791,7 +1769,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
break;
}
switch (effect->TargetB.GetSelectionCategory())
switch (spellEffectInfo.TargetB.GetSelectionCategory())
{
case TARGET_SELECT_CATEGORY_NEARBY:
case TARGET_SELECT_CATEGORY_CONE:
@@ -1803,8 +1781,8 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
break;
}
TC_LOG_ERROR("sql.sql", "SourceEntry %u SourceGroup %u in `condition` table - spell %u does not have implicit targets of types: _AREA_, _CONE_, _NEARBY_, __CHAIN__ for effect %u, SourceGroup needs correction, ignoring.", cond->SourceEntry, origGroup, cond->SourceEntry, uint32(i));
cond->SourceGroup &= ~(1 << i);
TC_LOG_ERROR("sql.sql", "SourceEntry %u SourceGroup %u in `condition` table - spell %u does not have implicit targets of types: _AREA_, _CONE_, _NEARBY_, __CHAIN__ for effect %u, SourceGroup needs correction, ignoring.", cond->SourceEntry, origGroup, cond->SourceEntry, uint32(spellEffectInfo.EffectIndex));
cond->SourceGroup &= ~(1 << spellEffectInfo.EffectIndex);
}
// all effects were removed, no need to add the condition at all
if (!cond->SourceGroup)
+5 -12
View File
@@ -2361,12 +2361,9 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, WorldObject const* c
return false;
bool immunedToAllEffects = true;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effect || !effect->IsEffect())
continue;
if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex, caster))
if (spellEffectInfo.IsEffect() && !IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster))
{
immunedToAllEffects = false;
break;
@@ -2379,16 +2376,12 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, WorldObject const* c
return Unit::IsImmunedToSpell(spellInfo, caster);
}
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const
{
SpellEffectInfo const* effect = spellInfo->GetEffect(index);
if (!effect)
if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellEffectInfo.IsEffect(SPELL_EFFECT_HEAL))
return true;
if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && effect->Effect == SPELL_EFFECT_HEAL)
return true;
return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
return Unit::IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster);
}
bool Creature::isElite() const
+1 -1
View File
@@ -128,7 +128,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool CanCreatureAttack(Unit const* victim, bool force = true) const;
void LoadTemplateImmunities();
bool IsImmunedToSpell(SpellInfo const* spellInfo, WorldObject const* caster) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const override;
bool isElite() const;
bool isWorldBoss() const;
@@ -442,9 +442,9 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU
// RewardSpell can teach multiple spells in trigger spell effects. But not all effects must be SPELL_EFFECT_LEARN_SPELL. See example spell 33950
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpell(), DIFFICULTY_NONE))
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
if (effect->IsEffect(SPELL_EFFECT_LEARN_SPELL))
packet.LearnSpells.push_back(effect->TriggerSpell);
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL))
packet.LearnSpells.push_back(spellEffectInfo.TriggerSpell);
quest->BuildQuestRewards(packet.Rewards, _session->GetPlayer());
@@ -142,13 +142,13 @@ namespace Trainer
// check ranks
bool hasLearnSpellEffect = false;
bool knowsAllLearnedSpells = true;
for (SpellEffectInfo const* spellEffect : sSpellMgr->AssertSpellInfo(trainerSpell->SpellId, DIFFICULTY_NONE)->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : sSpellMgr->AssertSpellInfo(trainerSpell->SpellId, DIFFICULTY_NONE)->GetEffects())
{
if (!spellEffect || !spellEffect->IsEffect(SPELL_EFFECT_LEARN_SPELL))
if (!spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL))
continue;
hasLearnSpellEffect = true;
if (!player->HasSpell(spellEffect->TriggerSpell))
if (!player->HasSpell(spellEffectInfo.TriggerSpell))
knowsAllLearnedSpells = false;
}
+4 -5
View File
@@ -2094,13 +2094,12 @@ Player* WorldObject::GetSpellModOwner() const
}
// function uses real base points (typically value - 1)
int32 WorldObject::CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effIndex, int32 const* basePoints /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const
int32 WorldObject::CalculateSpellDamage(Unit const* target, SpellEffectInfo const& spellEffectInfo, int32 const* basePoints /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const
{
SpellEffectInfo const* effect = spellProto->GetEffect(effIndex);
if (variance)
*variance = 0.0f;
return effect ? effect->CalcValue(this, basePoints, target, variance, castItemId, itemLevel) : 0;
return spellEffectInfo.CalcValue(this, basePoints, target, variance, castItemId, itemLevel);
}
float WorldObject::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const
@@ -2231,8 +2230,8 @@ int32 WorldObject::ModSpellDuration(SpellInfo const* spellInfo, WorldObject cons
sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_BATTLE) ||
sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_GUARDIAN)))
{
SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0);
if (unitTarget->HasAura(53042) && effect && unitTarget->HasSpell(effect->TriggerSpell))
SpellEffectInfo const& effect = spellInfo->GetEffect(EFFECT_0);
if (unitTarget->HasAura(53042) && unitTarget->HasSpell(effect.TriggerSpell))
duration *= 2;
}
}
+2 -1
View File
@@ -50,6 +50,7 @@ class Player;
class Scenario;
class Spell;
class SpellCastTargets;
class SpellEffectInfo;
class SpellInfo;
class TempSummon;
class Transport;
@@ -564,7 +565,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
Player* GetAffectingPlayer() const;
Player* GetSpellModOwner() const;
int32 CalculateSpellDamage(Unit const* target, SpellInfo const* spellInfo, uint8 effIndex, int32 const* basePoints = nullptr, float* variance = nullptr, uint32 castItemId = 0, int32 itemLevel = -1) const;
int32 CalculateSpellDamage(Unit const* target, SpellEffectInfo const& spellEffectInfo, int32 const* basePoints = nullptr, float* variance = nullptr, uint32 castItemId = 0, int32 itemLevel = -1) const;
// target dependent range checks
float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const;
@@ -116,13 +116,19 @@ public:
// this also applies for transform auras
if (SpellInfo const* transform = sSpellMgr->GetSpellInfo(unit->getTransForm(), unit->GetMap()->GetDifficultyID()))
for (SpellEffectInfo const* effect : transform->GetEffects())
if (effect && effect->IsAura(SPELL_AURA_TRANSFORM))
if (CreatureTemplate const* transformInfo = sObjectMgr->GetCreatureTemplate(effect->MiscValue))
{
for (SpellEffectInfo const& spellEffectInfo : transform->GetEffects())
{
if (spellEffectInfo.IsAura(SPELL_AURA_TRANSFORM))
{
if (CreatureTemplate const* transformInfo = sObjectMgr->GetCreatureTemplate(spellEffectInfo.MiscValue))
{
cinfo = transformInfo;
break;
}
}
}
}
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
if (receiver->IsGameMaster())
+30 -37
View File
@@ -1663,19 +1663,15 @@ void Player::SetObjectScale(float scale)
SendMovementSetCollisionHeight(scale * GetCollisionHeight(), WorldPackets::Movement::UpdateCollisionHeightReason::Scale);
}
bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const
bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const
{
SpellEffectInfo const* effect = spellInfo->GetEffect(index);
if (!effect || !effect->IsEffect())
return false;
// players are immune to taunt (the aura and the spell effect).
if (effect->IsAura(SPELL_AURA_MOD_TAUNT))
if (spellEffectInfo.IsAura(SPELL_AURA_MOD_TAUNT))
return true;
if (effect->IsEffect(SPELL_EFFECT_ATTACK_ME))
if (spellEffectInfo.IsEffect(SPELL_EFFECT_ATTACK_ME))
return true;
return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
return Unit::IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster);
}
void Player::RegenerateAll()
@@ -2724,9 +2720,9 @@ void Player::RemoveTalent(TalentEntry const* talent)
RemoveSpell(talent->SpellID, true);
// search for spells that the talent teaches and unlearn them
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
if (effect && effect->TriggerSpell > 0 && effect->Effect == SPELL_EFFECT_LEARN_SPELL)
RemoveSpell(effect->TriggerSpell, true);
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
if (talent->OverridesSpellID)
RemoveOverrideSpell(talent->OverridesSpellID, talent->SpellID);
@@ -3123,13 +3119,15 @@ bool Player::HandlePassiveSpellLearn(SpellInfo const* spellInfo)
// passive spells which apply aura and have an item requirement are to be added manually, instead of casted
if (spellInfo->EquippedItemClass >= 0)
{
for (SpellEffectInfo const* effectInfo : spellInfo->GetEffects())
if (effectInfo && effectInfo->IsAura())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (spellEffectInfo.IsAura())
{
if (!HasAura(spellInfo->Id) && HasItemFitToSpellRequirements(spellInfo))
AddAura(spellInfo->Id, this);
return false;
}
}
}
//Check CasterAuraStates
@@ -8096,7 +8094,7 @@ void Player::ApplyArtifactPowerRank(Item* artifact, ArtifactPowerRankEntry const
continue;
if (powerAura->HasEffect(auraEffect->GetEffIndex()))
auraEffect->ChangeAmount(artifactPowerRank->AuraPointsOverride ? artifactPowerRank->AuraPointsOverride : auraEffect->GetSpellEffectInfo()->CalcValue());
auraEffect->ChangeAmount(artifactPowerRank->AuraPointsOverride ? artifactPowerRank->AuraPointsOverride : auraEffect->GetSpellEffectInfo().CalcValue());
}
}
else
@@ -8108,9 +8106,8 @@ void Player::ApplyArtifactPowerRank(Item* artifact, ArtifactPowerRankEntry const
args.TriggerFlags = TRIGGERED_FULL_MASK;
args.CastItem = artifact;
if (artifactPowerRank->AuraPointsOverride)
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (spellInfo->GetEffect(i))
args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), artifactPowerRank->AuraPointsOverride);
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + spellEffectInfo.EffectIndex), artifactPowerRank->AuraPointsOverride);
CastSpell(this, artifactPowerRank->SpellID, args);
}
@@ -8409,11 +8406,9 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
int32 const effectPct = std::max(0, 100 - (lvlDifference * lvlPenaltyFactor));
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->GetEffect(i)->IsEffect())
args.AddSpellMod(static_cast<SpellValueMod>(SPELLVALUE_BASE_POINT0 + i), CalculatePct(spellInfo->GetEffect(i)->CalcValue(this), effectPct));
}
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect())
args.AddSpellMod(static_cast<SpellValueMod>(SPELLVALUE_BASE_POINT0 + spellEffectInfo.EffectIndex), CalculatePct(spellEffectInfo.CalcValue(this), effectPct));
}
CastSpell(target, spellInfo->Id, args);
}
@@ -24560,9 +24555,9 @@ void Player::LearnQuestRewardedSpells(Quest const* quest)
// check learned spells state
bool found = false;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (effect && effect->Effect == SPELL_EFFECT_LEARN_SPELL && !HasSpell(effect->TriggerSpell))
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && !HasSpell(spellEffectInfo.TriggerSpell))
{
found = true;
break;
@@ -24573,11 +24568,11 @@ void Player::LearnQuestRewardedSpells(Quest const* quest)
if (!found)
return;
SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0);
if (!effect)
if (spellInfo->GetEffects().empty())
return;
uint32 learned_0 = effect->TriggerSpell;
SpellEffectInfo const& effect = spellInfo->GetEffect(EFFECT_0);
uint32 learned_0 = effect.TriggerSpell;
if (!HasSpell(learned_0))
{
found = false;
@@ -25264,11 +25259,9 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons
// special check to filter things like Shield Wall, the aura is not permanent and must stay even without required item
if (!spellInfo->IsPassive())
{
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
if (effect && effect->IsAura())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsAura())
return true;
}
}
// tabard not have dependent spells
@@ -27461,9 +27454,9 @@ void Player::ActivateTalentGroup(ChrSpecializationEntry const* spec)
RemoveSpell(talentInfo->SpellID, true);
// search for spells that the talent teaches and unlearn them
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
if (effect && effect->TriggerSpell > 0 && effect->Effect == SPELL_EFFECT_LEARN_SPELL)
RemoveSpell(effect->TriggerSpell, true);
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
if (talentInfo->OverridesSpellID)
RemoveOverrideSpell(talentInfo->OverridesSpellID, talentInfo->SpellID);
@@ -27482,9 +27475,9 @@ void Player::ActivateTalentGroup(ChrSpecializationEntry const* spec)
RemoveSpell(talentInfo->SpellID, true);
// search for spells that the talent teaches and unlearn them
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
if (effect && effect->TriggerSpell > 0 && effect->Effect == SPELL_EFFECT_LEARN_SPELL)
RemoveSpell(effect->TriggerSpell, true);
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
if (talentInfo->OverridesSpellID)
RemoveOverrideSpell(talentInfo->OverridesSpellID, talentInfo->SpellID);
+1 -1
View File
@@ -1085,7 +1085,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void Update(uint32 time) override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const override;
void SetInWater(bool inWater) override;
+13 -17
View File
@@ -137,26 +137,22 @@ void Totem::UnSummon(uint32 msTime)
AddObjectToRemoveList();
}
bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const
bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const
{
/// @todo possibly all negative auras immune?
if (GetEntry() == 5925)
return false;
if (SpellEffectInfo const* effect = spellInfo->GetEffect(index))
{
switch (effect->ApplyAuraName)
{
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_MOD_FEAR:
case SPELL_AURA_TRANSFORM:
return true;
default:
break;
}
}
else
return true;
return Creature::IsImmunedToSpellEffect(spellInfo, index, caster);
switch (spellEffectInfo.ApplyAuraName)
{
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_MOD_FEAR:
case SPELL_AURA_TRANSFORM:
return true;
default:
break;
}
return Creature::IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster);
}
+1 -1
View File
@@ -50,7 +50,7 @@ class TC_GAME_API Totem : public Minion
void UpdateAttackPowerAndDamage(bool /*ranged*/) override { }
void UpdateDamagePhysical(WeaponAttackType /*attType*/) override { }
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const override;
protected:
TotemType m_type;
+6 -6
View File
@@ -538,20 +538,20 @@ void Player::UpdateMastery()
if (!chrSpec)
return;
for (uint32 i = 0; i < MAX_MASTERY_SPELLS; ++i)
for (int32 masterySpellId : chrSpec->MasterySpellID)
{
if (Aura* aura = GetAura(chrSpec->MasterySpellID[i]))
if (Aura* aura = GetAura(masterySpellId))
{
for (SpellEffectInfo const* effect : aura->GetSpellInfo()->GetEffects())
for (AuraEffect* auraEff : aura->GetAuraEffects())
{
if (!effect)
if (!auraEff)
continue;
float mult = effect->BonusCoefficient;
float mult = auraEff->GetSpellEffectInfo().BonusCoefficient;
if (G3D::fuzzyEq(mult, 0.0f))
continue;
aura->GetEffect(effect->EffectIndex)->ChangeAmount(int32(value * mult));
auraEff->ChangeAmount(int32(value * mult));
}
}
}
+68 -82
View File
@@ -1507,7 +1507,7 @@ void Unit::HandleEmoteCommand(uint32 anim_id, Trinity::IteratorPair<int32 const*
SendMessageToSet(packet.Write(), true);
}
/*static*/ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* spellInfo /*= nullptr*/, int8 effIndex /*= -1*/)
/*static*/ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* spellInfo /*= nullptr*/, SpellEffectInfo const* spellEffectInfo /*= nullptr*/)
{
// only physical spells damage gets reduced by armor
if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
@@ -1519,16 +1519,12 @@ void Unit::HandleEmoteCommand(uint32 anim_id, Trinity::IteratorPair<int32 const*
return false;
// bleeding effects are not reduced by armor
if (effIndex != -1)
if (spellEffectInfo)
{
// bleeding effects are not reduced by armor
if (SpellEffectInfo const* effect = spellInfo->GetEffect(effIndex))
{
if (effect->ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE ||
effect->Effect == SPELL_EFFECT_SCHOOL_DAMAGE)
if (spellInfo->GetEffectMechanicMask(effIndex) & (1 << MECHANIC_BLEED))
return false;
}
if (spellEffectInfo->ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE ||
spellEffectInfo->Effect == SPELL_EFFECT_SCHOOL_DAMAGE)
if (spellInfo->GetEffectMechanicMask(spellEffectInfo->EffectIndex) & (1 << MECHANIC_BLEED))
return false;
}
}
return true;
@@ -1834,7 +1830,7 @@ void Unit::HandleEmoteCommand(uint32 anim_id, Trinity::IteratorPair<int32 const*
int32 manaReduction = currentAbsorb;
// lower absorb amount by talents
if (float manaMultiplier = absorbAurEff->GetSpellEffectInfo()->CalcValueMultiplier(absorbAurEff->GetCaster()))
if (float manaMultiplier = absorbAurEff->GetSpellEffectInfo().CalcValueMultiplier(absorbAurEff->GetCaster()))
manaReduction = int32(float(manaReduction) * manaMultiplier);
int32 manaTaken = -damageInfo.GetVictim()->ModifyPower(POWER_MANA, -manaReduction);
@@ -2020,19 +2016,19 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr
if (!meleeAttackOverrides.empty())
{
meleeAttackAuraEffect = meleeAttackOverrides.front();
meleeAttackSpellId = meleeAttackAuraEffect->GetSpellEffectInfo()->TriggerSpell;
meleeAttackSpellId = meleeAttackAuraEffect->GetSpellEffectInfo().TriggerSpell;
}
}
else
{
auto itr = std::find_if(meleeAttackOverrides.begin(), meleeAttackOverrides.end(), [&](AuraEffect const* aurEff)
{
return aurEff->GetSpellEffectInfo()->MiscValue != 0;
return aurEff->GetSpellEffectInfo().MiscValue != 0;
});
if (itr != meleeAttackOverrides.end())
{
meleeAttackAuraEffect = *itr;
meleeAttackSpellId = meleeAttackAuraEffect->GetSpellEffectInfo()->MiscValue;
meleeAttackSpellId = meleeAttackAuraEffect->GetSpellEffectInfo().MiscValue;
}
}
@@ -2338,12 +2334,12 @@ int32 Unit::GetMechanicResistChance(SpellInfo const* spellInfo) const
return 0;
int32 resistMech = 0;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& effect : spellInfo->GetEffects())
{
if (!effect || !effect->IsEffect())
if (!effect.IsEffect())
break;
int32 effectMech = spellInfo->GetEffectMechanic(effect->EffectIndex);
int32 effectMech = spellInfo->GetEffectMechanic(effect.EffectIndex);
if (effectMech)
{
int32 temp = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effectMech);
@@ -3107,22 +3103,19 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(AuraCreateInfo& createInfo)
return nullptr;
// update basepoints with new values - effect amount will be recalculated in ModStackAmount
for (SpellEffectInfo const* effect : createInfo.GetSpellInfo()->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : createInfo.GetSpellInfo()->GetEffects())
{
if (!effect)
continue;
AuraEffect const* eff = foundAura->GetEffect(effect->EffectIndex);
if (!eff)
AuraEffect const* auraEff = foundAura->GetEffect(spellEffectInfo.EffectIndex);
if (!auraEff)
continue;
int32 bp;
if (createInfo.BaseAmount)
bp = *(createInfo.BaseAmount + effect->EffectIndex);
bp = *(createInfo.BaseAmount + spellEffectInfo.EffectIndex);
else
bp = effect->BasePoints;
bp = spellEffectInfo.BasePoints;
int32* oldBP = const_cast<int32*>(&(foundAura->GetEffect(effect->EffectIndex)->m_baseAmount)); // todo 6.x review GetBaseAmount and GetCastItemGUID in this case
int32* oldBP = const_cast<int32*>(&(auraEff->m_baseAmount)); // todo 6.x review GetBaseAmount and GetCastItemGUID in this case
*oldBP = bp;
}
@@ -3978,9 +3971,9 @@ void Unit::RemoveMovementImpairingAuras(bool withRoot)
}
// turn off snare auras by setting amount to 0
for (SpellEffectInfo const* spellEffectInfo : aura->GetSpellInfo()->GetEffects())
if (spellEffectInfo && iter->second->HasEffect(spellEffectInfo->EffectIndex) && spellEffectInfo->Mechanic == MECHANIC_SNARE)
aura->GetEffect(spellEffectInfo->EffectIndex)->ChangeAmount(0);
for (SpellEffectInfo const& spellEffectInfo : aura->GetSpellInfo()->GetEffects())
if (iter->second->HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.Mechanic == MECHANIC_SNARE)
aura->GetEffect(spellEffectInfo.EffectIndex)->ChangeAmount(0);
++iter;
}
@@ -4498,9 +4491,9 @@ bool Unit::HasAuraWithMechanic(uint32 mechanicMask) const
if (spellInfo->Mechanic && (mechanicMask & (1 << spellInfo->Mechanic)))
return true;
for (SpellEffectInfo const* spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo && iter->second->HasEffect(spellEffectInfo->EffectIndex) && spellEffectInfo->IsEffect() && spellEffectInfo->Mechanic)
if (mechanicMask & (1 << spellEffectInfo->Mechanic))
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (iter->second->HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.IsEffect() && spellEffectInfo.Mechanic)
if (mechanicMask & (1 << spellEffectInfo.Mechanic))
return true;
}
@@ -5908,13 +5901,15 @@ void Unit::SetMinion(Minion *minion, bool apply)
{
// All summoned by totem minions must disappear when it is removed.
if (SpellInfo const* spInfo = sSpellMgr->GetSpellInfo(minion->ToTotem()->GetSpell(), GetMap()->GetDifficultyID()))
for (SpellEffectInfo const* effect : spInfo->GetEffects())
{
if (!effect || effect->Effect != SPELL_EFFECT_SUMMON)
continue;
{
for (SpellEffectInfo const& spellEffectInfo : spInfo->GetEffects())
{
if (!spellEffectInfo.IsEffect(SPELL_EFFECT_SUMMON))
continue;
RemoveAllMinionsByEntry(effect->MiscValue);
}
RemoveAllMinionsByEntry(spellEffectInfo.MiscValue);
}
}
}
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->m_unitData->CreatedBySpell, GetMap()->GetDifficultyID());
@@ -6352,7 +6347,7 @@ void Unit::EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damag
SendEnergizeSpellLog(victim, spellInfo->Id, gain, overEnergize, powerType);
}
uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const* effect, uint32 stack /*= 1*/) const
uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const& spellEffectInfo, uint32 stack /*= 1*/) const
{
if (!spellProto || !victim || damagetype == DIRECT_DAMAGE)
return pdamage;
@@ -6364,7 +6359,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
// For totems get damage bonus from owner
if (GetTypeId() == TYPEID_UNIT && IsTotem())
if (Unit* owner = GetOwner())
return owner->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype, effect, stack);
return owner->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype, spellEffectInfo, stack);
int32 DoneTotal = 0;
float DoneTotalMod = SpellDamagePctDone(victim, spellProto, damagetype);
@@ -6380,9 +6375,9 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
DoneAdvertisedBenefit += static_cast<Guardian const*>(this)->GetBonusDamage();
// Check for table values
if (effect->BonusCoefficientFromAP > 0.0f)
if (spellEffectInfo.BonusCoefficientFromAP > 0.0f)
{
float ApCoeffMod = effect->BonusCoefficientFromAP;
float ApCoeffMod = spellEffectInfo.BonusCoefficientFromAP;
if (Player* modOwner = GetSpellModOwner())
{
ApCoeffMod *= 100.0f;
@@ -6412,7 +6407,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
}
// Default calculation
float coeff = effect->BonusCoefficient;
float coeff = spellEffectInfo.BonusCoefficient;
if (DoneAdvertisedBenefit)
{
if (Player* modOwner = GetSpellModOwner())
@@ -6839,12 +6834,12 @@ float Unit::SpellCritChanceTaken(Unit const* caster, Spell* spell, AuraEffect co
return damage;
}
uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const* spellEffect, uint32 stack /*= 1*/) const
uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const& spellEffectInfo, uint32 stack /*= 1*/) const
{
// For totems get healing bonus from owner (statue isn't totem in fact)
if (GetTypeId() == TYPEID_UNIT && IsTotem())
if (Unit* owner = GetOwner())
return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, spellEffect, stack);
return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, spellEffectInfo, stack);
// No bonus healing for potion spells
if (spellProto->SpellFamilyName == SPELLFAMILY_POTION)
@@ -6882,14 +6877,14 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
DoneAdvertisedBenefit += static_cast<Guardian const*>(this)->GetBonusDamage();
// Check for table values
float coeff = spellEffect->BonusCoefficient;
if (spellEffect->BonusCoefficientFromAP > 0.0f)
float coeff = spellEffectInfo.BonusCoefficient;
if (spellEffectInfo.BonusCoefficientFromAP > 0.0f)
{
WeaponAttackType const attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK;
float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS));
APbonus += GetTotalAttackPowerValue(attType);
DoneTotal += int32(spellEffect->BonusCoefficientFromAP * stack * APbonus);
DoneTotal += int32(spellEffectInfo.BonusCoefficientFromAP * stack * APbonus);
}
else if (coeff <= 0.0f) // no AP and no SP coefs, skip
{
@@ -6911,19 +6906,19 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
DoneTotal += int32(DoneAdvertisedBenefit * coeff * stack);
}
for (SpellEffectInfo const* effect : spellProto->GetEffects())
for (SpellEffectInfo const& otherSpellEffect : spellProto->GetEffects())
{
if (!effect)
continue;
switch (effect->ApplyAuraName)
switch (otherSpellEffect.ApplyAuraName)
{
// Bonus healing does not apply to these spells
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
DoneTotal = 0;
break;
default:
break;
}
if (effect->Effect == SPELL_EFFECT_HEALTH_LEECH)
if (otherSpellEffect.IsEffect(SPELL_EFFECT_HEALTH_LEECH))
DoneTotal = 0;
}
@@ -7071,7 +7066,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const
for (AuraEffectList::const_iterator i = mHealingDoneOfStatPercent.begin(); i != mHealingDoneOfStatPercent.end(); ++i)
{
// stat used dependent from misc value (stat index)
Stats usedStat = Stats((*i)->GetSpellEffectInfo()->MiscValue);
Stats usedStat = Stats((*i)->GetSpellEffectInfo().MiscValue);
advertisedBenefit += int32(CalculatePct(GetStat(usedStat), (*i)->GetAmount()));
}
}
@@ -7159,13 +7154,13 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo, WorldObject const* caste
}
bool immuneToAllEffects = true;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
// State/effect immunities applied by aura expect full spell immunity
// Ignore effects with mechanic, they are supposed to be checked separately
if (!effect || !effect->IsEffect())
if (!spellEffectInfo.IsEffect())
continue;
if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex, caster))
if (!IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster))
{
immuneToAllEffects = false;
break;
@@ -7226,25 +7221,20 @@ uint32 Unit::GetMechanicImmunityMask() const
return mask;
}
bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const
bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const
{
if (!spellInfo)
return false;
SpellEffectInfo const* effect = spellInfo->GetEffect(index);
if (!effect)
return false;
if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
return false;
// If m_immuneToEffect type contain this effect type, IMMUNE effect.
uint32 eff = effect->Effect;
auto const& effectList = m_spellImmune[IMMUNITY_EFFECT];
if (effectList.count(eff) > 0)
if (effectList.count(spellEffectInfo.Effect) > 0)
return true;
if (uint32 mechanic = effect->Mechanic)
if (uint32 mechanic = spellEffectInfo.Mechanic)
{
SpellImmuneContainer const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
if (mechanicList.count(mechanic) > 0)
@@ -7253,7 +7243,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Worl
if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
{
if (uint32 aura = effect->ApplyAuraName)
if (AuraType aura = spellEffectInfo.ApplyAuraName)
{
SpellImmuneContainer const& list = m_spellImmune[IMMUNITY_STATE];
if (list.count(aura) > 0)
@@ -7265,7 +7255,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Worl
AuraEffectList const& immuneAuraApply = GetAuraEffectsByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL);
for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter)
if (((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school
((caster && !IsFriendlyTo(caster)) || !spellInfo->IsPositiveEffect(index))) // Harmful
((caster && !IsFriendlyTo(caster)) || !spellInfo->IsPositiveEffect(spellEffectInfo.EffectIndex))) // Harmful
return true;
}
}
@@ -9044,7 +9034,7 @@ void Unit::TriggerOnPowerChangeAuras(Powers power, int32 oldVal, int32 newVal)
if (effect->GetMiscValue() == power)
{
uint32 effectAmount = effect->GetAmount();
uint32 triggerSpell = effect->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = effect->GetSpellEffectInfo().TriggerSpell;
float oldValueCheck = oldVal;
float newValueCheck = newVal;
@@ -11337,13 +11327,13 @@ Aura* Unit::AddAura(SpellInfo const* spellInfo, uint32 effMask, Unit* target)
if (target->IsImmunedToSpell(spellInfo, this))
return nullptr;
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!(effMask & (1 << i)))
if (!(effMask & (1 << spellEffectInfo.EffectIndex)))
continue;
if (target->IsImmunedToSpellEffect(spellInfo, i, this))
effMask &= ~(1 << i);
if (target->IsImmunedToSpellEffect(spellInfo, spellEffectInfo, this))
effMask &= ~(1 << spellEffectInfo.EffectIndex);
}
if (!effMask)
@@ -11779,12 +11769,9 @@ void Unit::HandleSpellClick(Unit* clicker, int8 seatId /*= -1*/)
{
uint8 i = 0;
bool valid = false;
for (SpellEffectInfo const* effect : spellEntry->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellEntry->GetEffects())
{
if (!effect)
continue;
if (effect->ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
if (spellEffectInfo.ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
{
valid = true;
break;
@@ -11808,9 +11795,8 @@ void Unit::HandleSpellClick(Unit* clicker, int8 seatId /*= -1*/)
else // This can happen during Player::_LoadAuras
{
int32 bp[MAX_SPELL_EFFECTS] = { };
for (SpellEffectInfo const* effect : spellEntry->GetEffects())
if (effect)
bp[effect->EffectIndex] = effect->BasePoints;
for (SpellEffectInfo const& spellEffectInfo : spellEntry->GetEffects())
bp[spellEffectInfo.EffectIndex] = spellEffectInfo.BasePoints;
bp[i] = seatId;
@@ -13057,11 +13043,11 @@ int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEf
bool Unit::IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications /*= false*/)
{
for (AuraEffect* aurEff : aura->GetAuraEffects())
for (AuraEffect const* aurEff : aura->GetAuraEffects())
{
if (!aurEff)
continue;
AuraType const auraType = AuraType(aurEff->GetSpellEffectInfo()->ApplyAuraName);
AuraType const auraType = aurEff->GetSpellEffectInfo().ApplyAuraName;
AuraEffectList const& auras = GetAuraEffectsByType(auraType);
for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end();)
{
+4 -4
View File
@@ -1646,11 +1646,11 @@ class TC_GAME_API Unit : public WorldObject
Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = nullptr);
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const;
uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const* effect, uint32 stack = 1) const;
uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const& spellEffectInfo, uint32 stack = 1) const;
float SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) const;
uint32 SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype) const;
int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const;
uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const* effect, uint32 stack = 1) const;
uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const& spellEffectInfo, uint32 stack = 1) const;
float SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const;
uint32 SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype) const;
@@ -1674,9 +1674,9 @@ class TC_GAME_API Unit : public WorldObject
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const;
bool IsImmunedToDamage(SpellInfo const* spellInfo) const;
virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const;
virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const;
static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr, int8 effIndex = -1);
static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr, SpellEffectInfo const* spellEffectInfo = nullptr);
static uint32 CalcArmorReducedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK, uint8 attackerLevel = 0);
static uint32 CalcSpellResistedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo);
static void CalcAbsorbResist(DamageInfo& damageInfo);
+16 -11
View File
@@ -4939,12 +4939,12 @@ void ObjectMgr::LoadQuests()
if (!spellInfo)
continue;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effect || effect->Effect != SPELL_EFFECT_QUEST_COMPLETE)
if (spellEffectInfo.Effect != SPELL_EFFECT_QUEST_COMPLETE)
continue;
uint32 quest_id = effect->MiscValue;
uint32 quest_id = spellEffectInfo.MiscValue;
Quest const* quest = GetQuestTemplate(quest_id);
@@ -5506,11 +5506,16 @@ void ObjectMgr::LoadSpellScripts()
continue;
}
uint8 i = (uint8)((uint32(itr->first) >> 24) & 0x000000FF);
SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
if (uint32(i) >= spellInfo->GetEffects().size())
{
TC_LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index %u for spell (Id: %u) as script id", uint32(i), spellId);
continue;
}
//check for correct spellEffect
SpellEffectInfo const* effect = spellInfo->GetEffect(i);
if (effect && (!effect->Effect || (effect->Effect != SPELL_EFFECT_SCRIPT_EFFECT && effect->Effect != SPELL_EFFECT_DUMMY)))
TC_LOG_ERROR("sql.sql", "Table `spell_scripts` - spell %u effect %u is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, i);
if (!spellInfo->GetEffect(i).Effect || (spellInfo->GetEffect(i).Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->GetEffect(i).Effect != SPELL_EFFECT_DUMMY))
TC_LOG_ERROR("sql.sql", "Table `spell_scripts` - spell %u effect %u is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
}
}
@@ -5527,10 +5532,10 @@ void ObjectMgr::LoadEventScripts()
// Load all possible script entries from spells
for (SpellNameEntry const* spellNameEntry : sSpellNameStore)
if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(spellNameEntry->ID, DIFFICULTY_NONE))
for (SpellEffectInfo const* effect : spell->GetEffects())
if (effect && effect->Effect == SPELL_EFFECT_SEND_EVENT)
if (effect->MiscValue)
evt_scripts.insert(effect->MiscValue);
for (SpellEffectInfo const& spellEffectInfo : spell->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_SEND_EVENT))
if (spellEffectInfo.MiscValue)
evt_scripts.insert(spellEffectInfo.MiscValue);
for (size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
{
+2 -2
View File
@@ -305,9 +305,9 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
return;
}
for (SpellEffectInfo const* effect: spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (effect && (effect->TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY || effect->TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY || effect->TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY))
if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY || spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY || spellEffectInfo.TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
return;
}
@@ -1089,6 +1089,7 @@ enum Team
enum SpellEffectName
{
SPELL_EFFECT_NONE = 0,
SPELL_EFFECT_INSTAKILL = 1,
SPELL_EFFECT_SCHOOL_DAMAGE = 2,
SPELL_EFFECT_DUMMY = 3,
@@ -575,9 +575,9 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //503 SPELL_AURA_MOD_PLAYER_CHOICE_REROLLS
};
AuraEffect::AuraEffect(Aura* base, SpellEffectInfo const* spellEfffectInfo, int32 const* baseAmount, Unit* caster) :
AuraEffect::AuraEffect(Aura* base, SpellEffectInfo const& spellEfffectInfo, int32 const* baseAmount, Unit* caster) :
m_base(base), m_spellInfo(base->GetSpellInfo()), m_effectInfo(spellEfffectInfo), m_spellmod(nullptr),
m_baseAmount(baseAmount ? *baseAmount : spellEfffectInfo->CalcBaseValue(caster, base->GetType() == UNIT_AURA_TYPE ? base->GetOwner()->ToUnit() : nullptr, base->GetCastItemId(), base->GetCastItemLevel())),
m_baseAmount(baseAmount ? *baseAmount : spellEfffectInfo.CalcBaseValue(caster, base->GetType() == UNIT_AURA_TYPE ? base->GetOwner()->ToUnit() : nullptr, base->GetCastItemId(), base->GetCastItemLevel())),
_amount(), _periodicTimer(0), _period(0), _ticksDone(0),
m_canBeRecalculated(true), m_isPeriodic(false)
{
@@ -621,10 +621,10 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
// default amount calculation
int32 amount = 0;
if (!m_spellInfo->HasAttribute(SPELL_ATTR8_MASTERY_SPECIALIZATION) || G3D::fuzzyEq(GetSpellEffectInfo()->BonusCoefficient, 0.0f))
amount = GetSpellEffectInfo()->CalcValue(caster, &m_baseAmount, GetBase()->GetOwner()->ToUnit(), nullptr, GetBase()->GetCastItemId(), GetBase()->GetCastItemLevel());
if (!m_spellInfo->HasAttribute(SPELL_ATTR8_MASTERY_SPECIALIZATION) || G3D::fuzzyEq(GetSpellEffectInfo().BonusCoefficient, 0.0f))
amount = GetSpellEffectInfo().CalcValue(caster, &m_baseAmount, GetBase()->GetOwner()->ToUnit(), nullptr, GetBase()->GetCastItemId(), GetBase()->GetCastItemLevel());
else if (caster && caster->GetTypeId() == TYPEID_PLAYER)
amount = int32(caster->ToPlayer()->m_activePlayerData->Mastery * GetSpellEffectInfo()->BonusCoefficient);
amount = int32(caster->ToPlayer()->m_activePlayerData->Mastery * GetSpellEffectInfo().BonusCoefficient);
// custom amount calculations go here
switch (GetAuraType())
@@ -668,12 +668,12 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
}
GetBase()->CallScriptEffectCalcAmountHandlers(this, amount, m_canBeRecalculated);
if (!GetSpellEffectInfo()->EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack))
if (!GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack))
amount *= GetBase()->GetStackAmount();
if (caster && GetBase()->GetType() == UNIT_AURA_TYPE)
{
uint32 stackAmountForBonuses = !GetSpellEffectInfo()->EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
uint32 stackAmountForBonuses = !GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
switch (GetAuraType())
{
@@ -719,7 +719,7 @@ void AuraEffect::ResetPeriodic(bool resetPeriodicTimer /*= false*/)
void AuraEffect::CalculatePeriodic(Unit* caster, bool resetPeriodicTimer /*= true*/, bool load /*= false*/)
{
_period = GetSpellEffectInfo()->ApplyAuraPeriod;
_period = GetSpellEffectInfo().ApplyAuraPeriod;
// prepare periodics
switch (GetAuraType())
@@ -801,7 +801,7 @@ void AuraEffect::CalculateSpellMod()
m_spellmod->type = GetAuraType() == SPELL_AURA_ADD_PCT_MODIFIER ? SPELLMOD_PCT : SPELLMOD_FLAT;
m_spellmod->spellId = GetId();
m_spellmod->mask = GetSpellEffectInfo()->SpellClassMask;
m_spellmod->mask = GetSpellEffectInfo().SpellClassMask;
}
m_spellmod->value = GetAmount();
break;
@@ -1006,7 +1006,7 @@ bool AuraEffect::IsAffectingSpell(SpellInfo const* spell) const
return false;
// Check family name and EffectClassMask
if (!spell->IsAffected(m_spellInfo->SpellFamilyName, GetSpellEffectInfo()->SpellClassMask))
if (!spell->IsAffected(m_spellInfo->SpellFamilyName, GetSpellEffectInfo().SpellClassMask))
return false;
return true;
@@ -1139,7 +1139,7 @@ bool AuraEffect::CheckEffectProc(AuraApplication* aurApp, ProcEventInfo& eventIn
case SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE:
{
// Don't proc extra attacks while already processing extra attack spell
uint32 triggerSpellId = GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpellId = GetSpellEffectInfo().TriggerSpell;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId, GetBase()->GetCastDifficulty()))
if (aurApp->GetTarget()->m_extraAttacks && triggeredSpellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
return false;
@@ -2527,8 +2527,8 @@ void AuraEffect::HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bo
}
//some spell has one aura of mount and one of vehicle
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
if (effect && effect->Effect == SPELL_EFFECT_SUMMON && effect->MiscValue == GetMiscValue())
for (SpellEffectInfo const& effect : GetSpellInfo()->GetEffects())
if (effect.IsEffect(SPELL_EFFECT_SUMMON) && effect.MiscValue == GetMiscValue())
displayId = 0;
}
@@ -4382,8 +4382,7 @@ void AuraEffect::HandleNoReagentUseAura(AuraApplication const* aurApp, uint8 mod
flag128 mask;
Unit::AuraEffectList const& noReagent = target->GetAuraEffectsByType(SPELL_AURA_NO_REAGENT_USE);
for (Unit::AuraEffectList::const_iterator i = noReagent.begin(); i != noReagent.end(); ++i)
if (SpellEffectInfo const* effect = (*i)->GetSpellEffectInfo())
mask |= effect->SpellClassMask;
mask |= (*i)->GetSpellEffectInfo().SpellClassMask;
target->ToPlayer()->SetNoRegentCostMask(mask);
}
@@ -4750,11 +4749,11 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod
if (GetAmount() <= 0)
return;
if (GetSpellEffectInfo()->ItemType == 0)
if (GetSpellEffectInfo().ItemType == 0)
return;
// Soul Shard
if (GetSpellEffectInfo()->ItemType == 6265)
if (GetSpellEffectInfo().ItemType == 6265)
{
// Soul Shard only from units that grant XP or honor
if (!plCaster->isHonorOrXPTarget(target) ||
@@ -4767,16 +4766,16 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod
uint32 count = GetAmount();
ItemPosCountVec dest;
InventoryResult msg = plCaster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellEffectInfo()->ItemType, count, &noSpaceForCount);
InventoryResult msg = plCaster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellEffectInfo().ItemType, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK)
{
count -= noSpaceForCount;
plCaster->SendEquipError(msg, nullptr, nullptr, GetSpellEffectInfo()->ItemType);
plCaster->SendEquipError(msg, nullptr, nullptr, GetSpellEffectInfo().ItemType);
if (count == 0)
return;
}
Item* newitem = plCaster->StoreNewItem(dest, GetSpellEffectInfo()->ItemType, true);
Item* newitem = plCaster->StoreNewItem(dest, GetSpellEffectInfo().ItemType, true);
if (!newitem)
{
plCaster->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
@@ -4902,7 +4901,7 @@ void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, boo
{
Unit* target = aurApp->GetTarget();
uint32 triggeredSpellId = GetSpellEffectInfo()->TriggerSpell;
uint32 triggeredSpellId = GetSpellEffectInfo().TriggerSpell;
SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggeredSpellId, GetBase()->GetCastDifficulty());
if (!triggeredSpellInfo)
return;
@@ -4946,7 +4945,7 @@ void AuraEffect::HandleTriggerSpellOnPowerPercent(AuraApplication const* aurApp,
Unit* target = aurApp->GetTarget();
int32 effectAmount = GetAmount();
uint32 triggerSpell = GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = GetSpellEffectInfo().TriggerSpell;
float powerAmountPct = GetPctOf(target->GetPower(Powers(GetMiscValue())), target->GetMaxPower(Powers(GetMiscValue())));
switch (AuraTriggerOnPowerChangeDirection(GetMiscValueB()))
@@ -4974,7 +4973,7 @@ void AuraEffect::HandleTriggerSpellOnPowerAmount(AuraApplication const* aurApp,
Unit* target = aurApp->GetTarget();
int32 effectAmount = GetAmount();
uint32 triggerSpell = GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = GetSpellEffectInfo().TriggerSpell;
float powerAmount = target->GetPower(Powers(GetMiscValue()));
switch (AuraTriggerOnPowerChangeDirection(GetMiscValueB()))
@@ -5133,7 +5132,7 @@ void AuraEffect::HandleMastery(AuraApplication const* aurApp, uint8 mode, bool /
void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) const
{
uint32 triggerSpellId = GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpellId = GetSpellEffectInfo().TriggerSpell;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId, GetBase()->GetCastDifficulty()))
{
if (Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? caster : target)
@@ -5148,7 +5147,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
void AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* caster) const
{
uint32 triggerSpellId = GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpellId = GetSpellEffectInfo().TriggerSpell;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId, GetBase()->GetCastDifficulty()))
{
if (Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? caster : target)
@@ -5177,13 +5176,13 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
// Consecrate ticks can miss and will not show up in the combat log
// dynobj auras must always have a caster
if (GetSpellEffectInfo()->Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
if (GetSpellEffectInfo().IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA) &&
ASSERT_NOTNULL(caster)->SpellHitResult(target, GetSpellInfo(), false) != SPELL_MISS_NONE)
return;
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
uint32 stackAmountForBonuses = !GetSpellEffectInfo()->EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
uint32 stackAmountForBonuses = !GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
// ignore negative values (can be result apply spellmods to aura damage
uint32 damage = std::max(GetAmount(), 0);
@@ -5248,7 +5247,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage, target);
// Calculate armor mitigation
if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), GetEffIndex()))
if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), &GetSpellEffectInfo()))
{
uint32 damageReducedArmor = Unit::CalcArmorReducedDamage(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetAttackType(), GetBase()->GetCasterLevel());
cleanDamage.mitigated_damage += damage - damageReducedArmor;
@@ -5257,7 +5256,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
{
if (GetSpellEffectInfo()->IsTargetingArea() || GetSpellEffectInfo()->IsAreaAuraEffect() || GetSpellEffectInfo()->Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
if (GetSpellEffectInfo().IsTargetingArea() || GetSpellEffectInfo().IsAreaAuraEffect() || GetSpellEffectInfo().IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
damage = target->CalculateAOEAvoidance(damage, m_spellInfo->SchoolMask, GetBase()->GetCasterGUID());
}
@@ -5302,7 +5301,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
bool AuraEffect::IsAreaAuraEffect() const
{
return GetSpellEffectInfo()->IsAreaAuraEffect();
return GetSpellEffectInfo().IsAreaAuraEffect();
}
void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) const
@@ -5317,13 +5316,13 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
}
// dynobj auras must always have a caster
if (GetSpellEffectInfo()->Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
if (GetSpellEffectInfo().IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA) &&
ASSERT_NOTNULL(caster)->SpellHitResult(target, GetSpellInfo(), false) != SPELL_MISS_NONE)
return;
CleanDamage cleanDamage = CleanDamage(0, 0, GetSpellInfo()->GetAttackType(), MELEE_HIT_NORMAL);
uint32 stackAmountForBonuses = !GetSpellEffectInfo()->EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
uint32 stackAmountForBonuses = !GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
// ignore negative values (can be result apply spellmods to aura damage
uint32 damage = std::max(GetAmount(), 0);
@@ -5337,7 +5336,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage, target);
// Calculate armor mitigation
if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), GetEffIndex()))
if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), &GetSpellEffectInfo()))
{
uint32 damageReducedArmor = Unit::CalcArmorReducedDamage(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetAttackType(), GetBase()->GetCasterLevel());
cleanDamage.mitigated_damage += damage - damageReducedArmor;
@@ -5346,7 +5345,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
{
if (GetSpellEffectInfo()->IsTargetingArea() || GetSpellEffectInfo()->IsAreaAuraEffect() || GetSpellEffectInfo()->Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
if (GetSpellEffectInfo().IsTargetingArea() || GetSpellEffectInfo().IsAreaAuraEffect() || GetSpellEffectInfo().IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
damage = target->CalculateAOEAvoidance(damage, m_spellInfo->SchoolMask, GetBase()->GetCasterGUID());
}
@@ -5390,7 +5389,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
if (!caster || !caster->IsAlive())
return;
float gainMultiplier = GetSpellEffectInfo()->CalcValueMultiplier(caster);
float gainMultiplier = GetSpellEffectInfo().CalcValueMultiplier(caster);
uint32 heal = caster->SpellHealingBonusDone(caster, GetSpellInfo(), uint32(new_damage * gainMultiplier), DOT, GetSpellEffectInfo(), stackAmountForBonuses);
heal = caster->SpellHealingBonusTaken(caster, GetSpellInfo(), heal, DOT);
@@ -5425,7 +5424,7 @@ void AuraEffect::HandlePeriodicHealthFunnelAuraTick(Unit* target, Unit* caster)
caster->ModifyHealth(-(int32)damage);
TC_LOG_DEBUG("spells", "PeriodicTick: donator %u target %u damage %u.", caster->GetEntry(), target->GetEntry(), damage);
float gainMultiplier = GetSpellEffectInfo()->CalcValueMultiplier(caster);
float gainMultiplier = GetSpellEffectInfo().CalcValueMultiplier(caster);
damage = int32(damage * gainMultiplier);
@@ -5453,7 +5452,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
if (GetBase()->IsPermanent() && target->IsFullHealth())
return;
uint32 stackAmountForBonuses = !GetSpellEffectInfo()->EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
uint32 stackAmountForBonuses = !GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack) ? GetBase()->GetStackAmount() : 1;
// ignore negative values (can be result apply spellmods to aura damage
uint32 damage = std::max(GetAmount(), 0);
@@ -5509,7 +5508,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con
return;
}
if (GetSpellEffectInfo()->Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
if (GetSpellEffectInfo().IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA) &&
caster->SpellHitResult(target, GetSpellInfo(), false) != SPELL_MISS_NONE)
return;
@@ -5521,7 +5520,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con
int32 drainedAmount = -target->ModifyPower(powerType, -drainAmount);
float gainMultiplier = GetSpellEffectInfo()->CalcValueMultiplier(caster);
float gainMultiplier = GetSpellEffectInfo().CalcValueMultiplier(caster);
SpellPeriodicAuraLogInfo pInfo(this, drainedAmount, drainAmount, 0, 0, 0, gainMultiplier, false);
@@ -5638,7 +5637,7 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con
uint32 gain = uint32(-target->ModifyPower(powerType, -damage));
float dmgMultiplier = GetSpellEffectInfo()->CalcValueMultiplier(caster);
float dmgMultiplier = GetSpellEffectInfo().CalcValueMultiplier(caster);
SpellInfo const* spellProto = GetSpellInfo();
// maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
@@ -5703,7 +5702,7 @@ void AuraEffect::HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEve
Unit* triggerCaster = aurApp->GetTarget();
Unit* triggerTarget = eventInfo.GetProcTarget();
uint32 triggerSpellId = GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpellId = GetSpellEffectInfo().TriggerSpell;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId, GetBase()->GetCastDifficulty()))
{
TC_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerSpellAuraProc: Triggering spell %u from aura %u proc", triggeredSpellInfo->Id, GetId());
@@ -5718,7 +5717,7 @@ void AuraEffect::HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp
Unit* triggerCaster = aurApp->GetTarget();
Unit* triggerTarget = eventInfo.GetProcTarget();
uint32 triggerSpellId = GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpellId = GetSpellEffectInfo().TriggerSpell;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId, GetBase()->GetCastDifficulty()))
{
CastSpellExtraArgs args(this);
@@ -5801,9 +5800,9 @@ void AuraEffect::HandleShowConfirmationPrompt(AuraApplication const* aurApp, uin
return;
if (apply)
player->AddTemporarySpell(GetSpellEffectInfo()->TriggerSpell);
player->AddTemporarySpell(GetSpellEffectInfo().TriggerSpell);
else
player->RemoveTemporarySpell(GetSpellEffectInfo()->TriggerSpell);
player->RemoveTemporarySpell(GetSpellEffectInfo().TriggerSpell);
}
void AuraEffect::HandleOverridePetSpecs(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -5897,7 +5896,7 @@ void AuraEffect::HandleLinkedSummon(AuraApplication const* aurApp, uint8 mode, b
return;
Unit* target = aurApp->GetTarget();
SpellInfo const* triggerSpellInfo = sSpellMgr->GetSpellInfo(GetSpellEffectInfo()->TriggerSpell, GetBase()->GetCastDifficulty());
SpellInfo const* triggerSpellInfo = sSpellMgr->GetSpellInfo(GetSpellEffectInfo().TriggerSpell, GetBase()->GetCastDifficulty());
if (!triggerSpellInfo)
return;
@@ -5914,9 +5913,9 @@ void AuraEffect::HandleLinkedSummon(AuraApplication const* aurApp, uint8 mode, b
else
{
std::vector<uint32> summonedEntries;
for (auto spellEffect : triggerSpellInfo->GetEffects())
if (spellEffect && spellEffect->Effect == SPELL_EFFECT_SUMMON)
if (uint32 summonEntry = spellEffect->MiscValue)
for (SpellEffectInfo const& spellEffect : triggerSpellInfo->GetEffects())
if (spellEffect.IsEffect(SPELL_EFFECT_SUMMON))
if (uint32 summonEntry = spellEffect.MiscValue)
summonedEntries.push_back(summonEntry);
// we don't know if there can be multiple summons for the same effect, so consider only 1 summon for each effect
+10 -10
View File
@@ -33,7 +33,7 @@ class TC_GAME_API AuraEffect
private:
~AuraEffect();
explicit AuraEffect(Aura* base, SpellEffectInfo const* spellEfffectInfo, int32 const* baseAmount, Unit* caster);
explicit AuraEffect(Aura* base, SpellEffectInfo const& spellEfffectInfo, int32 const* baseAmount, Unit* caster);
public:
Unit* GetCaster() const { return GetBase()->GetCaster(); }
@@ -48,13 +48,13 @@ class TC_GAME_API AuraEffect
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
uint32 GetId() const { return m_spellInfo->Id; }
uint32 GetEffIndex() const { return m_effectInfo->EffectIndex; }
SpellEffIndex GetEffIndex() const { return m_effectInfo.EffectIndex; }
int32 GetBaseAmount() const { return m_baseAmount; }
int32 GetPeriod() const { return _period; }
int32 GetMiscValueB() const { return GetSpellEffectInfo()->MiscValueB; }
int32 GetMiscValue() const { return GetSpellEffectInfo()->MiscValue; }
AuraType GetAuraType() const { return (AuraType)GetSpellEffectInfo()->ApplyAuraName; }
int32 GetMiscValueB() const { return GetSpellEffectInfo().MiscValueB; }
int32 GetMiscValue() const { return GetSpellEffectInfo().MiscValue; }
AuraType GetAuraType() const { return GetSpellEffectInfo().ApplyAuraName; }
int32 GetAmount() const { return _amount; }
void SetAmount(int32 amount) { _amount = amount; m_canBeRecalculated = false; }
@@ -86,7 +86,7 @@ class TC_GAME_API AuraEffect
bool IsPeriodic() const { return m_isPeriodic; }
void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; }
bool IsAffectingSpell(SpellInfo const* spell) const;
bool HasSpellClassMask() const { return GetSpellEffectInfo()->SpellClassMask; }
bool HasSpellClassMask() const { return GetSpellEffectInfo().SpellClassMask; }
void SendTickImmune(Unit* target, Unit* caster) const;
void PeriodicTick(AuraApplication* aurApp, Unit* caster) const;
@@ -97,17 +97,17 @@ class TC_GAME_API AuraEffect
// add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras
void HandleShapeshiftBoosts(Unit* target, bool apply) const;
SpellEffectInfo const* GetSpellEffectInfo() const { return m_effectInfo; }
SpellEffectInfo const& GetSpellEffectInfo() const { return m_effectInfo; }
bool IsEffect() const { return m_effectInfo->Effect != 0; }
bool IsEffect(SpellEffectName effectName) const { return m_effectInfo->Effect == uint32(effectName); }
bool IsEffect() const { return m_effectInfo.Effect != 0; }
bool IsEffect(SpellEffectName effectName) const { return m_effectInfo.Effect == effectName; }
bool IsAreaAuraEffect() const;
private:
Aura* const m_base;
SpellInfo const* const m_spellInfo;
SpellEffectInfo const* m_effectInfo;
SpellEffectInfo const& m_effectInfo;
SpellModifier* m_spellmod;
+75 -70
View File
@@ -115,9 +115,9 @@ void AuraApplication::_InitFlags(Unit* caster, uint32 effMask)
if (IsSelfcast() || !caster || !caster->IsFriendlyTo(GetTarget()))
{
bool negativeFound = false;
for (SpellEffectInfo const* effect : GetBase()->GetSpellInfo()->GetEffects())
for (uint8 i = 0; i < GetBase()->GetSpellInfo()->GetEffects().size(); ++i)
{
if (effect && ((1 << effect->EffectIndex) & effMask) && !GetBase()->GetSpellInfo()->IsPositiveEffect(effect->EffectIndex))
if (((1 << i) & effMask) && !GetBase()->GetSpellInfo()->IsPositiveEffect(i))
{
negativeFound = true;
break;
@@ -130,9 +130,9 @@ void AuraApplication::_InitFlags(Unit* caster, uint32 effMask)
else
{
bool positiveFound = false;
for (SpellEffectInfo const* effect : GetBase()->GetSpellInfo()->GetEffects())
for (uint8 i = 0; i < GetBase()->GetSpellInfo()->GetEffects().size(); ++i)
{
if (effect && ((1 << effect->EffectIndex) & effMask) && GetBase()->GetSpellInfo()->IsPositiveEffect(effect->EffectIndex))
if (((1 << i) & effMask) && GetBase()->GetSpellInfo()->IsPositiveEffect(i))
{
positiveFound = true;
break;
@@ -300,17 +300,17 @@ uint32 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint32 availab
{
case TYPEID_UNIT:
case TYPEID_PLAYER:
for (SpellEffectInfo const* effect : spellProto->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellProto->GetEffects())
{
if (effect && effect->IsUnitOwnedAuraEffect())
effMask |= 1 << effect->EffectIndex;
if (spellEffectInfo.IsUnitOwnedAuraEffect())
effMask |= 1 << spellEffectInfo.EffectIndex;
}
break;
case TYPEID_DYNAMICOBJECT:
for (SpellEffectInfo const* effect : spellProto->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellProto->GetEffects())
{
if (effect && effect->Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
effMask |= 1 << effect->EffectIndex;
if (spellEffectInfo.IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
effMask |= 1 << spellEffectInfo.EffectIndex;
}
break;
default:
@@ -482,9 +482,9 @@ void Aura::_InitEffects(uint32 effMask, Unit* caster, int32 const* baseAmount)
// shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism
_effects.resize(GetSpellInfo()->GetEffects().size());
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
if (effect && effMask & (1 << effect->EffectIndex))
_effects[effect->EffectIndex] = new AuraEffect(this, effect, baseAmount ? baseAmount + effect->EffectIndex : nullptr, caster);
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
if (effMask & (1 << spellEffectInfo.EffectIndex))
_effects[spellEffectInfo.EffectIndex] = new AuraEffect(this, spellEffectInfo, baseAmount ? baseAmount + spellEffectInfo.EffectIndex : nullptr, caster);
}
Aura::~Aura()
@@ -643,9 +643,9 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
{
bool addUnit = true;
// check target immunities
for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex, caster))
itr->second &= ~(1 << effIndex);
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), spellEffectInfo, caster))
itr->second &= ~(1 << spellEffectInfo.EffectIndex);
if (!itr->second || itr->first->IsImmunedToSpell(GetSpellInfo(), caster) || !CanBeAppliedOn(itr->first))
addUnit = false;
@@ -1071,8 +1071,8 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode /*= AURA_REMOVE_B
bool Aura::HasMoreThanOneEffectForType(AuraType auraType) const
{
uint32 count = 0;
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
if (effect && HasEffect(effect->EffectIndex) && AuraType(effect->ApplyAuraName) == auraType)
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
if (HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.ApplyAuraName == auraType)
++count;
return count > 1;
@@ -1080,8 +1080,8 @@ bool Aura::HasMoreThanOneEffectForType(AuraType auraType) const
bool Aura::IsArea() const
{
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
if (effect && HasEffect(effect->EffectIndex) && effect->IsAreaAuraEffect())
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
if (HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.IsAreaAuraEffect())
return true;
return false;
@@ -1117,12 +1117,12 @@ bool Aura::CanBeSaved() const
if (GetCasterGUID() != GetOwner()->GetGUID())
{
// owner == caster for area auras, check for possible bad data in DB
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
{
if (!effect || !effect->IsEffect())
if (!spellEffectInfo.IsEffect())
continue;
if (effect->IsTargetingArea() || effect->IsAreaAuraEffect())
if (spellEffectInfo.IsTargetingArea() || spellEffectInfo.IsAreaAuraEffect())
return false;
}
@@ -1568,17 +1568,17 @@ bool Aura::CanStackWith(Aura const* existingAura) const
if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))
return false;
for (SpellEffectInfo const* effect : existingSpellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : existingSpellInfo->GetEffects())
{
// prevent remove triggering aura by triggered aura
if (effect && effect->TriggerSpell == GetId())
if (spellEffectInfo.TriggerSpell == GetId())
return true;
}
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
{
// prevent remove triggered aura by triggering aura refresh
if (effect && effect->TriggerSpell == existingAura->GetId())
if (spellEffectInfo.TriggerSpell == existingAura->GetId())
return true;
}
@@ -1625,36 +1625,39 @@ bool Aura::CanStackWith(Aura const* existingAura) const
return true;
// check same periodic auras
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
auto hasPeriodicNonAreaEffect = [](SpellInfo const* spellInfo)
{
SpellEffectInfo const* effect = m_spellInfo->GetEffect(i);
if (!effect)
continue;
switch (effect->ApplyAuraName)
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
// DOT or HOT from different casters will stack
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_DUMMY:
case SPELL_AURA_PERIODIC_HEAL:
case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
case SPELL_AURA_PERIODIC_ENERGIZE:
case SPELL_AURA_PERIODIC_MANA_LEECH:
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_POWER_BURN:
case SPELL_AURA_OBS_MOD_POWER:
case SPELL_AURA_OBS_MOD_HEALTH:
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
{
SpellEffectInfo const* existingEffect = m_spellInfo->GetEffect(i);
switch (spellEffectInfo.ApplyAuraName)
{
// DOT or HOT from different casters will stack
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_WEAPON_PERCENT_DAMAGE:
case SPELL_AURA_PERIODIC_DUMMY:
case SPELL_AURA_PERIODIC_HEAL:
case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
case SPELL_AURA_PERIODIC_ENERGIZE:
case SPELL_AURA_PERIODIC_MANA_LEECH:
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_POWER_BURN:
case SPELL_AURA_OBS_MOD_POWER:
case SPELL_AURA_OBS_MOD_HEALTH:
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
// periodic auras which target areas are not allowed to stack this way (replenishment for example)
if (effect->IsTargetingArea() || (existingEffect && existingEffect->IsTargetingArea()))
break;
}
return true;
default:
break;
if (spellEffectInfo.IsTargetingArea())
return false;
return true;
default:
break;
}
}
}
return false;
};
if (hasPeriodicNonAreaEffect(m_spellInfo) && hasPeriodicNonAreaEffect(existingSpellInfo))
return true;
}
if (HasEffectType(SPELL_AURA_CONTROL_VEHICLE) && existingAura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE))
@@ -2382,13 +2385,13 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit* c
if (Unit* target = ObjectAccessor::GetUnit(*GetUnitOwner(), targetPair.first))
targets.emplace(target, targetPair.second);
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
{
if (!effect || !HasEffect(effect->EffectIndex))
if (!HasEffect(spellEffectInfo.EffectIndex))
continue;
// area auras only
if (effect->Effect == SPELL_EFFECT_APPLY_AURA)
if (spellEffectInfo.IsEffect(SPELL_EFFECT_APPLY_AURA))
continue;
// skip area update if owner is not in world!
@@ -2399,11 +2402,11 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit* c
continue;
std::vector<Unit*> units;
ConditionContainer* condList = effect->ImplicitTargetConditions;
ConditionContainer* condList = spellEffectInfo.ImplicitTargetConditions;
float radius = effect->CalcRadius(ref);
float radius = spellEffectInfo.CalcRadius(ref);
SpellTargetCheckTypes selectionType = TARGET_CHECK_DEFAULT;
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY_NONRANDOM:
@@ -2445,6 +2448,8 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit* c
selectionType = TARGET_CHECK_SUMMONED;
break;
}
default:
break;
}
if (selectionType != TARGET_CHECK_DEFAULT)
@@ -2458,17 +2463,17 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit* c
}
for (Unit* unit : units)
targets[unit] |= 1 << effect->EffectIndex;
targets[unit] |= 1 << spellEffectInfo.EffectIndex;
}
}
void UnitAura::AddStaticApplication(Unit* target, uint32 effMask)
{
// only valid for non-area auras
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
{
if (effect && (effMask & (1 << effect->EffectIndex)) && effect->Effect != SPELL_EFFECT_APPLY_AURA)
effMask &= ~(1 << effect->EffectIndex);
if ((effMask & (1 << spellEffectInfo.EffectIndex)) && !spellEffectInfo.IsEffect(SPELL_EFFECT_APPLY_AURA))
effMask &= ~(1 << spellEffectInfo.EffectIndex);
}
if (!effMask)
@@ -2500,18 +2505,18 @@ void DynObjAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit*
Unit* dynObjOwnerCaster = GetDynobjOwner()->GetCaster();
float radius = GetDynobjOwner()->GetRadius();
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
{
if (!effect || !HasEffect(effect->EffectIndex))
if (!HasEffect(spellEffectInfo.EffectIndex))
continue;
// we can't use effect type like area auras to determine check type, check targets
SpellTargetCheckTypes selectionType = effect->TargetA.GetCheckType();
if (effect->TargetB.GetReferenceType() == TARGET_REFERENCE_TYPE_DEST)
selectionType = effect->TargetB.GetCheckType();
SpellTargetCheckTypes selectionType = spellEffectInfo.TargetA.GetCheckType();
if (spellEffectInfo.TargetB.GetReferenceType() == TARGET_REFERENCE_TYPE_DEST)
selectionType = spellEffectInfo.TargetB.GetCheckType();
std::vector<Unit*> units;
ConditionContainer* condList = effect->ImplicitTargetConditions;
ConditionContainer* condList = spellEffectInfo.ImplicitTargetConditions;
Trinity::WorldObjectSpellAreaTargetCheck check(radius, GetDynobjOwner(), dynObjOwnerCaster, dynObjOwnerCaster, m_spellInfo, selectionType, condList, TARGET_OBJECT_TYPE_UNIT);
Trinity::UnitListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> searcher(GetDynobjOwner(), units, check);
@@ -2521,6 +2526,6 @@ void DynObjAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit*
units.erase(std::remove_if(units.begin(), units.end(), [this](Unit* unit) { return !unit->IsSelfOrInSameMap(GetDynobjOwner()); }), units.end());
for (Unit* unit : units)
targets[unit] |= 1 << effect->EffectIndex;
targets[unit] |= 1 << spellEffectInfo.EffectIndex;
}
}
File diff suppressed because it is too large Load Diff
+25 -25
View File
@@ -515,21 +515,21 @@ class TC_GAME_API Spell
void SelectExplicitTargets();
void SelectSpellTargets();
void SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32& processedEffectMask);
void SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void SelectImplicitTargetDestTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void SelectImplicitDestDestTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void SelectImplicitTargetObjectTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, WorldObject* target, uint32 effMask);
void SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void SelectImplicitLineTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectEffectImplicitTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType, uint32& processedEffectMask);
void SelectImplicitChannelTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType);
void SelectImplicitNearbyTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectImplicitConeTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectImplicitAreaTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType);
void SelectImplicitTargetDestTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType);
void SelectImplicitDestDestTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType);
void SelectImplicitCasterObjectTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType);
void SelectImplicitTargetObjectTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType);
void SelectImplicitChainTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType, WorldObject* target, uint32 effMask);
void SelectImplicitTrajTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType);
void SelectImplicitLineTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType, uint32 effMask);
void SelectEffectTypeImplicitTargets(uint32 effIndex);
void SelectEffectTypeImplicitTargets(SpellEffectInfo const& spellEffectInfo);
uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer* condList);
template<class SEARCHER> void SearchTargets(SEARCHER& searcher, uint32 containerMask, WorldObject* referer, Position const* pos, float radius);
@@ -577,7 +577,7 @@ class TC_GAME_API Spell
bool CheckSpellCancelsConfuse(uint32* param1) const;
bool CheckSpellCancelsNoActions(uint32* param1) const;
int32 CalculateDamage(uint8 effIndex, Unit const* target, float* var = nullptr) const;
int32 CalculateDamage(SpellEffectInfo const& spellEffectInfo, Unit const* target, float* var = nullptr) const;
void Delayed();
void DelayedChannel();
@@ -586,9 +586,9 @@ class TC_GAME_API Spell
void DoCreateItem(uint32 itemId, ItemContext context = ItemContext::NONE, std::vector<int32> const& bonusListIDs = std::vector<int32>());
bool CheckEffectTarget(Unit const* target, SpellEffectInfo const* effect, Position const* losPosition) const;
bool CheckEffectTarget(GameObject const* target, SpellEffectInfo const* effect) const;
bool CheckEffectTarget(Item const* target, SpellEffectInfo const* effect) const;
bool CheckEffectTarget(Unit const* target, SpellEffectInfo const& spellEffectInfo, Position const* losPosition) const;
bool CheckEffectTarget(GameObject const* target, SpellEffectInfo const& spellEffectInfo) const;
bool CheckEffectTarget(Item const* target, SpellEffectInfo const& spellEffectInfo) const;
bool CanAutoCast(Unit* target);
void CheckSrc();
void CheckDst();
@@ -626,7 +626,7 @@ class TC_GAME_API Spell
void SendChannelStart(uint32 duration);
void SendResurrectRequest(Player* target);
void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, SpellEffectHandleMode mode);
void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, SpellEffectInfo const& spellEffectInfo, SpellEffectHandleMode mode);
void HandleThreatSpells();
static Spell const* ExtractSpellFromEvent(BasicEvent* event);
@@ -818,7 +818,7 @@ class TC_GAME_API Spell
struct TargetInfoBase
{
virtual void PreprocessTarget(Spell* /*spell*/) { }
virtual void DoTargetSpellHit(Spell* spell, uint8 effIndex) = 0;
virtual void DoTargetSpellHit(Spell* spell, SpellEffectInfo const& spellEffectInfo) = 0;
virtual void DoDamageAndTriggers(Spell* /*spell*/) { }
uint32 EffectMask = 0;
@@ -831,7 +831,7 @@ class TC_GAME_API Spell
struct TargetInfo : public TargetInfoBase
{
void PreprocessTarget(Spell* spell) override;
void DoTargetSpellHit(Spell* spell, uint8 effIndex) override;
void DoTargetSpellHit(Spell* spell, SpellEffectInfo const& spellEffectInfo) override;
void DoDamageAndTriggers(Spell* spell) override;
ObjectGuid TargetGUID;
@@ -860,7 +860,7 @@ class TC_GAME_API Spell
struct GOTargetInfo : public TargetInfoBase
{
void DoTargetSpellHit(Spell* spell, uint8 effIndex) override;
void DoTargetSpellHit(Spell* spell, SpellEffectInfo const& spellEffectInfo) override;
ObjectGuid TargetGUID;
uint64 TimeDelay = 0ULL;
@@ -869,7 +869,7 @@ class TC_GAME_API Spell
struct ItemTargetInfo : public TargetInfoBase
{
void DoTargetSpellHit(Spell* spell, uint8 effIndex) override;
void DoTargetSpellHit(Spell* spell, SpellEffectInfo const& spellEffectInfo) override;
Item* TargetItem = nullptr;
};
@@ -886,13 +886,13 @@ class TC_GAME_API Spell
void AddDestTarget(SpellDestination const& dest, uint32 effIndex);
SpellMissInfo PreprocessSpellHit(Unit* unit, TargetInfo& targetInfo);
void DoSpellEffectHit(Unit* unit, uint8 effIndex, TargetInfo& targetInfo);
void DoSpellEffectHit(Unit* unit, SpellEffectInfo const& spellEffectInfo, TargetInfo& targetInfo);
void DoTriggersOnSpellHit(Unit* unit, uint32 effMask);
bool UpdateChanneledTargetList();
bool IsValidDeadOrAliveTarget(Unit const* target) const;
void HandleLaunchPhase();
void DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, SpellEffectInfo const* effect);
void DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, SpellEffectInfo const& spellEffectInfo);
void PrepareTargetProcessing();
void FinishTargetProcessing();
+24 -31
View File
@@ -527,7 +527,7 @@ void Spell::EffectSchoolDMG()
if (unitCaster && apply_direct_bonus)
{
uint32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE, effectInfo);
uint32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE, *effectInfo);
damage = bonus + uint32(bonus * variance);
damage = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE);
}
@@ -1061,7 +1061,7 @@ void Spell::EffectPowerDrain()
// add spell damage bonus
if (unitCaster)
{
uint32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE, effectInfo);
uint32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE, *effectInfo);
damage = bonus + uint32(bonus * variance);
damage = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE);
}
@@ -1183,10 +1183,10 @@ void Spell::EffectHeal()
}
// Death Pact - return pct of max health to caster
else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && m_spellInfo->SpellFamilyFlags[0] & 0x00080000)
addhealth = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, int32(unitCaster->CountPctFromMaxHealth(damage)), HEAL, effectInfo);
addhealth = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, int32(unitCaster->CountPctFromMaxHealth(damage)), HEAL, *effectInfo);
else
{
uint32 bonus = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL, effectInfo);
uint32 bonus = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL, *effectInfo);
addhealth = bonus + uint32(bonus * variance);
}
@@ -1210,7 +1210,7 @@ void Spell::EffectHealPct()
uint32 heal = unitTarget->CountPctFromMaxHealth(damage);
if (unitCaster)
{
heal = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, heal, HEAL, effectInfo);
heal = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, heal, HEAL, *effectInfo);
heal = unitTarget->SpellHealingBonusTaken(unitCaster, m_spellInfo, heal, HEAL);
}
@@ -1227,7 +1227,7 @@ void Spell::EffectHealMechanical()
uint32 heal = damage;
if (unitCaster)
heal = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, heal, HEAL, effectInfo);
heal = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, heal, HEAL, *effectInfo);
heal += uint32(heal * variance);
if (unitCaster)
@@ -1246,7 +1246,7 @@ void Spell::EffectHealthLeech()
uint32 bonus = 0;
if (unitCaster)
bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE, effectInfo);
bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE, *effectInfo);
damage = bonus + uint32(bonus * variance);
@@ -1263,7 +1263,7 @@ void Spell::EffectHealthLeech()
if (unitCaster && unitCaster->IsAlive())
{
healthGain = unitCaster->SpellHealingBonusDone(unitCaster, m_spellInfo, healthGain, HEAL, effectInfo);
healthGain = unitCaster->SpellHealingBonusDone(unitCaster, m_spellInfo, healthGain, HEAL, *effectInfo);
healthGain = unitCaster->SpellHealingBonusTaken(unitCaster, m_spellInfo, healthGain, HEAL);
HealInfo healInfo(unitCaster, unitCaster, healthGain, m_spellInfo, m_spellSchoolMask);
@@ -1445,10 +1445,9 @@ void Spell::EffectPersistentAA()
return;
// only handle at last effect
for (uint8 i = effectInfo->EffectIndex + 1; i < MAX_SPELL_EFFECTS; ++i)
if (SpellEffectInfo const* otherEffect = m_spellInfo->GetEffect(i))
if (otherEffect && otherEffect->IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
return;
for (size_t i = effectInfo->EffectIndex + 1; i < m_spellInfo->GetEffects().size(); ++i)
if (m_spellInfo->GetEffect(SpellEffIndex(i)).IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
return;
ASSERT(!_dynObjAura);
@@ -2765,17 +2764,15 @@ void Spell::EffectWeaponDmg()
// and handle all effects at once
for (size_t j = effectInfo->EffectIndex + 1; j < m_spellInfo->GetEffects().size(); ++j)
{
SpellEffectInfo const* effect = m_spellInfo->GetEffect(j);
if (!effect)
continue;
switch (effect->Effect)
switch (m_spellInfo->GetEffect(SpellEffIndex(j)).Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
return; // we must calculate only at last weapon effect
break;
default:
break;
}
}
@@ -2798,22 +2795,20 @@ void Spell::EffectWeaponDmg()
bool normalized = false;
float weaponDamagePercentMod = 1.0f;
for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
{
if (!effect)
continue;
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
fixed_bonus += CalculateDamage(effect->EffectIndex, unitTarget);
fixed_bonus += CalculateDamage(spellEffectInfo, unitTarget);
break;
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
fixed_bonus += CalculateDamage(effect->EffectIndex, unitTarget);
fixed_bonus += CalculateDamage(spellEffectInfo, unitTarget);
normalized = true;
break;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
ApplyPct(weaponDamagePercentMod, CalculateDamage(effect->EffectIndex, unitTarget));
ApplyPct(weaponDamagePercentMod, CalculateDamage(spellEffectInfo, unitTarget));
break;
default:
break; // not weapon damage effect, just skip
@@ -2844,13 +2839,11 @@ void Spell::EffectWeaponDmg()
int32 weaponDamage = unitCaster->CalculateDamage(m_attackType, normalized, addPctMods);
// Sequence is important
for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
{
if (!effect)
continue;
// We assume that a spell have at most one fixed_bonus
// and at most one weaponDamagePercentMod
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
@@ -3276,8 +3269,8 @@ void Spell::EffectScriptEffect()
return;
// Effects for 58418 and 58420 are all DIFFICULTY_NONE so always valid
uint32 spellID = m_spellInfo->GetEffect(EFFECT_0)->CalcValue();
uint32 questID = m_spellInfo->GetEffect(EFFECT_1)->CalcValue();
uint32 spellID = m_spellInfo->GetEffect(EFFECT_0).CalcValue();
uint32 questID = m_spellInfo->GetEffect(EFFECT_1).CalcValue();
if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE)
unitTarget->CastSpell(unitTarget, spellID, true);
@@ -3312,7 +3305,7 @@ void Spell::EffectScriptEffect()
{
/// @todo a hack, range = 11, should after some time cast, otherwise too far
unitCaster->CastSpell(parent, 62496, true);
unitTarget->CastSpell(parent, m_spellInfo->GetEffect(EFFECT_0)->CalcValue()); // DIFFICULTY_NONE, so effect always valid
unitTarget->CastSpell(parent, damage); // DIFFICULTY_NONE, so effect always valid
}
}
}
File diff suppressed because it is too large Load Diff
+15 -18
View File
@@ -27,18 +27,18 @@
#include <boost/container/flat_set.hpp>
#include <bitset>
class Unit;
class Player;
class AuraEffect;
class Item;
class Player;
class Spell;
class SpellMgr;
class SpellInfo;
class Unit;
class WorldObject;
class AuraEffect;
struct Condition;
struct SpellChainNode;
struct SpellModifier;
struct SpellTargetPosition;
struct Condition;
enum WeaponAttackType : uint8;
enum SpellCastTargetFlags : uint32
@@ -262,11 +262,12 @@ struct TC_GAME_API ImmunityInfo
class TC_GAME_API SpellEffectInfo
{
friend class SpellInfo;
SpellInfo const* _spellInfo;
public:
uint32 EffectIndex;
uint32 Effect;
uint32 ApplyAuraName;
SpellEffIndex EffectIndex;
SpellEffectName Effect;
AuraType ApplyAuraName;
uint32 ApplyAuraPeriod;
int32 BasePoints;
float RealPointsPerLevel;
@@ -298,7 +299,7 @@ public:
float ResourceCoefficient;
} Scaling;
SpellEffectInfo() : _spellInfo(nullptr), EffectIndex(0), Effect(0), ApplyAuraName(0), ApplyAuraPeriod(0),
SpellEffectInfo(SpellInfo const* spellInfo) : _spellInfo(spellInfo), EffectIndex(EFFECT_0), Effect(SPELL_EFFECT_NONE), ApplyAuraName(AuraType(0)), ApplyAuraPeriod(0),
BasePoints(0), RealPointsPerLevel(0), PointsPerResource(0), Amplitude(0), ChainAmplitude(0),
BonusCoefficient(0), MiscValue(0), MiscValueB(0), Mechanic(MECHANIC_NONE), PositionFacing(0),
RadiusEntry(nullptr), MaxRadiusEntry(nullptr), ChainTargets(0), ItemType(0), TriggerSpell(0),
@@ -346,8 +347,6 @@ private:
ImmunityInfo _immunityInfo;
};
typedef std::vector<SpellEffectInfo const*> SpellEffectInfoVector;
typedef std::vector<SpellXSpellVisualEntry const*> SpellVisualVector;
typedef std::unordered_map<uint32, SpellVisualVector> SpellVisualMap;
@@ -571,10 +570,9 @@ class TC_GAME_API SpellInfo
SpellSchoolMask GetSchoolMask() const;
uint32 GetAllEffectsMechanicMask() const;
uint32 GetEffectMechanicMask(uint32 effIndex) const;
uint32 GetEffectMechanicMask(SpellEffIndex effIndex) const;
uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
Mechanics GetEffectMechanic(uint32 effIndex) const;
//bool HasAnyEffectMechanic() const;
Mechanics GetEffectMechanic(SpellEffIndex effIndex) const;
uint32 GetDispelMask() const;
static uint32 GetDispelMask(DispelType type);
uint32 GetExplicitTargetMask() const;
@@ -614,8 +612,8 @@ class TC_GAME_API SpellInfo
uint32 GetSpellXSpellVisualId(WorldObject const* caster = nullptr) const;
uint32 GetSpellVisual(WorldObject const* caster = nullptr) const;
SpellEffectInfoVector const& GetEffects() const { return _effects; }
SpellEffectInfo const* GetEffect(uint32 index) const { return index < _effects.size() ? _effects[index] : nullptr; }
std::vector<SpellEffectInfo> const& GetEffects() const { return _effects; }
SpellEffectInfo const& GetEffect(SpellEffIndex index) const { ASSERT(index < _effects.size()); return _effects[index]; }
// spell diminishing returns
DiminishingGroup GetDiminishingReturnsGroupForSpell() const;
@@ -624,7 +622,7 @@ class TC_GAME_API SpellInfo
int32 GetDiminishingReturnsLimitDuration() const;
// spell immunities
void ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const* effect, bool apply) const;
void ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& spellEffectInfo, bool apply) const;
bool CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInfo) const;
bool SpellCancelsAuraEffect(AuraEffect const* aurEff) const;
@@ -646,10 +644,9 @@ class TC_GAME_API SpellInfo
// unloading helpers
void _UnloadImplicitTargetConditionLists();
void _UnloadSpellEffects();
private:
SpellEffectInfoVector _effects;
std::vector<SpellEffectInfo> _effects;
SpellVisualVector _visuals;
SpellSpecificType _spellSpecific = SPELL_SPECIFIC_NORMAL;
AuraStateType _auraState = AURA_STATE_NONE;
+148 -159
View File
@@ -146,21 +146,15 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg
bool needCheckReagents = false;
// check effects
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effect)
continue;
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case 0:
continue;
// craft spell for crafting non-existed item (break client recipes list show)
case SPELL_EFFECT_CREATE_ITEM:
case SPELL_EFFECT_CREATE_LOOT:
{
if (effect->ItemType == 0)
if (spellEffectInfo.ItemType == 0)
{
// skip auto-loot crafting spells, it does not need explicit item info (but has special fake items sometimes).
if (!spellInfo->IsLootCrafting())
@@ -177,14 +171,14 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg
}
// also possible IsLootCrafting case but fake items must exist anyway
else if (!sObjectMgr->GetItemTemplate(effect->ItemType))
else if (!sObjectMgr->GetItemTemplate(spellEffectInfo.ItemType))
{
if (msg)
{
if (player)
ChatHandler(player->GetSession()).PSendSysMessage("Craft spell %u has created a non-existing in DB item (Entry: %u) and then...", spellInfo->Id, effect->ItemType);
ChatHandler(player->GetSession()).PSendSysMessage("Craft spell %u has created a non-existing in DB item (Entry: %u) and then...", spellInfo->Id, spellEffectInfo.ItemType);
else
TC_LOG_ERROR("sql.sql", "Craft spell %u has created a non-existing item in DB item (Entry: %u) and then...", spellInfo->Id, effect->ItemType);
TC_LOG_ERROR("sql.sql", "Craft spell %u has created a non-existing item in DB item (Entry: %u) and then...", spellInfo->Id, spellEffectInfo.ItemType);
}
return false;
}
@@ -194,20 +188,22 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg
}
case SPELL_EFFECT_LEARN_SPELL:
{
SpellInfo const* spellInfo2 = sSpellMgr->GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE);
SpellInfo const* spellInfo2 = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
if (!IsSpellValid(spellInfo2, player, msg))
{
if (msg)
{
if (player)
ChatHandler(player->GetSession()).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, effect->TriggerSpell);
ChatHandler(player->GetSession()).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellEffectInfo.TriggerSpell);
else
TC_LOG_ERROR("sql.sql", "Spell %u learn to invalid spell %u, and then...", spellInfo->Id, effect->TriggerSpell);
TC_LOG_ERROR("sql.sql", "Spell %u learn to invalid spell %u, and then...", spellInfo->Id, spellEffectInfo.TriggerSpell);
}
return false;
}
break;
}
default:
break;
}
}
@@ -980,17 +976,14 @@ void SpellMgr::LoadSpellLearnSkills()
if (entry.Difficulty != DIFFICULTY_NONE)
continue;
for (SpellEffectInfo const* effect : entry.GetEffects())
for (SpellEffectInfo const& spellEffectInfo : entry.GetEffects())
{
if (!effect)
continue;
SpellLearnSkillNode dbc_node;
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_SKILL:
dbc_node.skill = uint16(effect->MiscValue);
dbc_node.step = uint16(effect->CalcValue());
dbc_node.skill = uint16(spellEffectInfo.MiscValue);
dbc_node.step = uint16(spellEffectInfo.CalcValue());
if (dbc_node.skill != SKILL_RIDING)
dbc_node.value = 1;
else
@@ -1077,12 +1070,12 @@ void SpellMgr::LoadSpellLearnSpells()
if (entry.Difficulty != DIFFICULTY_NONE)
continue;
for (SpellEffectInfo const* effect : entry.GetEffects())
for (SpellEffectInfo const& spellEffectInfo : entry.GetEffects())
{
if (effect && effect->Effect == SPELL_EFFECT_LEARN_SPELL)
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL))
{
SpellLearnSpellNode dbc_node;
dbc_node.Spell = effect->TriggerSpell;
dbc_node.Spell = spellEffectInfo.TriggerSpell;
dbc_node.Active = true; // all dbc based learned spells is active (show in spell book or hide by client itself)
dbc_node.OverridesSpell = 0;
@@ -1093,7 +1086,7 @@ void SpellMgr::LoadSpellLearnSpells()
// talent or passive spells or skill-step spells auto-cast and not need dependent learning,
// pet teaching spells must not be dependent learning (cast)
// other required explicit dependent learning
dbc_node.AutoLearned = effect->TargetA.GetTarget() == TARGET_UNIT_PET || entry.HasAttribute(SPELL_ATTR0_CU_IS_TALENT) || entry.IsPassive() || entry.HasEffect(SPELL_EFFECT_SKILL_STEP);
dbc_node.AutoLearned = spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_PET || entry.HasAttribute(SPELL_ATTR0_CU_IS_TALENT) || entry.IsPassive() || entry.HasEffect(SPELL_EFFECT_SKILL_STEP);
SpellLearnSpellMapBounds db_node_bounds = dbSpellLearnSpells.equal_range(entry.Id);
@@ -1216,20 +1209,19 @@ void SpellMgr::LoadSpellTargetPositions()
continue;
}
SpellEffectInfo const* effect = spellInfo->GetEffect(effIndex);
if (!effect)
if (effIndex >= spellInfo->GetEffects().size())
{
TC_LOG_ERROR("sql.sql", "Spell (Id: %u, EffectIndex: %u) listed in `spell_target_position` does not have an effect at index %u.", spellId, effIndex, effIndex);
continue;
}
// target facing is in degrees for 6484 & 9268... (blizz sucks)
if (effect->PositionFacing > 2 * M_PI)
st.target_Orientation = effect->PositionFacing * float(M_PI) / 180;
if (spellInfo->GetEffect(effIndex).PositionFacing > 2 * M_PI)
st.target_Orientation = spellInfo->GetEffect(effIndex).PositionFacing * float(M_PI) / 180;
else
st.target_Orientation = effect->PositionFacing;
st.target_Orientation = spellInfo->GetEffect(effIndex).PositionFacing;
if (effect->TargetA.GetTarget() == TARGET_DEST_DB || effect->TargetB.GetTarget() == TARGET_DEST_DB)
if (spellInfo->GetEffect(effIndex).TargetA.GetTarget() == TARGET_DEST_DB || spellInfo->GetEffect(effIndex).TargetB.GetTarget() == TARGET_DEST_DB)
{
std::pair<uint32, SpellEffIndex> key = std::make_pair(spellId, effIndex);
mSpellTargetPositions[key] = st;
@@ -1420,12 +1412,12 @@ void SpellMgr::LoadSpellGroupStackRules()
for (uint32 spellId : spellIds)
{
SpellInfo const* spellInfo = AssertSpellInfo(spellId, DIFFICULTY_NONE);
for (SpellEffectInfo const* effectInfo : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effectInfo->IsAura())
if (!spellEffectInfo.IsAura())
continue;
uint32 auraName = effectInfo->ApplyAuraName;
uint32 auraName = spellEffectInfo.ApplyAuraName;
for (std::vector<uint32> const& subGroup : SubGroups)
{
if (std::find(subGroup.begin(), subGroup.end(), auraName) != subGroup.end())
@@ -1616,18 +1608,18 @@ void SpellMgr::LoadSpellProcs()
TC_LOG_ERROR("sql.sql", "The `spell_proc` table entry for spellId %u has wrong `HitMask` set: %u", spellInfo->Id, procEntry.HitMask);
if (procEntry.HitMask && !(procEntry.ProcFlags & TAKEN_HIT_PROC_FLAG_MASK || (procEntry.ProcFlags & DONE_HIT_PROC_FLAG_MASK && (!procEntry.SpellPhaseMask || procEntry.SpellPhaseMask & (PROC_SPELL_PHASE_HIT | PROC_SPELL_PHASE_FINISH)))))
TC_LOG_ERROR("sql.sql", "The `spell_proc` table entry for spellId %u has `HitMask` value defined, but it will not be used for defined `ProcFlags` and `SpellPhaseMask` values.", spellInfo->Id);
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if ((procEntry.DisableEffectsMask & (1u << i)) && (!spellInfo->GetEffect(i) || !spellInfo->GetEffect(i)->IsAura()))
TC_LOG_ERROR("sql.sql", "The `spell_proc` table entry for spellId %u has DisableEffectsMask with effect %u, but effect %u is not an aura effect", spellInfo->Id, static_cast<uint32>(i), static_cast<uint32>(i));
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if ((procEntry.DisableEffectsMask & (1u << spellEffectInfo.EffectIndex)) && !spellEffectInfo.IsAura())
TC_LOG_ERROR("sql.sql", "The `spell_proc` table entry for spellId %u has DisableEffectsMask with effect %u, but effect %u is not an aura effect", spellInfo->Id, static_cast<uint32>(spellEffectInfo.EffectIndex), static_cast<uint32>(spellEffectInfo.EffectIndex));
if (procEntry.AttributesMask & PROC_ATTR_REQ_SPELLMOD)
{
bool found = false;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effect || !effect->IsAura())
if (!spellEffectInfo.IsAura())
continue;
if (effect->ApplyAuraName == SPELL_AURA_ADD_PCT_MODIFIER || effect->ApplyAuraName == SPELL_AURA_ADD_FLAT_MODIFIER)
if (spellEffectInfo.ApplyAuraName == SPELL_AURA_ADD_PCT_MODIFIER || spellEffectInfo.ApplyAuraName == SPELL_AURA_ADD_FLAT_MODIFIER)
{
found = true;
break;
@@ -1761,19 +1753,19 @@ void SpellMgr::LoadSpellProcs()
bool addTriggerFlag = false;
uint32 procSpellTypeMask = PROC_SPELL_TYPE_NONE;
uint32 nonProcMask = 0;
for (SpellEffectInfo const* effect : spellInfo.GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo.GetEffects())
{
if (!effect || !effect->IsEffect())
if (!spellEffectInfo.IsEffect())
continue;
uint32 auraName = effect->ApplyAuraName;
uint32 auraName = spellEffectInfo.ApplyAuraName;
if (!auraName)
continue;
if (!isTriggerAura[auraName])
{
// explicitly disable non proccing auras to avoid losing charges on self proc
nonProcMask |= 1 << effect->EffectIndex;
nonProcMask |= 1 << spellEffectInfo.EffectIndex;
continue;
}
@@ -1799,9 +1791,9 @@ void SpellMgr::LoadSpellProcs()
if (!procSpellTypeMask)
{
for (SpellEffectInfo const* effectInfo : spellInfo.GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo.GetEffects())
{
if (effectInfo && effectInfo->IsAura())
if (spellEffectInfo.IsAura())
{
TC_LOG_ERROR("sql.sql", "Spell Id %u has DBC ProcFlags %u, but it's of non-proc aura type, it probably needs an entry in `spell_proc` table to be handled correctly.", spellInfo.Id, spellInfo.ProcFlags);
break;
@@ -1815,9 +1807,9 @@ void SpellMgr::LoadSpellProcs()
procEntry.SchoolMask = 0;
procEntry.ProcFlags = spellInfo.ProcFlags;
procEntry.SpellFamilyName = 0;
for (SpellEffectInfo const* effect : spellInfo.GetEffects())
if (effect && effect->IsEffect() && isTriggerAura[effect->ApplyAuraName])
procEntry.SpellFamilyMask |= effect->SpellClassMask;
for (SpellEffectInfo const& spellEffectInfo : spellInfo.GetEffects())
if (spellEffectInfo.IsEffect() && isTriggerAura[spellEffectInfo.ApplyAuraName])
procEntry.SpellFamilyMask |= spellEffectInfo.SpellClassMask;
if (procEntry.SpellFamilyMask)
procEntry.SpellFamilyName = spellInfo.SpellFamilyName;
@@ -1826,12 +1818,12 @@ void SpellMgr::LoadSpellProcs()
procEntry.SpellPhaseMask = PROC_SPELL_PHASE_HIT;
procEntry.HitMask = PROC_HIT_NONE; // uses default proc @see SpellMgr::CanSpellTriggerProcOnEvent
for (SpellEffectInfo const* effect : spellInfo.GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo.GetEffects())
{
if (!effect || !effect->IsAura())
if (!spellEffectInfo.IsAura())
continue;
switch (effect->ApplyAuraName)
switch (spellEffectInfo.ApplyAuraName)
{
// Reflect auras should only proc off reflects
case SPELL_AURA_REFLECT_SPELLS:
@@ -1951,7 +1943,7 @@ void SpellMgr::LoadSpellPetAuras()
Field* fields = result->Fetch();
uint32 spell = fields[0].GetUInt32();
uint8 eff = fields[1].GetUInt8();
SpellEffIndex eff = SpellEffIndex(fields[1].GetUInt8());
uint32 pet = fields[2].GetUInt32();
uint32 aura = fields[3].GetUInt32();
@@ -1966,18 +1958,17 @@ void SpellMgr::LoadSpellPetAuras()
TC_LOG_ERROR("sql.sql", "The spell %u listed in `spell_pet_auras` does not exist.", spell);
continue;
}
SpellEffectInfo const* effect = spellInfo->GetEffect(eff);
if (!effect)
if (eff >= spellInfo->GetEffects().size())
{
TC_LOG_ERROR("spells", "The spell %u listed in `spell_pet_auras` does not have any effect at index %u", spell, uint32(eff));
continue;
}
if (effect->Effect != SPELL_EFFECT_DUMMY &&
(effect->Effect != SPELL_EFFECT_APPLY_AURA ||
effect->ApplyAuraName != SPELL_AURA_DUMMY))
if (spellInfo->GetEffect(eff).Effect != SPELL_EFFECT_DUMMY &&
(spellInfo->GetEffect(eff).Effect != SPELL_EFFECT_APPLY_AURA ||
spellInfo->GetEffect(eff).ApplyAuraName != SPELL_AURA_DUMMY))
{
TC_LOG_ERROR("spells", "Spell %u listed in `spell_pet_auras` does not have any dummy aura or dummy effect", spell);
TC_LOG_ERROR("spells", "The spell %u listed in `spell_pet_auras` does not have any dummy aura or dummy effect.", spell);
continue;
}
@@ -1988,7 +1979,7 @@ void SpellMgr::LoadSpellPetAuras()
continue;
}
PetAura pa(pet, aura, effect->TargetA.GetTarget() == TARGET_UNIT_PET, effect->CalcValue());
PetAura pa(pet, aura, spellInfo->GetEffect(eff).TargetA.GetTarget() == TARGET_UNIT_PET, spellInfo->GetEffect(eff).CalcValue());
mSpellPetAuraMap[(spell<<8) + eff] = pa;
}
@@ -2016,11 +2007,11 @@ void SpellMgr::LoadEnchantCustomAttr()
if (!spellInfo.HasAttribute(SPELL_ATTR2_PRESERVE_ENCHANT_IN_ARENA) || !spellInfo.HasAttribute(SPELL_ATTR0_NOT_SHAPESHIFT))
continue;
for (SpellEffectInfo const* effect : spellInfo.GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo.GetEffects())
{
if (effect && effect->Effect == SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY)
if (spellEffectInfo.Effect == SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY)
{
uint32 enchId = effect->MiscValue;
uint32 enchId = spellEffectInfo.MiscValue;
SpellItemEnchantmentEntry const* ench = sSpellItemEnchantmentStore.LookupEntry(enchId);
if (!ench)
continue;
@@ -2108,10 +2099,10 @@ void SpellMgr::LoadSpellLinked()
}
if (effect >= 0)
for (SpellEffectInfo const* eff : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (eff && eff->CalcValue() == abs(effect))
TC_LOG_ERROR("sql.sql", "The spell %u Effect: %u listed in `spell_linked_spell` has same bp%u like effect (possible hack)", abs(trigger), abs(effect), eff->EffectIndex);
if (spellEffectInfo.CalcValue() == abs(effect))
TC_LOG_ERROR("sql.sql", "The spell %u Effect: %u listed in `spell_linked_spell` has same bp%u like effect (possible hack).", abs(trigger), abs(effect), uint32(spellEffectInfo.EffectIndex));
}
spellInfo = GetSpellInfo(abs(effect), DIFFICULTY_NONE);
@@ -2252,11 +2243,11 @@ void SpellMgr::LoadPetDefaultSpells()
{
if (spellEntry.Difficulty != DIFFICULTY_NONE)
for (SpellEffectInfo const* effect : spellEntry.GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellEntry.GetEffects())
{
if (effect && (effect->Effect == SPELL_EFFECT_SUMMON || effect->Effect == SPELL_EFFECT_SUMMON_PET))
if (spellEffectInfo.IsEffect(SPELL_EFFECT_SUMMON) || spellEffectInfo.IsEffect(SPELL_EFFECT_SUMMON_PET))
{
uint32 creature_id = effect->MiscValue;
uint32 creature_id = spellEffectInfo.MiscValue;
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creature_id);
if (!cInfo)
continue;
@@ -2952,12 +2943,9 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
for (SpellInfo const& spellInfo : mSpellInfoMap)
{
SpellInfo* spellInfoMutable = const_cast<SpellInfo*>(&spellInfo);
for (SpellEffectInfo const* effect : spellInfoMutable->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfoMutable->GetEffects())
{
if (!effect)
continue;
switch (effect->ApplyAuraName)
switch (spellEffectInfo.ApplyAuraName)
{
case SPELL_AURA_MOD_POSSESS:
case SPELL_AURA_MOD_CONFUSE:
@@ -2979,9 +2967,11 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
case SPELL_AURA_POWER_BURN:
spellInfoMutable->AttributesCu |= SPELL_ATTR0_CU_NO_INITIAL_THREAT;
break;
default:
break;
}
switch (effect->ApplyAuraName)
switch (spellEffectInfo.ApplyAuraName)
{
case SPELL_AURA_OPEN_STABLE: // No point in saving this, since the stable dialog can't be open on aura load anyway.
// Auras that require both caster & target to be in world cannot be saved
@@ -2996,9 +2986,11 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
case SPELL_AURA_BATTLEGROUND_PLAYER_POSITION_FACTIONAL:
spellInfoMutable->AttributesCu |= SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED;
break;
default:
break;
}
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_SCHOOL_DAMAGE:
case SPELL_EFFECT_HEALTH_LEECH:
@@ -3013,9 +3005,11 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
case SPELL_EFFECT_DAMAGE_FROM_MAX_HEALTH_PCT:
spellInfoMutable->AttributesCu |= SPELL_ATTR0_CU_CAN_CRIT;
break;
default:
break;
}
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_SCHOOL_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE:
@@ -3053,7 +3047,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
// only enchanting profession enchantments procs can stack
if (IsPartOfSkillLine(SKILL_ENCHANTING, spellInfo.Id))
{
uint32 enchantId = effect->MiscValue;
uint32 enchantId = spellEffectInfo.MiscValue;
SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
if (!enchant)
break;
@@ -3077,6 +3071,8 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
}
break;
}
default:
break;
}
}
@@ -3084,67 +3080,64 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
if (!spellInfoMutable->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
{
bool setFlag = false;
for (SpellEffectInfo const* effect : spellInfoMutable->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfoMutable->GetEffects())
{
if (!effect)
continue;
if (effect->IsEffect())
if (spellEffectInfo.IsEffect())
{
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_SCHOOL_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
case SPELL_EFFECT_TRIGGER_SPELL:
case SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE:
break;
case SPELL_EFFECT_PERSISTENT_AREA_AURA:
case SPELL_EFFECT_APPLY_AURA:
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
case SPELL_EFFECT_APPLY_AURA_ON_PET:
case SPELL_EFFECT_APPLY_AREA_AURA_SUMMONS:
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY_NONRANDOM:
if (effect->ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE ||
effect->ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE_PERCENT ||
effect->ApplyAuraName == SPELL_AURA_DUMMY ||
effect->ApplyAuraName == SPELL_AURA_PERIODIC_LEECH ||
effect->ApplyAuraName == SPELL_AURA_PERIODIC_HEALTH_FUNNEL ||
effect->ApplyAuraName == SPELL_AURA_PERIODIC_DUMMY)
break;
/* fallthrough */
default:
{
// No value and not interrupt cast or crowd control without SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY flag
if (!effect->CalcValue() && !((effect->Effect == SPELL_EFFECT_INTERRUPT_CAST || spellInfoMutable->HasAttribute(SPELL_ATTR0_CU_AURA_CC)) && !spellInfoMutable->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)))
case SPELL_EFFECT_SCHOOL_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
case SPELL_EFFECT_TRIGGER_SPELL:
case SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE:
break;
case SPELL_EFFECT_PERSISTENT_AREA_AURA:
case SPELL_EFFECT_APPLY_AURA:
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
case SPELL_EFFECT_APPLY_AURA_ON_PET:
case SPELL_EFFECT_APPLY_AREA_AURA_SUMMONS:
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY_NONRANDOM:
if (spellEffectInfo.ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE ||
spellEffectInfo.ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE_PERCENT ||
spellEffectInfo.ApplyAuraName == SPELL_AURA_DUMMY ||
spellEffectInfo.ApplyAuraName == SPELL_AURA_PERIODIC_LEECH ||
spellEffectInfo.ApplyAuraName == SPELL_AURA_PERIODIC_HEALTH_FUNNEL ||
spellEffectInfo.ApplyAuraName == SPELL_AURA_PERIODIC_DUMMY)
break;
/* fallthrough */
default:
{
// No value and not interrupt cast or crowd control without SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY flag
if (!spellEffectInfo.CalcValue() && !((spellEffectInfo.Effect == SPELL_EFFECT_INTERRUPT_CAST || spellInfoMutable->HasAttribute(SPELL_ATTR0_CU_AURA_CC)) && !spellInfoMutable->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)))
break;
// Sindragosa Frost Breath
if (spellInfoMutable->Id == 69649 || spellInfoMutable->Id == 71056 || spellInfoMutable->Id == 71057 || spellInfoMutable->Id == 71058 || spellInfoMutable->Id == 73061 || spellInfoMutable->Id == 73062 || spellInfoMutable->Id == 73063 || spellInfoMutable->Id == 73064)
break;
// Sindragosa Frost Breath
if (spellInfoMutable->Id == 69649 || spellInfoMutable->Id == 71056 || spellInfoMutable->Id == 71057 || spellInfoMutable->Id == 71058 || spellInfoMutable->Id == 73061 || spellInfoMutable->Id == 73062 || spellInfoMutable->Id == 73063 || spellInfoMutable->Id == 73064)
break;
// Frostbolt
if (spellInfoMutable->SpellFamilyName == SPELLFAMILY_MAGE && (spellInfoMutable->SpellFamilyFlags[0] & 0x20))
break;
// Frostbolt
if (spellInfoMutable->SpellFamilyName == SPELLFAMILY_MAGE && (spellInfoMutable->SpellFamilyFlags[0] & 0x20))
break;
// Frost Fever
if (spellInfoMutable->Id == 55095)
break;
// Frost Fever
if (spellInfoMutable->Id == 55095)
break;
// Haunt
if (spellInfoMutable->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellInfoMutable->SpellFamilyFlags[1] & 0x40000))
break;
// Haunt
if (spellInfoMutable->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellInfoMutable->SpellFamilyFlags[1] & 0x40000))
break;
setFlag = true;
break;
}
setFlag = true;
break;
}
}
if (setFlag)
@@ -3203,18 +3196,15 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
{
bool allNonBinary = true;
bool overrideAttr = false;
for (SpellEffectInfo const* effect : spellInfoMutable->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfoMutable->GetEffects())
{
if (!effect)
continue;
if (effect->IsAura() && effect->TriggerSpell)
if (spellEffectInfo.IsAura() && spellEffectInfo.TriggerSpell)
{
switch (effect->ApplyAuraName)
switch (spellEffectInfo.ApplyAuraName)
{
case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
if (SpellInfo const* triggerSpell = sSpellMgr->GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE))
if (SpellInfo const* triggerSpell = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE))
{
overrideAttr = true;
if (triggerSpell->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL))
@@ -3259,14 +3249,13 @@ inline void ApplySpellFix(std::initializer_list<uint32> spellIds, void(*fix)(Spe
inline void ApplySpellEffectFix(SpellInfo* spellInfo, SpellEffIndex effectIndex, void(*fix)(SpellEffectInfo*))
{
SpellEffectInfo const* effect = spellInfo->GetEffect(effectIndex);
if (!effect)
if (spellInfo->GetEffects().size() <= effectIndex)
{
TC_LOG_ERROR("server.loading", "Spell effect info correction specified for non-existing effect %u of spell %u", uint32(effectIndex), spellInfo->Id);
return;
}
fix(const_cast<SpellEffectInfo*>(effect));
fix(const_cast<SpellEffectInfo*>(&spellInfo->GetEffect(effectIndex)));
}
void SpellMgr::LoadSpellInfoCorrections()
@@ -3427,7 +3416,7 @@ void SpellMgr::LoadSpellInfoCorrections()
{
ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo)
{
spellEffectInfo->Effect = 0;
spellEffectInfo->Effect = SPELL_EFFECT_NONE;
});
});
@@ -3765,7 +3754,7 @@ void SpellMgr::LoadSpellInfoCorrections()
//! HACK: This spell break quest complete for alliance and on retail not used
ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo)
{
spellEffectInfo->Effect = 0;
spellEffectInfo->Effect = SPELL_EFFECT_NONE;
});
});
@@ -4056,7 +4045,7 @@ void SpellMgr::LoadSpellInfoCorrections()
// this spell initially granted Shadow damage immunity, however it was removed but the data was left in client
ApplySpellEffectFix(spellInfo, EFFECT_2, [](SpellEffectInfo* spellEffectInfo)
{
spellEffectInfo->Effect = 0;
spellEffectInfo->Effect = SPELL_EFFECT_NONE;
});
});
@@ -4098,7 +4087,7 @@ void SpellMgr::LoadSpellInfoCorrections()
// THIS IS HERE BECAUSE COOLDOWN ON CREATURE PROCS WERE NOT IMPLEMENTED WHEN THE SCRIPT WAS WRITTEN
ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo)
{
spellEffectInfo->Effect = 0;
spellEffectInfo->Effect = SPELL_EFFECT_NONE;
});
});
@@ -4477,7 +4466,7 @@ void SpellMgr::LoadSpellInfoCorrections()
// Until we figure out what it's actually used for we disable it.
ApplySpellEffectFix(spellInfo, EFFECT_2, [](SpellEffectInfo* spellEffectInfo)
{
spellEffectInfo->Effect = 0;
spellEffectInfo->Effect = SPELL_EFFECT_NONE;
});
});
@@ -4498,26 +4487,24 @@ void SpellMgr::LoadSpellInfoCorrections()
if (!spellInfo)
continue;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
// Fix range for trajectory triggered spell
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (!effect)
continue;
if (effect->IsEffect() && (effect->TargetA.GetTarget() == TARGET_DEST_TRAJ || effect->TargetB.GetTarget() == TARGET_DEST_TRAJ))
if (spellEffectInfo.IsEffect() && (spellEffectInfo.TargetA.GetTarget() == TARGET_DEST_TRAJ || spellEffectInfo.TargetB.GetTarget() == TARGET_DEST_TRAJ))
{
// Get triggered spell if any
if (SpellInfo* spellInfoTrigger = const_cast<SpellInfo*>(GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE)))
for (SpellInfo const& spellInfoTrigger : _GetSpellInfo(spellEffectInfo.TriggerSpell))
{
float maxRangeMain = spellInfo->GetMaxRange();
float maxRangeTrigger = spellInfoTrigger->GetMaxRange();
float maxRangeTrigger = spellInfoTrigger.GetMaxRange();
// check if triggered spell has enough max range to cover trajectory
if (maxRangeTrigger < maxRangeMain)
spellInfoTrigger->RangeEntry = spellInfo->RangeEntry;
const_cast<SpellInfo&>(spellInfoTrigger).RangeEntry = spellInfo->RangeEntry;
}
}
switch (effect->Effect)
switch (spellEffectInfo.Effect)
{
case SPELL_EFFECT_CHARGE:
case SPELL_EFFECT_CHARGE_DEST:
@@ -4527,17 +4514,19 @@ void SpellMgr::LoadSpellInfoCorrections()
if (!spellInfo->Speed && !spellInfo->SpellFamilyName && !spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION))
spellInfo->Speed = SPEED_CHARGE;
break;
default:
break;
}
if (effect->TargetA.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE || effect->TargetB.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE)
if (spellEffectInfo.TargetA.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE || spellEffectInfo.TargetB.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE)
if (G3D::fuzzyEq(spellInfo->ConeAngle, 0.f))
spellInfo->ConeAngle = 90.f;
// Area auras may not target area (they're self cast)
if (effect->IsAreaAuraEffect() && effect->IsTargetingArea())
if (spellEffectInfo.IsAreaAuraEffect() && spellEffectInfo.IsTargetingArea())
{
const_cast<SpellEffectInfo*>(effect)->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER);
const_cast<SpellEffectInfo*>(effect)->TargetB = SpellImplicitTargetInfo(0);
const_cast<SpellEffectInfo&>(spellEffectInfo).TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER);
const_cast<SpellEffectInfo&>(spellEffectInfo).TargetB = SpellImplicitTargetInfo(0);
}
}
+37 -39
View File
@@ -118,32 +118,25 @@ bool _SpellScript::EffectHook::IsEffectAffected(SpellInfo const* spellEntry, uin
std::string _SpellScript::EffectHook::EffIndexToString() const
{
switch (effIndex)
{
case EFFECT_ALL:
return "EFFECT_ALL";
case EFFECT_FIRST_FOUND:
return "EFFECT_FIRST_FOUND";
case EFFECT_0:
return "EFFECT_0";
case EFFECT_1:
return "EFFECT_1";
case EFFECT_2:
return "EFFECT_2";
}
if (effIndex == EFFECT_ALL)
return "EFFECT_ALL";
if (effIndex == EFFECT_FIRST_FOUND)
return "EFFECT_FIRST_FOUND";
if (effIndex < MAX_SPELL_EFFECTS)
return Trinity::StringFormat("EFFECT_%u", uint32(effIndex));
return "Invalid Value";
}
bool _SpellScript::EffectNameCheck::Check(SpellInfo const* spellEntry, uint8 effIndex) const
{
SpellEffectInfo const* effect = spellEntry->GetEffect(effIndex);
if (!effect)
if (spellEntry->GetEffects().size() <= effIndex)
return false;
if (!effect->Effect && !effName)
SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndex));
if (!spellEffectInfo.Effect && !effName)
return true;
if (!effect->Effect)
if (!spellEffectInfo.Effect)
return false;
return (effName == SPELL_EFFECT_ANY) || (effect->Effect == effName);
return (effName == SPELL_EFFECT_ANY) || (spellEffectInfo.Effect == effName);
}
std::string _SpellScript::EffectNameCheck::ToString() const
@@ -161,14 +154,14 @@ std::string _SpellScript::EffectNameCheck::ToString() const
bool _SpellScript::EffectAuraNameCheck::Check(SpellInfo const* spellEntry, uint8 effIndex) const
{
SpellEffectInfo const* effect = spellEntry->GetEffect(effIndex);
if (!effect)
if (spellEntry->GetEffects().size() <= effIndex)
return false;
if (!effect->ApplyAuraName && !effAurName)
SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndex));
if (!spellEffectInfo.ApplyAuraName && !effAurName)
return true;
if (!effect->ApplyAuraName)
if (!spellEffectInfo.ApplyAuraName)
return false;
return (effAurName == SPELL_AURA_ANY) || (effect->ApplyAuraName == effAurName);
return (effAurName == SPELL_AURA_ANY) || (spellEffectInfo.ApplyAuraName == effAurName);
}
std::string _SpellScript::EffectAuraNameCheck::ToString() const
@@ -270,12 +263,12 @@ bool SpellScript::TargetHook::CheckEffect(SpellInfo const* spellEntry, uint8 eff
if (!targetType)
return false;
SpellEffectInfo const* effect = spellEntry->GetEffect(effIndexToCheck);
if (!effect)
if (spellEntry->GetEffects().size() <= effIndexToCheck)
return false;
if (effect->TargetA.GetTarget() != targetType &&
effect->TargetB.GetTarget() != targetType)
SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndexToCheck));
if (spellEffectInfo.TargetA.GetTarget() != targetType &&
spellEffectInfo.TargetB.GetTarget() != targetType)
return false;
SpellImplicitTargetInfo targetInfo(targetType);
@@ -485,6 +478,16 @@ SpellInfo const* SpellScript::GetSpellInfo() const
return m_spell->GetSpellInfo();
}
SpellEffectInfo const& SpellScript::GetEffectInfo(SpellEffIndex effIndex) const
{
return GetSpellInfo()->GetEffect(effIndex);
}
SpellValue const* SpellScript::GetSpellValue() const
{
return m_spell->m_spellValue;
}
WorldLocation const* SpellScript::GetExplTargetDest() const
{
if (m_spell->m_targets.HasDst())
@@ -706,11 +709,11 @@ void SpellScript::PreventHitDefaultEffect(SpellEffIndex effIndex)
m_hitPreventDefaultEffectMask |= 1 << effIndex;
}
SpellEffectInfo const* SpellScript::GetEffectInfo() const
SpellEffectInfo const& SpellScript::GetEffectInfo() const
{
ASSERT(IsInEffectHook(), "Script: `%s` Spell: `%u`: function SpellScript::GetEffectInfo was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
return m_spell->effectInfo;
return *m_spell->effectInfo;
}
int32 SpellScript::GetEffectValue() const
@@ -772,16 +775,6 @@ Difficulty SpellScript::GetCastDifficulty() const
return m_spell->GetCastDifficulty();
}
SpellValue const* SpellScript::GetSpellValue() const
{
return m_spell->m_spellValue;
}
SpellEffectInfo const* SpellScript::GetEffectInfo(SpellEffIndex effIndex) const
{
return GetSpellInfo()->GetEffect(effIndex);
}
bool AuraScript::_Validate(SpellInfo const* entry)
{
for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
@@ -1154,6 +1147,11 @@ SpellInfo const* AuraScript::GetSpellInfo() const
return m_aura->GetSpellInfo();
}
SpellEffectInfo const& AuraScript::GetEffectInfo(SpellEffIndex effIndex) const
{
return m_aura->GetSpellInfo()->GetEffect(effIndex);
}
uint32 AuraScript::GetId() const
{
return m_aura->GetId();
+3 -2
View File
@@ -413,8 +413,8 @@ class TC_GAME_API SpellScript : public _SpellScript
GameObject* GetGObjCaster() const;
Unit* GetOriginalCaster() const;
SpellInfo const* GetSpellInfo() const;
SpellEffectInfo const& GetEffectInfo(SpellEffIndex effIndex) const;
SpellValue const* GetSpellValue() const;
SpellEffectInfo const* GetEffectInfo(SpellEffIndex effIndex) const;
// methods useable after spell is prepared
// accessors to the explicit targets of the spell
@@ -490,7 +490,7 @@ class TC_GAME_API SpellScript : public _SpellScript
void PreventHitDefaultEffect(SpellEffIndex effIndex);
// method available only in EffectHandler method
SpellEffectInfo const* GetEffectInfo() const;
SpellEffectInfo const& GetEffectInfo() const;
int32 GetEffectValue() const;
void SetEffectValue(int32 value);
@@ -927,6 +927,7 @@ class TC_GAME_API AuraScript : public _SpellScript
// returns proto of the spell
SpellInfo const* GetSpellInfo() const;
SpellEffectInfo const& GetEffectInfo(SpellEffIndex effIndex) const;
// returns spellid of the spell
uint32 GetId() const;
@@ -604,13 +604,13 @@ class spell_garothi_fel_bombardment_periodic : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->BasePoints) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandlePeriodic(AuraEffect const* /*aurEff*/)
void HandlePeriodic(AuraEffect const* aurEff)
{
if (Unit* caster = GetCaster())
caster->CastSpell(GetTarget(), uint32(GetSpellInfo()->GetEffect(EFFECT_0)->BasePoints), true);
caster->CastSpell(GetTarget(), uint32(aurEff->GetSpellEffectInfo().CalcValue(caster)), true);
}
void Register() override
@@ -757,13 +757,13 @@ class spell_garothi_annihilation_selector : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->BasePoints) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleHit(SpellEffIndex effIndex)
void HandleHit(SpellEffIndex /*effIndex*/)
{
if (Unit* caster = GetCaster())
caster->CastSpell(GetHitUnit(), uint32(GetSpellInfo()->GetEffect(effIndex)->BasePoints), true);
caster->CastSpell(GetHitUnit(), uint32(GetEffectInfo().CalcValue(caster)), true);
}
void Register() override
+6 -6
View File
@@ -886,10 +886,10 @@ public:
bool known = target && target->HasSpell(spellInfo->Id);
SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0);
bool learn = effect ? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false;
SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(EFFECT_0);
bool learn = spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL);
SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell, spellInfo->Difficulty) : nullptr;
SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, spellInfo->Difficulty);
bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
bool passive = spellInfo->IsPassive();
@@ -959,10 +959,10 @@ public:
bool known = target && target->HasSpell(id);
SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0);
bool learn = effect? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false;
SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(EFFECT_0);
bool learn = spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL);
SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE) : nullptr;
SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
bool passive = spellInfo->IsPassive();
@@ -270,7 +270,7 @@ class spell_occuthar_eyes_of_occuthar : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
bool Load() override
@@ -500,21 +500,21 @@ public:
void SpellHit(Unit* /*caster*/, SpellInfo const* spellInfo) override
{
// We only care about interrupt effects and only if they are durring a spell currently being cast
if (spellInfo->HasEffect(SPELL_EFFECT_INTERRUPT_CAST) && me->IsNonMeleeSpellCast(false))
//We only care about interrupt effects and only if they are durring a spell currently being cast
if (!spellInfo->HasEffect(SPELL_EFFECT_INTERRUPT_CAST) || !me->IsNonMeleeSpellCast(false))
return;
//Interrupt effect
me->InterruptNonMeleeSpells(false);
//Normally we would set the cooldown equal to the spell duration
//but we do not have access to the DurationStore
switch (CurrentNormalSpell)
{
// Interrupt effect
me->InterruptNonMeleeSpells(false);
// Normally we would set the cooldown equal to the spell duration
// but we do not have access to the DurationStore
switch (CurrentNormalSpell)
{
case SPELL_ARCMISSLE: ArcaneCooldown = 5000; break;
case SPELL_FIREBALL: FireCooldown = 5000; break;
case SPELL_FROSTBOLT: FrostCooldown = 5000; break;
}
case SPELL_ARCMISSLE: ArcaneCooldown = 5000; break;
case SPELL_FIREBALL: FireCooldown = 5000; break;
case SPELL_FROSTBOLT: FrostCooldown = 5000; break;
}
}
@@ -299,7 +299,7 @@ class spell_shadow_portal_rooms : public SpellScriptLoader
return InstanceHasScript(GetCaster(), ScholomanceScriptName);
}
void HandleSendEvent(SpellEffIndex effIndex)
void HandleSendEvent(SpellEffIndex /*effIndex*/)
{
// If only one player in threat list fail spell
@@ -309,7 +309,7 @@ class spell_shadow_portal_rooms : public SpellScriptLoader
int8 phase_to_set = 0;
int32 gate_to_close = 0;
switch (GetSpellInfo()->GetEffect(effIndex)->MiscValue)
switch (GetEffectInfo().MiscValue)
{
case SPELL_EVENT_HALLOFSECRETS:
pos_to_summon = 0; // Not yet spawned
@@ -603,12 +603,12 @@ class spell_kalecgos_tap_check : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffect(EFFECT_0) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
GetHitUnit()->CastSpell(GetCaster(), (uint32)GetEffectInfo(EFFECT_0)->CalcValue(), true);
GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().CalcValue(), true);
}
void Register() override
@@ -380,7 +380,7 @@ public:
void HandleForceCast(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetHitUnit(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true);
GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell, true);
}
void Register() override
@@ -412,7 +412,7 @@ public:
void HandleForceCast(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetHitUnit(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true);
GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell, true);
}
void Register() override
@@ -417,16 +417,16 @@ class spell_baleroc_decimating_strike : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
if (!spellInfo->GetEffect(EFFECT_0))
if (spellInfo->GetEffects().size() <= EFFECT_2)
return false;
SpellEffectInfo const* spellEffectInfo = spellInfo->GetEffect(EFFECT_2);
return spellEffectInfo && ValidateSpellInfo({ uint32(spellEffectInfo->BasePoints) });
SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(EFFECT_2);
return ValidateSpellInfo({ uint32(spellEffectInfo.CalcValue()) });
}
void ChangeDamage()
{
int32 healthPctDmg = GetHitUnit()->CountPctFromMaxHealth(GetSpellInfo()->GetEffect(EFFECT_0)->BasePoints);
int32 flatDmg = GetSpellInfo()->GetEffect(EFFECT_2)->BasePoints;
int32 healthPctDmg = GetHitUnit()->CountPctFromMaxHealth(GetEffectInfo(EFFECT_0).CalcValue(GetCaster()));
int32 flatDmg = GetEffectInfo(EFFECT_2).CalcValue(GetCaster());
SetHitDamage(healthPctDmg < flatDmg ? flatDmg : healthPctDmg);
}
@@ -800,7 +800,8 @@ class spell_baleroc_vital_flame : public AuraScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_VITAL_SPARK });
return ValidateSpellInfo({ SPELL_VITAL_SPARK })
&& !sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, DIFFICULTY_NONE)->GetEffects().empty();
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -812,7 +813,7 @@ class spell_baleroc_vital_flame : public AuraScript
}
stacks = GetCaster()->GetAuraCount(SPELL_VITAL_SPARK);
int32 healingPct = sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, GetCastDifficulty())->GetEffect(EFFECT_0)->BasePoints * stacks;
int32 healingPct = sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, GetCastDifficulty())->GetEffect(EFFECT_0).CalcValue(GetCaster()) * stacks;
if (GetAura()->GetEffect(EFFECT_0)->GetAmount() < healingPct)
GetAura()->GetEffect(EFFECT_0)->SetAmount(healingPct);
@@ -540,7 +540,7 @@ public:
/// TODO: Remove this once we find a general rule for WorldObject::MovePosition (this spell shouldn't take the Z change into consideration)
Unit* caster = GetCaster();
float angle = float(rand_norm()) * static_cast<float>(2 * M_PI);
uint32 dist = caster->GetCombatReach() + GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(caster) * (float)rand_norm();
uint32 dist = caster->GetCombatReach() + GetSpellInfo()->GetEffect(EFFECT_0).CalcRadius(caster) * (float)rand_norm();
float x = caster->GetPositionX() + dist * std::cos(angle);
float y = caster->GetPositionY() + dist * std::sin(angle);
@@ -387,7 +387,7 @@ public:
{
CastSpellExtraArgs args;
args.AddSpellMod(SPELLVALUE_BASE_POINT0, aurEff->GetAmount());
caster->CastSpell(GetTarget(), aurEff->GetSpellEffectInfo()->TriggerSpell, args);
caster->CastSpell(GetTarget(), aurEff->GetSpellEffectInfo().TriggerSpell, args);
}
}
@@ -242,14 +242,14 @@ class spell_ooze_zap : public SpellScriptLoader
{
PrepareSpellScript(spell_ooze_zap_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_OOZE_ZAP });
return spellInfo->GetEffects().size() > EFFECT_1 && ValidateSpellInfo({ SPELL_OOZE_ZAP });
}
SpellCastResult CheckRequirement()
{
if (!GetCaster()->HasAura(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()))
if (!GetCaster()->HasAura(GetEffectInfo(EFFECT_1).CalcValue()))
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; // This is actually correct
if (!GetExplTargetUnit())
@@ -330,7 +330,7 @@ class spell_energize_aoe : public SpellScriptLoader
{
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end();)
{
if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()) == QUEST_STATUS_INCOMPLETE)
if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetEffectInfo(EFFECT_1).CalcValue()) == QUEST_STATUS_INCOMPLETE)
++itr;
else
targets.erase(itr++);
@@ -1409,7 +1409,7 @@ class spell_silithus_summon_cultist_periodic : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
@@ -1419,7 +1419,7 @@ class spell_silithus_summon_cultist_periodic : public AuraScript
// All these spells trigger a spell that requires reagents; if the
// triggered spell is cast as "triggered", reagents are not consumed
if (Unit* caster = GetCaster())
caster->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, CastSpellExtraArgs(TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)).SetTriggeringAura(aurEff));
caster->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, CastSpellExtraArgs(TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)).SetTriggeringAura(aurEff));
}
void Register() override
@@ -148,7 +148,7 @@ public:
// clone
player->CastSpell(summon, SPELL_CLONE_PLAYER, true);
// phase the summon
PhasingHandler::AddPhase(summon, spellInfo->GetEffect(EFFECT_0)->MiscValueB, true);
PhasingHandler::AddPhase(summon, spellInfo->GetEffect(EFFECT_0).MiscValueB, true);
}
}
++insanityHandled;
@@ -1500,7 +1500,7 @@ class spell_halion_combustion_consumption_periodic : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void HandleTick(AuraEffect const* aurEff)
@@ -1510,7 +1510,7 @@ class spell_halion_combustion_consumption_periodic : public SpellScriptLoader
if (!caster)
return;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
int32 radius = caster->GetObjectScale() * M_PI * 10000 / 3;
CastSpellExtraArgs args(aurEff);
@@ -1606,8 +1606,8 @@ class spell_halion_damage_aoe_summon : public SpellScriptLoader
{
PreventHitDefaultEffect(effIndex);
Unit* caster = GetCaster();
uint32 entry = uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValue);
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValueB));
uint32 entry = uint32(GetEffectInfo().MiscValue);
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetEffectInfo().MiscValueB));
uint32 duration = uint32(GetSpellInfo()->GetDuration());
Position pos = caster->GetPosition();
@@ -1707,10 +1707,10 @@ class spell_halion_clear_debuffs : public SpellScriptLoader
return ValidateSpellInfo({ SPELL_CLEAR_DEBUFFS, SPELL_TWILIGHT_REALM });
}
void HandleScript(SpellEffIndex effIndex)
void HandleScript(SpellEffIndex /*effIndex*/)
{
if (GetHitUnit()->HasAura(GetSpellInfo()->GetEffect(effIndex)->CalcValue()))
GetHitUnit()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(effIndex)->CalcValue());
if (GetHitUnit()->HasAura(GetEffectInfo().CalcValue()))
GetHitUnit()->RemoveAurasDueToSpell(GetEffectInfo().CalcValue());
}
void Register() override
@@ -1891,7 +1891,7 @@ class spell_halion_blazing_aura : public SpellScriptLoader
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetHitUnit(), GetSpellInfo()->GetEffect(EFFECT_1)->TriggerSpell);
GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell);
}
void Register() override
@@ -499,8 +499,7 @@ class spell_mistress_kiss_area : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0);
return effect0 && ValidateSpellInfo({ static_cast<uint32>(effect0->CalcValue()) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void FilterTargets(std::list<WorldObject*>& targets)
@@ -538,8 +537,7 @@ class spell_fel_streak_visual : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0);
return effect0 && ValidateSpellInfo({ static_cast<uint32>(effect0->CalcValue()) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleScript(SpellEffIndex /*effIndex*/)
@@ -1189,7 +1189,7 @@ class spell_jormungars_slime_pool : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
@@ -1199,7 +1199,7 @@ class spell_jormungars_slime_pool : public AuraScript
int32 const radius = static_cast<int32>(((aurEff->GetTickNumber() / 60.f) * 0.9f + 0.1f) * 10000.f * 2.f / 3.f);
CastSpellExtraArgs args(aurEff);
args.AddSpellMod(SPELLVALUE_RADIUS_MOD, radius);
GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, args);
GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, args);
}
void Register() override
@@ -1277,12 +1277,12 @@ class spell_icehowl_arctic_breath : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0)->CalcValue()) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleScriptEffect(SpellEffIndex effIndex)
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
uint32 spellId = GetSpellInfo()->GetEffect(effIndex)->CalcValue();
uint32 spellId = GetEffectInfo().CalcValue();
GetCaster()->CastSpell(GetHitUnit(), spellId, true);
}
@@ -811,7 +811,7 @@ class spell_valkyr_essences : public SpellScriptLoader
GetTarget()->CastSpell(GetTarget(), SPELL_SURGE_OF_SPEED, true);
// Twin Vortex part
int32 stacksCount = dmgInfo.GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue() / 1000 - 1;
int32 stacksCount = dmgInfo.GetSpellInfo()->GetEffect(EFFECT_0).CalcValue() / 1000 - 1;
if (stacksCount)
{
@@ -311,7 +311,7 @@ class spell_trollgore_invader_taunt : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffect(EFFECT_0) && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0)->CalcValue()) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleTaunt(SpellEffIndex /*effIndex*/)
@@ -2791,7 +2791,7 @@ class spell_hor_evasion : public SpellScriptLoader
return;
float angle = pos.GetAngle(&home);
float dist = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster());
float dist = GetEffectInfo().CalcRadius(GetCaster());
target->MovePosition(pos, dist, angle);
dest.Relocate(pos);
@@ -2849,7 +2849,7 @@ class spell_hor_quel_delars_will : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void HandleReagent(SpellEffIndex effIndex)
@@ -2857,7 +2857,7 @@ class spell_hor_quel_delars_will : public SpellScript
PreventHitDefaultEffect(effIndex);
// dummy spell consumes reagent, don't ignore it
GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST));
GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST));
}
void Register() override
@@ -813,7 +813,7 @@ class spell_blood_queen_pact_of_the_darkfallen_dmg : public SpellScriptLoader
void PeriodicTick(AuraEffect const* aurEff)
{
SpellInfo const* damageSpell = sSpellMgr->AssertSpellInfo(SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE, GetCastDifficulty());
int32 damage = damageSpell->GetEffect(EFFECT_0)->CalcValue();
int32 damage = damageSpell->GetEffect(EFFECT_0).CalcValue();
float multiplier = 0.3375f + 0.1f * uint32(aurEff->GetTickNumber() / 10); // do not convert to 0.01f - we need tick number/10 as INT (damage increases every 10 ticks)
damage = int32(damage * multiplier);
@@ -1829,7 +1829,8 @@ class spell_igb_rocket_pack : public SpellScriptLoader
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_ROCKET_PACK_DAMAGE, SPELL_ROCKET_BURST });
return ValidateSpellInfo({ SPELL_ROCKET_PACK_DAMAGE, SPELL_ROCKET_BURST })
&& !sSpellMgr->AssertSpellInfo(SPELL_ROCKET_PACK_DAMAGE, DIFFICULTY_NONE)->GetEffects().empty();
}
void HandlePeriodic(AuraEffect const* /*aurEff*/)
@@ -1843,7 +1844,7 @@ class spell_igb_rocket_pack : public SpellScriptLoader
SpellInfo const* damageInfo = sSpellMgr->AssertSpellInfo(SPELL_ROCKET_PACK_DAMAGE, GetCastDifficulty());
CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
args.CastDifficulty = GetCastDifficulty();
args.AddSpellBP0(2 * (damageInfo->GetEffect(EFFECT_0)->CalcValue() + aurEff->GetTickNumber() * aurEff->GetPeriod()));
args.AddSpellBP0(2 * (damageInfo->GetEffect(EFFECT_0).CalcValue() + aurEff->GetTickNumber() * aurEff->GetPeriod()));
GetTarget()->CastSpell(nullptr, SPELL_ROCKET_PACK_DAMAGE, args);
GetTarget()->CastSpell(nullptr, SPELL_ROCKET_BURST, TRIGGERED_FULL_MASK);
}
@@ -1971,10 +1972,10 @@ class spell_igb_periodic_trigger_with_power_cost : public SpellScriptLoader
{
PrepareAuraScript(spell_igb_periodic_trigger_with_power_cost_AuraScript);
void HandlePeriodicTick(AuraEffect const* /*aurEff*/)
void HandlePeriodicTick(AuraEffect const* aurEff)
{
PreventDefaultAction();
GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->GetEffect(EFFECT_0)->TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST));
GetTarget()->CastSpell(GetTarget(), aurEff->GetSpellEffectInfo().TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST));
}
void Register() override
@@ -582,9 +582,8 @@ class spell_marrowgar_coldflame_damage : public SpellScriptLoader
if (target->HasAura(SPELL_IMPALED))
return false;
if (SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(EFFECT_0))
if (target->GetExactDist2d(GetOwner()) > effect->CalcRadius())
return false;
if (target->GetExactDist2d(GetOwner()) > GetEffectInfo(EFFECT_0).CalcRadius())
return false;
if (Aura* aur = target->GetAura(GetId()))
if (aur->GetOwner() != GetOwner())
@@ -1057,7 +1057,7 @@ class spell_putricide_unstable_experiment : public SpellScriptLoader
break;
}
GetCaster()->CastSpell(target, uint32(GetSpellInfo()->GetEffect(stage)->CalcValue()), true);
GetCaster()->CastSpell(target, uint32(GetEffectInfo(SpellEffIndex(stage)).CalcValue()), true);
}
void Register() override
@@ -1114,9 +1114,8 @@ class spell_putricide_ooze_tank_protection : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0);
SpellEffectInfo const* effect1 = spellInfo->GetEffect(EFFECT_1);
return effect0 && effect1 && ValidateSpellInfo({ effect0->TriggerSpell, effect1->TriggerSpell });
return spellInfo->GetEffects().size() > EFFECT_1
&& ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell, spellInfo->GetEffect(EFFECT_1).TriggerSpell });
}
void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo)
@@ -1124,7 +1123,7 @@ class spell_putricide_ooze_tank_protection : public SpellScriptLoader
PreventDefaultAction();
Unit* actionTarget = eventInfo.GetActionTarget();
actionTarget->CastSpell(nullptr, aurEff->GetSpellEffectInfo()->TriggerSpell, aurEff);
actionTarget->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, aurEff);
}
void Register() override
@@ -1152,12 +1151,12 @@ class spell_putricide_choking_gas_bomb : public SpellScriptLoader
void HandleScript(SpellEffIndex /*effIndex*/)
{
uint32 skipIndex = urand(0, 2);
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
{
if (!effect || effect->EffectIndex == skipIndex)
if (spellEffectInfo.EffectIndex == skipIndex)
continue;
uint32 spellId = uint32(effect->CalcValue());
uint32 spellId = uint32(spellEffectInfo.CalcValue());
GetCaster()->CastSpell(GetCaster(), spellId, GetCaster()->GetGUID());
}
}
@@ -1314,10 +1313,10 @@ class spell_putricide_mutated_plague : public SpellScriptLoader
if (!caster)
return;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
SpellInfo const* spell = sSpellMgr->AssertSpellInfo(triggerSpell, GetCastDifficulty());
int32 damage = spell->GetEffect(EFFECT_0)->CalcValue(caster);
int32 damage = spell->GetEffect(EFFECT_0).CalcValue(caster);
float multiplier = 2.0f;
if (GetTarget()->GetMap()->Is25ManRaid())
multiplier = 3.0f;
@@ -1331,15 +1330,15 @@ class spell_putricide_mutated_plague : public SpellScriptLoader
GetTarget()->CastSpell(GetTarget(), triggerSpell, args);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
uint32 healSpell = uint32(GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue());
uint32 healSpell = uint32(aurEff->GetSpellEffectInfo().CalcValue());
SpellInfo const* healSpellInfo = sSpellMgr->GetSpellInfo(healSpell, GetCastDifficulty());
if (!healSpellInfo)
return;
int32 heal = healSpellInfo->GetEffect(EFFECT_0)->CalcValue() * GetStackAmount();
int32 heal = healSpellInfo->GetEffect(EFFECT_0).CalcValue() * GetStackAmount();
CastSpellExtraArgs args(GetCasterGUID());
args.AddSpellBP0(heal);
GetTarget()->CastSpell(GetTarget(), healSpell, args);
@@ -1505,8 +1504,8 @@ class spell_putricide_mutated_transformation : public SpellScriptLoader
return;
}
uint32 entry = uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValue);
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValueB));
uint32 entry = uint32(GetEffectInfo().MiscValue);
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetEffectInfo().MiscValueB));
uint32 duration = uint32(GetSpellInfo()->GetDuration());
Position pos = caster->GetPosition();
@@ -550,14 +550,13 @@ class spell_rotface_mutated_infection : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_2);
return effect && ValidateSpellInfo({ uint32(effect->CalcValue()) });
return spellInfo->GetEffects().size() > EFFECT_2 && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_2).CalcValue()) });
}
void HandleEffectRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->CastSpell(target, uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue()), { aurEff, GetCasterGUID() });
target->CastSpell(target, uint32(GetEffectInfo(EFFECT_2).CalcValue()), { aurEff, GetCasterGUID() });
}
void Register() override
@@ -776,11 +775,11 @@ class spell_rotface_unstable_ooze_explosion : public SpellScriptLoader
void CheckTarget(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(EFFECT_0);
PreventHitDefaultEffect(effIndex);
if (!GetExplTargetDest())
return;
uint32 triggered_spell_id = GetSpellInfo()->GetEffect(effIndex)->TriggerSpell;
uint32 triggered_spell_id = GetEffectInfo().TriggerSpell;
float x, y, z;
GetExplTargetDest()->GetPosition(x, y, z);
@@ -1571,14 +1571,17 @@ class spell_frostwarden_handler_focus_fire : public SpellScriptLoader
{
PrepareAuraScript(spell_frostwarden_handler_focus_fire_AuraScript);
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffects().size() > EFFECT_1;
}
void PeriodicTick(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
if (Unit* caster = GetCaster())
{
if (SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(EFFECT_1))
caster->GetThreatManager().AddThreat(GetTarget(), -float(effect->CalcValue()), GetSpellInfo(), true, true);
caster->GetThreatManager().AddThreat(GetTarget(), -float(GetEffectInfo(EFFECT_1).CalcValue()), GetSpellInfo(), true, true);
caster->GetAI()->SetData(DATA_WHELP_MARKER, 0);
}
}
@@ -2494,14 +2494,14 @@ class spell_the_lich_king_summon_into_air : public SpellScriptLoader
{
PrepareSpellScript(spell_the_lich_king_summon_into_air_SpellScript);
void ModDestHeight(SpellEffIndex effIndex)
void ModDestHeight(SpellEffIndex /*effIndex*/)
{
static Position const offset = {0.0f, 0.0f, 15.0f, 0.0f};
WorldLocation* dest = const_cast<WorldLocation*>(GetExplTargetDest());
dest->RelocateOffset(offset);
GetHitDest()->RelocateOffset(offset);
// spirit bombs get higher
if (GetSpellInfo()->GetEffect(effIndex)->MiscValue == NPC_SPIRIT_BOMB)
if (GetEffectInfo().MiscValue == NPC_SPIRIT_BOMB)
{
static Position const offsetExtra = { 0.0f, 0.0f, 5.0f, 0.0f };
dest->RelocateOffset(offsetExtra);
@@ -2695,7 +2695,7 @@ class spell_the_lich_king_vile_spirits : public SpellScriptLoader
void OnPeriodic(AuraEffect const* aurEff)
{
if (_is25Man || ((aurEff->GetTickNumber() - 1) % 5))
GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo()->TriggerSpell, { aurEff, GetCasterGUID() });
GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, { aurEff, GetCasterGUID() });
}
void Register() override
@@ -248,7 +248,7 @@ class ValithriaDespawner : public BasicEvent
default:
return;
}
creature->DespawnOrUnsummon(0, 10s);
}
@@ -1235,7 +1235,7 @@ class spell_dreamwalker_summoner : public SpellScriptLoader
if (!GetHitUnit())
return;
GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
}
void Register() override
@@ -1326,7 +1326,7 @@ class spell_dreamwalker_summon_suppresser_effect : public SpellScriptLoader
if (!GetHitUnit())
return;
GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING));
}
void Register() override
@@ -1462,7 +1462,7 @@ class spell_dreamwalker_twisted_nightmares : public SpellScriptLoader
// return;
if (InstanceScript* instance = GetHitUnit()->GetInstanceScript())
GetHitUnit()->CastSpell(nullptr, GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER));
GetHitUnit()->CastSpell(nullptr, GetEffectInfo().TriggerSpell, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER));
}
void Register() override
@@ -1847,7 +1847,7 @@ class spell_icc_sprit_alarm : public SpellScriptLoader
{
PreventHitDefaultEffect(effIndex);
uint32 trapId = 0;
switch (GetSpellInfo()->GetEffect(effIndex)->MiscValue)
switch (GetEffectInfo().MiscValue)
{
case EVENT_AWAKEN_WARD_1:
trapId = GO_SPIRIT_ALARM_1;
@@ -193,8 +193,8 @@ class spell_grobbulus_poison_cloud : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0);
return effect0 && ValidateSpellInfo({ effect0->TriggerSpell });
return !spellInfo->GetEffects().empty()
&& ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
@@ -203,7 +203,7 @@ class spell_grobbulus_poison_cloud : public SpellScriptLoader
if (!aurEff->GetTotalTicks())
return;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
int32 mod = int32(((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 10000 * 2 / 3);
CastSpellExtraArgs args(aurEff);
@@ -1899,7 +1899,7 @@ class spell_arcane_overload : public SpellScriptLoader
{
Creature* arcaneOverload = GetCaster()->ToCreature();
targets.remove_if(ExactDistanceCheck(arcaneOverload,
GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(arcaneOverload) * arcaneOverload->GetObjectScale()));
GetEffectInfo(EFFECT_0).CalcRadius(arcaneOverload) * arcaneOverload->GetObjectScale()));
}
void Register() override
@@ -453,7 +453,7 @@ class spell_oculus_ride_ruby_emerald_amber_drake_que : public SpellScriptLoader
// caster of the triggered spell is wrong for an unknown reason, handle it here correctly
PreventDefaultAction();
if (Unit* caster = GetCaster())
GetTarget()->CastSpell(caster, aurEff->GetSpellEffectInfo()->TriggerSpell, true);
GetTarget()->CastSpell(caster, aurEff->GetSpellEffectInfo().TriggerSpell, true);
}
void Register() override
@@ -181,12 +181,17 @@ class spell_krystallus_shatter_effect : public SpellScriptLoader
{
PrepareSpellScript(spell_krystallus_shatter_effect_SpellScript);
bool Validate(SpellInfo const* spellInfo) override
{
return !spellInfo->GetEffects().empty();
}
void CalculateDamage()
{
if (!GetHitUnit())
return;
float radius = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster());
float radius = GetSpellInfo()->GetEffect(EFFECT_0).CalcRadius(GetCaster());
if (!radius)
return;
@@ -1526,13 +1526,13 @@ class spell_tar_blaze : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
{
// should we use custom damage?
GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, true);
GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, true);
}
void Register() override
@@ -1792,7 +1792,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader
class spell_vehicle_throw_passenger_SpellScript : public SpellScript
{
PrepareSpellScript(spell_vehicle_throw_passenger_SpellScript);
void HandleScript(SpellEffIndex effIndex)
void HandleScript(SpellEffIndex /*effIndex*/)
{
Spell* baseSpell = GetSpell();
SpellCastTargets targets = baseSpell->m_targets;
@@ -1825,7 +1825,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader
}
}
}
if (target && target->IsWithinDist2d(targets.GetDstPos(), GetSpellInfo()->GetEffect(effIndex)->CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct
if (target && target->IsWithinDist2d(targets.GetDstPos(), GetEffectInfo().CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct
passenger->EnterVehicle(target, 0);
else
{
@@ -1583,7 +1583,7 @@ class spell_freya_iron_roots : public SpellScriptLoader
void HandleSummon(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
uint32 entry = uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValue);
uint32 entry = uint32(GetEffectInfo().MiscValue);
Position pos = GetCaster()->GetPosition();
// Not good at all, but this prevents having roots in a different position then player
@@ -448,23 +448,22 @@ class spell_ulduar_cancel_stone_grip : public SpellScriptLoader
{
PrepareSpellScript(spell_ulduar_cancel_stone_gripSpellScript);
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffects().size() > EFFECT_1;
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit* target = GetHitUnit();
if (!target || !target->GetVehicle())
return;
switch (target->GetMap()->GetDifficultyID())
{
case DIFFICULTY_10_N:
target->RemoveAura(GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue());
break;
case DIFFICULTY_25_N:
target->RemoveAura(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue());
break;
default:
break;
}
SpellEffIndex effectIndexToCancel = EFFECT_0;
if (target->GetMap()->Is25ManRaid())
effectIndexToCancel = EFFECT_1;
target->RemoveAura(GetEffectInfo(effectIndexToCancel).CalcValue());
}
void Register() override
@@ -647,7 +646,7 @@ class spell_kologarn_summon_focused_eyebeam : public SpellScriptLoader
void HandleForceCast(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetCaster()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true);
GetCaster()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, true);
}
void Register() override
@@ -959,13 +959,13 @@ struct npc_thorim_trashAI : public ScriptedAI
static uint32 GetTotalHeal(SpellInfo const* spellInfo, Unit const* caster)
{
uint32 heal = 0;
for (SpellEffectInfo const* effect : spellInfo->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (effect->IsEffect(SPELL_EFFECT_HEAL))
heal += effect->CalcValue(caster);
if (spellEffectInfo.IsEffect(SPELL_EFFECT_HEAL))
heal += spellEffectInfo.CalcValue(caster);
if (effect->IsEffect(SPELL_EFFECT_APPLY_AURA) && effect->IsAura(SPELL_AURA_PERIODIC_HEAL))
heal += spellInfo->GetMaxTicks() * effect->CalcValue(caster);
if (spellEffectInfo.IsEffect(SPELL_EFFECT_APPLY_AURA) && spellEffectInfo.IsAura(SPELL_AURA_PERIODIC_HEAL))
heal += spellInfo->GetMaxTicks() * spellEffectInfo.CalcValue(caster);
}
return heal;
}
@@ -108,7 +108,7 @@ class spell_moragg_ray : public SpellScriptLoader
if (Unit* target = GetTarget()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f, true))
{
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
GetTarget()->CastSpell(target, triggerSpell, aurEff);
}
}
@@ -1327,7 +1327,7 @@ public:
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleScript(SpellEffIndex /*effIndex*/)
@@ -590,10 +590,9 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect2 = spellInfo->GetEffect(EFFECT_2);
if (!effect2)
if (spellInfo->GetEffects().size() <= EFFECT_2)
return false;
uint32 triggeredSpellId = effect2->CalcValue();
uint32 triggeredSpellId = spellInfo->GetEffect(EFFECT_2).CalcValue();
return !triggeredSpellId || ValidateSpellInfo({ triggeredSpellId });
}
@@ -601,7 +600,7 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript
{
PreventDefaultAction();
if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo()->CalcValue())
if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValue())
{
int32 bp = 0;
if (AuraEffect const* healEffect = GetEffect(EFFECT_0))
@@ -619,7 +618,7 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript
void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo()->CalcValue())
if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValue())
GetTarget()->RemoveAurasDueToSpell(triggeredSpellId);
}
@@ -262,14 +262,15 @@ class spell_mother_shahraz_saber_lash : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_1)->TriggerSpell });
return spellInfo->GetEffects().size() > EFFECT_1
&& ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_1).TriggerSpell });
}
void OnTrigger(AuraEffect const* aurEff)
{
PreventDefaultAction();
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0))
GetUnitOwner()->CastSpell(target, triggerSpell, true);
}
@@ -290,14 +291,15 @@ class spell_mother_shahraz_generic_periodic : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty()
&& ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void OnTrigger(AuraEffect const* aurEff)
{
PreventDefaultAction();
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0))
GetUnitOwner()->CastSpell(target, triggerSpell, true);
}
@@ -309,12 +309,17 @@ class spell_gruul_shatter_effect : public SpellScriptLoader
{
PrepareSpellScript(spell_gruul_shatter_effect_SpellScript);
bool Validate(SpellInfo const* spellInfo) override
{
return !spellInfo->GetEffects().empty();
}
void CalculateDamage()
{
if (!GetHitUnit())
return;
float radius = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster());
float radius = GetEffectInfo(EFFECT_0).CalcRadius(GetCaster());
if (!radius)
return;
@@ -171,8 +171,7 @@ class spell_broggok_poison_cloud : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0);
return effect0 && ValidateSpellInfo({ effect0->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
@@ -181,7 +180,7 @@ class spell_broggok_poison_cloud : public SpellScriptLoader
if (!aurEff->GetTotalTicks())
return;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
int32 mod = int32(((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 10000 * 2 / 3);
GetTarget()->CastSpell(nullptr, triggerSpell, CastSpellExtraArgs(aurEff).AddSpellMod(SPELLVALUE_RADIUS_MOD, mod));
}
@@ -512,9 +512,10 @@ class spell_astromancer_wrath_of_the_astromancer : public SpellScriptLoader
{
PrepareAuraScript(spell_astromancer_wrath_of_the_astromancer_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_WRATH_OF_THE_ASTROMANCER_DOT });
return ValidateSpellInfo({ SPELL_WRATH_OF_THE_ASTROMANCER_DOT })
&& spellInfo->GetEffects().size() > EFFECT_1;
}
void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -524,7 +525,7 @@ class spell_astromancer_wrath_of_the_astromancer : public SpellScriptLoader
return;
Unit* target = GetUnitOwner();
target->CastSpell(target, GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue(), false);
target->CastSpell(target, GetEffectInfo(EFFECT_1).CalcValue(), false);
}
void Register() override
+9 -12
View File
@@ -120,14 +120,14 @@ public:
absorbedAmount = 0;
}
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_DK_RUNIC_POWER_ENERGIZE, SPELL_DK_VOLATILE_SHIELDING });
return ValidateSpellInfo({ SPELL_DK_RUNIC_POWER_ENERGIZE, SPELL_DK_VOLATILE_SHIELDING }) && spellInfo->GetEffects().size() > EFFECT_1;
}
bool Load() override
{
absorbPct = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue(GetCaster());
absorbPct = GetEffectInfo(EFFECT_1).CalcValue(GetCaster());
maxHealth = GetCaster()->GetMaxHealth();
absorbedAmount = 0;
return true;
@@ -465,8 +465,7 @@ class spell_dk_death_strike : public SpellScript
SPELL_DK_FROST,
SPELL_DK_DEATH_STRIKE_OFFHAND
})
&& spellInfo->GetEffect(EFFECT_1)
&& spellInfo->GetEffect(EFFECT_2);
&& spellInfo->GetEffects().size() > EFFECT_2;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
@@ -475,12 +474,10 @@ class spell_dk_death_strike : public SpellScript
if (AuraEffect* enabler = caster->GetAuraEffect(SPELL_DK_DEATH_STRIKE_ENABLER, EFFECT_0, GetCaster()->GetGUID()))
{
SpellInfo const* spellInfo = GetSpellInfo();
// Heals you for 25% of all damage taken in the last 5 sec,
int32 heal = CalculatePct(enabler->CalculateAmount(GetCaster()), spellInfo->GetEffect(EFFECT_1)->CalcValue(GetCaster()));
int32 heal = CalculatePct(enabler->CalculateAmount(GetCaster()), GetEffectInfo(EFFECT_1).CalcValue(GetCaster()));
// minimum 7.0% of maximum health.
int32 pctOfMaxHealth = CalculatePct(spellInfo->GetEffect(EFFECT_2)->CalcValue(GetCaster()), caster->GetMaxHealth());
int32 pctOfMaxHealth = CalculatePct(GetEffectInfo(EFFECT_2).CalcValue(GetCaster()), caster->GetMaxHealth());
heal = std::max(heal, pctOfMaxHealth);
caster->CastSpell(caster, SPELL_DK_DEATH_STRIKE_HEAL, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_BASE_POINT0, heal));
@@ -574,14 +571,14 @@ class spell_dk_ghoul_explode : public SpellScript
{
PrepareSpellScript(spell_dk_ghoul_explode);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_DK_CORPSE_EXPLOSION_TRIGGERED });
return ValidateSpellInfo({ SPELL_DK_CORPSE_EXPLOSION_TRIGGERED }) && spellInfo->GetEffects().size() > EFFECT_2;
}
void HandleDamage(SpellEffIndex /*effIndex*/)
{
SetHitDamage(GetCaster()->CountPctFromMaxHealth(GetEffectInfo(EFFECT_2)->CalcValue(GetCaster())));
SetHitDamage(GetCaster()->CountPctFromMaxHealth(GetEffectInfo(EFFECT_2).CalcValue(GetCaster())));
}
void Suicide(SpellEffIndex /*effIndex*/)
+5 -6
View File
@@ -472,7 +472,7 @@ class spell_dru_ferocious_bite : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_DRUID_INCARNATION_KING_OF_THE_JUNGLE })
&& sSpellMgr->AssertSpellInfo(SPELL_DRUID_INCARNATION_KING_OF_THE_JUNGLE, DIFFICULTY_NONE)->GetEffect(EFFECT_1);
&& sSpellMgr->AssertSpellInfo(SPELL_DRUID_INCARNATION_KING_OF_THE_JUNGLE, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_1;
}
void HandleHitTargetBurn(SpellEffIndex /*effIndex*/)
@@ -709,7 +709,7 @@ public:
spellMod->op = SpellModOp::PeriodicHealingAndDamage;
spellMod->type = SPELLMOD_FLAT;
spellMod->spellId = GetId();
spellMod->mask = aurEff->GetSpellEffectInfo()->SpellClassMask;
spellMod->mask = aurEff->GetSpellEffectInfo().SpellClassMask;
}
spellMod->value = aurEff->GetAmount() / 7;
}
@@ -1959,8 +1959,7 @@ public:
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect2 = spellInfo->GetEffect(EFFECT_2);
if (!effect2 || effect2->IsEffect() || effect2->CalcValue() <= 0)
if (spellInfo->GetEffects().size() <= EFFECT_2 || spellInfo->GetEffect(EFFECT_2).IsEffect() || spellInfo->GetEffect(EFFECT_2).CalcValue() <= 0)
return false;
return true;
}
@@ -1969,7 +1968,7 @@ public:
{
targets.remove_if(RaidCheck(GetCaster()));
uint32 const maxTargets = uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue(GetCaster()));
uint32 const maxTargets = uint32(GetEffectInfo(EFFECT_2).CalcValue(GetCaster()));
if (targets.size() > maxTargets)
{
@@ -2010,7 +2009,7 @@ public:
return;
// calculate from base damage, not from aurEff->GetAmount() (already modified)
float damage = caster->CalculateSpellDamage(GetUnitOwner(), GetSpellInfo(), aurEff->GetEffIndex());
float damage = caster->CalculateSpellDamage(GetUnitOwner(), aurEff->GetSpellEffectInfo());
// Wild Growth = first tick gains a 6% bonus, reduced by 2% each tick
float reduction = 2.f;
+46 -33
View File
@@ -52,7 +52,7 @@ class spell_gen_absorb0_hitlimit1 : public AuraScript
bool Load() override
{
// Max absorb stored in 1 dummy effect
limit = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue();
limit = GetSpellInfo()->GetEffect(EFFECT_1).CalcValue();
return true;
}
@@ -229,7 +229,7 @@ class spell_gen_arena_drink : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
if (!spellInfo->GetEffect(EFFECT_0)->IsAura() || spellInfo->GetEffect(EFFECT_0)->ApplyAuraName != SPELL_AURA_MOD_POWER_REGEN)
if (spellInfo->GetEffects().empty() || !spellInfo->GetEffect(EFFECT_0).IsAura(SPELL_AURA_MOD_POWER_REGEN))
{
TC_LOG_ERROR("spells", "Aura %d structure has been changed - first aura is no longer SPELL_AURA_MOD_POWER_REGEN", GetId());
return false;
@@ -328,7 +328,7 @@ class spell_gen_aura_of_fear : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
@@ -337,7 +337,7 @@ class spell_gen_aura_of_fear : public AuraScript
if (!roll_chance_i(GetSpellInfo()->ProcChance))
return;
GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, true);
GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, true);
}
void Register() override
@@ -676,18 +676,18 @@ class spell_gen_burning_depths_necrolyte_image : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_2)->CalcValue()) });
return spellInfo->GetEffects().size() > EFFECT_2 && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_2).CalcValue()) });
}
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
caster->CastSpell(GetTarget(), uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue()));
caster->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_2).CalcValue()));
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue()), GetCasterGUID());
GetTarget()->RemoveAurasDueToSpell(uint32(GetEffectInfo(EFFECT_2).CalcValue()), GetCasterGUID());
}
void Register() override
@@ -1344,7 +1344,7 @@ class spell_gen_despawn_self : public SpellScript
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (GetEffectInfo()->IsEffect(SPELL_EFFECT_DUMMY) || GetEffectInfo()->IsEffect(SPELL_EFFECT_SCRIPT_EFFECT))
if (GetEffectInfo().IsEffect(SPELL_EFFECT_DUMMY) || GetEffectInfo().IsEffect(SPELL_EFFECT_SCRIPT_EFFECT))
GetCaster()->ToCreature()->DespawnOrUnsummon();
}
@@ -1594,18 +1594,20 @@ class spell_gen_gift_of_naaru : public AuraScript
{
PrepareAuraScript(spell_gen_gift_of_naaru);
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffects().size() > EFFECT_1;
}
void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/)
{
if (!GetCaster() || !aurEff->GetTotalTicks())
return;
if (SpellEffectInfo const* eff1 = GetSpellInfo()->GetEffect(EFFECT_1))
{
float healPct = eff1->CalcValue() / 100.0f;
float heal = healPct * GetCaster()->GetMaxHealth();
int32 healTick = std::floor(heal / aurEff->GetTotalTicks());
amount += healTick;
}
float healPct = GetEffectInfo(EFFECT_1).CalcValue() / 100.0f;
float heal = healPct * GetCaster()->GetMaxHealth();
int32 healTick = std::floor(heal / aurEff->GetTotalTicks());
amount += healTick;
}
void Register() override
@@ -1906,7 +1908,7 @@ class spell_gen_mounted_charge : public SpellScript
if (spell->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT))
OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT);
if (spell->GetEffect(EFFECT_0)->Effect == SPELL_EFFECT_CHARGE)
if (spell->GetEffect(EFFECT_0).IsEffect(SPELL_EFFECT_CHARGE))
OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge::HandleChargeEffect, EFFECT_0, SPELL_EFFECT_CHARGE);
}
};
@@ -1946,7 +1948,7 @@ class spell_gen_negative_energy_periodic : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell });
return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
@@ -1955,7 +1957,7 @@ class spell_gen_negative_energy_periodic : public AuraScript
CastSpellExtraArgs args(aurEff);
args.AddSpellMod(SPELLVALUE_MAX_TARGETS, aurEff->GetTickNumber() / 10 + 1);
GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, args);
GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, args);
}
void Register() override
@@ -2147,16 +2149,21 @@ class spell_gen_oracle_wolvar_reputation : public SpellScript
{
PrepareSpellScript(spell_gen_oracle_wolvar_reputation);
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffects().size() > EFFECT_1;
}
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
void HandleDummy(SpellEffIndex effIndex)
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Player* player = GetCaster()->ToPlayer();
uint32 factionId = GetEffectInfo(effIndex)->CalcValue();
int32 repChange = GetEffectInfo(EFFECT_1)->CalcValue();
uint32 factionId = GetEffectInfo().CalcValue();
int32 repChange = GetEffectInfo(EFFECT_1).CalcValue();
FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
if (!factionEntry)
@@ -2260,7 +2267,7 @@ class spell_gen_proc_below_pct_damaged : public SpellScriptLoader
if (!damageInfo || !damageInfo->GetDamage())
return false;
int32 pct = GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue();
int32 pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue();
if (eventInfo.GetActionTarget()->HealthBelowPctDamaged(pct, damageInfo->GetDamage()))
return true;
@@ -2513,11 +2520,16 @@ class spell_gen_remove_on_health_pct : public AuraScript
{
PrepareAuraScript(spell_gen_remove_on_health_pct);
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffects().size() > EFFECT_1;
}
void PeriodicTick(AuraEffect const* /*aurEff*/)
{
// they apply damage so no need to check for ticks here
if (GetTarget()->HealthAbovePct(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()))
if (GetTarget()->HealthAbovePct(GetEffectInfo(EFFECT_1).CalcValue()))
{
Remove(AURA_REMOVE_BY_ENEMY_SPELL);
PreventDefaultAction();
@@ -2542,7 +2554,7 @@ class spell_gen_remove_on_full_health : public AuraScript
void PeriodicTick(AuraEffect const* aurEff)
{
// if it has only periodic effect, allow 1 tick
bool onlyEffect = (GetSpellInfo()->GetEffects().size() == 1);
bool onlyEffect = GetSpellInfo()->GetEffects().size() == 1;
if (onlyEffect && aurEff->GetTickNumber() <= 1)
return;
@@ -3379,8 +3391,9 @@ class spell_gen_eject_passenger : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0);
if (!effect || effect->CalcValue() < 1)
if (spellInfo->GetEffects().empty())
return false;
if (spellInfo->GetEffect(EFFECT_0).CalcValue() < 1)
return false;
return true;
}
@@ -3572,9 +3585,9 @@ class spell_gen_mixology_bonus : public AuraScript
{
PrepareAuraScript(spell_gen_mixology_bonus);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_MIXOLOGY });
return ValidateSpellInfo({ SPELL_MIXOLOGY }) && !spellInfo->GetEffects().empty();
}
bool Load() override
@@ -3590,7 +3603,7 @@ class spell_gen_mixology_bonus : public AuraScript
void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/)
{
if (GetCaster()->HasAura(SPELL_MIXOLOGY) && GetCaster()->HasSpell(GetSpellInfo()->GetEffect(EFFECT_0)->TriggerSpell))
if (GetCaster()->HasAura(SPELL_MIXOLOGY) && GetCaster()->HasSpell(GetEffectInfo(EFFECT_0).TriggerSpell))
{
switch (GetId())
{
@@ -3973,14 +3986,14 @@ class spell_gen_face_rage : public AuraScript
{
PrepareAuraScript(spell_gen_face_rage);
bool Validate(SpellInfo const* /*spell*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_FACE_RAGE });
return ValidateSpellInfo({ SPELL_FACE_RAGE }) && spellInfo->GetEffects().size() > EFFECT_2;
}
void OnRemove(AuraEffect const* /*effect*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(EFFECT_2)->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(GetEffectInfo(EFFECT_2).TriggerSpell);
}
void Register() override
@@ -4001,7 +4014,7 @@ class spell_gen_impatient_mind : public AuraScript
void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell);
}
void Register() override
+10 -3
View File
@@ -28,6 +28,7 @@
#include "Player.h"
#include "ScriptedCreature.h"
#include "SpellAuraEffects.h"
#include "SpellMgr.h"
#include "SpellScript.h"
#include "Vehicle.h"
#include "World.h"
@@ -539,6 +540,13 @@ class spell_pilgrims_bounty_feast_on : public SpellScriptLoader
{
PrepareSpellScript(spell_pilgrims_bounty_feast_on_SpellScript);
bool Validate(SpellInfo const* spellInfo) override
{
return !spellInfo->GetEffects().empty()
&& ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) })
&& !sSpellMgr->AssertSpellInfo(spellInfo->GetEffect(EFFECT_0).CalcValue(), DIFFICULTY_NONE)->GetEffects().empty();
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
@@ -576,8 +584,7 @@ class spell_pilgrims_bounty_feast_on : public SpellScriptLoader
if (Aura* aura = caster->GetAura(GetEffectValue()))
{
if (aura->GetStackAmount() == 1)
if (SpellEffectInfo const* effect = aura->GetSpellInfo()->GetEffect(EFFECT_0))
caster->RemoveAurasDueToSpell(effect->CalcValue());
caster->RemoveAurasDueToSpell(aura->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue());
aura->ModStackAmount(-1);
}
}
@@ -1328,7 +1335,7 @@ class spell_brewfest_relay_race_intro_force_player_to_throw : public SpellScript
PreventHitDefaultEffect(effIndex);
// All this spells trigger a spell that requires reagents; if the
// triggered spell is cast as "triggered", reagents are not consumed
GetHitUnit()->CastSpell(nullptr, GetEffectInfo()->TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST));
GetHitUnit()->CastSpell(nullptr, GetEffectInfo().TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST));
}
void Register() override
+2 -1
View File
@@ -211,7 +211,8 @@ class spell_hun_masters_call : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffect(EFFECT_0) && ValidateSpellInfo({ SPELL_HUNTER_MASTERS_CALL_TRIGGERED, uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) });
return !spellInfo->GetEffects().empty()
&& ValidateSpellInfo({ SPELL_HUNTER_MASTERS_CALL_TRIGGERED, uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
bool Load() override
+14 -26
View File
@@ -1121,12 +1121,12 @@ class spell_item_crystal_spire_of_karabor : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffect(EFFECT_0) != nullptr;
return !spellInfo->GetEffects().empty();
}
bool CheckProc(ProcEventInfo& eventInfo)
{
int32 pct = GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue();
int32 pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue();
if (HealInfo* healInfo = eventInfo.GetHealInfo())
if (Unit* healTarget = healInfo->GetTarget())
if (healTarget->GetHealth() - healInfo->GetEffectiveHeal() <= healTarget->CountPctFromMaxHealth(pct))
@@ -3765,7 +3765,7 @@ class spell_item_artifical_stamina : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffect(EFFECT_1) != nullptr;
return spellInfo->GetEffects().size() > EFFECT_1;
}
bool Load() override
@@ -3776,7 +3776,7 @@ class spell_item_artifical_stamina : public AuraScript
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
if (Item* artifact = GetOwner()->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID()))
amount = GetSpellInfo()->GetEffect(EFFECT_1)->BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100;
amount = GetEffectInfo(EFFECT_1).BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100;
}
void Register() override
@@ -3791,7 +3791,7 @@ class spell_item_artifical_damage : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffect(EFFECT_1) != nullptr;
return spellInfo->GetEffects().size() > EFFECT_1;
}
bool Load() override
@@ -3802,7 +3802,7 @@ class spell_item_artifical_damage : public AuraScript
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
if (Item* artifact = GetOwner()->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID()))
amount = GetSpellInfo()->GetEffect(EFFECT_1)->BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100;
amount = GetSpellInfo()->GetEffect(EFFECT_1).BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100;
}
void Register() override
@@ -3817,11 +3817,6 @@ enum AuraProcRemoveSpells
SPELL_JOM_GABBAR = 29602,
SPELL_BATTLE_TRANCE = 45040,
SPELL_WORLD_QUELLER_FOCUS = 90900,
SPELL_AZURE_WATER_STRIDER = 118089,
SPELL_CRIMSON_WATER_STRIDER = 127271,
SPELL_ORANGE_WATER_STRIDER = 127272,
SPELL_JADE_WATER_STRIDER = 127274,
SPELL_GOLDEN_WATER_STRIDER = 127278,
SPELL_BRUTAL_KINSHIP_1 = 144671,
SPELL_BRUTAL_KINSHIP_2 = 145738
};
@@ -3838,7 +3833,7 @@ class spell_item_talisman_of_ascendance : public AuraScript
void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell);
}
void Register() override
@@ -3859,7 +3854,7 @@ class spell_item_jom_gabbar : public AuraScript
void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell);
}
void Register() override
@@ -3880,7 +3875,7 @@ class spell_item_battle_trance : public AuraScript
void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell);
}
void Register() override
@@ -3901,7 +3896,7 @@ class spell_item_world_queller_focus : public AuraScript
void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell);
}
void Register() override
@@ -3919,21 +3914,14 @@ class spell_item_water_strider : public AuraScript
{
PrepareAuraScript(spell_item_water_strider);
bool Validate(SpellInfo const* /*spell*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo(
{
SPELL_AZURE_WATER_STRIDER,
SPELL_CRIMSON_WATER_STRIDER,
SPELL_ORANGE_WATER_STRIDER,
SPELL_JADE_WATER_STRIDER,
SPELL_GOLDEN_WATER_STRIDER
});
return spellInfo->GetEffects().size() > EFFECT_1;
}
void OnRemove(AuraEffect const* /*effect*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(EFFECT_1)->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(EFFECT_1).TriggerSpell);
}
void Register() override
@@ -3955,7 +3943,7 @@ class spell_item_brutal_kinship : public AuraScript
void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell);
GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell);
}
void Register() override
+18 -14
View File
@@ -172,7 +172,7 @@ class spell_mage_arcane_barrage : public SpellScript
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_MAGE_ARCANE_BARRAGE_R3, SPELL_MAGE_ARCANE_BARRAGE_ENERGIZE })
&& spellInfo->GetEffect(EFFECT_1);
&& spellInfo->GetEffects().size() > EFFECT_1;
}
void ConsumeArcaneCharges()
@@ -188,7 +188,7 @@ class spell_mage_arcane_barrage : public SpellScript
void HandleEffectHitTarget(SpellEffIndex /*effIndex*/)
{
if (GetHitUnit()->GetGUID() != _primaryTarget)
SetHitDamage(CalculatePct(GetHitDamage(), GetEffectInfo(EFFECT_1)->CalcValue(GetCaster())));
SetHitDamage(CalculatePct(GetHitDamage(), GetEffectInfo(EFFECT_1).CalcValue(GetCaster())));
}
void MarkPrimaryTarget(SpellEffIndex /*effIndex*/)
@@ -237,8 +237,10 @@ class spell_mage_arcane_explosion : public SpellScript
if (!ValidateSpellInfo({ SPELL_MAGE_ARCANE_MAGE, SPELL_MAGE_REVERBERATE }))
return false;
SpellEffectInfo const* damageEffect = spellInfo->GetEffect(EFFECT_1);
return damageEffect && damageEffect->IsEffect(SPELL_EFFECT_SCHOOL_DAMAGE);
if (spellInfo->GetEffects().size() <= EFFECT_1)
return false;
return spellInfo->GetEffect(EFFECT_1).IsEffect(SPELL_EFFECT_SCHOOL_DAMAGE);
}
void CheckRequiredAuraForBaselineEnergize(SpellEffIndex effIndex)
@@ -350,11 +352,11 @@ class spell_mage_cauterize_AuraScript : public AuraScript
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffect(EFFECT_2) && ValidateSpellInfo
return spellInfo->GetEffects().size() > EFFECT_2 && ValidateSpellInfo
({
SPELL_MAGE_CAUTERIZE_DOT,
SPELL_MAGE_CAUTERIZED,
spellInfo->GetEffect(EFFECT_2)->TriggerSpell
spellInfo->GetEffect(EFFECT_2).TriggerSpell
});
}
@@ -372,7 +374,7 @@ class spell_mage_cauterize_AuraScript : public AuraScript
}
GetTarget()->SetHealth(GetTarget()->CountPctFromMaxHealth(effect1->GetAmount()));
GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->GetEffect(EFFECT_2)->TriggerSpell, TRIGGERED_FULL_MASK);
GetTarget()->CastSpell(GetTarget(), GetEffectInfo(EFFECT_2).TriggerSpell, TRIGGERED_FULL_MASK);
GetTarget()->CastSpell(GetTarget(), SPELL_MAGE_CAUTERIZE_DOT, TRIGGERED_FULL_MASK);
GetTarget()->CastSpell(GetTarget(), SPELL_MAGE_CAUTERIZED, TRIGGERED_FULL_MASK);
}
@@ -583,9 +585,9 @@ class spell_mage_ice_lance : public SpellScript
{
// Thermal Void
if (Aura const* thermalVoid = caster->GetAura(SPELL_MAGE_THERMAL_VOID))
if (SpellEffectInfo const* thermalVoidEffect = thermalVoid->GetSpellInfo()->GetEffect(EFFECT_0))
if (!thermalVoid->GetSpellInfo()->GetEffects().empty())
if (Aura* icyVeins = caster->GetAura(SPELL_MAGE_ICY_VEINS))
icyVeins->SetDuration(icyVeins->GetDuration() + thermalVoidEffect->CalcValue(caster) * IN_MILLISECONDS);
icyVeins->SetDuration(icyVeins->GetDuration() + thermalVoid->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(caster) * IN_MILLISECONDS);
// Chain Reaction
if (caster->HasAura(SPELL_MAGE_CHAIN_REACTION_DUMMY))
@@ -620,7 +622,7 @@ class spell_mage_ice_lance_damage : public SpellScript
{
int32 originalDamage = GetHitDamage();
float targetIndex = float(spellValue->EffectBasePoints[EFFECT_1]);
float multiplier = std::pow(GetEffectInfo()->CalcDamageMultiplier(GetCaster(), GetSpell()), targetIndex);
float multiplier = std::pow(GetEffectInfo().CalcDamageMultiplier(GetCaster(), GetSpell()), targetIndex);
SetHitDamage(int32(originalDamage * multiplier));
}
}
@@ -834,7 +836,8 @@ class spell_mage_ring_of_frost : public AuraScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE });
return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE })
&& !sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffects().empty();
}
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
@@ -846,7 +849,7 @@ class spell_mage_ring_of_frost : public AuraScript
void Apply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
std::list<TempSummon*> minions;
GetTarget()->GetAllMinionsByEntry(minions, sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0)->MiscValue);
GetTarget()->GetAllMinionsByEntry(minions, sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0).MiscValue);
// Get the last summoned RoF, save it and despawn older ones
for (TempSummon* summon : minions)
@@ -890,13 +893,14 @@ class spell_mage_ring_of_frost_freeze : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE });
return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE })
&& !sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffects().empty();
}
void FilterTargets(std::list<WorldObject*>& targets)
{
WorldLocation const* dest = GetExplTargetDest();
float outRadius = sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0)->CalcRadius();
float outRadius = sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0).CalcRadius();
float inRadius = 6.5f;
targets.remove_if([dest, outRadius, inRadius](WorldObject* target)
+7 -6
View File
@@ -326,14 +326,15 @@ class spell_monk_stagger_debuff_aura : public AuraScript
{
PrepareAuraScript(spell_monk_stagger_debuff_aura);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_MONK_STAGGER_DAMAGE_AURA })
&& !sSpellMgr->GetSpellInfo(SPELL_MONK_STAGGER_DAMAGE_AURA, DIFFICULTY_NONE)->GetEffects().empty();
}
bool Load() override
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_MONK_STAGGER_DAMAGE_AURA, GetCastDifficulty());
SpellEffectInfo const* effInfo = !spellInfo ? nullptr : spellInfo->GetEffect(EFFECT_0);
if (!effInfo)
return false;
_period = float(effInfo->ApplyAuraPeriod);
_period = float(sSpellMgr->AssertSpellInfo(SPELL_MONK_STAGGER_DAMAGE_AURA, GetCastDifficulty())->GetEffect(EFFECT_0).ApplyAuraPeriod);
return true;
}
+4 -4
View File
@@ -898,7 +898,7 @@ public:
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, GetCastDifficulty()); // Then get the SpellProto and add the dummy effect value
AddPct(mod, spellInfo->GetEffect(EFFECT_0)->CalcValue());
AddPct(mod, spellInfo->GetEffect(EFFECT_0).CalcValue());
}
int32 const ownerBonus = owner->GetStat(STAT_STAMINA) * mod;
@@ -940,7 +940,7 @@ public:
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, GetCastDifficulty()); // Then get the SpellProto and add the dummy effect value
mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1)->CalcValue());
mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1).CalcValue());
}
bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f * mod;
@@ -970,7 +970,7 @@ public:
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, GetCastDifficulty()); // Then get the SpellProto and add the dummy effect value
mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1)->CalcValue());
mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1).CalcValue());
}
bonusDamage = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.1287f * mod;
@@ -1410,7 +1410,7 @@ public:
amount = -90;
// Night of the dead
else if (Aura* aur = owner->GetAuraOfRankedSpell(SPELL_NIGHT_OF_THE_DEAD))
amount = aur->GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue();
amount = aur->GetSpellInfo()->GetEffect(EFFECT_2).CalcValue();
}
}
}
+20 -28
View File
@@ -174,9 +174,9 @@ public:
{
PrepareAuraScript(spell_pri_atonement_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT_HEAL });
return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT_HEAL }) && spellInfo->GetEffects().size() > EFFECT_1;
}
bool CheckProc(ProcEventInfo& eventInfo)
@@ -193,7 +193,7 @@ public:
{
if (Unit* target = ObjectAccessor::GetUnit(*GetTarget(), targetGuid))
{
if (target->GetExactDist(GetTarget()) < GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue())
if (target->GetExactDist(GetTarget()) < GetEffectInfo(EFFECT_1).CalcValue())
GetTarget()->CastSpell(target, SPELL_PRIEST_ATONEMENT_HEAL, args);
return false;
@@ -325,14 +325,14 @@ class spell_pri_guardian_spirit : public SpellScriptLoader
uint32 healPct = 0;
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL });
return ValidateSpellInfo({ SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL }) && spellInfo->GetEffects().size() > EFFECT_1;
}
bool Load() override
{
healPct = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue();
healPct = GetEffectInfo(EFFECT_1).CalcValue();
return true;
}
@@ -387,11 +387,10 @@ class spell_pri_holy_words : public AuraScript
SPELL_PRIEST_HOLY_WORD_CHASTISE,
SPELL_PRIEST_HOLY_WORD_SANCTIFY,
SPELL_PRIEST_HOLY_WORD_SERENITY
})
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SERENITY, DIFFICULTY_NONE)->GetEffect(EFFECT_1)
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SANCTIFY, DIFFICULTY_NONE)->GetEffect(EFFECT_2)
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SANCTIFY, DIFFICULTY_NONE)->GetEffect(EFFECT_3)
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_CHASTISE, DIFFICULTY_NONE)->GetEffect(EFFECT_1);
})
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SERENITY, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_1
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SANCTIFY, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_3
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_CHASTISE, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_1;
}
void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& eventInfo)
@@ -428,7 +427,7 @@ class spell_pri_holy_words : public AuraScript
}
SpellInfo const* targetSpellInfo = sSpellMgr->AssertSpellInfo(targetSpellId, GetCastDifficulty());
int32 cdReduction = targetSpellInfo->GetEffect(cdReductionEffIndex)->CalcValue(GetTarget());
int32 cdReduction = targetSpellInfo->GetEffect(cdReductionEffIndex).CalcValue(GetTarget());
GetTarget()->GetSpellHistory()->ModifyCooldown(targetSpellInfo, Seconds(-cdReduction));
}
@@ -632,18 +631,15 @@ class spell_pri_power_word_radiance : public SpellScript
{
PrepareSpellScript(spell_pri_power_word_radiance);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT, SPELL_PRIEST_ATONEMENT_TRIGGERED, SPELL_PRIEST_TRINITY });
return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT, SPELL_PRIEST_ATONEMENT_TRIGGERED, SPELL_PRIEST_TRINITY })
&& spellInfo->GetEffects().size() > EFFECT_3;
}
void OnTargetSelect(std::list<WorldObject*>& targets)
{
SpellEffectInfo const* eff2 = GetEffectInfo(EFFECT_2);
if (!eff2)
return;
uint32 maxTargets = eff2->CalcValue(GetCaster()) + 1; // adding 1 for explicit target unit
uint32 maxTargets = GetEffectInfo(EFFECT_2).CalcValue(GetCaster()) + 1; // adding 1 for explicit target unit
if (targets.size() > maxTargets)
{
Unit* explTarget = GetExplTargetUnit();
@@ -669,11 +665,7 @@ class spell_pri_power_word_radiance : public SpellScript
if (caster->HasAura(SPELL_PRIEST_TRINITY))
return;
SpellEffectInfo const* effect3 = GetEffectInfo(EFFECT_3);
if (!effect3)
return;
uint32 durationPct = effect3->CalcValue(caster);
uint32 durationPct = GetEffectInfo(EFFECT_3).CalcValue(caster);
if (caster->HasAura(SPELL_PRIEST_ATONEMENT))
caster->CastSpell(GetHitUnit(), SPELL_PRIEST_ATONEMENT_TRIGGERED, CastSpellExtraArgs(SPELLVALUE_DURATION_PCT, durationPct).SetTriggerFlags(TRIGGERED_FULL_MASK));
}
@@ -799,19 +791,19 @@ public:
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, SPELL_PRIEST_PRAYER_OF_MENDING_AURA })
&& sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, DIFFICULTY_NONE)->GetEffect(EFFECT_0);
&& !sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, DIFFICULTY_NONE)->GetEffects().empty();
}
bool Load() override
{
_spellInfoHeal = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, DIFFICULTY_NONE);
_healEffectDummy = _spellInfoHeal->GetEffect(EFFECT_0);
_healEffectDummy = &_spellInfoHeal->GetEffect(EFFECT_0);
return true;
}
void CastPrayerOfMendingAura(Unit* caster, Unit* target, uint8 stack)
{
uint32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy->CalcValue(caster), HEAL, _healEffectDummy);
uint32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy->CalcValue(caster), HEAL, *_healEffectDummy);
CastSpellExtraArgs args;
args.TriggerFlags = TRIGGERED_FULL_MASK;
args.AddSpellMod(SPELLVALUE_AURA_STACK, stack);
@@ -1264,7 +1256,7 @@ class spell_pri_angelic_feather_trigger : public SpellScriptLoader
void HandleEffectDummy(SpellEffIndex /*effIndex*/)
{
Position destPos = GetHitDest()->GetPosition();
float radius = GetEffectInfo()->CalcRadius();
float radius = GetEffectInfo().CalcRadius();
// Caster is prioritary
if (GetCaster()->IsWithinDist2d(&destPos, radius))
+11 -5
View File
@@ -634,14 +634,19 @@ class spell_q12683_take_sputum_sample : public SpellScriptLoader
{
PrepareSpellScript(spell_q12683_take_sputum_sample_SpellScript);
bool Validate(SpellInfo const* spellInfo) override
{
return spellInfo->GetEffects().size() > EFFECT_1;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
uint32 reqAuraId = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue();
uint32 reqAuraId = GetEffectInfo(EFFECT_1).CalcValue();
Unit* caster = GetCaster();
if (caster->HasAuraEffect(reqAuraId, 0))
{
uint32 spellId = GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue();
uint32 spellId = GetEffectInfo().CalcValue();
caster->CastSpell(caster, spellId, true);
}
}
@@ -1916,7 +1921,8 @@ class spell_q13086_cannons_target : public SpellScriptLoader
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0)->CalcValue()) });
return !spellInfo->GetEffects().empty()
&& ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleEffectDummy(SpellEffIndex /*effIndex*/)
@@ -2160,7 +2166,7 @@ class spell_q12308_escape_from_silverbrook_summon_worgen : public SpellScriptLoa
void ModDest(SpellDestination& dest)
{
float dist = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster());
float dist = GetEffectInfo(EFFECT_0).CalcRadius(GetCaster());
float angle = frand(0.75f, 1.25f) * float(M_PI);
Position pos = GetCaster()->GetNearPosition(dist, angle);
@@ -2301,7 +2307,7 @@ class spell_q12619_emblazon_runeblade : public SpellScriptLoader
{
PreventDefaultAction();
if (Unit* caster = GetCaster())
caster->CastSpell(caster, aurEff->GetSpellEffectInfo()->TriggerSpell, aurEff);
caster->CastSpell(caster, aurEff->GetSpellEffectInfo().TriggerSpell, aurEff);
}
void Register() override
+14 -16
View File
@@ -270,27 +270,25 @@ class spell_warl_devour_magic : public SpellScriptLoader
{
PrepareSpellScript(spell_warl_devour_magic_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL });
return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL })
&& spellInfo->GetEffects().size() > EFFECT_1;
}
void OnSuccessfulDispel(SpellEffIndex /*effIndex*/)
{
if (SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(EFFECT_1))
{
Unit* caster = GetCaster();
CastSpellExtraArgs args;
args.TriggerFlags = TRIGGERED_FULL_MASK;
args.AddSpellBP0(effect->CalcValue(caster));
Unit* caster = GetCaster();
CastSpellExtraArgs args;
args.TriggerFlags = TRIGGERED_FULL_MASK;
args.AddSpellBP0(GetEffectInfo(EFFECT_1).CalcValue(caster));
caster->CastSpell(caster, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args);
caster->CastSpell(caster, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args);
// Glyph of Felhunter
if (Unit* owner = caster->GetOwner())
if (owner->GetAura(SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING))
owner->CastSpell(owner, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args);
}
// Glyph of Felhunter
if (Unit* owner = caster->GetOwner())
if (owner->GetAura(SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING))
owner->CastSpell(owner, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args);
}
void Register() override
@@ -517,7 +515,7 @@ class spell_warl_seed_of_corruption_dummy : public SpellScriptLoader
if (!caster)
return;
amount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * ASSERT_NOTNULL(GetSpellInfo()->GetEffect(EFFECT_0))->CalcValue(caster) / 100;
amount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * GetEffectInfo(EFFECT_0).CalcValue(caster) / 100;
}
void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo)
@@ -711,7 +709,7 @@ class spell_warl_soul_swap_dot_marker : public SpellScriptLoader
if (!swapSpellScript)
return;
flag128 classMask = GetEffectInfo()->SpellClassMask;
flag128 classMask = GetEffectInfo().SpellClassMask;
for (Unit::AuraApplicationMap::const_iterator itr = appliedAuras.begin(); itr != appliedAuras.end(); ++itr)
{
+7 -6
View File
@@ -437,9 +437,10 @@ class spell_warr_item_t10_prot_4p_bonus : public SpellScriptLoader
{
PrepareAuraScript(spell_warr_item_t10_prot_4p_bonus_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_WARRIOR_STOICISM });
return ValidateSpellInfo({ SPELL_WARRIOR_STOICISM })
&& spellInfo->GetEffects().size() > EFFECT_1;
}
void HandleProc(ProcEventInfo& eventInfo)
@@ -447,7 +448,7 @@ class spell_warr_item_t10_prot_4p_bonus : public SpellScriptLoader
PreventDefaultAction();
Unit* target = eventInfo.GetActionTarget();
int32 bp0 = CalculatePct(target->GetMaxHealth(), GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue());
int32 bp0 = CalculatePct(target->GetMaxHealth(), GetEffectInfo(EFFECT_1).CalcValue());
CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
args.AddSpellBP0(bp0);
target->CastSpell(nullptr, SPELL_WARRIOR_STOICISM, args);
@@ -553,7 +554,7 @@ public:
if (!ValidateSpellInfo({ SPELL_WARRIOR_SHOCKWAVE, SPELL_WARRIOR_SHOCKWAVE_STUN }))
return false;
return spellInfo->GetEffect(EFFECT_0) && spellInfo->GetEffect(EFFECT_3);
return spellInfo->GetEffects().size() > EFFECT_3;
}
bool Load() override
@@ -570,8 +571,8 @@ public:
// Cooldown reduced by 20 sec if it strikes at least 3 targets.
void HandleAfterCast()
{
if (_targetCount >= uint32(GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue()))
GetCaster()->ToPlayer()->GetSpellHistory()->ModifyCooldown(GetSpellInfo()->Id, Seconds(-GetSpellInfo()->GetEffect(EFFECT_3)->CalcValue()));
if (_targetCount >= uint32(GetEffectInfo(EFFECT_0).CalcValue()))
GetCaster()->ToPlayer()->GetSpellHistory()->ModifyCooldown(GetSpellInfo()->Id, Seconds(-GetEffectInfo(EFFECT_3).CalcValue()));
}
void Register() override
+2 -5
View File
@@ -286,12 +286,9 @@ bool EquippedOk(Player* player, uint32 spellId)
if (!spell)
return false;
for (SpellEffectInfo const* effect : spell->GetEffects())
for (SpellEffectInfo const& spellEffectInfo : spell->GetEffects())
{
if (!effect)
continue;
uint32 reqSpell = effect->TriggerSpell;
uint32 reqSpell = spellEffectInfo.TriggerSpell;
if (!reqSpell)
continue;
+4 -4
View File
@@ -2220,10 +2220,10 @@ public:
break;
}
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE))
if (SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0))
if (effect0->Effect == SPELL_EFFECT_SUMMON_OBJECT_WILD)
return effect0->MiscValue;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE);
if (spellInfo && spellInfo->GetEffect(EFFECT_0).Effect == SPELL_EFFECT_SUMMON_OBJECT_WILD)
return spellInfo->GetEffect(EFFECT_0).MiscValue;
return 0;
}