62 734
modifications
Page créée avec « local localdata = require( 'Module:Infobox/Localdata' ) local icon = require( 'Module:Icône' ) -------------------------------------------------------- -----… » |
Harmonisation des identifiants techniques |
||
(25 versions intermédiaires par le même utilisateur non affichées) | |||
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' ) | ||
local explosionIcon = icon._build({ 'explosion' }) | |||
local effectIcon = icon._build({ 'effet' }) | |||
local tooltip = require( 'Module:Infobulle' ) | |||
local tooltipDmgAllPerks = 'Dégâts avec toutes les aptitudes mentionnées' | |||
local tooltipDmgPerk = 'Dégâts supplémentaires par attaque avec cette aptitude' | |||
local tooltipAttsecAllPerks = 'Attaques par seconde avec toutes les aptitudes mentionnées' | |||
local tooltipAttsecPerk = 'Attaques supplémentaires par seconde avec cette aptitude' | |||
local tooltipReloadAllPerks = 'Durée du rechargement avec toutes les aptitudes mentionnées' | |||
local tooltipReloadPerk = 'Diminution de la durée de rechargement avec cette aptitude' | |||
local tooltipStyle = 'color:#51E527;' | |||
-------------------------------------------------------- | -------------------------------------------------------- | ||
Ligne 6 : | Ligne 18 : | ||
-------------------------------------------------------- | -------------------------------------------------------- | ||
-- Récupère un paramètre | -- Récupère un paramètre au format number | ||
-- si nil ou n'est pas nombre | -- Force à 0 si nil ou s'il n'est pas un nombre | ||
function forceNumber(data) | function forceNumber(data) | ||
return tonumber(data) or 0 | |||
end | |||
return data | -- Formatage du nombre pour l'affichage | ||
function formatNumber(data, round) | |||
return string.format(round or "%.1f", data) | |||
end | end | ||
-- Formatage des infobulles | |||
-- | function formatTooltip(text, title) | ||
return tooltip._build({ text, title, style = tooltipStyle }) | |||
end | end | ||
-------------------------------------------------------- | |||
----- Calcul des dégâts ----- | |||
-------------------------------------------------------- | |||
-- Type d'arme | -- Type d'arme | ||
local weaponCompletType = localdata[ | local weaponCompletType = (localdata['type'] or ''):lower() | ||
local weaponType = weaponCompletType:gsub( | local weaponType = weaponCompletType:gsub(' unique', '') | ||
local isUnique = weaponCompletType:find(' unique') | local isUnique = weaponCompletType:find(' unique') ~= nil | ||
-- | -- Nombre d'attaques par seconde | ||
local attacksPerSec = forceNumber(localdata["attack shots/sec"]) | local attacksPerSec = forceNumber(localdata["attack shots/sec"]) | ||
-- | -- Durée du rechargement | ||
local reloadTime = 0 | |||
local | if weaponType == "gun" or weaponType == "gunautomatic" or weaponType == "gunhandload" then | ||
reloadTime = forceNumber(localdata["reload time"]) | |||
end | end | ||
-- projectiles | -- Nombre de projectiles par attaque | ||
local proj = 1 | local proj = 1 | ||
if weaponType == "gun" or weaponType == "gunautomatic" or weaponType == "gunhandload" then | if weaponType == "gun" or weaponType == "gunautomatic" or weaponType == "gunhandload" then | ||
proj = forceNumber(localdata["projectiles"]) | |||
if proj == 0 then proj = 1 end -- on force à 1 si projectile non renseigné | |||
end | end | ||
local clipRounds = forceNumber(localdata["clip rounds"]) | -- Taille du magasin | ||
local ammoUse = forceNumber(localdata["ammo use"]) | local clipRounds = forceNumber(localdata["clip rounds"]) | ||
-- Nombre de cartouches par attaque | |||
local ammoUse = forceNumber(localdata["ammo use"]) | |||
-- Nombre d'attaques par rechargement | |||
local shotsPerReload = 0 | local shotsPerReload = 0 | ||
if ammoUse > 0 then | if ammoUse > 0 then | ||
shotsPerReload = math.floor(clipRounds / ammoUse) | |||
end | end | ||
-- | -- Dégâts par type : balistique, explosif, effet | ||
local | |||
local dmgNormTotal = forceNumber(localdata["damage"]) | |||
local dmgNormProj = dmgNormTotal / proj | |||
local dmgEffProj = forceNumber(localdata["effect damage"]) | |||
local dmgEffTotal = dmgEffProj * proj | |||
local dmgExplProj = forceNumber(localdata["explosion damage"]) | |||
local dmgExplTotal = dmgExplProj * proj | |||
-- | -- Effets des aptitudes sur les dégâts | ||
local perksAttacksPerSec = 0 | |||
local perksDmgNorm = 0 | |||
local perksDmgEff = 0 | |||
local perksDmgExpl = 0 | |||
local perksReloadTime = 0 | local perksReloadTime = 0 | ||
local perksAttacksPerSecItems = '' | |||
local perksDmgItems = '' | |||
local perksReloadTimeItems = '' | |||
for i = 1, 9 do | for i = 1, 9 do | ||
local perk = localdata["perk" .. i] | |||
if perk then | |||
-- Calcul de chaque donnée | |||
local perkAttacksPerSec = attacksPerSec * forceNumber(localdata["perk" .. i .. " attsec mult"]) | |||
local perkDmgNorm = (dmgNormTotal * forceNumber(localdata["perk" .. i .. " mult"])) + forceNumber(localdata["perk" .. i .. " add"]) | |||
local perkDmgEff = (dmgEffTotal * forceNumber(localdata["perk" .. i .. " eff mult"])) + forceNumber(localdata["perk" .. i .. " eff add"]) | |||
local perkDmgExpl = (dmgExplTotal * forceNumber(localdata["perk" .. i .. " expl mult"])) + forceNumber(localdata["perk" .. i .. " expl add"]) | |||
local perkReloadTime = reloadTime * forceNumber(localdata["perk" .. i .. " reload mult"]) | |||
-- Somme des effets et gestion | |||
-- de l'affichage de la table Effets des aptitudes | |||
if perkAttacksPerSec > 0 then | |||
perksAttacksPerSec = perksAttacksPerSec + perkAttacksPerSec | |||
perksAttacksPerSecItems = perksAttacksPerSecItems .. '<li>' .. perk .. '<div style="float:right;">+ ' .. formatTooltip(formatNumber(perkAttacksPerSec), tooltipAttsecPerk) .. '</div></li>' | |||
end | |||
if perkDmgNorm > 0 or perkDmgEff > 0 or perkDmgExpl > 0 then | |||
perksDmgItems = perksDmgItems .. '<li>' .. perk .. '<div style="float:right;">' | |||
local | local addDmg = '' | ||
if perkDmgNorm > 0 then | |||
perksDmgNorm = perksDmgNorm + perkDmgNorm | |||
addDmg = addDmg .. ' + ' .. formatNumber(perkDmgNorm) | |||
end | |||
if perkDmgExpl > 0 then | |||
perksDmgExpl = perksDmgExpl + perkDmgExpl | |||
addDmg = addDmg .. ' + ' .. formatNumber(perkDmgExpl) .. ' ' .. explosionIcon | |||
end | |||
end | |||
if perkDmgEff > 0 then | |||
perksDmgEff = perksDmgEff + perkDmgEff | |||
addDmg = addDmg .. ' + ' .. formatNumber(perkDmgEff) .. ' ' .. effectIcon | |||
end | |||
perksDmgItems = perksDmgItems .. formatTooltip(addDmg, tooltipDmgPerk) .. '</div></li>' | |||
end | |||
if perkReloadTime > 0 then | |||
perksReloadTime = perksReloadTime + perkReloadTime | |||
perksReloadTimeItems = perksReloadTimeItems .. '<li>' .. perk .. '<div style="float:right;">- ' .. formatTooltip(formatNumber(perkReloadTime), tooltipReloadPerk) .. ' s</div></li>' | |||
end | |||
else | |||
break | |||
end | |||
end | end | ||
local | local perksAttacksPerSecTotal = attacksPerSec + perksAttacksPerSec | ||
local | local perksDmgNormProj = perksDmgNorm / proj | ||
local perksDmgNormTotal = dmgNormTotal + perksDmgNorm | |||
local perksDmgNormProjTotal = dmgNormProj + perksDmgNormProj | |||
local perksDmgEffProj = perksDmgEff / proj | |||
local perksDmgEffTotal = dmgEffTotal + perksDmgEff | |||
local perksDmgEffProjTotal = dmgEffProj + perksDmgEffProj | |||
local | local perksDmgExplProj = perksDmgExpl / proj | ||
local | local perksDmgExplTotal = dmgExplTotal + perksDmgExpl | ||
local | local perksDmgExplProjTotal = dmgExplTotal + perksDmgExplProj | ||
local perksReloadTimeTotal = reloadTime - perksReloadTime | |||
local | |||
-- | -- Dégâts par seconde | ||
local | local dps = (dmgNormTotal + dmgExplTotal) * attacksPerSec | ||
local | local perksDps = (perksDmgNormTotal + perksDmgExplTotal) * perksAttacksPerSecTotal | ||
-- Dégâts par seconde en prenant en compte la durée du rechargement | |||
local dpsReload = 0 | |||
local perksDpsReload = 0 | |||
local coeff = 1 | local coeff = 1 | ||
if weaponType == "gunhandload" then | if weaponType == "gunhandload" then | ||
coeff = shotsPerReload | |||
end | end | ||
if shotsPerReload > 0 then | if shotsPerReload > 0 then | ||
if attacksPerSec > 0 then | |||
dpsReload = ((dmgNormTotal + dmgExplTotal) * shotsPerReload) / | |||
((shotsPerReload / attacksPerSec) + reloadTime * coeff) | |||
end | |||
if perksAttacksPerSecTotal > 0 then | |||
perksDpsReload = ((perksDmgNormTotal + perksDmgExplTotal) * shotsPerReload) / | |||
((shotsPerReload / perksAttacksPerSecTotal) + perksReloadTimeTotal * coeff) | |||
end | |||
end | end | ||
-- Multiplicateur des chances de critique | |||
local critChanceMult = forceNumber(localdata["crit % mult"]) | |||
if weaponType == 'gunautomatic' and perksAttacksPerSecTotal > 0 then | |||
-- Pour les armes automatiques, on divise par le nombre d'attaques par seconde | |||
critChanceMult = critChanceMult / perksAttacksPerSecTotal | |||
end | |||
-------------------------------------------------------- | -------------------------------------------------------- | ||
Ligne 175 : | Ligne 196 : | ||
-------------------------------------------------------- | -------------------------------------------------------- | ||
-- Dégâts par attaque | |||
local dmgPerAttackCell = formatNumber(dmgNormTotal) | |||
if perksDmgNorm > 0 then | |||
dmgPerAttackCell = dmgPerAttackCell .. ' (' .. formatTooltip(formatNumber(perksDmgNormTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
if dmgExplTotal > 0 then | |||
dmgPerAttackCell = dmgPerAttackCell .. ' + ' .. formatNumber(dmgExplTotal) | |||
if perksDmgExpl > 0 then | |||
dmgPerAttackCell = dmgPerAttackCell .. ' (' .. formatTooltip(formatNumber(perksDmgExplTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
dmgPerAttackCell = dmgPerAttackCell .. ' ' .. explosionIcon | |||
end | |||
if dmgEffTotal > 0 then | |||
local effectDuration = localdata["effect duration"] or "1" | |||
dmgPerAttackCell = dmgPerAttackCell .. ' + ' .. formatNumber(dmgEffTotal) | |||
if perksDmgEff > 0 then | |||
dmgPerAttackCell = dmgPerAttackCell .. ' (' .. formatTooltip(formatNumber(perksDmgEffTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
dmgPerAttackCell = dmgPerAttackCell .. ' sur ' .. effectDuration .. ' s ' .. effectIcon | |||
end | |||
local | -- Dégâts par projectile | ||
if | local dmgPerProjCell = formatNumber(dmgNormProj) | ||
if | if perksDmgNormProj > 0 then | ||
dmgPerProjCell = dmgPerProjCell .. ' (' .. formatTooltip(formatNumber(perksDmgNormProjTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
if dmgExplProj > 0 then | |||
dmgPerProjCell = dmgPerProjCell .. ' + ' .. formatNumber(dmgExplProj) | |||
if perksDmgExplProj > 0 then | |||
dmgPerProjCell = dmgPerProjCell .. ' (' .. formatTooltip(formatNumber(perksDmgExplProjTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
dmgPerProjCell = dmgPerProjCell .. ' ' .. explosionIcon | |||
end | |||
if dmgEffProj > 0 then | |||
local effectDuration = localdata["effect duration"] or "1" | |||
dmgPerProjCell = dmgPerProjCell .. ' + ' .. formatNumber(dmgEffProj) | |||
if perksDmgEffProj > 0 then | |||
dmgPerProjCell = dmgPerProjCell .. ' (' .. formatTooltip(formatNumber(perksDmgEffProjTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
dmgPerProjCell = dmgPerProjCell .. ' sur ' .. effectDuration .. ' s ' .. effectIcon | |||
end | end | ||
if | -- Dégâts par seconde | ||
local dpsCell = formatNumber(dps) | |||
if perksDps > dps then | |||
dpsCell = dpsCell .. ' ('.. formatTooltip(formatNumber(perksDps), tooltipDmgAllPerks) .. ')' | |||
end | |||
if dmgEffTotal > 0 then | |||
dpsCell = dpsCell .. ' + ' .. formatNumber(dmgEffTotal) | |||
if perksDmgEff > 0 then | |||
dpsCell = dpsCell .. ' (' .. formatTooltip(formatNumber(perksDmgEffTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
dpsCell = dpsCell .. ' ' .. effectIcon | |||
end | end | ||
local | -- Dégâts par seconde (avec rechargement) | ||
if | local dpsReloadCell = formatNumber(dpsReload) | ||
if | if perksDpsReload > dpsReload then | ||
dpsReloadCell = dpsReloadCell .. ' ('.. formatTooltip(formatNumber(perksDpsReload), tooltipDmgAllPerks) .. ')' | |||
end | |||
if dmgEffTotal > 0 then | |||
dpsReloadCell = dpsReloadCell .. ' + ' .. formatNumber(dmgEffTotal) | |||
if perksDmgEff > 0 then | |||
dpsReloadCell = dpsReloadCell .. ' (' .. formatTooltip(formatNumber(perksDmgEffTotal), tooltipDmgAllPerks) .. ')' | |||
end | |||
dpsReloadCell = dpsReloadCell .. ' ' .. effectIcon | |||
end | end | ||
-- Multiplicateur de critique | |||
local critMultCell = 'x ' .. formatNumber(critChanceMult, "%.2f") | |||
-- Attaques par seconde | |||
local attackPerSecCell = formatNumber(attacksPerSec) | |||
if perksAttacksPerSec > 0 then | |||
attackPerSecCell = attackPerSecCell .. ' (' .. formatTooltip(formatNumber(perksAttacksPerSecTotal), tooltipAttsecAllPerks) .. ')' | |||
end | end | ||
local | -- Durée de rechargement | ||
local reloadTimeCell = formatNumber(reloadTime) | |||
if | if perksReloadTime > 0 then | ||
reloadTimeCell = reloadTimeCell .. ' (' .. formatTooltip(formatNumber(perksReloadTimeTotal), tooltipReloadAllPerks) .. ')' | |||
end | end | ||
-- Effets des aptitudes | |||
if | if #perksDmgItems > 0 then | ||
if | perksDmgItems = '<ul class="avt-simple-list">' .. perksDmgItems .. '</ul>' | ||
else | |||
perksDmgItems = nil | |||
end | |||
if #perksAttacksPerSecItems > 0 then | |||
perksAttacksPerSecItems = '<ul class="avt-simple-list">' .. perksAttacksPerSecItems .. '</ul>' | |||
else | |||
perksAttacksPerSecItems = nil | |||
end | |||
if #perksReloadTimeItems > 0 then | |||
perksReloadTimeItems = '<ul class="avt-simple-list">' .. perksReloadTimeItems .. '</ul>' | |||
else | |||
perksReloadTimeItems = nil | |||
end | end | ||
-------------------------------------------------------- | -------------------------------------------------------- | ||
Ligne 265 : | Ligne 305 : | ||
{ 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' }}, | ||
{ type = 'table', title = 'Conditions d\'utilisation', rows = { | { type = 'table', title = 'Conditions d\'utilisation', rows = { | ||
{ type = 'row', label = 'Compétence', value = ' | { type = 'row', label = 'Compétence', value = 'skill' }, | ||
{ type = 'row', label = 'Force', value = ' | { type = 'row', label = 'Force', value = 'strength req' } | ||
}}, | }}, | ||
{ type = 'table', title = 'Statistiques de combat', collapseparameters = { collapsible = true, collapsed = true }, rows = { | { type = 'table', title = 'Statistiques de combat', collapseparameters = { collapsible = true, collapsed = true }, rows = { | ||
{ type = 'row', label = 'Dégâts par attaque', value = function() return dmgPerAttackCell end }, | |||
{ type = 'row', label = 'Dégâts par projectile', value = function() return dmgPerProjCell 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 }, | |||
{ 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 attackPerSecCell end }, | |||
{ type = 'row', label = 'Points d\'action', value = 'ap' }, | |||
{ type = 'row', label = 'Projectiles', value = 'projectiles' }, | |||
{ 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', value = function() return formatNumber(shotsPerReload) end }, | |||
{ type = 'row', label = 'Capacité', value = 'clip rounds' }, | |||
{ type = 'row', label = 'Durée de rechargement', value = function() return reloadTimeCell end } | |||
}}, | |||
{ type = 'table', title = 'Effets des aptitudes', collapseparameters = { collapsible = true, collapsed = true }, rows = { | |||
{ type = 'row', label = 'Dégâts', value = function() return perksDmgItems end }, | |||
{ type = 'row', label = 'Attaques par seconde', value = function() return perksAttacksPerSecItems end }, | |||
{ type = 'row', label = 'Rechargement', value = function() return perksReloadTimeItems end } | |||
}}, | }}, | ||
{ type = 'table', title = 'Autres propriétés', rows = { | { type = 'table', title = 'Autres propriétés', rows = { | ||
Ligne 295 : | Ligne 340 : | ||
{ type = 'row', label = 'Réparation', value = 'repair' }, | { type = 'row', label = 'Réparation', value = 'repair' }, | ||
{ type = 'row', label = 'Quêtes', value = 'quêtes' } | { type = 'row', label = 'Quêtes', value = 'quêtes' } | ||
}}, | }}, | ||
{ type = 'table', title = 'Technique', collapseparameters = { collapsible = true, collapsed = true }, rows = { | { type = 'table', title = 'Technique', collapseparameters = { collapsible = true, collapsed = true }, rows = { | ||
{ type = 'row', label = '[[Form | { type = 'row', label = '[[Form ID]]', value = 'formid' }, | ||
{ type = 'row', label = 'Editor ID', value = 'editorid' } | { type = 'row', label = '[[Editor ID]]', value = 'editorid' } | ||
}}, | }}, | ||
{ type = 'text', value = 'pied' } | { type = 'text', value = 'pied' } | ||
} | } | ||
} | } |
modifications