[SUPPORT] Advanced Turn Based Tile Toolkit

Hi there! It’s going forward, but a bit slowly. Work has been busy, and in addition I’m getting married in a week and then going on an extended honeymoon, so I’ll be pretty occupied for the next few weeks. I have however implemented both a cover and accuracy system that is probably pretty close to what I’ll end up including in the update. I’ll explain my solution in this post so that anyone who needs a cover system quickly can replicate what I’ve done.

First to create some context for the blueprints below, I’m creating a new example map to include features like cover and accuracy. Since I do not consider these features generic enough to include in the base toolkit (to avid it from getting cluttered) I’ve added these features in child actors of the original actors. The example map has the working title SciFi because of some SciFi themed assets I’m using, so the child actors are called for instance BP_GridManager_SciFi and ATBTT_PlayerController_SciFi. In the blueprints below I will frequently be casting to these child actors to get access to their functions and variables, though if you want to replicate this yourself you might not want to use child actors and could just modify the base actors themselves.

The goal of my solution for cover is to have everything be pregenerated based on the terrain placed in the level, both to save time for the users and to speed up processing during gameplay.

For cover I have created a new array called Cover Array in BP_GridManager (or really BP_GridManager_SciFi). This array is a nested array of structs. It is an array of arrays, where each nested array is an array of structs containing an index integer and a cover float. The main array is resized to be the size of the grid. The idea is to have each index of the array represent a tile on the grid and each member within the nested array represent a tile edge of each tile, pointing to which index the edge is facing and what its cover value is (hope that’s clear :stuck_out_tongue: ).

To auto generate cover at the start of the game I have created a new trace channel I call Cover Trace. I then trace between all tiles two times using this trace, one quite low and one quite high. If the high trace is blocked I count this as full cover between tiles (with a high cover value). If the high trace is not blocked, but the low one is I count it as half cover.


I’ve made the following function to check whether a tile has cover from another tile. If the attacking tile is on the other side of the cover edge, accuracy is always reduced by the same amount, regardless of how far to the side of the cover the attacker is standing. This is both easier to calculate and probably for a player to understand.

For calculating hit chance I want to take into account more factors than just cover, so I have made the following function to take distance and other modifiers into account:

All functions so far have been contained in BP_GridManager_SciFi. I have also created a new unit child actor currently called Unit_Player_SciFi_Weapon (so called because I’m experimenting with units carrying weapons that can be switched). This unit has new attributes called Accuracy and Dodge. Accuracy is a value between 0 and 1 representing the base percentage chance this unit has to hit another unit with its attack. Dodge is a similar number subtracted from the accuracy of any unit trying to hit it. Here are the nodes I use in the event graph of this unit. These nodes are inserted as part of the Attack Victim event, before Attack Animation, but after all other nodes.

It is still a work in progress and I have also added more functions for displaying XCOM-style shields for cover and such. What I have described above should still hopefully be enough to get you started. I hope I have explained it well enough, but feel free to ask if you have any questions. Like I said I will probably not have any time to work on this until I return from my honeymoon in August.