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 Tensei
  • smt2 for Shin Megami Tensei II
  • smtif for Shin Megami Tensei if... (alias for smt2)
  • smtn for Shin Megami Tensei: Nine
  • desum for Shin Megami Tensei: Devil Summoner
  • sh1 for Devil Summoner: Soul Hackers
  • p2is 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.


--For calculated stats in SMT1, SMT2, SMTif, SMT Devil Summoner
--To do:
	--Mega-CD SMT1
	--Make PSP Devil Summoner functional
	--Find out Soul Hackers formulas
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/Endurance
	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)
	}
	if statTable[stat] then
		return statTable[stat]
	else
		error("No such stat as \"" .. stat .. "\"")
	end
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/Endurance
	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)
	}
	if statTable[stat] then
		return statTable[stat]
	else
		error("No such stat as \"" .. stat .. "\"")
	end
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/Endurance
	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)
	}
	if statTable[stat] then
		return statTable[stat]
	else
		error("No such stat as \"" .. stat .. "\"")
	end
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 vitality = args[6] --Vitality/Endurance
	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/2) + (magic*2),
		mdef = intelligence + math.floor(level/2) + math.floor(magic/4) + math.floor(vitality/2)
	}
	local statTablePSP = {
		atk = (level + strength) * 2,
		acc = math.floor((level * 1.5) + agility + (strength + luck)/4),
		def = (level + vitality) * 2,
		eva = math.floor((level * 1.5) + agility + (intelligence + luck)/4),
		matk = math.floor((intelligence/2) + (magic*2)),
		mdef = math.floor(intelligence + (level/2) + (magic/4) + (vitality/2))
	}
	if statTable[stat] then
		return statTable[stat]
	else
		error("No such stat as \"" .. stat .. "\"")
	end
end

return p