Hi DevForum,
Recently I’ve been working on a combat system with some abilities, and wanted to know what topics you guys would use to create such things, such as OOP, metatables, modules, etc.
I want to hear what your opinions on the matter, so I can learn things I possibly don’t know and apply them to make my code more efficient. (This can also help out other people reading this)
My approach to the matter was using OOP to create a .new() function for the character’s information for an M1 system (although I don’t know if this is the best way to go about things). I did this so I could list the cooldowns, damage, swing speed, endlag, etc. described by the weapon you’re using (a modulescript will contain information on your weapon).
In addition to that, I added checks to make sure you can m1, combo increase, and I added events for stuns and things of that nature
Example of what I’m doing:
function CombatModule.new(player : Player, weaponInformation : {}, clientData)
local self = setmetatable({}, CombatModule)
self.Player = player
self.Character = player.Character or player.CharacterAdded:Wait()
self.Weapon = weaponInformation.Name
self.ComboCooldown = 1
self.Windup = weaponInformation.Windup
self.M1Time = weaponInformation.M1Time
self.Endlag = weaponInformation.Endlag
self.LastM1 = 0
self.LastComboEnd = 0
self.M1Cooldown = false
self.Combo = 1
self.MaxCombo = 5
self.Damage = weaponInformation.Damage
self.Animations = {}
for i,v in Animations:GetChildren() do
self.Animations[v.Name] = player.Character:WaitForChild("Humanoid").Animator:LoadAnimation(v)
end
return self
end
As for the ability matter, I’m kind of stuck on what the best approach is, not only to the m1 system but this as well. I’d love to hear what anyone has to say about this topic!