Module:CalculatedStats: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 52: | Line 52: | ||
local luck = args[7] --Luck | local luck = args[7] --Luck | ||
local levelMinus20 = math.max(level - 20,0) | local levelMinus20 = math.max(level - 20,0) | ||
local isBoss = false | |||
if args["boss"] then | |||
isBoss = true | |||
end | |||
local statTable = { | local statTable = { | ||
atk = levelMinus20 + (strength * 3) + math.floor(vitality / 4), | atk = levelMinus20 + (strength * 3) + math.floor(vitality / 4), | ||
Line 60: | Line 64: | ||
mefc = intelligence + math.floor(magic / 8) | mefc = intelligence + math.floor(magic / 8) | ||
} | } | ||
if isBoss then | |||
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" } | local stats = { "atk", "acc", "def", "eva", "matk", "mefc" } | ||
for i, stat in ipairs(stats) do | for i, stat in ipairs(stats) do |
Revision as of 21:05, 20 September 2024
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: --Mega-CD SMT1; it seems to have different formulas depending on if it is a boss or normal demon --Verify formulas (esp. Soul Hackers) --Sources: --https://w.atwiki.jp/shinmegamitensei1/pages/449.html#id_abe440aa --https://w.atwiki.jp/shinmegamitensei1/pages/61.html --https://w.atwiki.jp/shinmegamitensei2/pages/703.html#id_abe440aa --https://w.atwiki.jp/devilsummoner/pages/115.html --https://szsk.github.io/data/sh/system/battle/parameter.html local getArgs = require('Module:Arguments').getArgs local p = {} local function round(number) return math.floor(number + 0.5) end local function outputCells(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 function p.smt1(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 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) } return outputCells(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 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["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 if args[stat] then statTable[stat] = args[stat] end end return outputCells(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 outputCells(statTable["atk"],statTable["acc"],statTable["def"],statTable["eva"],statTable["matk"],statTable["mefc"]) end function p.smtif(frame) return p.smt2(frame) end 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[8] then platform = string.lower(args[8]) --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), accPSP = math.floor((level * 1.5) + agility + (strength + luck) / 4), evaPSP = math.floor((level * 1.5) + agility + (intelligence + luck) / 4), matkPSP = math.floor((intelligence / 2) + (magic * 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 = bothPlatsValue("acc") local outputDef = statTable["def"] local outputEva = bothPlatsValue("eva") local outputMatk = bothPlatsValue("matk") local outputMdef = bothPlatsValue("mdef") return outputCells(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, phit = math.floor(level * 1.5) + math.floor(agility * 1.2) + math.floor(luck * 0.6), matk = intelligence * 2 + math.floor(magic * 7.5), mhit = intelligence * 2 + math.floor(magic / 2) * 2, def = (level + endurance) * 2 + 16, eva = math.floor(level * 1.5) + agility + math.floor(luck / 2) } local stats = { "patk", "phit", "matk", "mhit", "def", "eva" } for i, stat in ipairs(stats) do if args[stat] then statTable[stat] = args[stat] end end return outputCells(statTable["patk"],statTable["phit"],statTable["matk"],statTable["mhit"],statTable["def"],statTable["eva"]) end return p