I’m working on a class fighting game and I’m trying to make the process of making new classes as simple as possible and I think I’ve done an okay job since it only requires you to copy 4 files and 2 of them are optional, but it does still feel a bit clunky at times.
The first file is the backend code for the class which looks like this
local Warrior = {}
Warrior.Ability1 = function(character,check)
local Cooldown = 0
local AttackTime = 0
local Damage = 0
if check then
return Cooldown, AttackTime, Damage
else
end
end
-- Warrior.Ability2, 3, and 4 would be below
return Warrior
The second one is the frontend code which is set up pretty much the same way but uses some inheritance to inherit from a base module.
local BaseClass = require(script.Parent.BaseClass)
local Warrior = setmetatable({},BaseClass)
Warrior.__index = Warrior
function Warrior.new(playerReference)
local self = setmetatable(BaseClass.new(),Warrior)
-- setup stuff such as loading animations
return self
end
function Warrior:Ability1()
local actionName = "Ability1"
local swingStart = 0.8
local swingFinish = self.player.Animation:GetAnimationLength(actionName) - 0.8
local delayBeforeDash = 0.8
local dashDuration = 0.3
local dashDistance = 50
task.spawn(function()
task.wait(delayBeforeDash)
Dash(self.character,dashDuration,dashDistance)
end)
-- DoAction is in BaseClass
Warrior:DoAction(self.player,nil,actionName)
end
return Warrior
And then the optional files are just weapon models and animations which is a child of the frontend code (module script) just to make it easier for the client to get whatever assets are needed for the class.
And that’s it looking to get advice on how I can maybe simplify this workflow or if it seems simple enough already.