Battle Turns based on Speed Stats

0 favourites
  • 4 posts
From the Asset Store
Strengthen your battle experiences with these 4 frantic, epic and intense battle music tracks!
  • 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. <img src="smileys/smiley17.gif" border="0" align="middle" />

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

  • I would use instance variables over an Array. And everything has suggested.

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