Skip to content

Commit

Permalink
[9792] Fix wrong damage dealing from commit [9784]
Browse files Browse the repository at this point in the history
  • Loading branch information
Laise committed Apr 25, 2010
1 parent 8bd5349 commit e7574d2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
62 changes: 38 additions & 24 deletions src/game/Spell.cpp
Expand Up @@ -1238,30 +1238,53 @@ void Spell::HandleDelayedSpellLaunch(TargetInfo *target)
// Fill base damage struct (unitTarget - is real spell target)
SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo->Id, m_spellSchoolMask);

for (int32 effectNumber = 0; effectNumber < MAX_EFFECT_INDEX; ++effectNumber)
if (missInfo == SPELL_MISS_NONE)
{
if (mask & (1 << effectNumber) && IsEffectHandledOnDelayedSpellLaunch(m_spellInfo, SpellEffectIndex(effectNumber)))
for (int32 effectNumber = 0; effectNumber < MAX_EFFECT_INDEX; ++effectNumber)
{
HandleEffects(unit, NULL, NULL, SpellEffectIndex(effectNumber), m_damageMultipliers[effectNumber]);
if ( m_applyMultiplierMask & (1 << effectNumber) )
if (mask & (1 << effectNumber) && IsEffectHandledOnDelayedSpellLaunch(m_spellInfo, SpellEffectIndex(effectNumber)))
{
// Get multiplier
float multiplier = m_spellInfo->DmgMultiplier[effectNumber];
// Apply multiplier mods
if (real_caster)
if(Player* modOwner = real_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_EFFECT_PAST_FIRST, multiplier, this);
m_damageMultipliers[effectNumber] *= multiplier;
HandleEffects(unit, NULL, NULL, SpellEffectIndex(effectNumber), m_damageMultipliers[effectNumber]);
if ( m_applyMultiplierMask & (1 << effectNumber) )
{
// Get multiplier
float multiplier = m_spellInfo->DmgMultiplier[effectNumber];
// Apply multiplier mods
if (real_caster)
if(Player* modOwner = real_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_EFFECT_PAST_FIRST, multiplier, this);
m_damageMultipliers[effectNumber] *= multiplier;
}
}
}
}

caster->CalculateSpellDamage(&damageInfo, m_damage, m_spellInfo, m_attackType);
if (m_damage > 0)
caster->CalculateSpellDamage(&damageInfo, m_damage, m_spellInfo, m_attackType);
}

target->damage = damageInfo.damage;
target->HitInfo = damageInfo.HitInfo;
}

void Spell::InitializeDamageMultipliers()
{
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if (m_spellInfo->Effect[i] == 0)
continue;

uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i];
if (Unit* realCaster = GetAffectiveCaster())
if(Player* modOwner = realCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this);

m_damageMultipliers[i] = 1.0f;
if( (m_spellInfo->EffectImplicitTargetA[i] == TARGET_CHAIN_DAMAGE || m_spellInfo->EffectImplicitTargetA[i] == TARGET_CHAIN_HEAL) &&
(EffectChainTarget > 1) )
m_applyMultiplierMask |= (1 << i);
}
}

bool Spell::IsAliveUnitPresentInTargetList()
{
// Not need check return true
Expand Down Expand Up @@ -2728,6 +2751,8 @@ void Spell::cast(bool skipCheck)
SendCastResult(castResult);
SendSpellGo(); // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...

InitializeDamageMultipliers();

// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
if (m_spellInfo->speed > 0.0f)
{
Expand Down Expand Up @@ -2862,17 +2887,6 @@ void Spell::_handle_immediate_phase()
// Don't do spell log, if is school damage spell
if(m_spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || m_spellInfo->Effect[j] == 0)
m_needSpellLog = false;

uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[j];
if (Unit* realCaster = GetAffectiveCaster())
if(Player* modOwner = realCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this);

// initialize multipliers
m_damageMultipliers[j] = 1.0f;
if( (m_spellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || m_spellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_HEAL) &&
(EffectChainTarget > 1) )
m_applyMultiplierMask |= (1 << j);
}

// initialize Diminishing Returns Data
Expand Down
1 change: 1 addition & 0 deletions src/game/Spell.h
Expand Up @@ -606,6 +606,7 @@ class Spell
void AddItemTarget(Item* target, SpellEffectIndex effIndex);
void DoAllEffectOnTarget(TargetInfo *target);
void HandleDelayedSpellLaunch(TargetInfo *target);
void InitializeDamageMultipliers();
void DoSpellHitOnUnit(Unit *unit, uint32 effectMask);
void DoAllEffectOnTarget(GOTargetInfo *target);
void DoAllEffectOnTarget(ItemTargetInfo *target);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9791"
#define REVISION_NR "9792"
#endif // __REVISION_NR_H__

2 comments on commit e7574d2

@morphau
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks :)

@erickeir
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks !

Please sign in to comment.