[SUPPORT] Advanced Turn Based Tile Toolkit

I’m struggling to get collision on the walls to work properly. It seems random. The same wall blocks one path but not another. My intent is to have doors that open so collision on the door and wall have to be correct. This is fairly easy in UE4 and works as intended in my other projects. Thank you.

Update: Collision is resolved but I am unable to figure out how to allow the mouse to interact with objects like opening a door.

Yep, the early ones especially, which is of course extra annoying for beginners. New tutorials are coming soon.

How have you set up the grid manager? Are you using the Trace for Walls option for this? If so, make sure your meshes are blocking the WallTrace channel. If this is already the case, send me a screenshot of your setup and I’ll try to figure out what might be wrong.

4.22 is coming soon, i guess this would be a very good opportunity for a fresh documentation… Just saying :cool:

Hi,found this via a google search for turn-based strategy + unreal, and it looks super-great. Only question I have is, how much can I configure the enemy AI? I’m new to game development, and scripting + AI are the things I’m most interested in.

@ Sorry for the late, thank you it work now like I want.

One more thing please.

I would like to have a simultaneous combat mode. I explain when a unit attack another unit a melee range (1 square around the target) both unit attack each other at the same time.

I want it only for melee attack. So if an archer attack from a distance he dont take damage. But if the same archer attack in the mele range of the other unit he take dammage.

Can you help me to setup this.

Thank You.

Already on it :slight_smile: Just finished recording a new tutorial changing meshes and animations for units and more are planned.

Happy to hear my toolkit is the top recommendation :slight_smile: AI is handled within ability blueprints. What this means is that all abilities have customizable code for evaluating the “value” of using a specific ability from a specific tile on a specific target. The AI loops through all these options and decides the best one based on the parameters set. Customizing the AI involves modifying this code. Note that AI is one of the more complex topics of TBS development and the system is pretty involved. It is designed to be highly modular and customizable, though, so once you understand it you can create all sorts of behaviors.

I see, that should not be too hard to implement. Basically in the abilities you use, when it normally calls for just the current unit to attack you would also call on the enemy unit to attack back (provided it lives). There might be some complications I’m not seeing, though. I’m busy tonight, but I’ll try to look into it tomorrow.

Edit: Managed a quick test. Made a copy of BP_Ability_MoveAttack and added this to the end of the ExecuteAbility of that ability. Should be a good starting point:

Nice!
Just a little question, your hex tile toolkit looks kinda Mutan Year Zero / Xcom 2 style when it comes to the actual game play “mechanic”. Is it posible to change this mechanic, to a more kinda RTS style gameplay? What i basically mean is, free movent of lets say 5 or 10 units through the hex or quad tiles, not this i make a move… the AI makes a move mechanic etc… If you know what i mean… The same guestion goes for the multiplayer mode.

I just want to let you know the thing I’m looking forward to the most today is getting home and watching them juicy videos you’re uploading right now drool slurps sounds

The toolkit is designed with turn based games in mind. If you want to make a real time game you should still be able to use some of the code for things like displaying a grid and interacting with it, but you would have to throw out and remake large parts of the code. I can only really recommend my toolkit if you intend to make a turn based game.

Glad to hear it! Three new tutorials are up now. All of them about changing the appearance and animations of units:

Thank you for posting these so fast . I assumed you’d start working on em the weekend and end them by next week. Also, appreciate the extra effort in making those video thumbnails (: looking good.

Thank’s

Thank’s for your awesome video.

Concerning my demand I try what you recommended me. But I think I’m a noob XD. Because is not working for me, maybe I do something wrong.

I have duplicated BP_Ability_MoveAttack and copying the same nodes you provided me.

Does I need to delete the original BP_Ability_MoveAttack and replace the reference ? Execute Ability on the original Blueprint have two branch and I only have one is normal ?

Sorry for my missunderstanding

No worries :slight_smile: I can be pretty efficient when I’m able to set aside the time. Glad you like the thumbnails. Thought I should have some way of differentiating the old and the new videos at a glance, and tiny screenshots of the editor aren’t very exciting or informative.

No problem, I could have been clearer. The idea behind this modification is that first you run the code that damages the enemy (and queue’s the current unit’s attack action) and after that you do the same thing, but with the roles reversed. So you need to do first what is done in MoveAttack ususally and then do the opposite. Here is a pastebin of the whole function.

Also, you need to select this ability as the default ability of your unit’s or they will continue to use the old one.

Thank you I have a better understanding now, and it work almost perfect. But I need to change two things to be perfect

  1. First I would like the two unit attack simultaneously (Or Simulate) because in the current state, the first unit attacking can kill the opponent before he attack back. What I wan is the two unit attack simultanously so if two unit have same life/Attack they die together.

  2. The second thing is about ranged unit that can attack from distanced tiles. In the current state a ranged unit take attack back damage to, while there are not in the in the melle range of the opponent. I don’t know if is clear, I’m not english but to be simple as I can a ranged unit dont take attack back damage unless he is in the melle range of the opponent unit (1 square arround this unit). In the case where a Ranged unit attack another Ranged they don’t take attack back damage too unless again there are in the mele range of the unit, again for me melle range is 1 square arround the unit.

I hope I was clear. I know it was better if I can find solution myself but I have no dev background so it’s litte hard for me to understand everything on blueprint.

Ok, I see. The first question is pretty tricky, but the second is easy. For only allowing counter-attacks for units with a range of 1, all you need to do is to add a branch that checks that the range of the target unit is equal to 1. If the range of the unit does not matter, but rather what the distance between the units is, you can use the GetDistanceInTiles… function from BP_GridManager.

So for your first question, it is more difficult because you are breaking up the turn structure of the game somewhat. I did some testing and managed to create a starting point for you. But know that you’re walking a bit into uncharted territory here.

BP_Ability_MoveAttackBack: ExecuteAbility()

BP_Ability_MoveAttackBack: Attack()

@MarsOdysseus I think @ meant the “FindDistanceIinTilesBetweenIndexes” function (typo in the Iin ) rather than “GetDistanceInTiles”. I couldn’t find anything at least with the “get distance” words.

Alright, so I finally was able to make some progress, thanks to your last videos (: I will ask you Qs about different topics. You dont have to quote me if it’s tiring to deal with this forums’ post interface either, just reference the Q number and bam!

So my destructible mesh is a BP_Unit_Anim duplicate and can now take damage, be destroyed and not take part in the initiative order and combat.

1-Is this how you would go about creating these meshes for destructible terrain? Walls, roofs, trees, vehicles, etc? You mentioned before that doing this as a child of BP_GridActor would give one more control at the cost of setting some things up first. What sort of benefits did you mean by control?

Again awesome videos. It’s all valuable info! Here are some notes that I’d like to talk and ask you about. Regarding collisions:

Path Trace: At runtime, determines what tiles can be walked on. The trace is cast once per tile from above. If anything blocks its way, the tile is not walkable by units.
Range Trace: Determines line of sight - what tiles are eligible for an attack opportunity. It is cast from the attacker’s tile. If units are set to Block it, they would most likely block themselves during the trace and end up with no targets.
Cover Trace: At runtime, determines what objects can grant Cover (advanced grid settings).
Wall Trace: Allows the grid to automatically detect what walls should cover paths as intended. Needs the Trace for Walls grid setting to be active.

2-Where are these traces’ logic located at, and is it possible I can see in my editor a visual representation of the lines for understanding these better (and debugging)? This could potentially answer Qs 3,4 & 5.

3-The default tiles in the grid manager have a Block behaviour on Path Trace. Why is it that the tile is still walkable? Is it because the Path Trace treats the Default Tile as the end point of its trace, acknowledging it is the Gridmanager’s tile and thus is free to be walkable?

4-Your wall meshes are set to block Range Trace for obvious reasons. Is it correct to say that if a wall blocks this trace, the trace will not be allowed to keep going in that direction, say for example, two tiles behind that wall?

5-From where to where are the Cover Traces cast?

6-How hard do you think it would be to implement vertical grids? As in, grids projected on walls haha. If there is enough space and after a certain height, certain units can just walk on that. Just want to pick your brain on it and hear your thoughts.

7-I think the next challenge I’ll work towards is interactive terrain meshes, just like xcom soldiers can open/close doors when they’re one tile away from them. I’ll also work towards a bit more complex interactions, like making my unit move in these contextual actions: for example, enter a phone booth and close the door, or get into a vehicle, or climb up/down a tree. Any words of advice as to where should I start digging my nose into for this? I’m expecting I’ll have to create these as BP_Abilities like in your advanced example, then build a system that checks when units are near the correct objects to be able to perform this ability.

Anyway, keep doing cool a$s mothafukkin logic . Also +1 from me to focus more on advanced/firaxisxcom-like features and video explanations!

Indeed, thanks for the correction. I was just going by memory there.

Very thoughtful, , but not to worry. I like to keep my responses tidy that way.

It depends a lot on your use case. If you just want some explosive barrels and boxes here and there I think it works pretty well, since units can already be targeted and damaged by default. For something more involved, though, with multi-tile strucutres or things that affect pathfinding beyond blocking an entire tile (such as walls between tiles etc) you would probably want to make something more from scratch. In that case I would consider creating a new actor based off BP_GridActor. What I mean by control is that you can just add the stuff you want, and do not need to inherit all the stuff you don’t need from BP_Unit, which you then need to override in various ways (as in the initiative sorting function).

It might actually be good to base them off BP_GA_Tile. That way you can specify what edges the tile blocks and you already have variables where all such edge modifications are stored. On destruction these tiles could look at their edge variables and try to re-add any edges they had previously blocked. This would require adding new code to allow such tiles to be targeted, though. Maybe a new TMap in the grid manager storing the index of each destructible tile and additions to all damaging abilities where a destructible tile is targeted if the hovered tile is not found in GridUnits, but does exist in GridDestructibles. Those are my first ideas, anyway.

Just the opposite, actually. If the trace is blocked it is treated as walkable. If it is not blocked it cannot be walked on.

All of these are correct.

In a few different places. PathTrace and WallTrace are used mostly in SetupGridArrays in BP_GridManager, which is run at the start of the game. PathTrace mainly in the CreateGridLocations function. WallTrace in the SetEdgesBasedOnTerrain function. CoverTrace is used in the BP_CoverSystem component and RangeTrace is used mostly in the FindTilesInRange and FindUnitsInRange functions, which are generally called by abilities. For all of these traces you can set the DrawDebugType input in the LineTraceByChannel function to ForDuration or Persistent to see exactly where they fire and what they hit.

See above, it is the opposite. They can be walked on because they are hit, not the other way around.

Yep. If RangeTrace is blocked at any point between a source and a target it returns true and prevents that tile from being seen.

Again, in BP_CoverSystem. By default they are run in all four cardinal directions twice. Once at HalfCoverHeight and once at FullCoverHeight, which are defined in BP_CoverSystem.

Like walking up walls? Pretty tricky. That all tiles are angled the same way is an assumption built into the toolkit. This is something I might revisit in the future, though.

I recommend checking out the 2D example Hydra’s Lair. In this I have objects that can be interacted with, including potions, weapons and switches for lighting torches/opening doors.

Thanks! Lots of plans both for features and documentation. My next videos will likely be about the sort of stuff I have discussed in this post. Namely how the various grids work and how walkability, edges and pathfinding works. As for features they will likely be driven by the sort of stuff I need for my own game, which I am working on at the moment. It is pretty different from XCOM, but it does use cover as well as very complex ability interactions.

Thanks for the in-depth response :slight_smile: The sharing of your wisdom is very much appreciated. I think I’ll start writing up some docs with all the info you’re giving me of the ATBTT’s functionality. You’ve given me a lot to work with, so I’ll start digging around and studying some more now.

Hello!
Me and my friend are developing a small turn based strategy game for our college project(with hopes to turn it into a fully fledged game afterwards) and this tool kit has been so much help!

We are currently working on the abilities for our different characters attacks.
For each attack we are using the laser ability as a base in order to easily implement hit chances etc.

We have come across a problem however, we are wanting to do an AP Cost check within the ability system blueprint however, we are unsure how to relay the AP Cost back to the ability system as we can’t find a variable for it. We are wondering how we would do this or if there is another way to implement it?

Hello everyone,

First of all, thanks for this awesome toolkit. I’ve bought it a few weeks ago and now proceed to use it.

For this moment I have a problem with spawning AI units during gameplay. I have two types of AI-controlled units: 1) Enemy (“E”) units move in random direction every turn (this is their default ability) and 2) Spawner (“S”) spawns several “E”-units randomly over the grid every turn and puts them at the end of “Enemy” faction in initiative order. The order of the initiative is described below:

  1. Player takes his turn and moves in selected direction;
  2. The Spawner spawns several additional Enemies and puts them at the end of “Enemy” faction in initiative order;
  3. All non-additional Enemies take their turns and move in random direction without delay between them. Then all additional Enemies become non-additional.

The problem is that spawned units have no default ability though it is clearly set up in “E”-unit attributes.

If it won’t bother you, could you write a short tutorial about spawning units during gameplay? It would help a lot.

Thanks again! (and sorry for my broken English)

Best of luck!

So you’re trying to access the AP cost of a specific ability from within BP_AbilitySystem? You should be able to find it either in the defaults of the approriate item in the Abilities array or specific ability in the AbilityRefs array.

There are some known issues with unit spawning that will be fixed in the next update. Here is the updated HandleUnitSpawning function in BP_Unit. I’ve tested out spawning AI units now, both using just the default ability and the ability system and it seems to work on my end (with this modified function). I used some very basic debug unit spawning here, like so:


Let me know if chaning the function works for your setup. If not, could you paste some screenshots of your unit spawning code and tell me what error you are seeing? How do you know that the problem is caused by the ability not being spawned?

Spawning units is one of those questions that keeps coming up, so I agree I should add some support for this. It might be better to add an example map over a tutorial video, though. I’ll put it high on my list.