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.😅😓