Module:AbilityTable: Difference between revisions

Jump to navigation Jump to search
Vergir (talk | contribs)
moveslow/dashslow cells read props from stat_to_props; dashslow skips GroundDashReductionPercent for Heavy Barrage (with help from vergir-bot LLM)
Vergir (talk | contribs)
dashslow: auto-detect caster GroundDashReductionPercent and note it; moveslow: note ChannelSlowPercent caster slow; remove dashslow_prop_overrides (with help from vergir-bot LLM)
Line 71: Line 71:
         "Itani Lo Sahn", -- has GroundDashReductionPercent but also disables stamina.
         "Itani Lo Sahn", -- has GroundDashReductionPercent but also disables stamina.
     },
     },
}
-- Per-ability prop overrides for dashslow: maps ability name to a subset of props to
-- use instead of the full stat_to_props["dashslow"] list.
-- Use when an ability has a prop that doesn't represent an enemy dash slow.
local dashslow_prop_overrides = {
    ["Heavy Barrage"] = { "MaxGroundDashReductionPercent", "MoveSpeedAndDashSlowPct", "EnemyDashSlowPercent" },
}
}


Line 379: Line 372:


local function moveslow_cells(ability)
local function moveslow_cells(ability)
     return pct_stat_cells(ability, "Move Slow", stat_to_props["moveslow"])
     local cells = pct_stat_cells(ability, "Move Slow", stat_to_props["moveslow"])
 
    -- If the ability slows the caster during channel, note it.
    local channel_slow = num_val(ability["ChannelSlowPercent"])
    if channel_slow and channel_slow ~= 0 then
        local note = "Also slows the caster for " .. math.abs(channel_slow) .. "%."
        cells["Notes"] = cells["Notes"] and (cells["Notes"] .. " " .. note) or note
    end
 
    return cells
end
end


local function dashslow_cells(ability)
local function dashslow_cells(ability)
     local fields = dashslow_prop_overrides[ability["Name"]] or stat_to_props["dashslow"]
     local props = stat_to_props["dashslow"]
     return pct_stat_cells(ability, "Dash Slow", fields)
 
    -- If GroundDashReductionPercent is set at base AND another dash slow prop
    -- exists anywhere (base or upgrades), the base value is a caster self-slow
    -- rather than an enemy debuff. Skip it for the main value and note it instead.
    local caster_dash_slow = nil
    local base_ground = num_val(ability["GroundDashReductionPercent"])
    if base_ground and base_ground ~= 0 then
        -- Check whether any other dashslow prop exists anywhere
        local other_props = { "MaxGroundDashReductionPercent", "MoveSpeedAndDashSlowPct", "EnemyDashSlowPercent" }
        local has_other = false
        for _, p in ipairs(other_props) do
            local v = num_val(ability[p])
            if v and v ~= 0 then has_other = true; break end
        end
        if not has_other then
            local upgrades = ability["Upgrades"]
            if type(upgrades) == "table" then
                for _, tier in ipairs(upgrades) do
                    if type(tier) == "table" then
                        for _, p in ipairs(props) do
                            local v = num_val(tier[p])
                            if v and v ~= 0 then has_other = true; break end
                        end
                    end
                    if has_other then break end
                end
            end
        end
        if has_other then
            caster_dash_slow = math.abs(base_ground)
            -- Use a filtered prop list that excludes GroundDashReductionPercent
            local filtered = {}
            for _, p in ipairs(props) do
                if p ~= "GroundDashReductionPercent" then
                    table.insert(filtered, p)
                end
            end
            props = filtered
        end
     end
 
    local cells = pct_stat_cells(ability, "Dash Slow", props)
 
    if caster_dash_slow then
        local note = "Gives " .. caster_dash_slow .. "% dash slow for the caster."
        cells["Notes"] = cells["Notes"] and (cells["Notes"] .. " " .. note) or note
    end
 
    return cells
end
end