Currently, when making my combat script, I insert players into a module script when they’re doing something (i,e. blocking, parrying, iframes)
and with server hitdetection it usually goes something like this
if IsParrying[HitCharacter] then...
--code code
elseif IsBlocking[HitCharacter] then...
--code code
by taking one look at it you can see it gets very redundant.
Now imagine that, but I make 13 different parry variations. It can easily make a script of code thats supposed to be 50 lines, go up to 200.
And that’s for every single attack in the game.
What I want to know
1- Is there a more efficient way of checking what status the player has?
2- Is using OOP a better method than simply having a module with tables in it?
Yes, I have tried, and no I have NOT succeeded
*If more info is required, feel free to let me know
Additionally, you can organize the code into a local function located higher up in the script that is called within the if statement, that way you don’t have to retype the code every time you need to use it, you can instead call the function, thus following the DRY principle.
If you have your own code for each type of parry, then you should definitely use “elseif”, but if you have many different variations of parry, but the essence is the same, then you can create a table in this structure: