Battle Turns based on Speed Stats

Get help using Construct 2

Post » Sat Jun 01, 2013 3:53 pm

Hi everyone, I'm in the process of trying to build a classic turn-based RPG. Since random, turn-based battles are the meat and potatoes of this, I'm working on getting my battle system up and running before I do anything else. I prototyped the basics, and it's easy enough to get a system in place where I just take turns between players and enemies, but I want to determine the order of turns per round based on a unit's speed stat - including re-calculating the turn order every round based on things like whether or not a unit died / fled (and thus the turn is skipped) or if they've been hastened/slowed.

From what I've been able to gather, the best way to accomplish this is through an array. I've been trying to wrap my head around them, and the way I currently envision it functioning is that at the start of the layout and then any given turn, I call a function to set each cell to a unit's speed stat based on the order of highest to lowest, and then draw the order of turns from the array. Once all player unit actions have been selected, it switches into a combat round where all units (player and enemy) take their turns in the order they were assigned.

The problem I'm running into is I can't seem to figure out how to actually sort the cells from high to low. I know that I can draw the max and minimum speeds from a list of all units in the battle, but I'm not sure how to go about retrieving anything in-between. The 'sort' action for the array doesn't seem to work either.

If anyone could help me figure that out, it'd be much appreciated! Bonus points if you happen to have any ideas how I'd distribute those turns to each unit after the fact, though I figure I'll cross that bridge when I come to it.
B
3
Posts: 2
Reputation: 729

Post » Sat Jun 01, 2013 6:24 pm

My first thoughts on how I would go about this is to have each good guy and bad guy have an instance variable called "turnMeter" which would have a value between 0 and 10. Each would also have an instance variable called "meterRate" which would typically be a value between 0.1 and 3. So when a player has a low level, their meterRate would be low like 0.1 so it would take awhile for their turnMeter to get filled up to 10. As they progress in level, their meterRate increases. If they have a "FastSpell" cast on them, I would multiply the meterRate by 1.5 to give them a 50% boost in speed temporarily.

So before each round starts, you'll determine the order of play by which units can fill up their turnMeter the quickest. If they are dead, their meterRate is 0.
B
10
S
3
Posts: 102
Reputation: 1,888

Post » Sat Jun 01, 2013 7:46 pm

I hadn't even thought of switching to a meter-based system, but it's definitely easier to put together and it's working perfectly. Thank you!
B
3
Posts: 2
Reputation: 729

Post » Sat Jun 01, 2013 9:02 pm

I would use instance variables over an Array. And everything @farmerdwight has suggested.
B
54
S
14
G
13
Posts: 818
Reputation: 17,459


Return to How do I....?

Who is online

Users browsing this forum: ColombageEnPLS, FabianB and 11 guests