Moving pieces a set distance toward another piece.

I’m looking to speed up the play of a rugby module that I’ve been working on.

I want all of the ‘player’ pieces to move up the board towards the ‘Ball’ piece but only to the limit of the ‘player’ piece’s particular movement range. Also not going beyond the ‘Ball’ piece.

I think I need to do something like using the ‘move fix distance’ trait but only have it trigger if ‘player’ piece location is < ‘Ball’ piece location but I’m not sure how to achieve this.

Any help is very much appreciated.

I don’t see any reply to this. If someone has a technique to offer, I am interested as well.

The following makes the assumptions:

  • that “up the board” literally means up the screen. If it means to the right, change Y to X. If it means down or left, the formula in step 3 will need some major changes which I don’t feel like figuring out right now.
  • that all players only need to move “up” towards the ball, never down.
  • that you aren’t using a Grid for movement, and therefore all distances are in pixels.
  • that each player has a Marker or Dynamic Property (DP) called MovementRange that indicates that player’s maximum movement in the Y direction.
  1. Add a Global Property (GP) called BallPosition. Make sure it’s defined as Numeric with a sane default value (0 should be safe).
  2. Add a Set Global Property (SGP) to the Ball piece. This should change BallPosition to equal {CurrentY} (or $CurrentY$ if you prefer the old syntax).
  3. To each player, add a Calculated Property (CP), MoveDistance, with the expression Max(CurrentY + MovementRange, BallPosition) - CurrentY
  4. To each player, add a Move Fixed Distance command, with the X distance set to 0 and the Y distance to either {MoveDistance} or $MoveDistance$.
  5. Add a Global Key Command (GKC) to the ball piece. Have it trigger on TriggerMove and send the command you provided for the above Move FIxed Distance command. You should be able to leave the Fast Match and Property Match Expression fields blank–if this command is slow to execute, those can be used to narrow their targets down to just the player pieces.
  6. Add a Trigger Action to the Ball piece. It needs to look for the command MovePlayers, and send the command to trigger the SGP you added in step 2, followed by TriggerMove.
  7. Add a Global Key Command somewhere (it could be a toolbar button, if you like) to send the MovePlayers command (again, you can use the optional fields to narrow its target down to only the Ball piece if the command is slow to execute).

No promises I didn’t screw up any syntax there, as I’m going from memory and haven’t actually plugged any of this in to VASSAL for testing.

Edit: On 2nd thought, you could actually skip step 3 completely, and instead set the Y distance for Move Fixed Distance to {Max(CurrentY + MovementRange, BallPosition) - CurrentY}.

1 Like

Ouch, thank you. I was afraid it would look something like this.

You can also do it without calculated properties. Just move the player pieces by their movement range, then check if CurrentY is less than the Ball’s Y coordinate (which should be stored as a Global Property whenever the Ball moves). If it is, trigger a move to that Y coordinate.

1 Like