User:Skkias/sandbox/Module:BaseStats
Jump to navigation
Jump to search
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