Turn Based Combat (RPG)

Get help using Construct 2

Post » Fri Oct 04, 2013 10:42 am

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
B
56
S
15
G
13
Posts: 825
Reputation: 17,643

Post » Fri Oct 04, 2013 11:32 am

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.
B
45
S
15
G
73
Posts: 2,021
Reputation: 43,424

Post » Sat Oct 05, 2013 5:50 am

Hmm, I'll put together a .capx and see how that turns out.
B
56
S
15
G
13
Posts: 825
Reputation: 17,643

Post » Sat Oct 05, 2013 7:07 am

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.Hutto2013-10-05 18:36:29
B
10
S
4
G
1
Posts: 58
Reputation: 1,420

Post » Sat Oct 05, 2013 10:13 am

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.
B
56
S
15
G
13
Posts: 825
Reputation: 17,643

Post » Sat Oct 05, 2013 10:37 am

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.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Sat Oct 05, 2013 4:05 pm

(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!
B
17
S
4
G
1
Posts: 332
Reputation: 3,099

Post » Sun Oct 06, 2013 9:11 am

You are right. I tried to teach my self arrays and failed miserably. Now I am afraid to back to them lol.
B
56
S
15
G
13
Posts: 825
Reputation: 17,643


Return to How do I....?

Who is online

Users browsing this forum: alextro, georeb, ivanski1983, Ryan Kocourek and 7 guests