How to make automated battles

I was planning to make a tabletop game where the characters/enemies in the game fight with each other with no commands sent from the player. In short, the battle is automated and the damages are random (including critical hits). I’m planning to make it all rely on the stat of the characters/enemies to make the automated battle good.

So, I was thinking if automated battles are possible with GDevelop or does it require coding (probably C++ codes to make it possible).

Yes, automated battles are possible, and you don’t need to code, I think. But surely you’ll need a lot of events :slight_smile:

And welcome! :smiley:

Got a sample on how it might work?
I’m just a noob on this program… and I don’t have an idea on how to make this thing possible.

Well… it’s a difficult task, you should start with some tutorials to get how GD works (concepts, logic style), otherwise you’ll crash against a wall :wink:
The wiki has some mechanisms, concepts and two beginners tutorials (step by step), there are advanced tutorials too:

Anyway, I would make an automated battle system through a “finite state machine”, with status as “wait”, “attack”, “follow”, etc (object variables). Then switch the states with pure logic:

  • If the object state is “wait” and is attacked or see an enemy, switch the state to “attack” or “follow” (depending on distance to target).
  • If the object state is “attack”, after some time attack the target, switch the state to “follow” if the target is far, or switch to “wait” if the target is destroyed/run away.
  • And so on…

I’ll just rephrase it: how to make a die roll (for automated battle)?
More likely with the percentile/chance stuff on the variables section…

GD has the expression “Random(x)”, it returns a random integer between 0 and x (0, 1, 2, … , x-1, x) :slight_smile:
With some work you can do a lot of nice things with it, I’ll put some examples:

  • A (very) simple random decision D = Random(5):

    [*]If D = 0 or D = 1 or D = 2: Attack

  • If D = 3, 4: Defend/Wait

  • If D = 5: Move/Run away


  • Random damage between 32 and 43.5 :
    32 + Random(115)/10
    // 115 = (43.5 - 32) * 10 to get an integer, then divide by 10 to get the decimals again

  • Random percentage of action A = Random(100):

    [*]If A < 15: Critical hit // 15% chance of critical hit

  • If A >= 15 and A < 45: Double attack // 45-15 = 30 % chance of double attack


In the first post I show some logic, and here some random math, now you should need just some imagination :wink:

Hmmm… I still don’t get it in the variables/event section on how to make it work.
Can you provide a screenie of it that shows the die roll/chance/random roll in the event portion?

Can you give me a more specific example? A generic event of a so general question would be painful :smiling_imp: