User Tag List

Results 1 to 6 of 6

Thread: Help determining the turn order for a combat

  1. #1
    Clicker Fusion 2.5 (Steam)

    Join Date
    Sep 2019
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help determining the turn order for a combat

    Hi!

    Can anyone help me with my game's turn order?

    I'm trying to make a combat system for my game. In a nutshell it'll be a turn-based combat where you can move and do one action and after that the turn moves to another unit. The characters should have priority based on their combat speed values so that the fastest get to act first and then the next one and so on.

    I have no problem if all the units in the combat have different speeds. The problems begin when there are units with shared values. Now they try to act at the same time. If I could store numbers 1-5 in the characters' alt values, I could get them to act at different times. I mean that the fastest gets a 5, the next one gets a 4 and so on. But I can't figure out a way to do that. At the moment those units who share the same speed, get also the same number (1 to 5).

    My original try had a foreachloop that compared the units' speed to a global value and if the global value was lower than the units speed, it raised the global value higher. Then, when the global value stayed the same, it set the unit's alt value to 5. Then it looked up the second highest speed and finally set the alt value to 4. But it still assigned the same alt value for those units who share the same speed.

    The next version had a normal fastloop looping 50 times. The max speed for each unit is 10 and there are maximum of 5 units at the same time. On these loops there was a square going around on my units and it had an alt value that changed between 1 and 10. If it was on a unit that has the same speed than the squares alt value, it set the square's another alt value from 15 to 10 and assigned that difference the unit's turn order determining alt value. And then from 10 to 6 and assigned 4 to my unit.

    And of course it worked out similarly than my first try. Even if I tried to restrict the actions using "run this event only once", it still worked similarly. Also, I'm quite sure that this is not a good way to do this.

    Can anyone help me? There has to be an easy way to this.😅😓

  2. #2
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,588
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    In essence, you want to be able to assign a bunch of objects a sequence of numbers based on their speed, but without any repetitions, right?

    There may be simpler/more elegant ways, but this ought to work. It's just a few lines of code, but I've split it up to make commenting clearer. The black numbers are the objects' speeds. The green numbers are the priority ranking that successfully avoids duplicates. The red and orange numbers show intermediate steps to get there.




  3. #3
    Clicker Fusion 2.5 (Steam)
    Linky's Avatar
    Join Date
    Mar 2020
    Location
    Egypt
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    In essence, you want to be able to assign a bunch of objects a sequence of numbers based on their speed, but without any repetitions, right?

    There may be simpler/more elegant ways, but this ought to work. It's just a few lines of code, but I've split it up to make commenting clearer. The black numbers are the objects' speeds. The green numbers are the priority ranking that successfully avoids duplicates. The red and orange numbers show intermediate steps to get there.



    Amazing explanation! I would have never explained it that way honestly xD ( or even with that clean method )

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,588
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I didn't know how to do it myself, so decided to figure it out not only to help Jamsteri, but as a learning exercise for myself. And in order to get my highly visual mind to find the solution with the least stress, I needed use these color-coded counters and so on. So when the time came to explain the solution, the 'visual teaching aids' were pretty much already in place

  5. #5
    Clicker Fusion 2.5 (Steam)

    Join Date
    Sep 2019
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, thanks for your answer and help! I also found out a way to do this myself, but your solution is much more elegant than mine In my version I managed to use my characters' positions on the map as a secondary priority determining thing, but I ended up with 65ish lines of code. I think I can combine these two methods to make a more compact version.

  6. #6
    Clicker

    Fusion 2.5Android Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Firefly 3D Module (Steam)
    roxflame's Avatar
    Join Date
    Oct 2008
    Location
    Melbourne, Australia
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have another idea for how it could be done as well. It's untested, but it is probably effective

    At the start of a round, set a flag for if a character has been processed yet, for all units to off.
    Then add all the speed values of all the characters to a highscore object, and it'll put them in numerical order automatically (use a foreach loop to achieve this)
    //When you need to pick the next unit
    + If character processed flag is set off
    + If character speed value = top high score
    + Pick one character at random (this will pick one from the remaining characters scoped from first 2 conditions)
    --
    1 character is now scoped, to ensure they don't get picked again:
    * Set processed flag on
    * Remove top high score
    * Run anything else you need to run.
    If the highscore list is empty, or if all the flags are on, then the round is done

    At the start of each round, set the flags back off, and refill the highscores object
    This method will pick different order for equal rated speed on characters on each round

Similar Threads

  1. Determining the difference in angles
    By JJames19119 in forum Fusion 2.5
    Replies: 4
    Last Post: 18th August 2017, 04:40 PM
  2. Determining active via expression?
    By Dengarde in forum Fusion 2.5
    Replies: 2
    Last Post: 18th October 2015, 03:32 AM
  3. Determining objects not in order
    By Captain825 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 17th March 2010, 08:26 PM
  4. determining distance
    By delusan in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 27th April 2007, 07:31 PM
  5. determining which palette you're using
    By FormerTGFGuy in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 17th August 2006, 01:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •