Hello! I wanted to know how people structure combat in their game since im terrible at it. Usually tools are my way to go since i know which module to require based on the tool. I construct a class based on the tool and when the tool is destroyed the controller is also destroyed.
Now this is easy to do with tools since you know what module to require since you need to actualy insert the local script inside the tool. But i want to structure combat where you can bind moves like tools but without them. If anyone ever did it themselves that could help me out much would be appreciated.
I’ve never made a combat framework, but this is just my idea on a way you could do it
Collect input data from client – Check if its a active ability – Send to server
Collect the data sent on the server – Check for cooldowns & if they actually own and/or have the ability equipped – Run ability & apply cooldowns (send visual effects to all clients)
Collect visual data sent from the server on all clients – Create the visual effects based on the data recieved
But there is probably a better way to do it, thats just my thinking
Yes this is exactly my layout. Im trying to be able to work with a ton of abilities like i mentioned earlier. I also want to able to switch abilities per request and disconnect previous connections. The problem is communicating beteeen modules and creating controllers when needed.
No, your reply is telling me how to rig a tool and create a hitbox.
I create a class which handles the tools moveset and everything regarding it. This is easy to do with tools since you know where the module is and which one to require based on the tool.
I want to structure framework with the same OOP structure but without the tools. Basicallt a moveset picker which gets abilities from different modules
It looks like you have a successful tool with with abilities there. Im trying to AVOID tools and structure an ability picker on the client which can go to modules and bind those moves to client inputs (hopefully i explained it well) my problem is being able to refer to those little ability modules and being able to disconnect and connect those input connections.
so you just want abilities in general? you just apply the same logic but remove the model from it, select the abilities on the server fire the client with the ability information it needs set the keybinds on the client using a table then have it fire the server on the client with the mouse position and ability id, check on the server if the owner owns the ability and if the ability is on cooldown and depending on the results execute it in the direction of the mouse position
local Abilities = {}
Abilities.__index = Abilities
function Abilities.newController()
local self = {}
self.connections = {}
setmetatable(self, Abilities)
return self
end)
funcrion Abilities:BindMove()
--right here im trying to figure out how to bind other modules context and make them usable
end
Please im not asking for any cooldowns or hitboxes ive been knowing that, just how to implement these modules. Again my problem is finding these modules and actually binding the move.
local Abilities = {};
setmetatable(Abilities, {
__call = function(T, ...)
return T:Start(...);
end
});
function Abilities:Start(...)
local packed_modules = {...}
local AbilitiesInstance = {};
for index, packed_module in pairs(packed_modules) do
AbilitiesInstance[packed_module.Name] = packed_module.Env;
end
AbilitiesInstance.Moves = {};
AbilitiesInstance.Environment = {};
setmetatable(AbilitiesInstance, {__index = Abilities});
return AbilitiesInstance;
end
function Abilities:BindMove(bind : Enum.Keybind, move : ModuleScript)
self.Moves[bind] = require(move);
end
function Abilities:ExecuteMoveAt(bind : Enum.Keybind)
if not self.Moves[bind] then
return false;
end
setfenv(self.Moves[bind], self); --// allows you to use methods in the superclass AbilitiesInstance, use Moves[bind] to get any move,will error in studio but in runtime it works
self.Moves[bind]();
end
function Abilities:PackModule(requiredModule, id : string)
return {Env = requiredModule, Name = id}
end
If only i could just run the module script, that module has a controller attached with its own methods all im trying to do is create the new controller when i bind the move, but now its expecting that module to use the same keyword .new to create the new controller. Example: controller.new, controller.make, etc
My understanding is, you make the moves in a module script which is a function, then require it and wrap it in an Abilities class, for like cooldowns and what not, store it in a main controller then make a method in the abilities class that calls the function and lets you use it whenever you need to use the ability