abunai10 / CaffeineIssues

0 stars 0 forks source link

Suggestion: Spell function to determine whether or not a spell is still in the air #12

Open LordNoxington opened 11 months ago

LordNoxington commented 11 months ago

I believe the best way to do this is to use OM Missiles and combat log events combined to produce an answer, but I simply used events in my solution

Using some super simplified examples from my code:

On spell cast event trigger expectCast()

if token == "SPELL_CAST_SUCCESS" and sourceGUID == player:GetGUID() then
            if spellName == "Shadow Bolt" then
                expectCast(destGUID, shadowMastery:GetID())
            end
end

function expectCast(target, spellid)
    if not target then return end
    if not spellid then return end

    if not expectedCasts[target] then
        expectedCasts[target] = {}
    end
    if expectedCasts[target] then
        if not expectedCasts[target][spellid] then
            expectedCasts[target][spellid] = GetTime()
        end
    end
end

Within an APL/Logic tree, checking if a spell is expected to land:

if _debuff(shadowEmbrace, object, player) not expectingCast(object, shadowEmbrace) then
   return _cast(shadowBolt, object)
end

In the case above, it is interesting to note that shadowBolt is the spell being casted, but we want to check if shadowEmbrace (a debuff provided by shadowBolt) is expected to land. i.e. one spell maps to multiple debuffs.