Module:LevelTables: Difference between revisionsGive feedback
Updated alt fire stats to new numbers |
Added support for new weapon data structure |
||
| Line 4: | Line 4: | ||
local heroes_data = mw.loadJsonData("Data:HeroData.json") | local heroes_data = mw.loadJsonData("Data:HeroData.json") | ||
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json") | local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json") | ||
-- Helper to safely get stats that may be nested under Weapon | |||
local function get_stat_value(data, key) | |||
if data[key] ~= nil then return data[key] end | |||
if data.Weapon and data.Weapon[key] ~= nil then return data.Weapon[key] end | |||
return 0 | |||
end | |||
-- Defines human-readable names for the internal property keys used in headers. | -- Defines human-readable names for the internal property keys used in headers. | ||
| Line 12: | Line 19: | ||
LightMeleeDamage = "Light Melee Damage", | LightMeleeDamage = "Light Melee Damage", | ||
HeavyMeleeDamage = "Heavy Melee Damage" | HeavyMeleeDamage = "Heavy Melee Damage" | ||
} | } | ||
| Line 114: | Line 114: | ||
suffix = " (" .. hero_data.alt_fire.suffix .. ")" | suffix = " (" .. hero_data.alt_fire.suffix .. ")" | ||
else | else | ||
base = (hero_data | base = get_stat_value(hero_data, property) | ||
level = (hero_data["LevelScaling"] and hero_data["LevelScaling"][property] or 0) | level = (hero_data["LevelScaling"] and hero_data["LevelScaling"][property] or 0) | ||
suffix = "" | suffix = "" | ||
local shots = (hero_data | local shots = get_stat_value(hero_data, "BulletsPerShot") | ||
local burst = (hero_data | if shots == 0 then shots = 1 end | ||
local burst = get_stat_value(hero_data, "BulletsPerBurst") | |||
if burst == 0 then burst = 1 end | |||
local hit_once = get_stat_value(hero_data, "HitOnceAcrossAllBullets") | |||
if (property == "BulletDamage" and (shots * burst) > 1) then | if (property == "BulletDamage" and (shots * burst) > 1) then | ||
if (not | if (not hit_once) then | ||
base = base * shots * burst | base = base * shots * burst | ||
level = level * shots * burst | level = level * shots * burst | ||
| Line 199: | Line 203: | ||
for _, hero in ipairs(filtered_heroes) do | for _, hero in ipairs(filtered_heroes) do | ||
addHeroRows(hero, false) | addHeroRows(hero, false) | ||
if (property == "BulletDamage" and | |||
-- Dynamically add alt-fire rows if the data exists | |||
if (property == "BulletDamage" and hero.Weapon and hero.Weapon.AltFire) then | |||
local alt_fire_data = hero.Weapon.AltFire | |||
local alt_fire_base = alt_fire_data.BulletDamage or 0 | |||
if alt_fire_base > 0 then | |||
-- Get scaling: prefer alt-fire specific key, fall back to main weapon scaling | |||
local alt_fire_level = (hero.LevelScaling and | |||
(hero.LevelScaling.BulletDamageAltFire or hero.LevelScaling[property])) or 0 | |||
-- Apply same pellet/burst logic as main weapon | |||
local shots = alt_fire_data.BulletsPerShot or 1 | |||
local burst = alt_fire_data.BulletsPerBurst or 1 | |||
local hit_once = alt_fire_data.HitOnceAcrossAllBullets or false | |||
local suffix = "alt fire" | |||
if (shots * burst) > 1 and not hit_once then | |||
alt_fire_base = alt_fire_base * shots * burst | |||
alt_fire_level = alt_fire_level * shots * burst | |||
if shots > 1 then suffix = suffix .. " " .. shots .. " pellets" end | |||
if burst > 1 then suffix = suffix .. " " .. burst .. " bullets" end | |||
end | |||
-- Add AOE indicator (without radius) | |||
if alt_fire_data.ExplosionRadius then | |||
suffix = suffix .. " AOE" | |||
end | |||
local alt_fire_hero_data = { | |||
Name = hero.Name, | |||
alt_fire = { | |||
base = alt_fire_base, | |||
level = alt_fire_level, | |||
suffix = suffix | |||
} | |||
} | |||
addHeroRows(alt_fire_hero_data, true) | |||
end | |||
end | end | ||
end | end | ||
| Line 248: | Line 286: | ||
local burst_heroes = {} | local burst_heroes = {} | ||
for _, hero in pairs(heroes_data) do | for _, hero in pairs(heroes_data) do | ||
local bullets_per_shot = get_stat_value(hero, "BulletsPerShot") | |||
local bullets_per_burst = get_stat_value(hero, "BulletsPerBurst") | |||
if (bullets_per_shot > 1 and not hero["IsDisabled"] and not hero["InDevelopment"]) then | |||
table.insert(spreadshot_heroes, hero) | table.insert(spreadshot_heroes, hero) | ||
elseif ( | elseif (bullets_per_burst > 1 and not hero["IsDisabled"] and not hero["InDevelopment"]) then | ||
table.insert(burst_heroes, hero) | table.insert(burst_heroes, hero) | ||
end | end | ||
| Line 260: | Line 301: | ||
local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n" | local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n" | ||
for _, hero in ipairs(spreadshot_heroes) do | for _, hero in ipairs(spreadshot_heroes) do | ||
local base = math.floor(hero | local base = math.floor(get_stat_value(hero, "BulletDamage") * 100) / 100 | ||
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | ||
local shots = hero | local shots = get_stat_value(hero, "BulletsPerShot") | ||
local hit_once = get_stat_value(hero, "HitOnceAcrossAllBullets") | |||
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}} | local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}} | ||
-- Checks for the special property and changes the output text accordingly. | -- Checks for the special property and changes the output text accordingly. | ||
local stat_str | local stat_str | ||
if | if hit_once then | ||
stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, " | stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, " | ||
.. base .. " total damage (hits only once), +" .. level .. " total\n" | .. base .. " total damage (hits only once), +" .. level .. " total\n" | ||
| Line 279: | Line 321: | ||
multishot_str = multishot_str .. "Weapons with burst fire (Burst Fire):\n" | multishot_str = multishot_str .. "Weapons with burst fire (Burst Fire):\n" | ||
for _, hero in ipairs(burst_heroes) do | for _, hero in ipairs(burst_heroes) do | ||
local base = math.floor(hero | local base = math.floor(get_stat_value(hero, "BulletDamage") * 100) / 100 | ||
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | ||
local shots = hero | local shots = get_stat_value(hero, "BulletsPerBurst") | ||
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}} | local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}} | ||
local stat_str = "* " .. hero_icon .. ": " .. shots .. " rounds, " | local stat_str = "* " .. hero_icon .. ": " .. shots .. " rounds, " | ||