How to make the "random" turn calculation only happen at the beginning of the battle, and keep the original randomly generated turn order for the rest of the battle? (like a ttrpg initiative role)

How to get the enemies to spawn in random enemy spawn cells? (right now, if i have 10 enemy spawn cells and spawn 5 enemies, all of the enemies will just spawn in the same enemy spawn cells nearest to the player every time a battle starts. I'm trying to give the enemy random start positions, though)
  • Keeping the turn order can be done via a formula for your turn calculation, e.g.:
    - Check Battle Turn node to check if it's the first turn (should be turn 1)
    - reuse the previous turn value using a Turn Value node if it's not the first turn

    Grid battles still use the battle spots to find the nearest available cell (e.g. when using the Spawn Battle Combatants node). E.g. only use the Additional Spot setup for your enemies and add random offsets there.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I'll try these out rn. I'm not exactly sure what you are saying. I'm hoping it'll make mor sense once I check the project back open. thank you for the quick reply tho
  • ok I tried the setup for the turn order. I have the "check battle turn" node going to a "random value" node on a success, and it goes to a "turn value" node on a failure.

    when "check battle turn" is set to 1, the game will only do the randomized order calculation on the first turn as intended, but it doesn't reuse the result on the following turns. it instead reverts back to a default turn order for the rest of the battle.

    I'm guessing the turn calculation resets on every battle turn?? Is there a way to stop it from doing that? Or maybe I just didn't implement your instructions correctly?
  • Hm, I'll look into it - can you give me more details on your turn based setup? E.g. this will definitely not work in Multi Turns mode.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited November 2022
    Multi-turns mode? I'm not sure how that works. I'm just switched the setup from the "2d grid battle" tutorial to turn based using the "ork playground" tutorial. i just wanted a grid-based, turn-based battle with a random but set initiative order that mimics ttrpgs.
    Post edited by Orochimaru on
  • Still, can you post the details on your turn based setup?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited November 2022
    Ok I'm not trying to be difficult or anything, I'm just not sure what you mean. I'm not sure what details you are asking for...

    it's the setup from the "2d grid-based battle" tutorial, but set to turn based instead of phase based.


    turn based mode: active (I don't want classic or multi-turn)

    turn calculation: random (because it redoes the random calculation before each new round, the last combatant in a round can get back-to-back turns before any other combatant can get their next turn. I definitely don't want that.)


    this is all I can think to tell you about the turn-based setup.
    Post edited by Orochimaru on
  • Orochimaru said: turn based mode: active (I don't want classic or multi-turn)
    That's what I mainly needed - depending on how your battle system is set up the turn order calculation is handled differently.
    I'll look into it.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Looked into it and my original suggestion doesn't work, but there's another way with a similar setup.

    In your formula, after Check Battle Turn and using a random value, store the current formula result into a float variable in the user's object variables.
    I.e. use a Change Variables node:
    - variable key e.g.: initialTurnValue
    - variable origin: Object
    - game object (variable origin): User
    - type: Float
    - operator: Set
    - float value: Value > Current Value (Formula)
    This stores the random value that was previously set to the formula value into a variable on the combatant.

    In the not-first-turn outcome of the formula, instead of using a Turn Value node, use a Value node that uses the Float Variable you stored (Object variable origin using the User, variable key initialTurnValue, etc.).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I appreciate the effort and care you put into helping. I'll try this out when I get off work and I'm gonna throw a 5 star review on the asset store page.
  • Thanks, I'd appreciate that :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited November 2022
    The new formula setup seems to work like a charm!

    I'm gonna keep testing it, but I guess it will just keep working right.
    Post edited by Orochimaru on
Sign In or Register to comment.