diff options
Diffstat (limited to 'src/game/Spell.cpp')
| -rw-r--r-- | src/game/Spell.cpp | 79 |
1 files changed, 35 insertions, 44 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 8b0014caaae..2656e1af3c5 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -295,14 +295,11 @@ void SpellCastTargets::write ( WorldPacket * data ) } Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer, bool skipCheck ) +: m_spellInfo(info), m_spellValue(new SpellValue(m_spellInfo)) +, m_caster(Caster) { - ASSERT( Caster != NULL && info != NULL ); - ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element"); - - m_spellInfo = info; m_customAttr = spellmgr.GetSpellCustomAttr(m_spellInfo->Id); m_skipCheck = skipCheck; - m_caster = Caster; m_selfContainer = NULL; m_triggeringContainer = triggeringContainer; m_referencedFromCurrentSpell = false; @@ -362,7 +359,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi } for(int i=0; i <3; ++i) - m_currentBasePoints[i] = m_spellInfo->EffectBasePoints[i]; + m_currentBasePoints[i] = m_spellValue->EffectBasePoints[i]; m_spellState = SPELL_STATE_NULL; @@ -419,6 +416,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi Spell::~Spell() { + delete m_spellValue; } void Spell::FillTargetMap() @@ -1506,7 +1504,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) //Chain: 2, 6, 22, 25, 45, 77 uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i]; - uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; + uint32 unMaxTargets = m_spellValue->MaxAffectedTargets; Unit::AuraEffectList const& Auras = m_caster->GetAurasByType(SPELL_AURA_MOD_MAX_AFFECTED_TARGETS); for(Unit::AuraEffectList::const_iterator j = Auras.begin();j != Auras.end(); ++j) @@ -1571,6 +1569,11 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) break; } + if(!IsPositiveSpell(m_spellInfo->Id)) + if(Unit *magnet = m_caster->SelectMagnetTarget(target)) + if(magnet != target) + m_targets.setUnitTarget(magnet); + switch(cur) { case TARGET_UNIT_MINIPET: @@ -1579,7 +1582,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) break; case TARGET_UNIT_TARGET_ALLY: case TARGET_UNIT_TARGET_RAID: - case TARGET_UNIT_TARGET_ANY: // SelectMagnetTarget()? + case TARGET_UNIT_TARGET_ANY: case TARGET_UNIT_TARGET_PARTY: TagUnitMap.push_back(target); break; @@ -1588,8 +1591,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) break; case TARGET_UNIT_TARGET_ENEMY: if(EffectChainTarget <= 1) - TagUnitMap.push_back(SelectMagnetTarget()); - else if(SelectMagnetTarget()) //TODO: chain target should also use magnet target + TagUnitMap.push_back(target); + else SearchChainTarget(TagUnitMap, radius_h, EffectChainTarget, SPELL_TARGETS_ENEMY); break; case TARGET_UNIT_CHAINHEAL: @@ -5386,40 +5389,6 @@ bool Spell::CheckTarget( Unit* target, uint32 eff ) return true; } -Unit* Spell::SelectMagnetTarget() -{ - Unit* target = m_targets.getUnitTarget(); - - if(target && m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && target->HasAuraType(SPELL_AURA_SPELL_MAGNET)) //Attributes & 0x10 what is this? - { - Unit::AuraEffectList const& magnetAuras = target->GetAurasByType(SPELL_AURA_SPELL_MAGNET); - for(Unit::AuraEffectList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr) - { - if(Unit* magnet = (*itr)->GetCaster()) - { - if((*itr)->GetParentAura()->DropAuraCharge()) - { - target = magnet; - m_targets.setUnitTarget(target); - AddUnitTarget(target, 0); - uint64 targetGUID = target->GetGUID(); - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - { - if (targetGUID == ihit->targetGUID) // Found in list - { - (*ihit).damage = target->GetHealth(); - break; - } - } - break; - } - } - } - } - - return target; -} - bool Spell::IsNeedSendToClient() const { return m_spellInfo->SpellVisual[0] || m_spellInfo->SpellVisual[1] || IsChanneledSpell(m_spellInfo) || @@ -5767,3 +5736,25 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk return SPELL_CAST_OK; } + +void Spell::SetSpellValue(SpellValueMod mod, int32 value) +{ + switch(mod) + { + case SPELLVALUE_BASE_POINT0: + m_spellValue->EffectBasePoints[0] = value - int32(m_spellInfo->EffectBaseDice[0]); + m_currentBasePoints[0] = m_spellValue->EffectBasePoints[0]; //this should be removed in the future + break; + case SPELLVALUE_BASE_POINT1: + m_spellValue->EffectBasePoints[1] = value - int32(m_spellInfo->EffectBaseDice[1]); + m_currentBasePoints[1] = m_spellValue->EffectBasePoints[1]; + break; + case SPELLVALUE_BASE_POINT2: + m_spellValue->EffectBasePoints[2] = value - int32(m_spellInfo->EffectBaseDice[2]); + m_currentBasePoints[2] = m_spellValue->EffectBasePoints[2]; + break; + case SPELLVALUE_MAX_TARGETS: + m_spellValue->MaxAffectedTargets = (uint32)value; + break; + } +} |
