I’m proud to announce that the Turn Based Strategy Grids plugin that I’ve been working on is just now released on the Marketplace! I would like to thank everyone who has made this possible by giving feedback on the work-in-progress thread and voting for it on Trello, thanks everyone!
In this post I will showcase the features that are in right now. I will continue to work on this plugin casually and I’m eager to get feedback and suggestions from people using it in their projects, or just based off the listed features. See information about incoming updates in the next post.
A brief history
I’ve always liked the Fire Emblem and Advance Wars series and for a long while my goal has been, and still is, to develop and release a game in this vein. I’ve started working on a personal TBS project over a year ago in various frameworks, implementing turn based gameplay, player input handling, bot AI, combat formulas, integrating LUA scripting, a dialogue system… aaand starting to create my own editor which I’ve reconsidered by now (it was fun trying). Here is some old footage of my past TBS project and its iterations:
TBS Game - JMonkeyEngine
TBS Game - Custom Editor
TBS Game - SFML
Five months back, after completing my CS studies I put the above project on hold to explore the awesomeness that is UE4. Seeing the interest for a TBS template on the UE4 Trello roadmap sparked me to take the things I learned and see if I can apply them in UE4 using blueprints. This would also help me decide whether or not to move my prior TBS project over to Unreal. That resulted in the creation of this plugin! It turned out quite well, so without further ado let me introduce it.
Turn Based Strategy Grids
(From the marketplace description) This blueprint system provides developers of turn based strategy games with logic for representing and querying 2D grid worlds. Its main function is the computation of action grids: queriable grids that efficiently store all pathing and attack options available to a unit during its current turn. Action grids are intended to be used for efficiently retrieving shortest paths to any reachable tile, for displaying the movement and attack options that are available to the player’s selected unit, and for providing AI units with a search function to retrieve the set or a subset of valid actions, which can then be processed by your high level AI controller. Action grids only need to be computed once per turn, after that all pathing and attack information can be retrieved without further computation.
The plugin includes features such as editing of level layouts in the editor and at run-time, multiple terrain types with different interaction per unit and optional line of sight checking when determining which tiles are within a unit’s attack range. Action grids can be merged to represent the influence radius of multiple units. An example map and player controller is included that demonstrates usage of the plugin in blueprints and handling of player input. All blueprint is commented and a detailed user guide is coming soon.
Integration in your project
The focus of this plugin is to provide the logic (the algorithms) for path and attack planning. It is designed to be easy to integrate into your existing UE4 project by not limiting you in your use of blueprints and your visualization of the map and units. Any blueprint class can be made compatible with this plugin by implementing the blueprint interface IGridActor that contains two pairs of straightforward Get- and Set-functions that you must implement.
Without modifying anything you can choose to use only the grid logic in this blueprint. The visualization shown in the screenshots and in the example map is optional and stored in separate blueprints that are used only for display. The visualization blueprints are gameplay ready, just not very special. Generally useful functions such as world<->grid coordinate conversion and tile picking are contained in blueprint function libraries so that you can call them throughout your project. When using coordinate conversion functions you can specify the grid’s origin and tile spacing in world space and as well as the height.
Note that this plugin provides the pathing and attack options according to mechanics of square tile TBS games like Fire Emblem and Advance Wars, but implementing the attacks is left to you.
Multiple terrain types - Terrain interaction can be customized per unit instance in terms of accessibility, movement cost and targetability. The plugin’s algorithms call a function taking a (terrain type, grid actor reference) pair to retrieve these parameters. This function can be user customized to define a unit’s capabilities and even allows units to change their terrain interaction in-game, which can be used for example when activating skills.
Unit pass-through - You can specify which units are allowed to move through which others, for example to allow team members to move through each other. The relation does not have to be symmetrical, so you can have rogue characters that can move through enemies but not vice versa.
Path exploration - Computes and efficiently stores all paths that a unit can take during its turn using Dijkstra’s algorithm. Any number of paths can be retrieved without further computation.
^ A visualization of Dijkstra’s intermediate result, not shown in actual example map
Attack range calculation - Determine all tiles within a unit’s attack range, before or after moving. Attack range is measured in Manhattan distance (horizontal plus vertical distance).
^ Before moving, attack range 2-2
^ After moving, attack range 2-2
Optional line of sight check - You can enable a LOS check to have vision blocking terrain. For each terrain type, you can then specify whether vision can pass through the tile area, and whether it can pass through the corner of the tile. The LOS check affects which tiles that are in attack range can actually be attacked, not to be confused with fog of war.
^ Attack range 3-5 with LOS check
Single tile data retrieval - Intended for handling player input and scripted AI. Retrievable data: whether you can reach that tile and if so, the path to that tile. The current occupant if any. Whether it is within your attack range or your move and attack range. A list of enemy units that are within the attack range of that tile if you stood there.
Multi tile search - Intended to assist high level AI. You can search action grids for tiles that satisfy a combination of conditions, including whether it is reachable, within attack range, occupied and by whom (friend or foe) and whether that tile has enemies within your attack range if you stood there. The list of tiles that is returned by the search function can then be processed by your high level AI. For tiles that have enemies within your attack range, you can retrieve the list of attackable enemies using single tile data retrieval.
Action grid merging - You can merge the action grids of multiple units to obtain a grid that represents their combined movement and attack range. This is useful for allowing the player to select multiple enemy units and preview their attack range. It can be used by AI as well to access the same information.
User guide is now available here: http://www.zkshao.com/downloads/TBStrategyGrids_UserGuide.pdf