abunai10 / CaffeineIssues

0 stars 0 forks source link

APL will be called even if it is not added to the Module:Sync function. #15

Open n00bsteam opened 10 months ago

n00bsteam commented 10 months ago

That's weird thing, sure it must not work so.

Moved this from discord ticket (already closed it there)

abunai10 commented 10 months ago

Can you let me know what you mean by it will be called? You mean it will go through the spells in the APL even if not given the APL:Execute() function in the module sync?

Is it being ran somewhere else?

n00bsteam commented 10 months ago

You mean it will go through the spells in the APL even if not given the APL:Execute() function in the module sync?

Yes.

Is it being ran somewhere else?

No.

abunai10 commented 10 months ago

Could you please attempt to reproduce this on your machine with no other products loaded? I've included a sample rotation below that should make it easy to isolate the issue.

local Unlocker, Caffeine = ...

local Module = Caffeine.Module:New("attempt");
local Player = Caffeine.UnitManager:Get("player");
local None = Caffeine.UnitManager:Get("none");
local blood_boil = Caffeine.Globals.SpellBook:GetSpell(50842);
local DefaultAPL = Caffeine.APL:New("default");

DefaultAPL:AddSpell(
    blood_boil:CastableIf(function(self)
        return self:IsKnownAndUsable()
    end):SetTarget(None)
);

Module:Sync(function()
        if Player:IsAffectingCombat() then
                DefaultAPL:Execute()
        end
end);

Caffeine:Register(Module);

Steps:

  1. Locally load above rotation on a death knight with Blood Boil
  2. Get in combat
  3. Casts Blood Boil
  4. Exit combat
  5. With bug, APL is expected to continue being called outside of sync, casting blood boil outside of combat.

If you cannot reproduce with this, I will need to see the relevant code so I can debug it.

n00bsteam commented 10 months ago

Perhaps I expressed myself incorrectly, the bug is in the following code:

local Unlocker, Caffeine = ...

local Module = Caffeine.Module:New("attempt");
local Player = Caffeine.UnitManager:Get("player");
local None = Caffeine.UnitManager:Get("none");
local blood_boil = Caffeine.Globals.SpellBook:GetSpell(50842);
local path_of_frost = Caffeine.Globals.SpellBook:GetSpell(3714);
local DefaultAPL = Caffeine.APL:New("default");
local blablaAPL = Caffeine.APL:New("blabla");

blablaAPL:AddSpell(
    path_of_frost:CastableIf(function(self)
        return self:IsKnownAndUsable()
    end):SetTarget(None)
);

DefaultAPL:AddSpell(
    blood_boil:CastableIf(function(self)
        return self:IsKnownAndUsable()
    end):SetTarget(None)
);

Module:Sync(function()
        if Player:IsAffectingCombat() then
                DefaultAPL:Execute()
        end
end);

Caffeine:Register(Module);

Path of Frost will be casts instant after module enabled

abunai10 commented 10 months ago

As soon as the US servers are back up I will test this - thank you.