aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-01 15:35:21 -0500
committermegamage <none@none>2009-06-01 15:35:21 -0500
commit6e4a8e1ea9c090bf2c33e28534f7875c3fa89d19 (patch)
tree24b9875be9925ad30fae09f5a163922c2c417a38
parente8fb84a4a2e81eae018ef0133147959b00c4352e (diff)
parent78228818b7b3d04a2cc86146c7be8b19689ab59b (diff)
*Merge.
--HG-- branch : trunk
-rw-r--r--src/game/Unit.cpp42
-rw-r--r--src/game/Unit.h1
2 files changed, 30 insertions, 13 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 201be24a239..7c38b3348a6 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -2748,6 +2748,27 @@ bool Unit::isBlockCritical()
return miss_chance;
}*/
+
+int32 Unit::GetMechanicResistChance(const SpellEntry *spell)
+{
+ if(!spell)
+ return 0;
+ int32 resist_mech = 0;
+ for(int eff = 0; eff < 3; ++eff)
+ {
+ if(spell->Effect[eff] == 0)
+ break;
+ int32 effect_mech = GetEffectMechanic(spell, eff);
+ if (effect_mech)
+ {
+ int32 temp = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech);
+ if (resist_mech < temp)
+ resist_mech = temp;
+ }
+ }
+ return resist_mech;
+}
+
// Melee based spells hit result calculations
SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
{
@@ -2800,6 +2821,12 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)
return SPELL_MISS_NONE;
+ // Chance resist mechanic
+ int32 resist_chance = pVictim->GetMechanicResistChance(spell)*100;
+ tmp += resist_chance;
+ if (roll < tmp)
+ return SPELL_MISS_RESIST;
+
// Ranged attack cannot be parry/dodge only deflect
// Check damage class instead of attack type to correctly handle judgements
// - they are meele, but can't be dodged/parried/deflected because of ranged dmg class
@@ -2918,20 +2945,9 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (IsDispelSpell(spell))
modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST);
// Chance resist mechanic (select max value from every mechanic spell effect)
- int32 resist_mech = 0;
- // Get effects mechanic and chance
- for(int eff = 0; eff < 3; ++eff)
- {
- int32 effect_mech = GetEffectMechanic(spell, eff);
- if (effect_mech)
- {
- int32 temp = pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech);
- if (resist_mech < temp)
- resist_mech = temp;
- }
- }
+ int32 resist_chance = pVictim->GetMechanicResistChance(spell);
// Apply mod
- modHitChance-=resist_mech;
+ modHitChance-=resist_chance;
// Chance resist debuff
modHitChance-=pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spell->Dispel));
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 375e21e5f4d..26c8fc39a97 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1170,6 +1170,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
float GetUnitParryChance() const;
float GetUnitBlockChance() const;
float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const;
+ int32 GetMechanicResistChance(const SpellEntry *spell);
bool CanUseAttackType( uint8 attacktype ) const
{
switch(attacktype)