Jump to content

[fix] Unit::MeleeSpellMissChance


Auntie Mangos

Recommended Posts

What bug does the patch fix? What features does the patch add?

replaces absolete melee miss chance calculation with current one.

better variable names ( HitChance -> hitChance, miss_chance -> missChance )

For which repository revision was the patch created?

9100

Is there a thread in the bug report section or at lighthouse?

-miss-chance-for-melee-damage"]here

Who has been writing this patch? Please include either forum user names or email addresses.

Me

http://pastebin.com/m6f26bddb

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 98c4f94..5f2c28f 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
-2529,44 +2529,41 @@ bool Unit::isSpellBlocked(Unit *pVictim, SpellEntry const * /*spellProto*/, Weap
float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell)
{
    // Calculate hit chance (more correct for chance mod)
-    int32 HitChance;
+	float hitChance = 0.0f;

    // PvP - PvE melee chances
-    int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7;
-    int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim);
-    if(leveldif < 3)
-        HitChance = 95 - leveldif;
-    else
-        HitChance = 93 - (leveldif - 2) * lchance;
+	if ( pVictim->GetTypeId() == TYPEID_PLAYER )
+		hitChance = 95.0f + skillDiff * (skillDiff > 0 ? 0.02f : 0.04f);
+	else if ( skillDiff < -10 )
+		hitChance = 94.0f + (skillDiff + 10) * 0.4f;
+	else
+		hitChance = 95.0f + skillDiff * 0.1f;

    // Hit chance depends from victim auras
    if(attType == RANGED_ATTACK)
-        HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE);
+        hitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE);
    else
-        HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);
+        hitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);

    // Spellmod from SPELLMOD_RESIST_MISS_CHANCE
    if(Player *modOwner = GetSpellModOwner())
-        modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, HitChance);
+        modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, hitChance);

    // Miss = 100 - hit
-    float miss_chance= 100.0f - HitChance;
+    float missChance = 100.0f - hitChance;

    // Bonuses from attacker aura and ratings
    if (attType == RANGED_ATTACK)
-        miss_chance -= m_modRangedHitChance;
+        missChance -= m_modRangedHitChance;
    else
-        miss_chance -= m_modMeleeHitChance;
-
-    // bonus from skills is 0.04%
-    miss_chance -= skillDiff * 0.04f;
+        missChance -= m_modMeleeHitChance;

    // Limit miss chance from 0 to 60%
-    if (miss_chance < 0.0f)
+    if (missChance < 0.0f)
        return 0.0f;
-    if (miss_chance > 60.0f)
+    if (missChance > 60.0f)
        return 60.0f;
-    return miss_chance;
+    return missChance;
}

// Melee based spells hit result calculations

Link to comment
Share on other sites

  • 40 years later...

I think miss chance against players is actually a lot more complicated than that. Since 3.0, there are diminishing returns for dodge, parry and chance to be missed that are gained from items stats (defense rating in this case). Hence you cannot calculate miss chance solely based on skill difference anymore.

For more information see: http://elitistjerks.com/f31/t29453-combat_ratings_level_80_a/

Also for some strange reason wowwiki gives two different formulas for the case where skill difference is below 10.

http://www.wowwiki.com/Miss says:

5% + (Defense Skill - Weapon Skill)*.1%

and http://www.wowwiki.com/Hit says:

5% + (Defense Skill - Weapon Skill)*.04%

Link to comment
Share on other sites

Dodge and parry (and block) are solved elsewhere. This function only returns miss chance against target. Defense rating is defense skill mutiplied by constant ( for those purposes this explanation will suffice ). However, you have a point concerning the formula. Which one is correct?

Link to comment
Share on other sites

Dodge and parry are not diminished.

Gains from dodge rating, parry rating, agility and defense (and maybe from strength for DKs?) is what is subject to DR ... and that should be calculated during "rating->%" and "stat->%" conversion

For miss you need to separate base miss and miss from defense rating, however I am unsure what if you do not have maxed "base" defense skill ... ?

Or is it simple 5% base miss and everything else is diminished (ie. there's no difference between "skilldiff" from level difference and from defense rating) :confused:

Link to comment
Share on other sites

I think miss chance against players is actually a lot more complicated than that. Since 3.0, there are diminishing returns for dodge, parry and chance to be missed that are gained from items stats (defense rating in this case). Hence you cannot calculate miss chance solely based on skill difference anymore.

For more information see: http://elitistjerks.com/f31/t29453-combat_ratings_level_80_a/

Also for some strange reason wowwiki gives two different formulas for the case where skill difference is below 10.

http://www.wowwiki.com/Miss says:

5% + (Defense Skill - Weapon Skill)*.1%

and http://www.wowwiki.com/Hit says:

5% + (Defense Skill - Weapon Skill)*.04%

Very interesting indeed, going by those 2 different formulas.

Lets say your player level is 80 and target mob is level 81:

5% + (Defense Skill - Weapon Skill)*.1% = 5% + (405-400)*.1% = 5.5%

5% + (Defense Skill - Weapon Skill)*.04% = 5% + (405-400)*0.04% = 5.2%

level 80 player against a level 82 target mob yields:

5% + (Defense Skill - Weapon Skill)*.1% = 5% + (410-400)*.1% = 6%

5% + (Defense Skill - Weapon Skill)*.04% = 5% + (410-400)*0.04% = 5.4%

level 80 player against a level 83 mob (raid boss) gives:

6% + (Defense Skill - Weapon Skill - 10)*.4% = 6% + (415-400-10)*.4% = 8%

Going by these facts from Wowwiki:

Applying these formulas gives the following base miss rate for a Level 80 character with a 400 Weapon Skill:

* v. Level 80 mob: 5.0% / dual-wield: 24%

* v. Level 81 mob: 5.5% / dual-wield: 24.5%

* v. Level 82 mob: 6.0% / dual-wield: 25% (level of most heroic bosses)

* v. Level 83 mob: 8.0% / dual-wield: 27% (level of raid bosses)

I would say 5% + (Defense Skill - Weapon Skill)*.1% should be the correct formula :)

Link to comment
Share on other sites

Very interesting indeed, going by those 2 different formulas.

Lets say your player level is 80 and target mob is level 81:

5% + (Defense Skill - Weapon Skill)*.1% = 5% + (405-400)*.1% = 5.5%

5% + (Defense Skill - Weapon Skill)*.04% = 5% + (405-400)*0.04% = 5.2%

level 80 player against a level 82 target mob yields:

5% + (Defense Skill - Weapon Skill)*.1% = 5% + (410-400)*.1% = 6%

5% + (Defense Skill - Weapon Skill)*.04% = 5% + (410-400)*0.04% = 5.4%

level 80 player against a level 83 mob (raid boss) gives:

6% + (Defense Skill - Weapon Skill - 10)*.4% = 6% + (415-400-10)*.4% = 8%

Going by these facts from Wowwiki:

Applying these formulas gives the following base miss rate for a Level 80 character with a 400 Weapon Skill:

* v. Level 80 mob: 5.0% / dual-wield: 24%

* v. Level 81 mob: 5.5% / dual-wield: 24.5%

* v. Level 82 mob: 6.0% / dual-wield: 25% (level of most heroic bosses)

* v. Level 83 mob: 8.0% / dual-wield: 27% (level of raid bosses)

I would say 5% + (Defense Skill - Weapon Skill)*.1% should be the correct formula :)

Ok, updated first post to match better formula :)

Link to comment
Share on other sites

Player versus Mob = works flawlessly

Mob versus player(especially a tank player) = broken

Player versus player = did not test

Try a well geared tank (who has at least 540 defense) against mobs, mobs can not even touch this tank.

Maybe you could use some of the info from http://www.wowwiki.com/Miss

Player/Mob vs Player

When a player or mob attacks a player, the base miss rate is 5%.

For each point of the defender's defense skill over the attacker's attack rating, the base miss rate increases by 0.04%.

For each point of the attacker's attack rating over the defender's defense skill, the base miss rate decreases by 0.02%.

Link to comment
Share on other sites

  • 7 months later...

patch updated for 10457

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 8428cf2..12bc683 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -2728,44 +2728,41 @@ bool Unit::IsSpellBlocked(Unit *pCaster, SpellEntry const * /*spellProto*/, Weap
float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell)
{
    // Calculate hit chance (more correct for chance mod)
-    int32 HitChance;
+    float hitChance = 0.0f;

    // PvP - PvE melee chances
-    int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7;
-    int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim);
-    if(leveldif < 3)
-        HitChance = 95 - leveldif;
-    else
-        HitChance = 93 - (leveldif - 2) * lchance;
+    if (pVictim->GetTypeId() == TYPEID_PLAYER)
+        hitChance = 95.0f + skillDiff * (skillDiff > 0 ? 0.02f : 0.04f);
+    else if (skillDiff < -10)
+        hitChance = 94.0f + (skillDiff + 10) * 0.4f;
+    else
+        hitChance = 95.0f + skillDiff * 0.1f;

    // Hit chance depends from victim auras
-    if(attType == RANGED_ATTACK)
-        HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE);
+    if (attType == RANGED_ATTACK)
+        hitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE);
    else
-        HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);
+        hitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);

    // Spellmod from SPELLMOD_RESIST_MISS_CHANCE
-    if(Player *modOwner = GetSpellModOwner())
-        modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, HitChance);
+    if (Player *modOwner = GetSpellModOwner())
+        modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, hitChance);

    // Miss = 100 - hit
-    float miss_chance= 100.0f - HitChance;
+    float missChance = 100.0f - hitChance;

    // Bonuses from attacker aura and ratings
    if (attType == RANGED_ATTACK)
-        miss_chance -= m_modRangedHitChance;
+        missChance -= m_modRangedHitChance;
    else
-        miss_chance -= m_modMeleeHitChance;
-
-    // bonus from skills is 0.04%
-    miss_chance -= skillDiff * 0.04f;
+        missChance -= m_modMeleeHitChance;

    // Limit miss chance from 0 to 60%
-    if (miss_chance < 0.0f)
+    if (missChance < 0.0f)
        return 0.0f;
-    if (miss_chance > 60.0f)
+    if (missChance > 60.0f)
        return 60.0f;
-    return miss_chance;
+    return missChance;    
}

// Melee based spells hit result calculations
@@ -2777,7 +2774,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
        attType = RANGED_ATTACK;

    // bonus from skills is 0.04% per skill Diff
-    int32 attackerWeaponSkill = int32(GetWeaponSkillValue(attType,pVictim));
+    int32 attackerWeaponSkill = (spell->EquippedItemClass == ITEM_CLASS_WEAPON) ? int32(GetWeaponSkillValue(attType,pVictim)) : GetMaxSkillValueForLevel();
    int32 skillDiff = attackerWeaponSkill - int32(pVictim->GetMaxSkillValueForLevel(this));
    int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this));

Link to comment
Share on other sites

Using this patch I noticed alot of misses with some palaind's spells like judgements, hammer of wrath and avenger shield: these spells are defined as damage class ranged so Unit::MeleeSpellHitResult wrongly looks for a ranged skill weapon despite these spells doesn't requires a weapon equipped and as result we got 0 and, since miss chance is now based on weapon skill difference, a base miss change of 60%.

To solve it I modified the patch above to include a check to use max skill level in case the melee spell doesn't require a weapon.

p.s.

bump!

Link to comment
Share on other sites

About Judgements, there is still a bug, because:

Patch 3.2.0 (2009-08-04):

Some of these attacks were considered ranged and some melee. They are all now considered melee attacks that can't be dodged, parried or blocked.

All paladin judgements are now properly considered as melee attacks that cannot be dodged, blocked or parried. Previously Seal of Light, Seal of Wisdom, Seal of Justice and Seal of Righteousness would cause the judgement to be considered a ranged attack.

About the patch, I'm gonna test it as soon, as I finish my current work :)

Link to comment
Share on other sites

http://www.wowwiki.com/Judgement

This Miss chance uses an effective weapon skill equal to your level * 5, regardless of what weapon you're actually wielding. In other words, if your Weapon Skill with the weapon you're wielding isn't fully trained up to your level * 5, this won't increase the Miss chance of your Judgements.

Thatìs why I put in code that all melee spells that doesn't require a weapon equiped, like judgements, use GetMaxSkillValueForLevel().

The part about can't be dodge is handled elsewere

Link to comment
Share on other sites

  • 4 weeks later...

So did anyone test it now?

To me, Revils' code looks good, from all i could find the calculations seem correct now for 3.x.

The only thing i can't really find any confirmation is the 0.02% part in

hitChance = 95.0f + skillDiff * (skillDiff > 0 ? 0.02f : 0.04f);

Wowwiki just states that formula like this, but at no other site or tool (like tankPoints, Rawr etc.) i can find this 0.02% part.

Link to comment
Share on other sites

Okay...so thrown out the mysterious 0.02% case, the rest seemed good to me, also after testing with boss target dummy, so accepted in [10608].

Note that diminishing returns for player's defense rating is still not implemented, however the necessary parameters aren't really researched for all classes it seems :(

Also, DR for dodge and parry are much more important i think...

Also thanks Revil for looking into the non-weapon melee/ranged abilities, hopefully no more chain-missing judgements...

-edit-

I'm not really convinced that the 60% cap makes sense, but couldn't find anything on this...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use