Multiple enemy turns for RPG

Hi, I’m currently working on a rpg and started work on the battle system. The issue I’m having is how to best go about creating the enemy turn coded as I want to be able to have a max of 4 enemies for the player to fight per fight as the enemy spawns would be random. Most of the tutorials only showcase a 1v1 turn base fight. I plan to have different enemies as well depending on the area (scene) that the player is currently in. Any direction or help would be appreciated!

Hey Feycrowns, welcome to the community! This is pretty interesting and I would like to take a crack at it. Could you show me what your code/events are so far?

For me when I think about how I would go about this, I believe I would set up a number scene variable for turn.

For me I would pick the turn order based off units speed, with the fastest going first.

Another way you could do it is just let your player character go first and then allow the enemies to go after. Set the number of turns to the number of active characters in the battle and after the last turn repeat the order based on number of surviving characters. Which tutorials have you tried or watched and maybe I can find some others for you that present different ways? I have a found a few good resources on Youtube

Hi sorry for the very late reply to your answer. Life got extremely busy and I wasn’t able to work much on the game itself. The tutorials I had followed where mainly the gdevelop top down rpg template/youtube video and the turn based rpg mini course by gdevelop vlogs.

Currently, my system for the turn base follows the topdown rpg template format of using Scene variable to change a “State” to match who’s turn it is. It’s still on so there’s not much to go off. I do what the battle format to go player characters first then enemies go maybe going with a turn number might be easier?

I would go with something as stupid as
Give every enemy object NUMBER variable BattleTurn which would be 0 by default
When battle starts and nothing happened yet i would set BattleTurn variable of Enemies to 0
Now in battle mode when there is enemies group turn i would
We need to give some order of who attack 1st
And so i would simply go from top to bottom
So assuming you have enemies in group called Enemies

Condition
Y position of Enemies is higher than Y position of Enemies
Number variable BattleTurn of Enemies is 0
Trigger Once

Action
Change number variable BattleTurn of Enemies set to 1

And in another event simply check if BattleTurn variable is 1
Then in action perform attack and turn BattleTurn to 2
And when there is player turn simply change BattleTurn to 0

I never use strings so i go with numbers
But you could make string variables and simply go with strings like
PreAttack EnemyAttack EnemyOnStandby
Or something like that

1 Like

It there a reason why the Y position is needed? Cause currently I have the enemies being spawned at set positions. I did try your method but the variable didn’t change for the enemy group. They remained to be set at BattleTurn 0.

Here is the code I have so far. Mainly using log messages to see if the player and enemy has taken an attack

Y because i assumed you will have same setup as i seen in all RPGs i seen in my childhood
Which more or less looks like this where enemies are in formation from top to bottom

As for your battle turn
Trigger once should be at the bottom of event not top

Ahhh I see! yeah I have them align in a similar manner. I will try it again with the changes you mentioned

1 Like

@ZeroX4 after a bit of hitting my head against it cause i was messing up some aspects I got it working as I wanted! Thank you again for your help

1 Like