Bug with GetSpellHitModifier() API

On the 2.5.1 PTR I noticed a weird bug with the GetSpellHitModifier() function. In Classic this function just returns your current spell hit chance which I used to show my character stats in a weak aura. This function updates anytime your spell hit changes (IE you equip a piece of spell hit gear).

On the PTR this function doesn’t seem to update when you equip pieces of spell hit gear anymore but it does update when you gain or lose full hit percentage points (like from gaining or losing the Totem of Wrath buff). My guess is that converting over to the spell hit rating system has made this function work a bit weirdly.

We’re in the Alpha phase atm.

Prepatch is Beta.

Then you get to pay to play test it.

And if you dont like waiting for it to get fixed…

Buzzard people will log in and tell you to unsub if you dont like it.

1 Like

Use GetCombatRating bonus.

local spellHit = GetCombatRatingBonus(CR_HIT_SPELL)

Also, no hit value returns nil instead of 0. Maybe set it to zero if it’s nil to avoid lua errors.

2 Likes

Hey I appreciate the suggestion but unfortunately this has the issue of only showing spell hit gained from gear. It does not show your cumulative hit including say Totem of Wrath, Draenei racial, or any other general hit gained from talents.

Hey I appreciate the suggestion but unfortunately this has the issue of only showing spell hit gained from gear. It does not show your cumulative hit including say Totem of Wrath, Draenei racial, or any other general hit gained from talents.

You’d need both API to make sure you get the value from all sources, including totems and enchants :

local spellHitRating  = GetCombatRatingBonus(CR_HIT_SPELL)
if spellHitRating == nil then -- sets the rating to 0 instead of nil when you have no hit
	spellHitRating = 0
end

local spellHit = GetSpellHitModifier() + spellHitRating
4 Likes

In theory this works but currently the API does not work this way. As it stands, GetSpellHitModifier() already shows Pure % hit + gear hit but it doesn’t update its value unless you gain a source of pure % hit.

So if you have 5% hit from gear and you place down totem of wrath, GetSpellHitModifier() will display 8% hit. However if you equip a new piece of gear with more hit on it, GetSpellHitModifier() will not update its value and still show 5%.

GetSpellHitModifier() displays your total hit % but it only updates when you gain or lose a source of pure hit % and not rating.

Because this I don’t believe there is an accurate and reliable way to get your current hit % without building some weak aura that manually adds and subtracts values for any pure hit % you can obtain (draenei racial, totems, talents, etc). I’m fairly certain this function is not working as intended.

What methods are you using to update your API ? Events or OnUpdate ? It’s most probably related to the update method rather than the API itself.

If you’re using Events, make sure you use all the events that can trigger a value change

UNIT_AURA, player
UNIT_STATS, player
UNIT_INVENTORY_CHANGED, player
BIND_ENCHANT
REPLACE_ENCHANT

And if you’re using OnUpdate, then you shouldn’t have any issue. It’s the best way to update these type of APIs. Just make sure your OnUpdate is throttled.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.