abunai10 / CaffeineIssues

0 stars 0 forks source link

Spell:GetTimeSinceLastCast,Spell:GetLastCastTime() #21

Closed JustRebeccabla closed 11 months ago

JustRebeccabla commented 11 months ago

image

Both no bueno.

abunai10 commented 11 months ago

The issue comes from the EventManager only tracking UNIT_SPELLCAST_SUCCEEDED for spells in the global spellbook.

I've added a check to ensure the spell is coming from the player before "GetSpell" and made it work for all spells now.

Will likely need to do something better than this in the future.


Caffeine.Globals.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...)
    local unit, castGUID, spellID = ...

    if unit ~= "player" then return end

    local spell = Caffeine.Globals.SpellBook:GetSpell(spellID)

    if unit == "player" and spell then
        spell.lastCastAt = GetTime()

        if spell:GetPostCastFunction() then
            spell:GetPostCastFunction()(spell)
        end
    end
end)```
Laksmack commented 11 months ago

This is still an issue, tested on tinkr today