The 2nd beta version of the grand new grid battles feature for ORK Framework is here.
See the earlier article about grid battles for general informations about grid battles and more details on the different grid types and how a battle grid can be set up in the scene.
Released in ORK Framework 2.8.0
Grid battles have been officially released in ORK 2.8.0 – see the release notes for details.
The Grid Prefabs contain some prefabs that can be used for the grid cell types – please enable Use Prefab Rotation when using these prefabs, since the prefabs already have the correct rotation set up – as well as a basic battle event for the move command.
The implementation of this feature is possible thanks to this group buy proposal – please use this thread to give feedback to the grid battle feature!
Battle Ranges
The previous Use Range and Affect Range settings of items and abilities, as well as the default use range settings (Battle System > Battle Settings) have been replaced by the new Battle Range settings, which also allow defining grid shapes that will be used in grid battles. Reusable templates can be defined in Battle System > Battle Range Templates, use them by selecting the Template range type in the ability/item use range or affect range settings.
Alternatively, you can also defin custom battle ranges in the individual ability/item range settings – and turn them into templates through the click of a button. The previous use/affect range settings will automatically be updated to custom battle ranges.
Grid Shapes
Battle ranges can optionally define a grid shape to be used in grid battles. This is determined by the Shape Type setting.
None
No special grid treatment, the range uses the min/max range settings like in non-grid battles.
All
Uses the whole grid.
Range
Uses all cells within a defined range around the origin cell (i.e. the user). The range defines the distance on the grid, not in world space. E.g.:
- A range of 1 uses all cells around the origin cell that can be reached with 1 step
- A range of 2 uses the cells that can be reached with 2 steps
A range of 1 looks like this in square and hexagonal grids (visualized by using a Mask):
A range of 2 looks like this in square and hexagonal grids (visualized by using a Mask):
Mask
Uses only defind cells around the origin cell (i.e. the user). The cells are selected in a grid mask in the battle range settings.
To create a mask, define the Range and click on the Create Mask button – an empty mask will be created (based on the used grid type set up in Battle System > Battle Grid Settings). You can enable/disable cells by clicking on them.
Battle Grid Settings
The general settings for battle grids can be found at Battle System > Battle Grid Settings in the ORK Framework editor.
Grid Settings
Define the used grid type, cell offset and raycast settings (e.g. used by mouse/touch controls).
Cell Selection
The cell selection is e.g. used when the player selects a cell to move to for the grid move command. Cells can be selected by moving a cursor through horizontal and vertical input keys, or by using mouse/touch input.
Orientation Selection
The orientation selection is used when the player selects the orientation of a combatant (e.g. turn end orientation or grid rotation command). By default, the orientation selection will use the same input methods as the cell selection, but this can be overridden to use a different setup.
The orientation selection can optionally display an information dialogue while selecting (Info Text settings), as well as display confirmation dialogue when a cell was selected (Accept Question Dialogue settings).
Combatant Placement
These settings handle how the player’s combatant placement at the start of a battle will be handled. You can trigger the combatant placement by using the Player Grid Placement step in a battle start event.
The combatant placement can optionally display an information dialogue while selecting a placement cell (Info Text settings), as well as display confirmation dialogue when a cell was selected (Accept Question Dialogue settings).
Move Command
The move command handles a combatant’s movement on the battle grid. Beside some pathfinding settings (e.g. if combatants can move over cells blocked by their allies), you can define the default move range and battle events used to animate the move command.
The move target cell selection can optionally display an information dialogue while selecting a cell (Info Text settings), as well as display confirmation dialogue when a cell was selected (Accept Question Dialogue settings).
Grid Highlighting
The grid highlighting defines how grid cells will be highlighted during different situations, e.g. when selecting a target cell for a move command.
A cell can be highlighted by spawning a prefab on the cell, and by blinking the cell (and spawned prefab).
Combatant Placement
These highlights are used during the combatant placement of the player.
- Placement
Highlights the cells available for placement. - Placement Selection
Highlights the currently selected cell if it’s available for placement. - No Placement Selection
Highlights the currently selected cell if it’s not available for placement (e.g. no placement cell or already blocked by another combatant).
Move Command
These highlights are used when selecting a target cell for a move command.
- Move Range
Highlights the cells available for movement. - Move Selection
Highlights the currently selected cell if it’s available for movement. - No Move Selection
Highlights the currently selected cell if it’s not available for placement (e.g. out of range or blocked cell). - Move Path
Highlights the path to the currently selected cell (if it’s available for movement).
Orientation Selection
Highlights the currently selected cell when selecting the orientation.
Use Range
Highlights the use range of items and abilities. The use range can be highlighted in the action selection (e.g. when selecting an ability in the battle menu) and target selection (i.e. after accepting the ability and while selecting the target).
Affect Range
Highlights the affect range of items and abilities. The affect range can be highlighted in the action selection (e.g. when selecting an ability in the battle menu) and target selection (i.e. after accepting the ability and while selecting the target).
Grid Battles
Beside setting up a battle grid in the scene (using a Battle Grid Component), there are some things to consider when using grid battles.
Battle Component
The Battle Grid Component only manages the battle grid, but doesn’t handle starting a battle. This is still done using a Battle component.
If a battle uses a grid (and which) is handled by the Grid Use Type setting in the Battle component:
- None
Doesn’t use a grid, i.e. regular battle. - Nearest Grid
Uses the nearest Battle Grid Component. - Define Grid
Allows you to select a game object with a Battle Grid Component.
Battle AI
There are several new battle AI steps available to handle AI controlled combatants (e.g. enemies) in grid battles.
Grid Move To Target
This step will use the Grid Move command to move to a previously found target (i.e. determined by the battle AI).
The battle AI ends if the user can perform a grid move command. If no grid move command can be executed (e.g. due to no move range left or reachable cells are currently blocked by other combatants) the Reachable slot will be executed next – a target is reachable if one of it’s neighbouring cells is a valid move target (i.e. not blocked or occupied by another combatant). Otherwise the Next slot will be executed.
Check Grid Distance
This step will check the grid distance (i.e. the cell distance) between the user and targets. Neighbouring cells have a grid distance of 1.
Grid Rotate To Target
This stepp will change the user’s grid orientation to look at a previously found target (i.e. determined by the battle AI). The battle AI will continue after this step.
Since use ranges in grid battles can depend on which way the combatant is looking (i.e. grid shapes), this can be useful to turn AI combatants toward their targets before trying to use actions.
Event System
There are several new event steps available for grid battles, they’re available in Battle > Grid steps.
Depending on which event type you’re using, there are different steps available.
Battle Start Events
Use a Player Grid Placement step to let the player use the Combatant Placement so place the player group combatants on selected grid cells.
Otherwise, all steps spawning and placing the combatants at battle spots will automatically place them at the nearest free cell on the grid. Battle spots will in any case be placed at the nearest free deployment cell at the start of a battle.
Battle Event: Grid Move Command
If you want to animate how a combatant follows the path to the target grid cell, you’ll need to do this in the battle event used to animate the grid move command. The downloadable grid prefabs contain an example of how this can be done.
In short, you’ll need at least 3 steps that cycle through the path cells:
- Check Grid Path Length
Check if there’s still a cell left on the path (i.e. greater 0). - Store Grid Path
Store the current path cell as a found object and remove it form the path. - Change Position (or other movement nodes)
Move to the position of the path cell that was stored as a found object.
This cycle will go through all path cells and move the user along the path until the target cell is reached.
In case you’re using Move Over Allies or Move Over Enemies in the pathfinding settings of the move command, you’ll also have to deal with combatants that stand on those cells, e.g. move them to the side or disable their colliders to move through them. The combatant of a cell can be used through the selected data feature, i.e. use a Select Combatant step to select the combatant from the stored grid cell.
The example battle event provided in the grid prefabs will disable the colliders (and NavMeshAgents) of all combatants on the path at the beginning of the event and enable them at the end.