rex_slg_movement
Introduction
This plugin could get move-able area, or get moving path between two chess/tiles on an orthogonal or isometric, or hexagonal board object.
This plugin could get move-able area, or get moving path between two chess/tiles on an orthogonal or isometric, or hexagonal board object.
There are 2 core actions in this plugin,
- "Action:Get moveable area", "Action:Get moveable area by UID" which could get move-able area.
- "Action:Get moving path", "Action:Get moving path by UID" which could get the shortest moving path between source chess to destination chess/tile.
Get moveable area
There are 5 parameters in this action.
There are 5 parameters in this action.
Chess
"Chess" is the target of moved chess instance.
"Chess" is the target of moved chess instance.
Moving points and Moving cost
Concept
Target chess has an energy point named "moving points", and each tile has a cost called "moving cost" to reduce the energy point of chess when this chess moves on the tile.
The tile is "move-able" if this chess could "stand on" with remainder moving points is equal or more then 0.
Concept
Target chess has an energy point named "moving points", and each tile has a cost called "moving cost" to reduce the energy point of chess when this chess moves on the tile.
The tile is "move-able" if this chess could "stand on" with remainder moving points is equal or more then 0.
Moving cost
This parameter could be a number type, or a string type. Each tile has an equal moving cost with this number value.
Put "Expression:INFINITY" in this parameter to be an infinity cost. User might set the path mode to "A*" to get better performance in this case.
This parameter could be a number type, or a string type. Each tile has an equal moving cost with this number value.
Put "Expression:INFINITY" in this parameter to be an infinity cost. User might set the path mode to "A*" to get better performance in this case.
Cost function
Moving cost of each tile could be got by a cost function named "Condition:On cost", if this parameter is a string.
There are some expressions could be used under this condition,
Moving cost of each tile could be got by a cost function named "Condition:On cost", if this parameter is a string.
There are some expressions could be used under this condition,
- Expression:ChessUID, to get target chess instance
- Expression:TileUID, Expression:TileX, Expression:TileY, to get the target tile
- Expression:PreTileUID, Expression:PreTileX, Expression:PreTileY, to get previous tile
- Expression:PreTilePathCost, to get path cost (accumulation cost from start tile) of previous tile
- Expression:StartTileUID, to test if previous tile is start tile by comparing PreTileUID to StartTileUID
Move chess "Expression:ChessUID"
from tile "Expression:PreTileUID" at ("Expression:PreTileX", "Expression:PreTileY") which has accumulation cost to Expression:PreTilePathCost
to tile "Expression:TileUID" at ("Expression:TileX", "Expression:TileY")
Then call "Action:Set cost" to set the moving cost of this tile.
"Expression:BLOCKING" could be used in the parameter of this action for a no move-able. Tile is also no move-able if no "Action:Set cost" had been called (i.e. no moving cost had been return) under "Condition:On cost".
"Expression:BLOCKING" could be used in the parameter of this action for a no move-able. Tile is also no move-able if no "Action:Set cost" had been called (i.e. no moving cost had been return) under "Condition:On cost".
Cache cost
If set "Cache cost" to "Yes" in property table, the "Condition:On cost"Set " will only be triggered once for each tile in a request.
Set "Cache cost" to "No" if user need to reference previous tile in cost function.
If Expression:PreTileUID, or ( Expression:PreTileX, Expression:PreTileY ) had been used under "Condition:On cost", remember set "Cache cost" to "Yes" usually.
If set "Cache cost" to "Yes" in property table, the "Condition:On cost"Set " will only be triggered once for each tile in a request.
Set "Cache cost" to "No" if user need to reference previous tile in cost function.
If Expression:PreTileUID, or ( Expression:PreTileX, Expression:PreTileY ) had been used under "Condition:On cost", remember set "Cache cost" to "Yes" usually.
Shuffle neighbors
Sample capx
If "Shuffle neighbors" in properties table sets to "Yes", the order of visited neighbors will be random, i.e. the order of visited nodes is not the same for each request.
Sample capx
If "Shuffle neighbors" in properties table sets to "Yes", the order of visited neighbors will be random, i.e. the order of visited nodes is not the same for each request.
Group
The picking result will be put in a group of instance group. It is sorted by checking order.
Figure below is the picked tiles of move-able area by configuration to
The picking result will be put in a group of instance group. It is sorted by checking order.
Figure below is the picked tiles of move-able area by configuration to
- Moving points = 3
- Cost = 1
- "Shuffle neighbors" = "No"
Filter
The picking result of moving area are tiles by default. Or use a filter function "Condition:On filter" if this parameter is not equal to "", to reset or add picked instances.
Use "Action:Append filter result" to add an instance by uid into picking result group, the tiles which had not been added into group will be excluded in this "Action:Get moveable area".
This is an advance optional feature. See the capx at the last section.
The picking result of moving area are tiles by default. Or use a filter function "Condition:On filter" if this parameter is not equal to "", to reset or add picked instances.
Use "Action:Append filter result" to add an instance by uid into picking result group, the tiles which had not been added into group will be excluded in this "Action:Get moveable area".
This is an advance optional feature. See the capx at the last section.
Get moving path
There are 5 parameters in this action.
There are 5 parameters in this action.
Chess, and tile/chess
The 1st and 2nd parameters are the moving source chess and moving destination indicated by tile or chess.
The 1st and 2nd parameters are the moving source chess and moving destination indicated by tile or chess.
Moving points and Moving cost
These two parameters are the same as "Action:Get moveable area", please see previous section.
The shortest path is the path which could let the chess has the maximum remainder moving point when it moves to destination.
These two parameters are the same as "Action:Get moveable area", please see previous section.
The shortest path is the path which could let the chess has the maximum remainder moving point when it moves to destination.
Group
The picking result will be put in a group of instance group like "Action:Get moveable area". User could pop this group to get moving destinations in-order and move chess to the next destination by rex_grid_move behavior.
The picking result will be put in a group of instance group like "Action:Get moveable area". User could pop this group to get moving destinations in-order and move chess to the next destination by rex_grid_move behavior.
User could set the "Force move" to "Yes" in properties table in rex_grid_move behavior, since the move-able (solid) had been determined by this "Get moving path" action.
To bind the group of moving path to private group of the moving chess, user could use "Expression: PrivateGroup" in rex_ginstgroup object to get private group name.
To bind the group of moving path to private group of the moving chess, user could use "Expression: PrivateGroup" in rex_ginstgroup object to get private group name.
Exact or nearest
Set "Exact" combo option to "nearest" could get moving path from start tile to nearest target tile.
The result of instance group would be empty if "Exact" to "" and no path found from start tile to exact target tile.
Get nearest target tile UID by "Expression:NearestTileUID" after request for both Exact or Nearest modes.
Set "Exact" combo option to "nearest" could get moving path from start tile to nearest target tile.
The result of instance group would be empty if "Exact" to "" and no path found from start tile to exact target tile.
Get nearest target tile UID by "Expression:NearestTileUID" after request for both Exact or Nearest modes.
Path mode
Set property "Path mode" to get a shorter path or shortest path.
Set property "Path mode" to get a shorter path or shortest path.
Get shortest path
Set property "Path mode" to
Set property "Path mode" to
- "Random": picking the shortest path randomly
- "Diagonal": picking the shortest path which has the maximum changing of moving direction
- "Straight": picking the shortest path which has the minimum changing of moving direction
- "Line": picking the shortest path which has the minimum changing of moving angle
Get shorter path
Set property "Path mode" to
Set property "Path mode" to
- "A*", "A* -line", "A* -random": using A-star algorithm to find path, this will have the best performance. It is recommended that using these mode only when moving point is set to "Expression:INFINITY".
Start and end points
Get tileUID or LX, LY of start and end point by these expressions
Get tileUID or LX, LY of start and end point by these expressions
- Start point: Expression:StartTileUID, Expression:StartX, Expression:StartY
- End point: Expression:EndTileUID, Expression:EndX, Expression:EndY
Wrap
Sample capx
Set "Wrap" in properties table to "Yes" in rex_board object will wrap the logical boundary. It will also effect the result of picking move-able area and moving path. Chess could move from left boundary to right boundary directly.
Sample capx
Set "Wrap" in properties table to "Yes" in rex_board object will wrap the logical boundary. It will also effect the result of picking move-able area and moving path. Chess could move from left boundary to right boundary directly.
This image is the result of picking move-able area in wrapped board.
Accumulated cost
Sample capx
"Expression:UID2PathCost" could be used to get accumulated cost from start tile to a specific chess/tile in moveable area or moving path after call "Action:Get moveable area" or "Action:Get moving path". Return (-1) if this specific chess/tile is not in the last scan of request.
Sample capx
"Expression:UID2PathCost" could be used to get accumulated cost from start tile to a specific chess/tile in moveable area or moving path after call "Action:Get moveable area" or "Action:Get moving path". Return (-1) if this specific chess/tile is not in the last scan of request.
Advance
Sample capx
This sample capx shows how to implement the filter function and cost function to get move-able area, moving path, and the enemies in a range.
Sample capx
This sample capx shows how to implement the filter function and cost function to get move-able area, moving path, and the enemies in a range.
No overlap with other chess
To exclude the tiles which had chess stand on for move-able area, it need to change the picking result of move-able area. Add the tile with no chess stand on, i.e. the cell of chess is empty, the other tiles which had not been added will be excluded.
To exclude the tiles which had chess stand on for move-able area, it need to change the picking result of move-able area. Add the tile with no chess stand on, i.e. the cell of chess is empty, the other tiles which had not been added will be excluded.
Pick enemies
The "Action:Get moveable area" also could pick enemies in a range condition. It need to change the picking result from tiles to the enemies which stand on these tiles.
The "Action:Get moveable area" also could pick enemies in a range condition. It need to change the picking result from tiles to the enemies which stand on these tiles.
No moving across enemies
To set the enemies to be no across, just set the cost of these tiles which had enemies to be "BLOCKING" in "Action:Set cost" under "Condition:On cost".
To set the enemies to be no across, just set the cost of these tiles which had enemies to be "BLOCKING" in "Action:Set cost" under "Condition:On cost".
Flood fill
Sample capx
"Action:Get moveable area" is using flood fill to find moveable area through "Condition:On cost". This feature also could be use for other propose, like picking neighbor chess/tile which have the same color in sample capx.
Sample capx
"Action:Get moveable area" is using flood fill to find moveable area through "Condition:On cost". This feature also could be use for other propose, like picking neighbor chess/tile which have the same color in sample capx.
The steps of picking are -
- Save target color in variable.
- Call "Action:Get moveable area", sets the parameter of moving point to 1.
- In "Condition:On cost", pick tile/chess instance by expression: TileUID, or ( expression: TileX, expression: TileY ), see Cost function section for more detail.
- Compare the color of picked instance with target color -- If the color of picked instance is matched to target color, return cost to 0 by "Action:Set cost". Otherwise do nothing, the cost will be BLOCKING by default.
- Finally, the matched tiles will be put into instance group by UID, then add the source tile into this group.
Move on tilemap
Sample capx
Covers all tiles (LZ=0) by string symbol, and sets the rex_board_squareTx to align the tilemap object. Then uses string symbol tile in input parameter of "Get moving path" action.
Since the results in instance group are not UID of instance, user could not pick tile instances by SOL actions in instance group plugin, uses
Sample capx
Covers all tiles (LZ=0) by string symbol, and sets the rex_board_squareTx to align the tilemap object. Then uses string symbol tile in input parameter of "Get moving path" action.
Since the results in instance group are not UID of instance, user could not pick tile instances by SOL actions in instance group plugin, uses
- "Condition:For each UID" and "Expression:Item" to retrieve the string symbol (Get moveable area), or
- "Expression:Pop( group_name , 0)" to get string symbol in order (Get moving path)
More samples
Diffusion
Sternhalma - Note that "Cache cost" is set to "No"
Diffusion
Sternhalma - Note that "Cache cost" is set to "No"