User:Skkias/sandbox/Module:BaseStats: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local BaseStats = {} -- Core Attributes BaseStats.attributes = { strength = { name = "Strength", bonus = { life = 2, -- +2 Life per Strength }, description = "Vital for melee weapons and survivability." }, dexterity = { name = "Dexterity", bonus = { accuracy = 5, -- +5 Accuracy per Dexterity evasion = 2, -- Hypothetical bonus }, description = "Essential for ra...") |
No edit summary |
||
Line 1: | Line 1: | ||
local | local p = {} | ||
-- | -- Define core attributes and bonuses | ||
p.attributes = { | |||
strength = { | strength = { | ||
name = "Strength", | name = "Strength", | ||
bonuses = { | |||
life = 2, -- +2 Life per Strength | life = 2, -- +2 Life per Strength | ||
meleeDamage = 1 -- +1% Melee Damage per Strength | |||
}, | }, | ||
description = "Vital for melee weapons and survivability." | description = "Vital for melee weapons and survivability." | ||
Line 12: | Line 13: | ||
dexterity = { | dexterity = { | ||
name = "Dexterity", | name = "Dexterity", | ||
bonuses = { | |||
accuracy = 5, -- +5 Accuracy per Dexterity | accuracy = 5, -- +5 Accuracy per Dexterity | ||
evasion = 2 | evasion = 2 -- +2 Evasion per Dexterity | ||
}, | }, | ||
description = "Essential for ranged weapons and evasion." | description = "Essential for ranged weapons and evasion." | ||
Line 20: | Line 21: | ||
intelligence = { | intelligence = { | ||
name = "Intelligence", | name = "Intelligence", | ||
bonuses = { | |||
mana = 2, -- +2 Mana per Intelligence | mana = 2, -- +2 Mana per Intelligence | ||
energyShield = 1 | energyShield = 1 -- +1 Energy Shield per Intelligence | ||
}, | }, | ||
description = "Crucial for spellcasting and energy shield management." | description = "Crucial for spellcasting and energy shield management." | ||
Line 28: | Line 29: | ||
} | } | ||
-- | -- Define derived stats | ||
p.derivedStats = { | |||
life = { | life = { | ||
name = "Life", | name = "Life", | ||
base = 50, -- Base value | base = 50, -- Base value | ||
description = "Represents health; increased by Strength and gear." | description = "Represents health; increased by Strength and gear." | ||
}, | }, | ||
mana = { | mana = { | ||
name = "Mana", | name = "Mana", | ||
base = 50, -- Base value | base = 50, -- Base value | ||
description = "Resource for skills; increased by Intelligence and gear." | description = "Resource for skills; increased by Intelligence and gear." | ||
}, | }, | ||
energyShield = { | energyShield = { | ||
name = "Energy Shield", | name = "Energy Shield", | ||
base = 0, -- Base value | base = 0, -- Base value | ||
description = "Acts as a buffer to Life; scales with Intelligence." | description = "Acts as a buffer to Life; scales with Intelligence." | ||
} | } | ||
} | } | ||
-- | -- Example function to calculate total Life based on Strength | ||
function p.calculateLife(strength) | |||
local baseLife = p.derivedStats.life.base | |||
local bonus = strength * p.attributes.strength.bonuses.life | |||
return baseLife + bonus | |||
end | |||
-- Example function to display all attributes | |||
function p.showAttributes() | |||
local output = "== Core Attributes ==\n" | |||
for key, attr in pairs(p.attributes) do | |||
output = output .. string.format("=== %s ===\n%s\nBonuses:\n", attr.name, attr.description) | |||
for stat, value in pairs(attr.bonuses) do | |||
output = output .. string.format("* %s: +%d\n", stat, value) | |||
end | |||
end | |||
return output | |||
end | |||
-- Return the module table | -- Return the module table | ||
return | return p |
Latest revision as of 20:35, 10 December 2024
local p = {}
-- Define core attributes and bonuses p.attributes = {
strength = { name = "Strength", bonuses = { life = 2, -- +2 Life per Strength meleeDamage = 1 -- +1% Melee Damage per Strength }, description = "Vital for melee weapons and survivability." }, dexterity = { name = "Dexterity", bonuses = { accuracy = 5, -- +5 Accuracy per Dexterity evasion = 2 -- +2 Evasion per Dexterity }, description = "Essential for ranged weapons and evasion." }, intelligence = { name = "Intelligence", bonuses = { mana = 2, -- +2 Mana per Intelligence energyShield = 1 -- +1 Energy Shield per Intelligence }, description = "Crucial for spellcasting and energy shield management." }
}
-- Define derived stats p.derivedStats = {
life = { name = "Life", base = 50, -- Base value description = "Represents health; increased by Strength and gear." }, mana = { name = "Mana", base = 50, -- Base value description = "Resource for skills; increased by Intelligence and gear." }, energyShield = { name = "Energy Shield", base = 0, -- Base value description = "Acts as a buffer to Life; scales with Intelligence." }
}
-- Example function to calculate total Life based on Strength function p.calculateLife(strength)
local baseLife = p.derivedStats.life.base local bonus = strength * p.attributes.strength.bonuses.life return baseLife + bonus
end
-- Example function to display all attributes function p.showAttributes()
local output = "== Core Attributes ==\n" for key, attr in pairs(p.attributes) do output = output .. string.format("=== %s ===\n%s\nBonuses:\n", attr.name, attr.description) for stat, value in pairs(attr.bonuses) do output = output .. string.format("* %s: +%d\n", stat, value) end end return output
end
-- Return the module table return p