aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorRat <gmstreetrat@gmail.com>2014-11-24 18:57:49 +0100
committerRat <gmstreetrat@gmail.com>2014-11-24 18:57:49 +0100
commit2144d6c85159ad1e8529ef8e8ee1476e947fca92 (patch)
tree75f88bd9e73e4e860d4d2e6608e078341844ae7d /src/server/game/Entities
parent42fa46a11d7ee09054fa3e759307e2a7318b4d71 (diff)
Core/Spells: core now builds without scripts project, still not stable
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp29
-rw-r--r--src/server/game/Entities/Creature/Creature.h2
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp4
-rw-r--r--src/server/game/Entities/Player/Player.cpp49
-rw-r--r--src/server/game/Entities/Totem/Totem.cpp8
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp13
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp2
7 files changed, 68 insertions, 39 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 25c1acddfdc..d342bb3c431 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1619,11 +1619,11 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
// This check must be done instead of 'if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))' for not break
// the check of mechanic immunity on DB (tested) because GetCreatureTemplate()->MechanicImmuneMask and m_spellImmune[IMMUNITY_MECHANIC] don't have same data.
bool immunedToAllEffects = true;
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficulty()))
{
- if (!spellInfo->Effects[i].IsEffect())
+ if (!effect || !effect->IsEffect())
continue;
- if (!IsImmunedToSpellEffect(spellInfo, i))
+ if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex))
{
immunedToAllEffects = false;
break;
@@ -1637,10 +1637,13 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
{
- if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Effects[index].Mechanic - 1)))
+ SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficulty());
+ if (!effect)
+ return true;
+ if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (effect->Mechanic - 1)))
return true;
- if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL)
+ if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && effect->Effect == SPELL_EFFECT_HEAL)
return true;
return Unit::IsImmunedToSpellEffect(spellInfo, index);
@@ -1680,13 +1683,13 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
}
bool bcontinue = true;
- for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficulty()))
{
- if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) ||
- (spellInfo->Effects[j].Effect == SPELL_EFFECT_INSTAKILL) ||
- (spellInfo->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
- (spellInfo->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
- )
+ if (effect && ((effect->Effect == SPELL_EFFECT_SCHOOL_DAMAGE) ||
+ (effect->Effect == SPELL_EFFECT_INSTAKILL) ||
+ (effect->Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
+ (effect->Effect == SPELL_EFFECT_HEALTH_LEECH)
+ ))
{
bcontinue = false;
break;
@@ -1728,9 +1731,9 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* victim)
}
bool bcontinue = true;
- for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficulty()))
{
- if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_HEAL))
+ if (effect && (effect->Effect == SPELL_EFFECT_HEAL))
{
bcontinue = false;
break;
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 9acde98a7a8..2de22942a62 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -405,7 +405,7 @@ struct TrainerSpell
uint32 ReqSkillLine;
uint32 ReqSkillRank;
uint32 ReqLevel;
- uint32 ReqAbility[3];
+ uint32 ReqAbility[MAX_SPELL_EFFECTS];
// helpers
bool IsCastable() const { return ReqAbility[0] != SpellID; }
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 2b13c859255..7091901c229 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1809,9 +1809,9 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, bool triggered /*= true
return;
bool self = false;
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficulty()))
{
- if (spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_CASTER)
+ if (effect && effect->TargetA.GetTarget() == TARGET_UNIT_CASTER)
{
self = true;
break;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 3866d28dae8..6bebd7a5fd7 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -3526,7 +3526,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent
// cast talents with SPELL_EFFECT_LEARN_SPELL (other dependent spells will learned later as not auto-learned)
// note: all spells with SPELL_EFFECT_LEARN_SPELL isn't passive
- if (!loading && spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL))
+ if (!loading && spellInfo->HasEffect(DIFFICULTY_NONE, SPELL_EFFECT_LEARN_SPELL))
{
// ignore stance requirement for talent learn spell (stance set for spell only for client spell description show)
CastSpell(this, spellId, true);
@@ -3537,7 +3537,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent
if (IsNeedCastPassiveSpellAtLearn(spellInfo))
CastSpell(this, spellId, true);
}
- else if (spellInfo->HasEffect(SPELL_EFFECT_SKILL_STEP))
+ else if (spellInfo->HasEffect(DIFFICULTY_NONE, SPELL_EFFECT_SKILL_STEP))
{
CastSpell(this, spellId, true);
return false;
@@ -3849,8 +3849,8 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
if (spellInfo->IsPassive())
{
- for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
- if (spellInfo->Effects[i].Effect == SPELL_EFFECT_DUAL_WIELD)
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
+ if (effect && effect->Effect == SPELL_EFFECT_DUAL_WIELD)
{
SetCanDualWield(false);
break;
@@ -4098,9 +4098,9 @@ bool Player::ResetTalents(bool no_cost)
RemoveSpell(talentInfo->SpellID, true);
// search for spells that the talent teaches and unlearn them
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- if (_spellEntry->Effects[i].TriggerSpell > 0 && _spellEntry->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL)
- RemoveSpell(_spellEntry->Effects[i].TriggerSpell, true);
+ for (SpellEffectInfo const* effect : _spellEntry->GetEffectsForDifficulty(DIFFICULTY_NONE))
+ if (effect && effect->TriggerSpell > 0 && effect->Effect == SPELL_EFFECT_LEARN_SPELL)
+ RemoveSpell(effect->TriggerSpell, true);
}
// Remove all specialization specific spells and give default ones which were overriden
@@ -8268,7 +8268,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
}
// not allow proc extra attack spell at extra attack
- if (m_extraAttacks && spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
+ if (m_extraAttacks && spellInfo->HasEffect(DIFFICULTY_NONE, SPELL_EFFECT_ADD_EXTRA_ATTACKS))
return;
float chance = (float)spellInfo->ProcChance;
@@ -15128,7 +15128,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
if (quest->GetRewSpellCast() > 0)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpellCast());
- if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM))
+ if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(DIFFICULTY_NONE, SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(DIFFICULTY_NONE, SPELL_EFFECT_CREATE_ITEM))
{
if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID()))
creature->CastSpell(this, quest->GetRewSpellCast(), true);
@@ -15139,7 +15139,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
else if (quest->GetRewSpell() > 0)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpell());
- if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM))
+ if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(DIFFICULTY_NONE, SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(DIFFICULTY_NONE, SPELL_EFFECT_CREATE_ITEM))
{
if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID()))
creature->CastSpell(this, quest->GetRewSpell(), true);
@@ -23326,9 +23326,9 @@ void Player::LearnQuestRewardedSpells(Quest const* quest)
// check learned spells state
bool found = false;
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
{
- if (spellInfo->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->Effects[i].TriggerSpell))
+ if (effect && effect->Effect == SPELL_EFFECT_LEARN_SPELL && !HasSpell(effect->TriggerSpell))
{
found = true;
break;
@@ -23339,8 +23339,12 @@ void Player::LearnQuestRewardedSpells(Quest const* quest)
if (!found)
return;
+ SpellEffectInfo const* effect = spellInfo->GetEffect(DIFFICULTY_NONE, EFFECT_0);
+ if (!effect)
+ return;
+
// prevent learn non first rank unknown profession and second specialization for same profession)
- uint32 learned_0 = spellInfo->Effects[0].TriggerSpell;
+ uint32 learned_0 = effect->TriggerSpell;
if (sSpellMgr->GetSpellRank(learned_0) > 1 && !HasSpell(learned_0))
{
SpellInfo const* learnedInfo = sSpellMgr->GetSpellInfo(learned_0);
@@ -23356,8 +23360,15 @@ void Player::LearnQuestRewardedSpells(Quest const* quest)
{
uint32 profSpell = itr2->second;
+ SpellEffectInfo const* effect0 = learnedInfo->GetEffect(DIFFICULTY_NONE, EFFECT_0);
+ if (!effect0)
+ continue;
+ SpellEffectInfo const* effect1 = learnedInfo->GetEffect(DIFFICULTY_NONE, EFFECT_1);
+ if (!effect1)
+ continue;
+
// specialization
- if (learnedInfo->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effects[1].Effect == 0 && profSpell)
+ if (effect0->Effect == SPELL_EFFECT_TRADE_SKILL && effect1->Effect == 0 && profSpell)
{
// search other specialization for same prof
for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
@@ -23369,8 +23380,16 @@ void Player::LearnQuestRewardedSpells(Quest const* quest)
if (!itrInfo)
return;
+
+ SpellEffectInfo const* itrEffect0 = itrInfo->GetEffect(DIFFICULTY_NONE, EFFECT_0);
+ if (!itrEffect0)
+ continue;
+ SpellEffectInfo const* itrEffect1 = itrInfo->GetEffect(DIFFICULTY_NONE, EFFECT_1);
+ if (!itrEffect1)
+ continue;
+
// compare only specializations
- if (itrInfo->Effects[0].Effect != SPELL_EFFECT_TRADE_SKILL || itrInfo->Effects[1].Effect != 0)
+ if (itrEffect0->Effect != SPELL_EFFECT_TRADE_SKILL || itrEffect1->Effect != 0)
continue;
// compare same chain spells
diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp
index 54956e591b4..d6aeb5dee9c 100644
--- a/src/server/game/Entities/Totem/Totem.cpp
+++ b/src/server/game/Entities/Totem/Totem.cpp
@@ -145,9 +145,10 @@ bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) con
/// @todo possibly all negative auras immune?
if (GetEntry() == 5925)
return false;
-
- switch (spellInfo->Effects[index].ApplyAuraName)
+ if (SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficulty(), index))
{
+ switch (effect->ApplyAuraName)
+ {
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_MOD_FEAR:
@@ -155,7 +156,10 @@ bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) con
return true;
default:
break;
+ }
}
+ else
+ return true;
return Creature::IsImmunedToSpellEffect(spellInfo, index);
}
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index ea15daed587..47567d1a35a 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -537,16 +537,16 @@ void Player::UpdateMastery()
if (Aura* aura = GetAura(chrSpec->MasterySpellID[i]))
{
- for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
+ for (SpellEffectInfo const* effect : aura->GetSpellEffectInfos())
{
- if (!aura->HasEffect(j))
+ if (!effect)
continue;
- float mult = aura->GetSpellInfo()->Effects[j].BonusCoefficient;
+ float mult = effect->BonusCoefficient;
if (G3D::fuzzyEq(mult, 0.0f))
continue;
- aura->GetEffect(j)->ChangeAmount(int32(value * aura->GetSpellInfo()->Effects[j].BonusCoefficient));
+ aura->GetEffect(effect->EffectIndex)->ChangeAmount(int32(value * effect->BonusCoefficient));
}
}
}
@@ -989,8 +989,9 @@ bool Guardian::UpdateStats(Stats stat)
AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0);
if (aurEff)
{
- SpellInfo const* spellInfo = aurEff->GetSpellInfo(); // Then get the SpellProto and add the dummy effect value
- AddPct(mod, spellInfo->Effects[EFFECT_1].CalcValue(owner)); // Ravenous Dead edits the original scale
+ SpellInfo const* spellInfo = aurEff->GetSpellInfo(); // Then get the SpellProto and add the dummy effect value
+ if (SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficulty(), EFFECT_1))
+ AddPct(mod, effect->CalcValue(owner)); // Ravenous Dead edits the original scale
}
// Glyph of the Ghoul
aurEff = owner->GetAuraEffect(58686, 0);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 144b27214b2..fd75103ab7d 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -16555,6 +16555,8 @@ bool Unit::IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplicat
{
for (AuraEffect* aurEff : aura->GetAuraEffects())
{
+ if (!aurEff)
+ continue;
AuraType const auraType = AuraType(aurEff->GetSpellEffectInfo()->ApplyAuraName);
AuraEffectList const& auras = GetAuraEffectsByType(auraType);
for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end();)