Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Turn-Based RPG Turn Order when you use Haste

Discussion in 'General Discussion' started by RLord321, Apr 25, 2020.

  1. RLord321

    RLord321

    Joined:
    Feb 25, 2017
    Posts:
    28
    I have a RPG game that generates a list of about 10 turns that you can see. The turn list is based on the characters speed value and based on clock ticks - it adds the speed until each reaches 1000 and whoever reaches 1000 first goes next (actTimer += speed).

    My problem is that since I have a pre-calculated turn list, how do I properly implement a haste (or slow) spell. This will obviously increase the rate of your turn (maybe actTimer += (speed * 1.5f)).

    But I already have the pre-calculated turn list up to 10 so this would only be effected either after the 10 entries in the queue already...which doesn't make sense. I also tried resetting the turn list from scratch but that doesn't work as the player who could be next can be waaay down the line if their speed was low.

    I also thought I could generate the list but keep cycling through as if a player took his turn. But then this wouldn't be accurate as what if I'm on turn 300 but on turn 10, someone used Haste or slow? I would have to know this when I am simulating the turns in the background to calculate accurately.

    So how would you implement a character using a Haste spell when you have a predefined turn-list that you display on the screen?
     
  2. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Why can't it be recalculated when they use the ability?
     
  3. RLord321

    RLord321

    Joined:
    Feb 25, 2017
    Posts:
    28
    I tried that and let's take the scenario where the player with the lowest speed is up next. If I recalculate, that player would again, be at the end of the line...which isn't fair because he/she was next.
     
  4. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    You can solve this with a pretty basic queue system to ignore that specific condition.
     
    EternalAmbiguity likes this.
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,553
    The solution is to get rid of precalculated turn list and rebuild the queue periodically.
     
  6. RLord321

    RLord321

    Joined:
    Feb 25, 2017
    Posts:
    28
    I found a way to recalculate the list and maintaining the right order. I now store a previousACT variable for all the players. This stores the last ACT value before it gets reset to 0 (their turn order). So now when someone does a modifier (Haste, Slow, etc), it will set all of the ACT's the the previousACT value and then restart the calculation.

    A simple solution and it works perfectly.
     
    EternalAmbiguity likes this.