BIG PROBLEM! 5V5 RPG Turn Order is Over 13000 Events and now the System cant handle anymore

From the Asset Store
Create complex dialogues with ease with this tool/template!
  • Ok first of all yes i am a noob. No developing exp at all just a normal guy with a big idea. Im working on a turn based rpg. Right now im creating the turn order and how to decide which character goes first based on how fast their speeds are. (Eg. P1 100spd, P2 101spd, P3 99spd. So P2 would go 1st, P1 goes 2nd and P3 goes last.) In my case I have 5v5 so thats a maximum of 10 players on screen at one time. Since I couldnt find a practical way of sorting out the turn orders I had to go with a very tedious way of going about things which has resulted in over 13000 events and ive still not gotten past turn order 5. The reason why there are soo many events is due to the sheer number of different turn orders involved with 10 characters on the screen at once ( thousands upon thousand of different combinations. Its possible for p1 to go 1st, 2nd, 3rd, 4th etc. )

    Basically in conclusion I need an efficient way that I can make a system that can determine turn order for a 5V5. Ive tried many times to look up demos, tutorials and youtube videos but no one can answer my question and Im desperate. Its taken me months just to finally make it to turn 5 out of 10 turns with 1000s of possible turn combinations. Ive hit 13000 events and now whenever I copy and paste an event it overlaps the previous event and i lose progress. heres a pic:

  • First off, my condolences for your 13,000 events and resolve to attempt this feat. If you were familiar with the math, you might have realized that there are 3,628,800 possible combinations of 10 positions. So you're lucky in that you seem to have hit a limitation so early...

    To determine turn order for 10 objects, the simplest way would be to use instance variables. If you had an instance variable for speed, and an instance variable for turn order, you could use the system "For Each (ordered)" to sort them by speed, and then assign each one a number from 0 to 9.

    + System: For each Sprite order by Sprite.speed descending
    -> Sprite: Set turnorder to LoopIndex
    

    What you would do now that they can be identified by their turn order is up to you. For example, you could keep track of the current turn in a separate global variable, and only allow the sprite with turnorder that matches the current turn to act.

  • I thought of this before but couldnt get it to work because i dont understand how loops work. I also dont understand what u meant by set turn order to loopindex. But everything else you mentioned like the speed and turn order variables I do understand.

  • In a loop like for each, every time it repeats, loopindex goes up by 1. So the first time it runs, loopindex is 0. The second time it will be 1, and then 2, ect.

    So if your loop runs 10 times in a for each, because you have 10 instances, loopindex will be 0-9, in order. And because we used an ordered for each, the order can be set by another variable, like speed.

  • Now Im just not sure how the events would work. So would i do a "for each" for every character? For example (object:player1, expression:player1.speed, order:by descending) then the same for players 2-10? Then set their turn order instance variable to loopindex?

  • i dont understand how loops work. I also dont understand what u meant by set turn order to loopindex.

    You absolutely need to study loops, arrays, dictionaries, functions, families and other basic concepts in C3 before starting a big project like this. It may take you a couple of days or event weeks, but will save you months of fruitless efforts in the future!

    In this case you can determine turn order even without loops. I assume you have 10 different sprites for players? You have to add them all into a family and define all instance variables on the family. You'll need "Speed" and "HasMoved" instance variables. On start of each turn pick players that haven't moved yet, and then pick the player with the highest speed among them.

    PlayersFamily HasMoved=0
    PlayersFamily Pick with highest Speed 
    

    That's it! You saved yourself 12999 events!

  • The problem with that is how do I make something that picks the fastest speed for me?

  • I don't understand what you mean. You add an event with the two conditions I posted above, this event will pick the player with the highest speed value, who hasn't moved yet. Then you can start the turn for this player - select its attack, spell etc.

  • Sorry im just a little slow. I kinda understand now. I'll test it out and get back to you thanks for the help.

  • > i dont understand how loops work. I also dont understand what u meant by set turn order to loopindex.

    You absolutely need to study loops, arrays, dictionaries, functions, families and other basic concepts in C3 before starting a big project like this. It may take you a couple of days or event weeks, but will save you months of fruitless efforts in the future!

    In this case you can determine turn order even without loops. I assume you have 10 different sprites for players? You have to add them all into a family and define all instance variables on the family. You'll need "Speed" and "HasMoved" instance variables. On start of each turn pick players that haven't moved yet, and then pick the player with the highest speed among them.

    > PlayersFamily HasMoved=0
    PlayersFamily Pick with highest Speed 
    

    That's it! You saved yourself 12999 events!

    so Im currently trying this method and the condition isnt working as intended past turn 1. so the first time i run it it does work. the fastest player (in this case P1) gets their turn then i assign a variable indicating they got a turn. I run the event again this time with a condition to not include whoever had the first turn but the event still includes P1 because their spd is still the fastest. What am i missing here?

  • You need to change HasMoved variable to 1 for the selected player in each turn. This will prevent it from being selected in the next turn.

    And after all players have moved and a new round begins - reset HasMoved to 0 for all players.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First off, my condolences for your 13,000 events and resolve to attempt this feat. If you were familiar with the math, you might have realized that there are 3,628,800 possible combinations of 10 positions. So you're lucky in that you seem to have hit a limitation so early...

    To determine turn order for 10 objects, the simplest way would be to use instance variables. If you had an instance variable for speed, and an instance variable for turn order, you could use the system "For Each (ordered)" to sort them by speed, and then assign each one a number from 0 to 9.

    > + System: For each Sprite order by Sprite.speed descending
    -> Sprite: Set turnorder to LoopIndex
    

    What you would do now that they can be identified by their turn order is up to you. For example, you could keep track of the current turn in a separate global variable, and only allow the sprite with turnorder that matches the current turn to act.

    Tried this out and i finally got it to work thanks for the help man.

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