edited September 18 in ORK Support
In BattleAI, I would like to make it possible to randomly move closer to the Target when the Target is outside of the User's move range.

For example, if the User's move range is 3 and the Target is 10 cells away, I would like the User to randomly approach the Target by 1 to 3 cells.
If I use "Move toward target(Nearest)" in the GridMove node, the User always move 3 cells closer to the Target.
So, Any suggestions on how to make this happen?

Thank you!

Post edited by modot on
  • Hm - I see 2 ways to do this:
    - give the combatant a random move range
    - handle this in the grid move schematic, stopping movement randomly after a cell
    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 September 20
    Thanks for the reply.

    >give the combatant a random move range
    I thought that the movement range calculations were done at the start of the turn and couldn't be changed mid-turn...
    I guess changing the movement range value would not be reflected after the determination of whether the target is outside the movement range or not? (maybe I'm misunderstanding something, sorry)

    >handle this in the grid move schematic, stopping movement randomly after a cell
    https://imgur.com/VAVxJgO
    I thought that if I left the loop of CheckGridPathLengh in the middle, as shown in the image, and specified the cell User is currently in in MoveTo of GridCellEvent, it would work, but it did not work as I expected. (It would eventually warp to a location with 0 movement range remaining).
    What should I fix?
    Post edited by modot on
  • Yeah, move range is calculated at turn start, so that'd be more of a general thing.

    You need to use a Clear Grid Path node to remove the remaining path, or the combatant will be set to the last cell at the end of the grid move action.
    Also, use another Set Grid Cell Combatant node to set the combatant as Combatant at the end (this'd usually be handled by finishing the path action, but clearing the path prevents 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!
  • Thanks as always for your spot-on advice, GIL.
    Thanks to you, it now works as desired.

    I would be happy to answer an additional question.
    I know that there is probably no easy way to recalculate the range of movement in the middle of a turn, but is there any way to change (from schematic or script)?
    The reason I ask is that in a combat system that allows multiple actions in one turn, there are quite a few situations where I would like to change the movement range in the middle of a turn.

    If this is not possible, is it possible to increase or decrease the range of movement cells that can be selected when the move command is selected?
  • You can change the grid move range at any time, e.g. in schematics using the Change Grid Move Range node.

    Via scripting you can change it like this, e.g. to add 10:
    combatant.Battle.GridMoveRange += 10;
    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!
  • Oh... why didn't I try this node!
    Thanks GIL!
Sign In or Register to comment.