Module:CalculatedStats: Difference between revisions
m (Fix) |
m (Users shouldn't be inputting stats manually so it should be fine) |
||
Line 2: | Line 2: | ||
--To do: | --To do: | ||
--Mega-CD SMT1 | --Mega-CD SMT1 | ||
--Make PSP Devil Summoner functional | --Make PSP Devil Summoner functional; probably add additional argument for platform for this and MCD SMT1 | ||
--Find out Soul Hackers formulas | --Find out Soul Hackers formulas | ||
--Add MT1, MT2, KMT support | |||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local p = {} | local p = {} | ||
Line 18: | Line 20: | ||
local intelligence = args[4] --Intelligence | local intelligence = args[4] --Intelligence | ||
local magic = args[5] --Magic | local magic = args[5] --Magic | ||
local vitality = args[6] --Vitality | local vitality = args[6] --Vitality | ||
local agility = args[7] --Agility | local agility = args[7] --Agility | ||
local luck = args[8] --Luck | local luck = args[8] --Luck | ||
Line 33: | Line 35: | ||
mefc = intelligence + round(magic/8) | mefc = intelligence + round(magic/8) | ||
} | } | ||
return statTable[stat] | |||
end | end | ||
Line 47: | Line 45: | ||
local intelligence = args[4] --Intelligence | local intelligence = args[4] --Intelligence | ||
local magic = args[5] --Magic | local magic = args[5] --Magic | ||
local vitality = args[6] --Vitality | local vitality = args[6] --Vitality | ||
local agility = args[7] --Agility | local agility = args[7] --Agility | ||
local luck = args[8] --Luck | local luck = args[8] --Luck | ||
Line 58: | Line 56: | ||
mefc = intelligence + math.floor(magic/4) | mefc = intelligence + math.floor(magic/4) | ||
} | } | ||
return statTable[stat] | |||
end | end | ||
Line 72: | Line 66: | ||
local intelligence = args[4] --Intelligence | local intelligence = args[4] --Intelligence | ||
local magic = args[5] --Magic | local magic = args[5] --Magic | ||
local vitality = args[6] --Vitality | local vitality = args[6] --Vitality | ||
local agility = args[7] --Agility | local agility = args[7] --Agility | ||
local luck = args[8] --Luck | local luck = args[8] --Luck | ||
Line 83: | Line 77: | ||
mefc = intelligence + math.floor(magic/4) | mefc = intelligence + math.floor(magic/4) | ||
} | } | ||
return statTable[stat] | |||
end | end | ||
Line 97: | Line 87: | ||
local intelligence = args[4] --Intelligence | local intelligence = args[4] --Intelligence | ||
local magic = args[5] --Magic | local magic = args[5] --Magic | ||
local | local endurance = args[6] --Endurance | ||
local agility = args[7] --Agility | local agility = args[7] --Agility | ||
local luck = args[8] --Luck | local luck = args[8] --Luck | ||
if args[9] then | |||
local platform = string.lower(args[9]) --game platform | |||
else | |||
local platform = "" | |||
end | |||
local statTable = { | local statTable = { | ||
atk = (level + strength) * 2, | atk = (level + strength) * 2, | ||
Line 106: | Line 101: | ||
eva = math.floor(level * 1.5) + agility + math.floor((intelligence + luck)/4), | eva = math.floor(level * 1.5) + agility + math.floor((intelligence + luck)/4), | ||
matk = math.floor(intelligence/2) + (magic*2), | matk = math.floor(intelligence/2) + (magic*2), | ||
mdef = intelligence + math.floor(level/2) + math.floor(magic/4) + math.floor(vitality/2) | mdef = intelligence + math.floor(level/2) + math.floor(magic/4) + math.floor(vitality/2), | ||
atkpsp = (level + strength) * 2, | |||
accpsp = math.floor((level * 1.5) + agility + (strength + luck)/4), | |||
defpsp = (level + vitality) * 2, | |||
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) + (vitality/2)) | |||
} | } | ||
if | if platform == "sat" then | ||
return statTable[stat] | return statTable[stat] | ||
elseif platform == "psp" then | |||
return statTable[stat..platform] | |||
else | else | ||
if 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[statpsp], "PlayStation Portable" } } | |||
end | |||
end | end | ||
end | end | ||
return p | return p |
Revision as of 00:21, 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 --Make PSP Devil Summoner functional; probably add additional argument for platform for this and MCD SMT1 --Find out Soul Hackers formulas --Add MT1, MT2, KMT support local getArgs = require('Module:Arguments').getArgs local p = {} local function round(number) return math.floor(number + 0.5) end function p.smt1(frame) local args = getArgs(frame) local stat = string.lower(args[1]) local level = args[2] --Level local strength = args[3] --Strength local intelligence = args[4] --Intelligence local magic = args[5] --Magic local vitality = args[6] --Vitality local agility = args[7] --Agility local luck = args[8] --Luck local levelMinus19 = level - 19 if levelMinus19 < 0 then levelMinus19 = 0 end 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 statTable[stat] end function p.smt2(frame) local args = getArgs(frame) local stat = string.lower(args[1]) local level = args[2] --Level local strength = args[3] --Strength local intelligence = args[4] --Intelligence local magic = args[5] --Magic local vitality = args[6] --Vitality local agility = args[7] --Agility local luck = args[8] --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 statTable[stat] end function p.smtif(frame) local args = getArgs(frame) local stat = string.lower(args[1]) local level = args[2] --Level local strength = args[3] --Strength local intelligence = args[4] --Intelligence local magic = args[5] --Magic local vitality = args[6] --Vitality local agility = args[7] --Agility local luck = args[8] --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 statTable[stat] end function p.desum(frame) local args = getArgs(frame) local stat = string.lower(args[1]) local level = args[2] --Level local strength = args[3] --Strength local intelligence = args[4] --Intelligence local magic = args[5] --Magic local endurance = args[6] --Endurance local agility = args[7] --Agility local luck = args[8] --Luck if args[9] then local platform = string.lower(args[9]) --game platform else local platform = "" end 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/2) + (magic*2), mdef = intelligence + math.floor(level/2) + math.floor(magic/4) + math.floor(vitality/2), atkpsp = (level + strength) * 2, accpsp = math.floor((level * 1.5) + agility + (strength + luck)/4), defpsp = (level + vitality) * 2, 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) + (vitality/2)) } if platform == "sat" then return statTable[stat] elseif platform == "psp" then return statTable[stat..platform] else if 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[statpsp], "PlayStation Portable" } } end end end return p