So, I’m trying to make a turn based rpg, but im unsure of how i could go about making the battle system, what i have in mind is that during the player’s turn the player characters (there would be two) would attack as many times as they could during a time limit, and on the enemy’s turn they would do the same, attacking during a time limit while the player characters dogde (think the mario and luigi series)
I dont have any code for this idea because im too stumped on how i could make it
‘Make a battle system for an RPG’ is a large and complex problem. Split it up into smaller problems and solve those instead. It helps if you know what your solution should look like in advance.
Example of how to break the large problem up into smaller tasks:
Detect when a battle starts
Load the battle scene (in case your battle takes place in a scene different from the ‘overworld’)
Determine what order each combatant acts in
Make a player select an attack
Figure out how the enemy AI should select its next move
Etcetera
In practice, even these smaller tasks will prove to be too big. The solution is to break the tasks down into even smaller tasks. Take, for instance, ‘make the player select an attack’. If your game is an RPG where you choose attacks from a menu, you might break this down into:
Draw a menu to screen that contains all attacks a character knows
Draw a cursor to screen that points at one attack
Make the cursor move to a new attack if the ‘down’ button is pressed
Etcetera
Do this until the solution is trivial. Drawing a cursor, for example, could be as simple as instantiating a Sprite2D at a certain position on the screen.
The difficult part isn’t implementing all these little solutions, it’s finding out where they collide to create unexpected behavior. For instance, if enemy A is next in the turn order but is KO’d before its turn starts, what should happen next? Depending on how you implemented the code for determining turn order, maybe enemy A still takes a turn despite the fact it shouldn’t be able to. But there’s no point in worrying about this until after you’ve actually implemented a turn order system.
That’s a really good answer.
I am currently working on a Turn-Based Battle System and can add one more thing to this, which could help you:
Look for Guides/Youtube Videos on how other People created Turn Based RPG’s. Try to understand what they are doing and take what you need for your specific system out of these.
But be careful: your scenes might start to look a bit messy if you combine different guides into one, but if you keep your scenes organised it will be easy to clean everything up you dont need.