Module:Damage: Difference between revisions
From Exiled Kingdoms Wiki
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
p = {} | p = {} | ||
local Comp = require( "Module:ValComp" ) | |||
resnm = { | resnm = { | ||
Line 56: | Line 57: | ||
function p.EleChk() | function p.EleChk() | ||
vto = mw.getCurrentFrame().args[2] | vto = mw.getCurrentFrame().args[2] | ||
chval = mw.getCurrentFrame().args[3] | |||
chsym = mw.getCurrentFrame().args[4] | |||
if (chval == nil or chval == '') then | |||
chval = 0 | |||
end | |||
if (chsym == nil or chsym == '') then | |||
chsym = gt | |||
end | |||
RawDmgs = mw.text.split(RawDmg,',',true) | RawDmgs = mw.text.split(RawDmg,',',true) | ||
vval = rresnm[vto] | vval = rresnm[vto] | ||
Line 61: | Line 70: | ||
vnum = RawDmgs[5] | vnum = RawDmgs[5] | ||
if (tonumber(vnum) == tonumber(vval)) then | if (tonumber(vnum) == tonumber(vval)) then | ||
isele = 1 | if (Comp.Compare(RawDmgs[4], chsym, chval) == true) then | ||
isele = 1 | |||
end | |||
end | end | ||
return isele | return isele |
Revision as of 20:23, 7 June 2017
p = {} local Comp = require( "Module:ValComp" )
resnm = {
[1] = 'Fire', [2] = 'Cold', [3] = 'Shock', [4] = 'Death', [5] = 'Toxic', [6] = 'Spirit' }
rresnm = {
Fire = 1, Cold = 2, Shock = 3, Death = 4, Toxic = 5, Spirit = 6 }
RawDmg = mw.getCurrentFrame().args[1]
function p.Min()
RawDmgs = mw.text.split(RawDmg,',',true) return RawDmgs[1]
end
function p.Max()
RawDmgs = mw.text.split(RawDmg,',',true) return RawDmgs[2]
end
function p.Speed()
RawDmgs = mw.text.split(RawDmg,',',true) return RawDmgs[6]
end
function p.Crit()
RawDmgs = mw.text.split(RawDmg,',',true) return RawDmgs[7]
end
function p.Elen()
RawDmgs = mw.text.split(RawDmg,',',true) return RawDmgs[4]
end
function p.EleDisp()
RawDmgs = mw.text.split(RawDmg,',',true) if (RawDmgs[4] == 0) then return end txtout = string.format("%s %s", getimg(RawDmgs[5]), RawDmgs[4]) return txtout
end
function p.EleChk()
vto = mw.getCurrentFrame().args[2] chval = mw.getCurrentFrame().args[3] chsym = mw.getCurrentFrame().args[4] if (chval == nil or chval == ) then chval = 0 end if (chsym == nil or chsym == ) then chsym = gt end RawDmgs = mw.text.split(RawDmg,',',true) vval = rresnm[vto] isele = 0 vnum = RawDmgs[5] if (tonumber(vnum) == tonumber(vval)) then if (Comp.Compare(RawDmgs[4], chsym, chval) == true) then isele = 1 end end return isele
end
function p.FullDisp()
RawDmgs = mw.text.split(RawDmg,',',true) txtout = string.format('%s %s', getimg(RawDmgs[3]), RawDmgs[1]) if (tonumber(RawDmgs[2]) > 0) then txtout = string.format('%s-%s', txtout, RawDmgs[2]) end if (tonumber(RawDmgs[4]) > 0) then txtout = string.format('%s +%s%s', txtout, getimg(RawDmgs[5]), RawDmgs[4]) end return txtout
end
function getimg(elemn)
txtrtn = if (tonumber(elemn) == 0) then txtrtn = '' else txtrtn = string.format('File:%s.png', resnm[tonumber(elemn)], resnm[tonumber(elemn)]) end return txtrtn
end
function p.DPS()
RawDmgs = mw.text.split(RawDmg,',',true) mind = tonumber(RawDmgs[1]) maxd = tonumber(RawDmgs[2]) crit = tonumber(RawDmgs[7]) eled = tonumber(RawDmgs[4]) speed = tonumber(RawDmgs[6]) critmult = tonumber(RawDmgs[8]) if (speed == 0) then speed = 10 end if (critmult == 0) then critmult = 1.5 end minmax = mind speed = speed / 10 if (maxd > 0) then --minmax minmax = (mind + maxd) / 2 else maxd = mind end basedmg = ((100-crit) / 100) * minmax + eled critdmg = (((maxd+1) + (maxd * critmult)) / 2) * (crit / 100) rdps = (basedmg + critdmg) * speed return string.format('%0.1f',rdps)
end
return p