diff --git a/src/APL/APL.lua b/src/APL/APL.lua index 49f0659..6de3bc3 100644 --- a/src/APL/APL.lua +++ b/src/APL/APL.lua @@ -109,21 +109,21 @@ function APLActor:Execute() -- print("Bastion: APL:Execute: Condition for spell " .. self:GetActor().spell:GetName()) self:GetActor().spell:CastableIf(self:GetActor().castableFunc):OnCast(self:GetActor().onCastFunc):Cast( self:GetActor().target, self:GetActor().condition) + else + -- print("Bastion: APL:Execute: No condition for spell " .. self:GetActor().spell:GetName()) + self:GetActor().spell:CastableIf(self:GetActor().castableFunc):OnCast(self:GetActor().onCastFunc):Cast( + self:GetActor().target) end - - -- print("Bastion: APL:Execute: No condition for spell " .. self:GetActor().spell:GetName()) - self:GetActor().spell:CastableIf(self:GetActor().castableFunc):OnCast(self:GetActor().onCastFunc):Cast( - self:GetActor().target) end if self:GetActor().item then if self:GetActor().condition then -- print("Bastion: APL:Execute: Condition for spell " .. self:GetActor().spell:GetName()) self:GetActor().item:UsableIf(self:GetActor().usableFunc):Use(self:GetActor().target, self:GetActor().condition) + else + -- print("Bastion: APL:Execute: No condition for spell " .. self:GetActor().spell:GetName()) + self:GetActor().item:UsableIf(self:GetActor().usableFunc):Use(self:GetActor().target) end - - -- print("Bastion: APL:Execute: No condition for spell " .. self:GetActor().spell:GetName()) - self:GetActor().item:UsableIf(self:GetActor().usableFunc):Use(self:GetActor().target) end if self:GetActor().action then -- print("Bastion: APL:Execute: Executing action " .. self:GetActor().action) @@ -209,7 +209,7 @@ end -- Add a spell to the APL ---@param spell Spell ----@param condition? fun(...):boolean +---@param condition? string|fun(...):boolean ---@return APLActor function APL:AddSpell(spell, condition) local castableFunc = spell.CastableIfFunc diff --git a/src/Spell/Spell.lua b/src/Spell/Spell.lua index 1cdc0a8..f4a5e19 100644 --- a/src/Spell/Spell.lua +++ b/src/Spell/Spell.lua @@ -161,11 +161,15 @@ end -- Cast the spell ---@param unit Unit ----@param condition string +---@param condition string|function ---@return boolean function Spell:Cast(unit, condition) - if condition and not self:EvaluateCondition(condition) then - return false + if condition then + if type(condition) == "string" and not self:EvaluateCondition(condition) then + return false + elseif type(condition) == "function" and not condition(self) then + return false + end end if not self:Castable() then