Calculate mechanic resist chance for melee abilities.

--HG--
branch : trunk
This commit is contained in:
krz
2009-05-30 20:40:05 +02:00
parent a3a7996fd1
commit 78228818b7
2 changed files with 30 additions and 13 deletions
+29 -13
View File
@@ -2804,6 +2804,27 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType,
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)
{
@@ -2829,6 +2850,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 can`t miss too
if (attType == RANGED_ATTACK)
return SPELL_MISS_NONE;
@@ -2917,20 +2944,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));
+1
View File
@@ -969,6 +969,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);
virtual uint32 GetShieldBlockValue() const =0;
uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }