Turn Based Combat (RPG)

0 favourites
  • 8 posts
From the Asset Store
A well commented RPG game template to learn from or use as a base for your own game!
  • Hey you,

    First off, I am not looking for someone to hand me the answer to my question. Unless its easy for you or something.

    Second, I suck with Arrays. I don't like them. I would like to avoid them if at all possible.

    Now my question! How do I implement a turn based battle system that you see in just about every RPG out there. You know, the standard all player characters attack, then that turn ends and the computer attacks.

    I have it all up in my head on how this would work but I just sort of need a kick in the right direction.

    Thank You,

    Stephen

  • I don't think you need to use arrays? What is your plan with them? I would just enable player attack. I'm not sure if you wanted a menu or you're clicking to attack? Then when the player has attacked, disable the player's ability to attack and then have the enemy choose a random move with random damage. It kinda depends on the design of the game but should be fairly straight forward in C2. I think it gets difficult once you start adding character progression and offensive/defensive stats but the basic turn based combat should be fine.

  • Hmm, I'll put together a .capx and see how that turns out.

  • I'd break it down like this:

    1. Begin round functionality happen

    2. For each character in party1 sorted by initiative

    --> They take their action

    3. For each character in party2 sorted by initiative

    --> They take their action

    4. End round functionality happen

    You need some way of distinguishing one set of characters (player characters) from another set (enemies). That way, you can cycle through each of one group to let them act before you cycle through each of the second group.

    I've been using rexrainbow's InstGroup plugin for similar behavior: http://www.scirra.com/forum/plugin-instance-group_topic49662_page1.html

    When I load the combat screen, I added each character to either the Left or Right InstGroup. Then I do a "Pick and keep character from group Left" with a subevent of "For each character".

    Don't forget you have to add some checks in there for combat ending events: all characters of one party are dead or have fled or surrendered or however your mechanics work.

    Hope that helps.

  • I don't want to use any plugins. You never know when the creator will up and quit the project. Reading through that post has helped a lot. Its all coming together in my head now.

  • What I found useful -

    Obviously a variable, or save to database (array, dictionary) of whose turn it is

    activeturn = "0" (computer, player1, etc)

    activeturn = "1" (human, player2, etc)

    At end of turn, swop activeturn.

    I put all my (computer or player 1 code into a group)

    I put all my (human or player 2 code into a group)

    Then perform a check and disable the non active group.

  • (Please forgive my arragonce below, don't take it seriously, it's a joke!)

    You don't hate arrays. You just don't know well enough about them and it scares you, and instead of accepting a long-term fear you change it into hate. A pseude hate.

    You also don't suck at them. All you have to do is to learn how to create for loops that scan through an array to either read or write values to it.

    Then you will notice how elaborate and gracefull arrays can be, and you will notice doors unlocking in your mind, how to create clever inventories, how to make very realistic tilemaps, map editors, data structures, AI routines in a very simple way!

    You can "sort" an array, thus if you put all characters ID and initiative values into it and then sort, you will get what you want.

    I think this is a wonderfull opportunity to open your mind to the ways of the arrays!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You are right. I tried to teach my self arrays and failed miserably. Now I am afraid to back to them lol.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)