diff options
author | krz <none@none> | 2009-06-07 19:10:01 +0200 |
---|---|---|
committer | krz <none@none> | 2009-06-07 19:10:01 +0200 |
commit | c7c092f54bc6aa988991c601d532322c5cb8df32 (patch) | |
tree | 53f5d369ff4176c595a3b1cb2cdb45b6dc7ad1b6 | |
parent | 5e87f3144cca2cae1add4acd18affcfbb2d981e5 (diff) |
Calculate spell critical hit chance at spell cast instead spell hit. Patch by thenecromancer.
--HG--
branch : trunk
-rw-r--r-- | src/game/Spell.cpp | 11 | ||||
-rw-r--r-- | src/game/Spell.h | 1 | ||||
-rw-r--r-- | src/game/Unit.cpp | 4 | ||||
-rw-r--r-- | src/game/Unit.h | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 411a130539e..3d05c57bdf3 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -731,6 +731,7 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) target.effectMask = 1<<effIndex; // Store index of effect target.processed = false; // Effects not apply on target target.damage = 0; + target.crit = false; // Calculate hit result if(m_originalCaster) @@ -1034,7 +1035,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo->Id, m_spellSchoolMask); // Add bonuses and fill damageInfo struct - caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo); + caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo, m_attackType, target->crit); // Send log damage message to client caster->SendSpellNonMeleeDamageLog(&damageInfo); @@ -5438,11 +5439,17 @@ void Spell::CalculateDamageDoneForAllTargets() continue; if (target.missCondition==SPELL_MISS_NONE) // In case spell hit target, do all effect on that target - target.damage += CalculateDamageDone(unit, mask, multiplier); + { + target.damage += CalculateDamageDone(unit, mask, multiplier); + target.crit = m_caster->isSpellCrit(unit, m_spellInfo, m_spellSchoolMask, m_attackType); + } else if (target.missCondition == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit) { if (target.reflectResult == SPELL_MISS_NONE) // If reflected spell hit caster -> do all effect on him + { target.damage += CalculateDamageDone(m_caster, mask, multiplier); + target.crit = m_caster->isSpellCrit(m_caster, m_spellInfo, m_spellSchoolMask, m_attackType); + } } } } diff --git a/src/game/Spell.h b/src/game/Spell.h index 94166425675..8da9facb264 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -525,6 +525,7 @@ class Spell uint8 effectMask:8; bool processed:1; int32 damage; + bool crit; }; std::list<TargetInfo> m_UniqueTargetInfo; uint8 m_needAliveTargetMask; // Mask req. alive targets diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 2ec904dd865..a8e15ebf691 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1169,7 +1169,7 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage return damageInfo.damage; } -void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType) +void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType, bool crit) { if (damage < 0) return; @@ -1181,7 +1181,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama SpellSchoolMask damageSchoolMask = SpellSchoolMask(damageInfo->schoolMask); uint32 crTypeMask = pVictim->GetCreatureTypeMask(); // Check spell crit chance - bool crit = isSpellCrit(pVictim, spellInfo, damageSchoolMask, attackType); + //bool crit = isSpellCrit(pVictim, spellInfo, damageSchoolMask, attackType); bool blocked = false; // Per-school calc switch (spellInfo->DmgClass) diff --git a/src/game/Unit.h b/src/game/Unit.h index 9929c173206..a0b33b18b73 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -957,7 +957,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK); void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss); - void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK); + void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK, bool crit = false); void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss); float MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const; |