Module:Sandbox/User:Sfoxrs/ecb: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(No difference)
|
Revision as of 12:36, 16 October 2020
Documentation for this module may be created at Module:Sandbox/User:Sfoxrs/ecb/doc
-- <pre>
local p = {}
local htnmlext = require('Module:Mw.html extension')
local yesno = require ("Module:Yesno")
local lang = mw.getContentLanguage()
function p.main(frame)
local args = frame:getParent().args
local damage = tonumber(args.damage) or 0
local target = args.target --primary, secondary
local souls = yesno(args.souls) or false
local vuln = yesno(args.vuln) or false
local slayerPerk = yesno(args.slayerPerk) or false
local slayerAbility = yesno(args.slayerAbility) or false
local spider = args.spider --0%, 2%, 3%
local addinfo = yesno(args.addinfo) or false
return calculateDamage(damage,target,souls,vuln,slayerPerk,slayerAbility,spider,addinfo)
end
function calculateDamage(damage,target,souls,vuln,slayerPerk,slayerAbility,spider,addinfo)
local amountHealed = 0
local damageFromSpecSoulsAvg = 0
local damageFromSpecSoulsMin = 0
local damageFromSpecSoulsMax = 0
--values without direct split soul damage modifiers
local vulnMod = 1; if(vuln) then vulnMod = 1.1 end
local slayerPerkMod = 1; if(slayerPerk) then slayerPerkMod = 1.07 end
local slayerAbilityMod = 1; if(slayerAbility) then slayerAbilityMod = 1.15 end
local spiderMod = 1; if (spider=="2%") then spiderMod = 1.02 elseif (spider=="3%") then spiderMod = 1.03 end
local noVulnDamage = math.max(1, math.ceil(damage/(vulnMod*slayerPerkMod*slayerAbilityMod*spiderMod)) )
local noVulnAmountHealed = 0
local noVulnDamageFromSpecSoulsAvg = 0
local noVulnDamageFromSpecSoulsMin = 0
local noVulnDamageFromSpecSoulsMax = 0
--soul split heals
if target=="Primary" then
amountHealed = math.floor(math.min(2000,damage)*.1) + math.floor(math.max(0,math.min(2000,damage-2000))*.05) + math.floor(math.max(0,damage-4000)*.0125)
noVulnAmountHealed = math.floor(math.min(2000,noVulnDamage)*.1) + math.floor(math.max(0,math.min(2000,noVulnDamage-2000))*.05) + math.floor(math.max(0,noVulnDamage-4000)*.0125)
elseif target=="Secondary" then
amountHealed = math.floor(math.min(2000,damage)*.1*.5) + math.floor(math.max(0,math.min(2000,damage-2000))*.05*.5) + math.floor(math.max(0,damage-4000)*.0125*.5)
noVulnAmountHealed = math.floor(math.min(2000,noVulnDamage)*.1*.5) + math.floor(math.max(0,math.min(2000,noVulnDamage-2000))*.05*.5) + math.floor(math.max(0,noVulnDamage-4000)*.0125*.5)
end
local avgIncreaseHealed = math.floor(amountHealed*.375)
local maxIncreaseHealed = math.floor(amountHealed*.5)
local noVulnAvgIncreaseHealed = math.floor(noVulnAmountHealed*.375)
local noVulnMaxIncreaseHealed = math.floor(noVulnAmountHealed*.5)
--split soul damage
--avg with amulet of souls
damageFromSpecSoulsAvg = math.floor(math.floor(math.floor(math.floor( (.5*math.floor(amountHealed*4) + .5*math.floor((amountHealed+avgIncreaseHealed)*4)) * vulnMod) * slayerPerkMod) * slayerAbilityMod) * spiderMod)
noVulnDamageFromSpecSoulsAvg = .5*math.floor(noVulnAmountHealed*4) + .5*math.floor((noVulnAmountHealed+noVulnAvgIncreaseHealed)*4)
--min with amulet of souls or no amulet of souls
damageFromSpecSoulsMin = math.floor(math.floor(math.floor(math.floor( math.floor(amountHealed*4) * vulnMod) * slayerPerkMod) * slayerAbilityMod) * spiderMod)
noVulnDamageFromSpecSoulsMin = math.floor(noVulnAmountHealed*4)
--max with amulet of souls
damageFromSpecSoulsMax = math.floor(math.floor(math.floor(math.floor( math.floor((amountHealed+maxIncreaseHealed)*4) * vulnMod) * slayerPerkMod) * slayerAbilityMod) * spiderMod)
noVulnDamageFromSpecSoulsMax = math.floor((noVulnAmountHealed+noVulnMaxIncreaseHealed)*4)
--table for output
local size = 30
local check = {
[true] = 'Yes check',
[false] = 'X mark'
}
local resultsDiv = mw.html.create( 'div' )
local resultsTable = mw.html.create( 'table' )
resultsTable:addClass( 'wikitable' )
:IF(addinfo)
:addClass( 'align-center-1 align-center-2 align-center-3 align-center-4 align-center-5 align-center-6' )
:ELSE()
:addClass( 'align-center-1 align-center-2 align-center-3 align-center-4 align-center-5' )
:END()
:tag( 'caption' )
:IF(addinfo)
:wikitext( 'Damage from Split Soul. This is calculated based on whether the target is a primary or a secondary target, whether the player has the Amulet of souls/Essence of Finality amulet equipped, and if the target is affected by a combination of: Vulnerability, a Slayer perk, a Slayer ability, and the NopeNopeNope perk. The Damage Increase column describes the increase coming from the Split Soul damage. The Increase from Split Soul damage modifiers column describes the base damage hitsplat and Split Soul damage increase with Split Soul damage modifiers to without Split Soul damage modifiers. ' )
:css('text-align', 'left')
:ELSE()
:wikitext( 'Damage from Split Soul. This is calculated based on whether the target is a primary or a secondary target, whether the player has the Amulet of souls/Essence of Finality amulet equipped, and if the target is affected by a combination of: Vulnerability, a Slayer perk, a Slayer ability, and the NopeNopeNope perk. The Damage Increase column describes the increase coming from the Split Soul damage. ' )
:css('text-align', 'left')
:END()
:tag( 'tr' )
:tag( 'th' )
:wikitext( 'Damage from Split Soul (' .. target .. ' target)' .. "<br/>Active Split Soul damage modifiers:")
:IF(vuln)
:wikitext(string.format("[[File:Vulnerability icon.png|link=Vulnerability|%dpx]]",size))
:END()
:IF(slayerPerk)
:wikitext(string.format("[[File:Demon_Slayer_(perk).png|link=Demon_Slayer_(perk)|%dpx]][[File:Dragon_Slayer_(perk).png|link=Dragon_Slayer_(perk)|%dpx]][[File:Undead_Slayer.png|link=Undead_Slayer|%dpx]]",size,size,size))
:END()
:IF(slayerAbility)
:wikitext(string.format("[[File:Demon_Slayer_(ability).png|link=Demon_Slayer_(ability)|%dpx]][[File:Dragon_Slayer_(ability).png|link=Dragon_Slayer_(ability)|%dpx]][[File:Undead_Slayer_(ability).png|link=Undead_Slayer_(ability)|%dpx]]",size,size,size))
:END()
:IF(spider~="0%")
:wikitext(string.format("[[File:NopeNopeNope_status_icon.png|link=Player-owned_farm#Perks|%dpx]]",size) .. spider)
:END()
:IF(vuln==false and slayerPerk==false and slayerAbility==false and spider=="0%")
:wikitext( ' None' )
:END()
:IF(addinfo)
:attr( 'colspan', 6 )
:ELSE()
:attr( 'colspan', 5 )
:END()
:done()
:done()
:tag( 'tr' )
:tag( 'th' )
:wikitext( string.format("[[File:Amulet_of_souls_(or).png|link=]]") .. string.format('[[File:%s.svg|20px|link=]]', check[yesno(souls)]) )
:done()
:tag( 'th' )
:wikitext( 'Base Hitsplat<br/>' .. string.format("[[File:Ranged-icon.png|link=]]") )
:done()
:tag( 'th' )
:wikitext( 'Split Soul damage<br/>' .. string.format("[[File:Split Soul hitsplat.png|link=]]") )
:done()
:tag( 'th' )
:wikitext( 'Total damage<br/>' .. string.format("[[File:Ranged-icon.png|link=]]") .. "+" .. string.format("[[File:Split Soul hitsplat.png|link=]]") )
:done()
:tag( 'th' )
:wikitext( 'Damage Increase<br/>(%)' )
:done()
:IF(addinfo)
:tag( 'th' )
:wikitext( 'Increase from Split Soul<br/>damage modifiers' )
:done()
:END()
:done()
:IF(souls)
:tag( 'tr' )
:tag( 'td' )
:wikitext( '<b>Average</b>' )
:done()
:tag( 'td' )
:wikitext( string.format("<b>%s</b>",lang:formatNum(damage)) )
:done()
:tag( 'td' )
:wikitext( string.format("<b>%s</b>",lang:formatNum(damageFromSpecSoulsAvg)) )
:done()
:tag( 'td' )
:wikitext( string.format("<b>%s</b>",lang:formatNum(damage+damageFromSpecSoulsAvg)) )
:done()
:tag( 'td' )
:wikitext( string.format("<b>%.2f</b>",lang:formatNum(damageFromSpecSoulsAvg/damage*100)) .. "<b>%</b>" )
:done()
:IF(addinfo)
:tag( 'td' )
:wikitext( string.format("<b>%.2f</b>", lang:formatNum(((damage+damageFromSpecSoulsAvg)/(noVulnDamage+noVulnDamageFromSpecSoulsAvg)-1)*100)) .. "<b>%</b>" )
:done()
:END()
:done()
:END()
:tag( 'tr' )
:tag( 'td' )
:IF(souls)
:wikitext( 'Minimum' )
:ELSE()
:wikitext( 'Damage' )
:END()
:done()
:tag( 'td' )
:wikitext( string.format("%s",lang:formatNum(damage)) )
:done()
:tag( 'td' )
:wikitext( string.format("%s",lang:formatNum(damageFromSpecSoulsMin)) )
:done()
:tag( 'td' )
:wikitext( string.format("%s",lang:formatNum(damage+damageFromSpecSoulsMin)) )
:done()
:tag( 'td' )
:wikitext( string.format("%.2f",lang:formatNum(damageFromSpecSoulsMin/damage*100)) .. "%" )
:done()
:IF(addinfo)
:tag( 'td' )
:wikitext( string.format("%.2f", lang:formatNum(((damage+damageFromSpecSoulsMin)/(noVulnDamage+noVulnDamageFromSpecSoulsMin)-1)*100)) .."%" )
:done()
:END()
:done()
:IF(souls)
:tag( 'tr' )
:tag( 'td' )
:wikitext( 'Maximum' )
:done()
:tag( 'td' )
:wikitext( string.format("%s",lang:formatNum(damage)) )
:done()
:tag( 'td' )
:wikitext( string.format("%s",lang:formatNum(damageFromSpecSoulsMax)) )
:done()
:tag( 'td' )
:wikitext( string.format("%s",lang:formatNum(damage+damageFromSpecSoulsMax)) )
:done()
:tag( 'td' )
:wikitext( string.format("%.2f",lang:formatNum(damageFromSpecSoulsMax/damage*100)) .. "%" )
:done()
:IF(addinfo)
:tag( 'td' )
:wikitext( string.format("%.2f", lang:formatNum(((damage+damageFromSpecSoulsMax)/(noVulnDamage+noVulnDamageFromSpecSoulsMax)-1)*100)) .."%" )
:done()
:END()
:done()
:END()
:done()
--return results (table)
resultsDiv:node(tostring(resultsTable))
return resultsDiv
end
return p