Documentation
Basic use
To use this module, do as follows for most games:
{{#invoke:CalculatedStats|<function>|<level>|<strength>|<intelligence>|<magic>|<vitality/endurance>|<agility>|<luck>}}
For Persona 2: Innocent Sin, do as follows for basic use:
{{#invoke:CalculatedStats|<function>|<level>|<strength>|<vitality>|<dexterity>|<agility>|<luck>}}
This module should not be invoked directly in the mainspace and should be part of a template, with the values filled with template parameters.
Valid values for function (case sensitive):
smt1
for Shin Megami Tenseismt2
for Shin Megami Tensei IIsmtif
for Shin Megami Tensei if... (alias forsmt2
)smtn
for Shin Megami Tensei: Ninedesum
for Shin Megami Tensei: Devil Summonersh1
for Devil Summoner: Soul Hackersp2is
for Persona 2: Innocent Sin
Platform
Shin Megami Tensei has different formulas for the Mega-CD version. Set the named parameter platform
to MCD
(case insensitive) to output the Mega-CD stats.
Shin Megami Tensei: Devil Summoner by default shows both the Sega Saturn and PlayStation Portable values for Magic Defense. Set the named parameter platform
to either SAT
or PSP
(case insensitive) to display only one of them.
Persona 2: Innocent Sin is similar to Devil Summoner but it applies for all stats. Set the named parameter platform
to PS
or PSP
to show only one platform's set of stats.
Boss
Shin Megami Tensei (Mega-CD) uses different stat calculations for bosses than it does for regular demons. Set the named parameter boss
to something (recommended: y
) to use the boss calculations.
Manual stat inputting
Devil Summoner: Soul Hackers and Shin Megami Tensei: Nine support manual input of stats through named arguments (see the code to know what to use). This is because some of the calculations for Devil Summoner: Soul Hackers and Shin Megami Tensei: Nine are not yet perfect.
Sources
All sources were verified and, if they were wrong, corrected formulas are used in this module.
- Shin Megami Tensei
- Shin Megami Tensei (Mega-CD)
- Shin Megami Tensei II and if...
- Shin Megami Tensei: Devil Summoner
- Devil Summoner: Soul Hackers
--For calculated stats in SMT1, SMT2, SMTif, SMT Devil Summoner --To do: --Fix Mega-CD SMT1 --Fix Soul Hackers --Add Persona 2: Eternal Punishment (formulas unknown) --Add Shin Megami Tensei: Nine (formulas unknown) local getArgs = require('Module:Arguments').getArgs local p = {} local function round(number) return math.floor(number + 0.5) end local function outputCells6(stat1,stat2,stat3,stat4,stat5,stat6) return string.format("| %s\n| %s\n| %s\n| %s\n| %s\n| %s",stat1,stat2,stat3,stat4,stat5,stat6) end local function outputCells4(stat1,stat2,stat3,stat4) return string.format("| %s\n| %s\n| %s\n| %s",stat1,stat2,stat3,stat4) end local function outputCells7(stat1,stat2,stat3,stat4,stat5,stat6,stat7) return string.format("| %s\n| %s\n| %s\n| %s\n| %s\n| %s\n| %s",stat1,stat2,stat3,stat4,stat5,stat6,stat7) end function p.smt1(frame) local args = getArgs(frame) if args["platform"] then if string.lower(args["platform"]) == "mcd" then return p.smt1mcd(frame) end end local level = args[1] --Level local strength = args[2] --Strength local intelligence = args[3] --Intelligence local magic = args[4] --Magic local vitality = args[5] --Vitality local agility = args[6] --Agility local luck = args[7] --Luck local levelMinus19 = math.max(level - 19,0) local statTable = { atk = levelMinus19 + (strength * 3) + round(vitality / 4), acc = round(strength / 4) + agility, def = round(levelMinus19 / 2) + round(strength / 4) + (vitality * 2), eva = round(intelligence / 8) + agility, matk = round(intelligence / 8) + magic, mefc = intelligence + round(magic / 8) } local stats = { "atk", "acc", "def", "eva", "matk", "mefc" } for i, stat in ipairs(stats) do --Manual override if args[stat] then statTable[stat] = args[stat] end end return outputCells6(statTable["atk"],statTable["acc"],statTable["def"],statTable["eva"],statTable["matk"],statTable["mefc"]) end function p.smt1mcd(frame) local args = getArgs(frame) local level = args[1] --Level local strength = args[2] --Strength local intelligence = args[3] --Intelligence local magic = args[4] --Magic local vitality = args[5] --Vitality local agility = args[6] --Agility local luck = args[7] --Luck local levelMinus19 = math.max(level - 19,0) local levelMinus20 = math.max(level - 20,0) local isBoss = false if args["boss"] then isBoss = true end local statTable = { atk = levelMinus20 + (strength * 3) + math.floor(vitality / 4), acc = math.floor(strength / 8) + agility + math.floor(luck / 10), --Incorrect def = math.floor(levelMinus20 / 2) + math.floor(strength / 4) + (vitality * 3), eva = math.floor(intelligence / 8) + agility, matk = math.floor(intelligence / 8) + magic, mefc = intelligence + math.floor(magic / 8) } if isBoss then statTable["atk"] = levelMinus19 + (strength * 3) + math.floor(vitality / 4) --Incorrect statTable["acc"] = math.floor(strength / 4) + agility statTable["def"] = math.floor(levelMinus20 / 2) + math.floor(strength / 4) + (vitality * 2) end local stats = { "atk", "acc", "def", "eva", "matk", "mefc" } for i, stat in ipairs(stats) do --Manual override if args[stat] then statTable[stat] = args[stat] end end return outputCells6(statTable["atk"],statTable["acc"],statTable["def"],statTable["eva"],statTable["matk"],statTable["mefc"]) end function p.smt2(frame) local args = getArgs(frame) local level = args[1] --Level local strength = args[2] --Strength local intelligence = args[3] --Intelligence local magic = args[4] --Magic local vitality = args[5] --Vitality local agility = args[6] --Agility local luck = args[7] --Luck local statTable = { atk = (level + strength) * 2, acc = math.floor(level * 1.5) + agility + math.floor((strength + luck) / 4), def = (level + vitality) * 2, eva = math.floor(level * 1.5) + agility + math.floor((intelligence + luck) / 4), matk = math.floor(intelligence / 4) + magic, mefc = intelligence + math.floor(magic / 4) } return outputCells6(statTable["atk"],statTable["acc"],statTable["def"],statTable["eva"],statTable["matk"],statTable["mefc"]) end p.smtif = p.smt2 function p.desum(frame) local args = getArgs(frame) local level = args[1] --Level local strength = args[2] --Strength local intelligence = args[3] --Intelligence local magic = args[4] --Magic local endurance = args[5] --Endurance local agility = args[6] --Agility local luck = args[7] --Luck local platform = "" if args["platform"] then platform = string.lower(args["platform"]) --game platform end local statTable = { atk = (level + strength) * 2, acc = math.floor(level * 1.5) + agility + math.floor((strength + luck) / 4), def = (level + endurance) * 2, eva = math.floor(level * 1.5) + agility + math.floor((intelligence + luck) / 4), matk = math.floor(intelligence / 2) + (magic * 2), mdef = intelligence + math.floor(level / 2) + math.floor(magic / 4) + math.floor(endurance / 2), mdefPSP = math.floor(intelligence + (level / 2) + (magic / 4) + (endurance / 2)) } local function bothPlatsValue(stat) if platform == "psp" then return statTable[stat.."PSP"] elseif platform == "sat" or statTable[stat] == statTable[stat.."PSP"] then return statTable[stat] else return frame:expandTemplate{ title = "tt", args = { statTable[stat], "Sega Saturn" } } .. "/" .. frame:expandTemplate{ title = "tt", args = { statTable[stat.."PSP"], "PlayStation Portable" } } end end local outputAtk = statTable["atk"] local outputAcc = statTable["acc"] local outputDef = statTable["def"] local outputEva = statTable["eva"] local outputMatk = statTable["matk"] local outputMdef = bothPlatsValue("mdef") return outputCells6(outputAtk,outputAcc,outputDef,outputEva,outputMatk,outputMdef) end function p.sh1(frame) local args = getArgs(frame) local level = args[1] --Level local strength = args[2] --Strength local intelligence = args[3] --Intelligence local magic = args[4] --Magic local endurance = args[5] --Endurance local agility = args[6] --Agility local luck = args[7] --Luck local statTable = { patk = (level + strength) * 2, --Seems good phit = math.floor(level * 1.5) + math.floor(agility * 1.2) + math.floor(luck * 0.6), --Needs work matk = intelligence * 2 + math.floor(magic * 7.5), --Needs work mhit = intelligence * 2 + math.floor(magic / 2) * 2, --Seems good def = (level + endurance) * 2 + 16, --Seems good eva = math.floor(level * 1.5) + agility + math.floor(luck / 2) --Seems good } local stats = { "patk", "phit", "matk", "mhit", "def", "eva" } for i, stat in ipairs(stats) do --Manual override if args[stat] then statTable[stat] = args[stat] end end return outputCells6(statTable["patk"],statTable["phit"],statTable["matk"],statTable["mhit"],statTable["def"],statTable["eva"]) end function p.p2is(frame) local args = getArgs(frame) local level = args[1] --Level local strength = args[2] --Strength local vitality = args[3] --Vitality local dexterity = args[4] --Dexterity local agility = args[5] --Agility local luck = args[6] --Luck local platform = "" if args["platform"] then platform = string.lower(args["platform"]) --game platform end local statTable = { atk = (level + strength) * 2, def = (level + vitality) * 2, matk = dexterity * 2 + math.floor(level * 0.8), mdef = math.floor(dexterity * 2.5) + math.floor(vitality / 2), atkPSP = math.floor(0.7 * ((level + strength) * 2)), defPSP = math.floor(0.8 * ((level + vitality) * 2)), matkPSP = math.floor(0.7 * (dexterity * 2 + math.floor(level * 0.8))), mdefPSP = math.floor(0.8 * (math.floor(dexterity * 2.5) + math.floor(vitality / 2))) } local function bothPlatsValue(stat) if platform == "psp" then return statTable[stat.."PSP"] elseif platform == "ps" then return statTable[stat] else return frame:expandTemplate{ title = "tt", args = { statTable[stat], "PlayStation" } } .. "/" .. frame:expandTemplate{ title = "tt", args = { statTable[stat.."PSP"], "PlayStation Portable" } } end end local outputAtk = bothPlatsValue("atk") local outputDef = bothPlatsValue("def") local outputMatk = bothPlatsValue("matk") local outputMdef = bothPlatsValue("mdef") return outputCells4(outputAtk,outputDef,outputMatk,outputMdef) end function p.smtn(frame) local args = getArgs(frame) local level = args[1] --Level local strength = args[2] --Strength local intelligence = args[3] --Intelligence local magic = args[4] --Magic local vitality = args[5] --Vitality local agility = args[6] --Agility local luck = args[7] --Luck local statTable = { atk = (level + strength) * 2, --Good acc = math.floor(level * 1.5) + agility + math.floor(luck / 2), --Similar but not quite pdef = (level + vitality) * 2 + 16, --Good peva = round(level * 1.5) + agility + round((intelligence + luck) / 4), matk = level + round(intelligence / 3) + magic * 3, --Good msuc = intelligence + math.floor(magic / 2), --Good mdef = intelligence + level + math.floor(magic / 2) + vitality } local stats = { "atk", "acc", "pdef", "peva", "matk", "msuc", "mdef" } for i, stat in ipairs(stats) do --Manual override if args[stat] then statTable[stat] = args[stat] end end return outputCells7(statTable["atk"],statTable["acc"],statTable["pdef"],statTable["peva"],statTable["matk"],statTable["msuc"],statTable["mdef"]) end return p