Editing Module:AbilityTable/ComplexRenderersGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 47: | Line 47: | ||
end | end | ||
-- | -- Returns true if prop exists with a non-zero value anywhere in the record | ||
-- | -- excluding the Upgrades key. | ||
local function | local function is_base_property(record, prop) | ||
for k, v in pairs(record) do | |||
for | if k == "Upgrades" then | ||
-- skip | |||
elseif k == prop then | |||
if type(v) == "table" then v = v["Value"] end | |||
if v ~= nil and v ~= 0 and v ~= "" and v ~= "0" and v ~= "0m" then | |||
return true | |||
end | |||
elseif type(v) == "table" then | |||
if is_base_property(v, prop) then return true end | |||
elseif type(v) == "string" then | |||
if v == prop then return true end | |||
end | |||
end | end | ||
return | return false | ||
end | end | ||
-- | -- Finds the base-level melee scale value by scanning for Scale.Type == "melee". | ||
local function find_base_melee_scale(ability) | |||
for _, v in pairs(ability) do | |||
if type(v) == "table" then | |||
local function | local scale = v["Scale"] | ||
if type(scale) == "table" | |||
for _, | and scale["Type"] == "melee" | ||
and type(scale["Value"]) == "number" | |||
and scale["Value"] > 0 | |||
local v | then | ||
return scale["Value"] | |||
if type( | |||
end | end | ||
end | end | ||
end | end | ||
return nil | |||
end | end | ||
-- | -- ============================================================ | ||
-- | -- Debuff short names (used by RenderDebuff) | ||
-- | -- ============================================================ | ||
local debuff_short_name = { | |||
["StunDuration"] = "stun", | |||
["SleepDuration"] = "sleep", | |||
["SilenceDuration"] = "silence", | |||
["SilenceDebuff"] = "silence", | |||
["PetrifyDuration"] = "petrify", | |||
["HexDuration"] = "hex", | |||
["ImmobilizeDuration"] = "immobilize", | |||
["LiftDuration"] = "lift", | |||
["HoldInPlaceDuration"] = "immobilize", | |||
["RestrictionDuration"] = "immobilize", | |||
["SlowPercent"] = "slow", | |||
["EnemySlowPct"] = "slow", | |||
["MoveSlowPercent"] = "slow", | |||
["GroundDashReductionPercent"] = "dash slow", | |||
["SlowDuration"] = "slow", | |||
["MaxSlowDuration"] = "slow", | |||
["BulletDamageAmpDuration"] = "bullet amp", | |||
["BulletResistReduction"] = "bullet resist reduction", | |||
["TimeSlowDuration"] = "time slow", | |||
["LateCheckoutStun"] = "stun", | |||
["BurnDuration"] = "burn", | |||
["BleedDuration"] = "bleed", | |||
["VenomDuration"] = "venom", | |||
["TossDuration"] = "knockback", | |||
} | |||
-- ============================================================ | -- ============================================================ | ||
| Line 116: | Line 119: | ||
-- additively through upgrades. Shows value in a named column | -- additively through upgrades. Shows value in a named column | ||
-- and generates upgrade notes with running totals. | -- and generates upgrade notes with running totals. | ||
-- ============================================================ | -- ============================================================ | ||
| Line 151: | Line 152: | ||
table.insert(notes, "T" .. i .. " upgrade increases " | table.insert(notes, "T" .. i .. " upgrade increases " | ||
.. col_name:lower() .. " by " .. delta .. suffix | .. col_name:lower() .. " by " .. delta .. suffix | ||
.. " (total " .. total .. suffix .. ")") | .. " (total " .. total .. suffix .. ").") | ||
running = total | running = total | ||
end | end | ||
| Line 168: | Line 169: | ||
local p = {} | local p = {} | ||
-- Renders charge count and time between charges. | -- Renders charge count and time between charges. | ||
| Line 206: | Line 174: | ||
function p.RenderCharges(ability) | function p.RenderCharges(ability) | ||
local base_charges = unwrap_value(ability["AbilityCharges"]) | local base_charges = unwrap_value(ability["AbilityCharges"]) | ||
local base_cooldown = | local base_cooldown = ability["AbilityCooldownBetweenCharge"] | ||
local has_base = base_charges ~= nil and base_charges > 0 | local has_base = base_charges ~= nil and base_charges > 0 | ||
local upgrade_info = find_in_upgrades(ability, "AbilityCharges") | local upgrade_info = find_in_upgrades(ability, "AbilityCharges") | ||
| Line 237: | Line 205: | ||
local charge_str = n .. " charge" .. (n ~= 1 and "s" or "") | local charge_str = n .. " charge" .. (n ~= 1 and "s" or "") | ||
if has_base then | if has_base then | ||
table.insert(note_parts, "+" .. charge_str .. " on T" .. upgrade_info.tier .. " upgrade") | table.insert(note_parts, "+" .. charge_str .. " on T" .. upgrade_info.tier .. " upgrade.") | ||
else | else | ||
local cd_str = upgrade_cooldown and (upgrade_cooldown .. "s") or "unknown" | local cd_str = upgrade_cooldown and (upgrade_cooldown .. "s") or "unknown" | ||
table.insert(note_parts, "Becomes charged on T" .. upgrade_info.tier | table.insert(note_parts, "Becomes charged on T" .. upgrade_info.tier | ||
.. " upgrade with " .. charge_str | .. " upgrade with " .. charge_str | ||
.. " and " .. cd_str .. " time between charges") | .. " and " .. cd_str .. " time between charges.") | ||
end | end | ||
end | end | ||
if ability["AbilityChargesConditionally"] ~= nil then | if ability["AbilityChargesConditionally"] ~= nil then | ||
table.insert(note_parts, "Has a conditional charge") | table.insert(note_parts, "Has a conditional charge.") | ||
end | end | ||
if #note_parts > 0 then | if #note_parts > 0 then | ||
| Line 255: | Line 223: | ||
end | end | ||
-- Renders | -- Renders light melee scaling. | ||
-- Special case for upgrades that | -- Special case for upgrades that change to heavy melee scaling. | ||
function p.RenderMelee(ability) | function p.RenderMelee(ability) | ||
local cells = {} | local cells = {} | ||
local base_scale = find_base_melee_scale(ability) | |||
if base_scale then | if base_scale then cells["Light Melee Scaling"] = "×" .. base_scale end | ||
local upgrades = ability["Upgrades"] | local upgrades = ability["Upgrades"] | ||
if type(upgrades) ~= "table" then return cells end | if type(upgrades) ~= "table" then return cells end | ||
local notes = {} | local notes = {} | ||
for i, tier in ipairs(upgrades) do | for i, tier in ipairs(upgrades) do | ||
if type(tier) == "table" then | if type(tier) == "table" then | ||
for _, v in pairs(tier) do | |||
for | |||
if type(v) == "table" then | if type(v) == "table" then | ||
local scale = v["Scale"] | local scale = v["Scale"] | ||
if type(scale) == "table" and | if type(scale) == "table" and type(scale["Value"]) == "number" then | ||
local stype = scale["Type"] | |||
local delta = scale["Value"] | |||
if stype == "heavy_melee" and delta > 0 then | |||
table.insert(notes, "T" .. i .. " upgrade changes scaling to ×" | |||
.. delta .. " of Heavy Melee damage.") | |||
elseif stype == "melee" and delta ~= 0 and base_scale then | |||
local final = math.floor((base_scale + delta) * 1000 + 0.5) / 1000 | |||
table.insert(notes, "T" .. i .. " upgrade adds ×" | |||
.. delta .. " scaling (total ×" .. final .. ").") | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
if #notes > 0 then cells["Notes"] = table.concat(notes, " ") end | |||
if #notes > 0 then cells["Notes"] = table.concat(notes, " | |||
return cells | return cells | ||
end | end | ||
-- Renders | -- Renders heal reduction percentage. | ||
-- | -- Special case for DisableHealing, shown as 100%. | ||
function p. | function p.RenderHealReduce(ability) | ||
-- | -- DisableHealing is always 100%, handle it separately | ||
local | local v = unwrap_value(ability["DisableHealing"]) | ||
if v and v ~= 0 then | |||
return { ["Heal Reduction"] = "100%" } | |||
end | end | ||
local upgrade = find_in_upgrades(ability, "DisableHealing") | |||
local | if upgrade then | ||
return { ["Heal Reduction"] = "100% (T" .. upgrade.tier .. ")" } | |||
if | |||
end | end | ||
-- | -- Everything else goes through the generic renderer | ||
local | local filtered = {} | ||
for _, prop in ipairs(Lists.lists["healreduce"]) do | |||
if prop ~= "DisableHealing" then table.insert(filtered, prop) end | |||
for | |||
end | end | ||
return render_upgradable_stat(ability, "Heal Reduction", filtered, "%") | |||
return | |||
end | end | ||
-- | -- Shows a note if an ability acquires a debuff via upgrades. | ||
-- | -- Shared by debuffresist and dispelmagic. | ||
function p. | function p.RenderDebuff(ability, stat) | ||
local | local stat_props = Lists.lists[stat] | ||
local | local cells = {} | ||
-- | -- If any prop exists in base, this is a base-level debuff — no note needed. | ||
for | for _, prop in ipairs(stat_props) do | ||
if | if is_base_property(ability, prop) then | ||
return cells | |||
end | end | ||
end | end | ||
| Line 434: | Line 295: | ||
if type(upgrades) ~= "table" then return cells end | if type(upgrades) ~= "table" then return cells end | ||
local | local tier_debuffs = {} | ||
local seen_names = {} | |||
for i, tier in ipairs(upgrades) do | for i, tier in ipairs(upgrades) do | ||
if type(tier) == "table" then | if type(tier) == "table" then | ||
local | local names_this_tier = {} | ||
local seen_this_tier = {} | |||
for | for _, prop in ipairs(stat_props) do | ||
if type(v) == "table" then | local v = tier[prop] | ||
if v ~= nil then | |||
if | if type(v) == "table" then v = v["Value"] end | ||
if v ~= nil and v ~= 0 and v ~= "" and v ~= "0" and v ~= "0m" then | |||
local short = debuff_short_name[prop] or "debuff" | |||
if not seen_this_tier[short] then | |||
seen_this_tier[short] = true | |||
if not seen_names[short] then | |||
seen_names[short] = true | |||
table.insert(names_this_tier, short) | |||
end | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
if #names_this_tier > 0 then | |||
if | tier_debuffs[i] = names_this_tier | ||
end | end | ||
end | end | ||
end | end | ||
local tier_indices = {} | |||
for i in pairs(tier_debuffs) do table.insert(tier_indices, i) end | |||
table.sort(tier_indices) | |||
local parts = {} | |||
for _, i in ipairs(tier_indices) do | |||
table.insert(parts, "T" .. i .. " " .. table.concat(tier_debuffs[i], " + ")) | |||
end | end | ||
if #parts > 0 then cells["Notes"] = table.concat(parts, ", ") end | |||
return cells | return cells | ||
end | end | ||
| Line 495: | Line 344: | ||
local channel_slow = unwrap_value(ability["ChannelSlowPercent"]) | local channel_slow = unwrap_value(ability["ChannelSlowPercent"]) | ||
if channel_slow and channel_slow ~= 0 then | if channel_slow and channel_slow ~= 0 then | ||
local note = "Also slows the caster for " .. math.abs(channel_slow) .. "%" | local note = "Also slows the caster for " .. math.abs(channel_slow) .. "%." | ||
cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note | cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note | ||
end | end | ||
| Line 551: | Line 400: | ||
if caster_dash_slow then | if caster_dash_slow then | ||
local note = "Gives " .. caster_dash_slow .. "% dash slow for the caster" | local note = "Gives " .. caster_dash_slow .. "% dash slow for the caster." | ||
cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note | cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note | ||
end | end | ||
return cells | return cells | ||
end | end | ||
return p | return p | ||