Introduction
I want to make status effects for my fighting/destruction game, but I’m having issues figuring out how I should make a status effect system. My initial idea months ago was to use OOP, although I wasn’t very experienced, and ended up creating a system with countless unsolvable answers at the time.
1. The way it would work is (from what I understand), that the module consisted of a status effects table (statusEffects
) that contained all of the functions that manage status effects such as the Ragdoll one, which causes players to ragdoll, and a “players” table (players
), which had a dictionary containing every status effect and their attributes.
2. The “players” table .__index
was equal to itself, and whenever a player was added they were indexed into the table as setmetatable({}, players)
. I assume that this was so that each player would have individual tables, and so the server could manipulate the values by utilizing the status effects table’s functions such as Ragdoll
.
An example of this is when the Ragdoll function changed the active
boolean to true
if it wasn’t active already.
I never added a feature that allowed the status effects to be stacked.
1
local statusEffects = {}
local players = {}
-- Status Effect Variables:
-- active : a boolean that determines whether a status effect is active or not.
-- duration : a numberValue that represents the current amount of time that a status effect has of being active. (all are 0 on default and will be changed when status effects are used.)
-- multiplier : a numberValue that represents the multiplier that a status effect has on a player. (all are 0 on default and will be changed when status effects are used.)
-- maxTime : the maximum time that a status effect can be activated for.
-- stackable : determines whether a status effect can stack or not.
players.statusEffects = {
["Ragdoll"] = { -- Ragdolls players for x amount of time.
active = false,
duration = 0,
maxTime = 7,
stackable = true
},
["Slowed"] = {
active = false,
duration = 0,
multiplier = 0,
maxTime = 10,
stackable = true
},
}
2
statusEffects.Ragdoll = function(player, timeSet)
local playerInTable = table.find(players, player.Name)
print(playerInTable)
if not playerInTable.Ragdoll.active then playerInTable.Ragdoll.active = true
for index, joint in pairs(player.Character:GetDescendants()) do
So, I’m pretty stuck and unsure about how to approach this, especially because I haven’t done anything related to OOP in months… So what should I do?