johnnylam88 / nerien-hekili-packs

Nerien's collection of Hekili action packs for various classes and specializations.
MIT License
6 stars 1 forks source link

Nice idea/Addon, would like to try to figure out if something would be possible. #1

Closed JourneyOver closed 2 months ago

JourneyOver commented 6 months ago

Finding this addon gave me the idea of creating my own for my own profiles for hekili, I do have a question though on if it would be possible or not as I haven't been able to figure it out on my own, but would it be possible to create a classes.lua file (equivalent of https://github.com/Hekili/hekili/blob/dragonflight/Classes.lua without it being an exact duplicate of the file) but just to add in code like from this PR https://github.com/Hekili/hekili/pull/2420 for example so that it would be possible to add health potions to hekili (or even do other things) without having to go in and edit the default hekili code?

would be a cool thing to do because then I couold add this code into a classes.lua file of my own:

local health_pots = {
    { name = "Refreshing Healing Potion 1", itemID = 191378 },
    { name = "Refreshing Healing Potion 2", itemID = 191379 },
    { name = "Refreshing Healing Potion 3", itemID = 191380 },
    { name = "Dreamwalkers Healing Potion 1", itemID = 207021 },
    { name = "Dreamwalkers Healing Potion 2", itemID = 207022 },
    { name = "Dreamwalkers Healing Potion 3", itemID = 207023 },
    { name = "Potion of Withering Dreams 1", itemID = 207039 },
    { name = "Potion of Withering Dreams 2", itemID = 207040 },
    { name = "Potion of Withering Dreams 3", itemID = 207041 },
}

for _, itemData in ipairs(health_pots) do
    local itemName = itemData.name:gsub("[^%w]+", "_"):lower()
    all:RegisterAbilities({
        [itemName] = {
            name = itemData.name,
            listName = function()
                local _, link, _, _, _, _, _, _, _, tex = GetItemInfo(itemData.itemID)
                if link and tex then return "|T" .. tex .. ":0|t " .. link end
                return "|cff00ccff[" .. itemData.name .. "]|r"
            end,
            cast = 0,
            cooldown = function() return time > 0 and 3600 or 60 end,
            gcd = "off",
            item = itemData.itemID,
            bagItem = true,
            startsCombat = false,
            texture = 4497595,
            usable = function()
                if GetItemCount(itemData.itemID) == 0 then return false, "requires " .. itemData.name .. " in bags" end
                if not IsUsableItem(itemData.itemID) then return false, itemData.name .. " on CD" end
                if health.current >= health.max then return false, "must be damaged" end
                return true
            end,
            readyTime = function()
                local start, duration = GetItemCooldown(itemData.itemID)
                return max(0, start + duration - query_time)
            end,
            handler = function()
                gain( 128250, "health" )
            end,
        }
    })
end

and have it work correctly without needing to go in and edit the classes.lua file of default hekili everytime they do an update.

johnnylam88 commented 2 months ago

Yes, this is all possible, but not in the scope of this addon. Your suggestion is much better as pullup request to the main Hekili addon.