Modification de Module:Infobox/Arme gamebryo
La modification peut être annulée. Veuillez vérifier les différences ci-dessous pour voir si c’est bien ce que vous voulez faire, puis publier ces changements pour finaliser l’annulation de cette modification.
Version actuelle | Votre texte | ||
Ligne 1 : | Ligne 1 : | ||
local localdata = require( 'Module:Infobox/Localdata' ) | local localdata = require( 'Module:Infobox/Localdata' ) | ||
local icon = require( 'Module:Icône' ) | local icon = require( 'Module:Icône' ) | ||
-------------------------------------------------------- | -------------------------------------------------------- | ||
Ligne 18 : | Ligne 6 : | ||
-------------------------------------------------------- | -------------------------------------------------------- | ||
-- Récupère un paramètre | -- Récupère un paramètre en forçant à 0 | ||
-- | -- si nil ou n'est pas nombre | ||
function forceNumber(data) | function forceNumber(data) | ||
if not data or type(data) ~= 'number' then | |||
return 0 | |||
end | |||
return data | |||
end | end | ||
-- | function formatData(data, round) | ||
-- local formattedData | |||
-- if data and data > 0 then | |||
-- formattedData = string.format(round, data) | |||
-- end | |||
return string.format(round or "%.1f", data) | return string.format(round or "%.1f", data) | ||
end | end | ||
-------------------------------------------------------- | -------------------------------------------------------- | ||
----- | ----- Calcul des dégâts et ----- | ||
----- et création des tables de stats ----- | |||
-------------------------------------------------------- | -------------------------------------------------------- | ||
-- Type d'arme | function buildStatsTables(localdata) | ||
local weaponCompletType = | -- Type d'arme | ||
local weaponType = weaponCompletType:gsub( | local weaponCompletType = localdata["type"] or "" | ||
local isUnique = weaponCompletType:find(' unique') | local weaponType = weaponCompletType:gsub(" unique", "") | ||
local isUnique = weaponCompletType:find(' unique') | |||
-- Dégâts | |||
local attacksPerSec = forceNumber(localdata["attack shots/sec"]) | |||
-- Augmentation des dégâts via les aptitudes | |||
-- Les aptitudes agissent comme un coefficient multiplicateur | |||
local perksAttacksPerSec = 0 | |||
for i = 1, 9 do | |||
local perkAttsecMult = forceNumber(localdata["perk" .. i .. " attsec mult"]) | |||
if perkAttsecMult > 0 then | |||
perksAttacksPerSec = perksAttacksPerSec + (attacksPerSec * perkAttsecMult) | |||
else | |||
break | |||
end | |||
end | |||
local perksAttacksPerSecTotal = attacksPerSec + perksAttacksPerSec | |||
-- Multiplicateur de critique | |||
local critChance = forceNumber(localdata["crit % mult"]) | |||
local critChanceModified = 0 | |||
if weaponType == 'gunautomatic' and perksAttacksPerSecTotal > 0 then | |||
critChanceModified = critChance / perksAttacksPerSecTotal | |||
end | |||
-- Nombre de projectiles | |||
local proj = 1 | |||
if weaponType == "gun" or weaponType == "gunautomatic" or weaponType == "gunhandload" then | |||
proj = forceNumber(localdata["projectiles"]) | |||
if proj == 0 then proj = 1 end | |||
end | |||
-- Nombre de projectiles | |||
local proj = 1 | |||
if weaponType == "gun" or weaponType == "gunautomatic" or weaponType == "gunhandload" then | |||
end | |||
local clipRounds = forceNumber(localdata["clip rounds"]) | |||
local clipRounds = forceNumber(localdata["clip rounds"]) | local ammoUse = forceNumber(localdata["ammo use"]) | ||
local shotsPerReload = 0 | |||
if ammoUse > 0 then | |||
shotsPerReload = math.floor(clipRounds / ammoUse) | |||
end | |||
-- | -- Durée de rechargement | ||
local | local reloadTime = 0 | ||
if | if weaponType == "gun" or weaponType == "gunautomatic" or weaponType == "gunhandload" then | ||
reloadTime = forceNumber(localdata["reload time"]) | |||
end | end | ||
-- | -- Durée de rechargement en prenant en compte les aptitudes | ||
local perksReloadTime = 0 | |||
local | for i = 1, 9 do | ||
local perkReloadTime = localdata["perk" .. i .. " reload mult"] | |||
if perkReloadTime and type(perkReloadTime) == "number" then | |||
perksReloadTime = perksReloadTime + (reloadTime * perkReloadTime) | |||
else | |||
break | |||
end | |||
end | |||
local | local perksReloadTimeTotal = reloadTime - perksReloadTime | ||
-- | -- Dégâts par type (simple, explosif, poison) | ||
local | local damNormTotal = forceNumber(localdata["damage"]) | ||
local | local damNormProj = damNormTotal / proj | ||
local damEffProj = forceNumber(localdata["effect damage"]) | |||
local | local damEffTotal = damEffProj * proj | ||
local damExplProj = forceNumber(localdata["explosion damage"]) | |||
local damExplTotal = damExplProj * proj | |||
local perksDamNorm = 0 | |||
for i = 1, 9 do | |||
local perkDamNormMult = localdata["perk" .. i .. " mult"] or 0 | |||
local perkDamNormAdd = localdata["perk" .. i .. " add"] or 0 | |||
if type(perkDamNormMult) == "number" and type(perkDamNormAdd) == "number" then | |||
perksDamNorm = perksDamNorm + (damNormTotal * perkDamNormMult) + perkDamNormAdd | |||
else | |||
break | |||
end | end | ||
end | |||
local perksDamNormProj = perksDamNorm / proj | |||
local perksDamNormTotal = damNormTotal + perksDamNorm | |||
local perksDamNormProjTotal = damNormProj + perksDamNormProj | |||
local perksDamEff = 0 | |||
for i = 1, 9 do | |||
local perkDamEffMult = localdata["perk" .. i .. " eff mult"] or 0 | |||
local perkDamEffAdd = localdata["perk" .. i .. " eff add"] or 0 | |||
if type(perkDamEffMult) == "number" and type(perkDamEffAdd) == "number" then | |||
perksDamEff = perksDamEff + (damEffProj * perkDamEffMult) + perkDamEffAdd | |||
else | |||
break | |||
end | |||
end | end | ||
local perksDamEffProj = perksDamEff / proj | |||
local perksDamEffTotal = damEffTotal + perksDamEff | |||
local perksDamEffProjTotal = damEffProj + perksDamEffProj | |||
local perksDamExpl = 0 | |||
for i = 1, 9 do | |||
local perkDamExplMult = localdata["perk" .. i .. " eff mult"] or 0 | |||
local perkDamExplAdd = localdata["perk" .. i .. " eff add"] or 0 | |||
if type(perkDamExplMult) == "number" and type(perkDamExplAdd) == "number" then | |||
perksDamExpl = perksDamExpl + (damExplTotal * perkDamExplMult) + perkDamExplAdd | |||
else | |||
break | |||
end | end | ||
end | end | ||
local | local perksDamExplProj = perksDamExpl / proj | ||
local perksDamExplTotal = damExplTotal + perksDamExpl | |||
local perksDamExplProjTotal = damExplTotal + perksDamExplProj | |||
-- Calcul du DPS | |||
local | local DPS = (damNormTotal + damExplTotal) * attacksPerSec | ||
local | local DPSPerks = (perksDamNormTotal + perksDamExplTotal) * perksAttacksPerSecTotal | ||
-- Calcul du DPS en prenant en compte la durée de rechargement | |||
local | local DPSReload = 0 | ||
local | local DPSReloadPerks = 0 | ||
local | local coeff = 1 | ||
if weaponType == "gunhandload" then | |||
coeff = shotsPerReload | |||
end | |||
if shotsPerReload > 0 then | |||
if attacksPerSec > 0 then | |||
DPSReload = ((damNormTotal + damExplTotal) * shotsPerReload) / | |||
((shotsPerReload / attacksPerSec) + reloadTime * coef) | |||
end | |||
if perksAttacksPerSecTotal > 0 then | |||
DPSReloadPerks = ((perksDamNormTotal + perksDamExplTotal) * shotsPerReload) / | |||
((shotsPerReload / perksAttacksPerSecTotal) + perksReloadTimeTotal * coef) | |||
end | |||
end | |||
-- | -------------------------------------------------------- | ||
----- Formatage des données ----- | |||
-------------------------------------------------------- | |||
local damagePerAttackCell = formatData(damNormTotal) | |||
if perksDamNormTotal > 0 then damagePerAttackCell = damagePerAttackCell .. ' (' .. formatData(perksDamNormTotal) .. ')' end | |||
if damExplTotal > 0 then | |||
damagePerAttackCell = damagePerAttackCell .. ' + ' .. formatData(damExplTotal) | |||
if perksDamExplTotal > 0 then damagePerAttackCell = damagePerAttackCell .. ' (' .. formatData(perksDamExplTotal) .. ')' end | |||
damagePerAttackCell = damagePerAttackCell .. ' ' .. icon.build({ 'explosion' }) | |||
end | |||
local | if damEffTotal > 0 then | ||
if | local effectDuration = localdata["effect duration"] or "1" | ||
damagePerAttackCell = damagePerAttackCell .. ' + ' .. formatData(damEffTotal) | |||
end | if perksDamEffTotal > 0 then damagePerAttackCell = damagePerAttackCell .. ' (' .. formatData(perksDamEffTotal) .. ')' end | ||
damagePerAttackCell = damagePerAttackCell .. ' sur ' .. effectDuration .. ' s ' .. icon.build({ 'effet' }) | |||
end | |||
if | local damagePerProjCell = formatData(damNormProj) | ||
if | if perksDamNormProj > 0 then damagePerProjCell = damagePerProjCell .. ' (' .. formatData(perksDamNormProj) .. ')' end | ||
if damExplProj > 0 then | |||
damagePerProjCell = damagePerProjCell .. ' + ' .. formatData(damExplProj) | |||
if perksDamExplProjTotal > 0 then damagePerProjCell = damagePerProjCell .. ' (' .. formatData(perksDamExplProjTotal) .. ')' end | |||
damagePerProjCell = damagePerProjCell .. ' ' .. icon.build({ 'explosion' }) | |||
end | end | ||
if damEffProj > 0 then | |||
local | local effectDuration = localdata["effect duration"] or "1" | ||
damagePerProjCell = damagePerProjCell .. ' + ' .. formatData(damEffProj) | |||
if perksDamEffProjTotal > 0 then damagePerProjCell = damagePerProjCell .. ' (' .. formatData(perksDamEffProjTotal) .. ')' end | |||
damagePerProjCell = damagePerProjCell .. ' sur ' .. effectDuration .. ' s ' .. icon.build({ 'effet' }) | |||
end | end | ||
local dpsCell = formatData(DPS) | |||
local | if DPSPerks > 0 then dpsCell = dpsCell .. ' ('.. formatData(DPSPerks) .. ')' end | ||
if | if damEffTotal > 0 then | ||
dpsCell = dpsCell .. ' + ' .. formatData(damEffTotal) | |||
end | if perksDamEffTotal > 0 then dpsCell = dpsCell .. ' (' .. perksDamEffTotal .. ')' end | ||
if | dpsCell = dpsCell .. ' ' .. icon.build({ 'effet' }) | ||
end | end | ||
local dpsReloadCell = formatData(DPSReload) | |||
local | if DPSReloadPerks > 0 then dpsReloadCell = dpsReloadCell .. ' ('.. formatData(DPSReloadPerks) .. ')' end | ||
if | if damEffTotal > 0 then | ||
dpsReloadCell = dpsReloadCell .. ' + ' .. formatData(damEffTotal) | |||
end | if perksDamEffTotal > 0 then dpsReloadCell = dpsReloadCell .. ' (' .. formatData(perksDamEffTotal) .. ')' end | ||
if | dpsReloadCell = dpsReloadCell .. ' ' .. icon.build({ 'effet' }) | ||
end | end | ||
local critMultCell = critChance | |||
local | if critChanceModified > 0 then critMultCell = critChanceModified end | ||
critMultCell = 'x ' .. formatData(critMultCell, "%.2f") | |||
if | |||
local attackPerSecondCell = formatData(attacksPerSec) | |||
if perksAttacksPerSecTotal > 0 then attackPerSecondCell = attackPerSecondCell .. ' (' .. formatData(perksAttacksPerSecTotal) .. ')' end | |||
local reloadTimeCell = formatData(reloadTime) | |||
local | if perksReloadTimeTotal > 0 then reloadTimeCell = reloadTimeCell .. ' (' .. formatData(perksReloadTimeTotal) .. ')' end | ||
if | |||
end | |||
-- | -------------------------------------------------------- | ||
----- Retour ----- | |||
-------------------------------------------------------- | |||
return { type = 'table', title = 'Statistiques de combat', collapseparameters = { collapsible = true, collapsed = true }, rows = { | |||
{ type = 'row', label = 'Dégâts par attaque', value = function() return damagePerAttackCell end }, | |||
{ type = 'row', label = 'Dégâts par projectile', value = function() return damagePerProjCell end }, | |||
{ type = 'row', label = 'Dégâts par seconde', value = function() return dpsCell end }, | |||
{ type = 'row', label = 'Dégâts par seconde (avec rechargement)', value = function() return dpsReloadCell end }, | |||
end | { type = 'row', label = 'Dégâts critiques', value = 'crit dmg' }, | ||
{ type = 'row', label = 'Multiplicateur de critique', value = function() return critMultCell end }, | |||
{ type = 'row', label = 'Attaques par seconde', value = function() return attackPerSecondCell end }, | |||
{ type = 'row', label = 'Points d\'action', value = 'ap' }, | |||
{ type = 'row', label = 'Projectiles', value = 'projectiles' }, | |||
end | { type = 'row', label = 'Dispersion', value = 'min spread' }, | ||
{ type = 'row', label = 'Effet', value = 'other effect' }, | |||
{ type = 'row', label = 'Effet critique', value = 'crit effect' } | |||
}}, | |||
{ type = 'table', title = 'Munitions et rechargement', collapseparameters = { collapsible = true, collapsed = true }, rows = { | |||
{ type = 'row', label = 'Type de munitions', value = 'ammo' }, | |||
{ type = 'row', label = 'Projectiles par tir', value = 'ammo use' }, | |||
{ type = 'row', label = 'Tirs par magasin', function() return formatData(shotsPerReload) end }, | |||
{ type = 'row', label = 'Capacité', value = 'clip rounds' }, | |||
{ type = 'row', label = 'Durée de rechargement', value = function() return reloadTimeCell end } | |||
}} | |||
end | end | ||
Ligne 304 : | Ligne 274 : | ||
{ type = 'title', value = 'nom', subtitle = 'sous-titre', icon = 'icône', subhead = { games = 'jeux', subject = 'Arme', link = 'Armes' }}, | { type = 'title', value = 'nom', subtitle = 'sous-titre', icon = 'icône', subhead = { games = 'jeux', subject = 'Arme', link = 'Armes' }}, | ||
{ type = 'images', imageparameters = { 'image', 'image2', 'image3', 'image4', 'image5' }, captionparameter = { 'légende', 'image desc' }}, | { type = 'images', imageparameters = { 'image', 'image2', 'image3', 'image4', 'image5' }, captionparameter = { 'légende', 'image desc' }}, | ||
buildStatsTables(localdata), | |||
{ type = 'table', title = 'Effets des aptitudes', rows = { | |||
-- TODO | |||
{ type = 'table', title = 'Effets des aptitudes' | |||
}}, | }}, | ||
{ type = 'table', title = 'Autres propriétés', rows = { | { type = 'table', title = 'Autres propriétés', rows = { | ||
Ligne 342 : | Ligne 286 : | ||
}}, | }}, | ||
{ type = 'table', title = 'Technique', collapseparameters = { collapsible = true, collapsed = true }, rows = { | { type = 'table', title = 'Technique', collapseparameters = { collapsible = true, collapsed = true }, rows = { | ||
{ type = 'row', label = '[[Form ID]]', value = ' | { type = 'row', label = '[[Form ID|Base ID]]', value = 'baseid' }, | ||
{ type = 'row', label = ' | { type = 'row', label = 'Editor ID', value = 'editorid' } | ||
}}, | }}, | ||
{ type = 'text', value = 'pied' } | { type = 'text', value = 'pied' } | ||
} | } | ||
} | } |