[SUPPORT] Advanced Turn Based Tile Toolkit

hey, so i dont know if someone already ask but, how we can spawn more “minions” during the game ? i want to start a basic game like risk

Sorry about the very late reply, people. Was busy all weekend.

Hmm, not entirely sure if I know what you’re saying here. What do you mean with “on pawn initiative” and “pawn with the initiative”? Do you mean that when a new unit is selected that is not controlled by the client, the camera focuses on this unit instead of staying focused on the unit specified as that client’s hero unit? How precisely do you want the end result to behave?

Sure, that is possible. Having it block visibility for finding tiles in range is easy. Just add collision to the corner thingy and have it block the RangeTrace trace channel.

Pathfinding is a bit more difficult. You essentially need to remove the edges from each of the surrounding tiles that pass through the corner where your actor is placed, and then re-add them when the actor is moved.

Since your corner actors always have a straightforward relationship with the surrounding tiles you can make this simpler by hardcoding it. The grid indexes of the surrounding tiles relative to the corner actor will depend on how you chose to offset the actor, but if it is offset to the south-east (positively on the X and Y axes) the surrounding tiles will have relative grid indexes 0, 1, 1000 and 1001. You could go through these tiles in the GridEdges TMap and use RemoveEdgeBothWays on two of the tiles to remove the diagonal crossing through your corner actor. If you have offset the actor as described above you will run RemoveEdge with the following parameters:

RemoveEdgeBothWays(GridIndex,GridIndex+1001) & RemoveEdgeBothWays(GridIndex+1000,GridIndex+1).

When your corner actor is moved or destroyed you would run AddEdgeBothWays with the same inputs.

Note that this will only affect RunPathfinding and FindTilesInRange the next time these are called. If you have a currently active unit displaying move or sight range when you make these changes, you need to re-run pathfinding/visibility for it to take effect.

Should be as simple as using SpawnActor. The construction script of BP_Unit has exposed variables where you can decide if the unit is to be automatically added to the grid and/or initiative order.

Thanks for your reply. I’m still having trouble getting it to stop finding tiles in range past this corner object. My Find Tiles in Range function works in straight lines (including diagonals) similar to the example you used in the Finding Tiles video. Could this be because my corner objects are not being stored in the Grid Index? Here are my collision settings and a screenshot of it successfully finding a tile through the corner object.

Additionally, do you think it’s easy to add in functionality so that one faction can pathfind/find tiles through certain objects and one faction can’t. Appreciate it!


Hmm, it should work. I’m guessing your mesh might not be set up properly for collision? To test this, try adding a collision box component to your actor that blocks RangeTrace.

This is certainly possible. The simplest way is to add a new custom pathfinding type. You can start by modifying SearchAndAddTileCustom1 and add more as needed. If you look in this function you’ll see how tiles are evaluated through several branches before they are added as tiles in move range. You can add more branches here that test against custom conditions. Beware that this is the most performance sensitive area of the entire toolkit, so make sure to keep the checks to a minimum and avoid expensive operations like casting.

Hello. Monokkel

I have multiple questions.First, I’m not sure how this occurred in my project but if the AI doesn’t reach its intended target to attack for some reason it won’t end its turn when it should.
Second, how do you make it so that you can make certain animation that aren’t part of the toolkit trigger the same mechanics such as damaging other units, death and movement. Lastly, from those last two examples Ability Elemental Attack and the Ability Attack Repeat I combined them together and now I was wonder where can change it so you can move again after you attack.

Many thanks, EagleEyeGamma.

Another question I had as well was how can i make it so they only gain AP back after you do Super effective damage to the target?

Update on this bug, apparently if i give the AI the same Elemental attack ability for some reason they’ll won’t end their turn if the target dies before getting off a second attack or if they don’t reach their target within their movement range.

A bit hard for me to know what might be happening here without knowing what you’ve changed. I could need some more specifics. Try using breakpoints in the ability to see where it stops and report back if that does not give you the answer. One guess is that when the target dies and the unit then tries to attack it with the second attack, the reference to the target unit no longer exists, causing the attack to fail out. You should check after the first attack if the target is dead and only run the second attack if it is not.

Check out my tutorials on adding custom units.

Are you using the ability system component or a single ability for each unit? If it is the latter you could use BP_Ability_MoveAttack as a base instead of BP_Ability_Attack, as only the first one has movement functionality.

Should be as simple as checking whether the attack was super effective and using this as input to a branch.

Hola Knut! Justo here after a UE4 break (at home at least), coming from the lands of Blender & ZBrush. I take it that update 2.3, with the variant Turn Managers, is still in development, yes? Would love to sink my teeth into your xcom-like variant and add in my real-time movement outside combat. Then hit my head against a wall until I become gud at big units.

Anyway, hope you’re having a nice time these days dude. Stay fresh, you are an amazing human being.

That model is fantastic, Justo! You manage to portray so much movement and emotion :smiley:

Version 2.3 has actually been out a while. Seems like I forgot to update the changelog (oops). 2.4 is actually live already, and I’m currently working on 2.5 You’ll find three different kinds of turn managers in the toolkit now. The base is a faction-style (similar to XCOM), but there is also a D&D-like initiative system and a secondary faction-style turn manager that does not select the next unit automatically (similar to Fire Emblem)

Thanks Knut, your praise means a lot to me. Indeed, I was looking at your changelog for info, I can see now you updated it.“Experiemntal hybrid real time third person/top-down turn based map” I see?! That sounds an amazing lot like what I was looking for actually. Downloading the latest version right now…Cheers!

Uhh, how am I supposed to see the new modes? I shall mention beforehand I am testing this in 4.23, if that’s an issue (I don’t see anywhere a quick notice on what’s the recommended engine version for the latest update).

The post announcing the update doesn’t really address this (had to dig around the thread pages to find it, too. In a thread with 200+ pages, I insist it’s a good idea to add hyperlinks to these longer posts in your changelog where the update version is named & described, so that anyone can quickly access further descriptions for more info. I have yet to find the 2.4 post). The assets in the update dont have a description that I could see that would let me know either.

My failed attempts to make things work:

I see the BP_TurnManager_Initiative, Strategy & Hybrid TurnManager child actors. I also see for each of those, a new Game Mode was created with its respective name. I tried using these gamemodes hoping that it would turn the game style automatically:
Tested all three modes in the JungleRaid map, but enemy behaviour seemed kind of broken for all three versions, so I assume this was not the intended test area for these modes. I also tried applying these Game Modes to the Example test map. The Strategy one didn’t really differ from playing the level with no game modes, other than the fact the PLAYER TURN and ENEMY TURN now appear at the beginning of each side’s phase. I suppose this is okay, since the default game style sort of acted this way originally (first move all your units, then the enemy moves, then you, etc…).

As for the Initiative mode, I assume the Initiative property in units is what would determine the initiative of all combat participants, regardless of team faction (D&D rules afaik) no? I tried assigning the units some arbitrary values, but in the end, all player units would act together, followed then by the enemy, almost as if this game mode was also Strategy. The way initiative works seems to have changed too, or was it always like this? From its description:

"The default units have initiative set to 0 for enemies and 1 for players, sorting them neatly into two separate acting teams. "

I think this statement is confusing, and wrong. Player units can have a value from 100 to 199. Enemy units from 0 to 99. Also, is this really the smart way of doing this? Clamping this value depending on team faction seems…prone to errors and convoluted? Why not just have it be one integer value from 0 to whatever, without constraints? What would happen if a unit is mondcontrolled or switched teams mid-game? I’m sure you have thought of this way more than I, so I’m simply curious to hear your thoughts as to why you decided to do it like this.

***TLDR: ***

If there is a post somewhere explaining how to make the gamemodes work do tell. Also I think documentation, both in this thread and in the project files, could be improved and are currently confusing for someone without a strong understanding of how the kit works. Things that would help to speed version-control-checks:
-Adding hyperlinks to the changelog in this thread
-Adding recommended UE version and current downloadable ATBTT version number in the official ATBTT description in the Epic Launcher would help (or the changelog too)

Sorry if this has been discussed elsewhere; I was not able to find such a post. Point me to it if there is sth like that :slight_smile: Cheers.

I generally always make a new update when UE4 makes a new engine version. This update was added along with UE4.23, so you need to use 4.23 in order to get the new functionality. It is probably a good idea for me to note what engine version is tied to what toolkit version. I’ll put it on my to-do.

Good idea. I’ve added hyperlinks to all the versions in the changelog. I also recommend looking at my Trello for somewhat more detailed changes. My written info on each update unfortunately vary in how informative they are, however. For the variant turn managers I have not yet created any tutorial or guide.

Getting them to work is intended to be pretty straightforward, though. There are game modes associated with each turn manager, and the only way these differ is to change the class of the TurnManagerClass variable, which is responsible for spawning the correct turn manager. If you select any of the three (non-hybrid) game modes as the game mode in the Example map they should all work without you needing to do any more work. The hybrid turn manager is different and made to work along the special hybrid units in that specific example map.

Broken in which way? The stealth system does interact with initiative a bit, so this might be what is happening here.

The difference between the default game mode and the Strategy one (besides the Player Turn text) is that a new unit is not selected automatically when the active unit ends its turn. They are otherwise very similar.

This statement is indeed confusing and wrong. This is something that has changed a lot over the updates, so I should do some cleaning up here. The behaviour of units that assign initiative values within a range (0-99 for enemies etc.) is specific to the BP_Unit_Debug class. This class was made only for quickly testing out stuff, and this was a quick way for me to make sure the factions did not have overlapping turns before I added the new variant turn managers. I should just remove this code now, as the variant turn managers makes this redundant. Thanks for reminding me of this. For now, use BP_Unit_Anim instead of the debug version.

As mentioned I have not yet made any real documentation for the new turn managers. After making tutorials on pathfinding I hope to tackle this next. For now, I’ll do my best to answer any questions in this thread. I agree with your suggestions and have added hyperlinks and will also name the UE4 version in future updates (and go back and add it retroactively when I have the time)

Hello, I’ve spent quite a bit of time troubleshooting this issue, I will try to describe what is going on. After I implemented the code you supplied this is what happens:
I have a simple node setup in the level BP to “on event play” spawn a custom unit on “playerstart”. the unit is fully animated and functional. the issue is that the “Host” player works as normal, while the client (remote) spawns on 0-0-0 transform. The remote has no control of the pawns to move or use abilities and I get an error when trying to move.

the intention was to make it so the host could control all the “NPC” units and the player would be able to control only their unit, as the remote in the multiplayer game. the screenshot is of the gameplay on “begin play” i will take additional screenshots of modified blueprints.

Hmm, I’m uncertain about how implementing the camera changes I gave you could have led to these issues. Are you sure it is related or are you getting the same errors when you use regular cameras? How are you spawning the new units? It seems like they are not being properly replicated.

I figured out why the camera control was not working, as the assigned actor was not being controlled by a player it was causing a bug. Once I fixed that issue the control was reestablished. Now for why it’s spawning at 000 is another issue I need to resolve, thank you for being so vigilant about helping people in this thread.

Good to hear you figured it out :slight_smile:

As for your spawning event I’m a bit unsure how the level blueprint works with networking. I assume it might always be owner by the server. How are you accessing the PlayerStart for the client here? It might be an idea to time the spawning of the units so that it happens after the TurnManager has acknowledged that all the players have joined the map. Depending on how you’ve set up your code in the level blueprint it it might trigger before the needed clients have joined, returning false locations being interpreted as 0,0,0. Mostly guessing here.

Hi, hope all is well

I’ve been playing around with the Add New Ability feature you created, thanks for that. it’s working fine for the majority of what i need it for. However there is one instance in which I want to Add an ability for a single turn, and i’m having trouble destroying that ability on the next turn after it has been added.

I was thinking, maybe this would be good to implement as a status effect? I’m actually venturing into a part of my project where I’ll be creating and using my own status effects quite a bit, so would also be really helpful to get a sense of whats the best way to think about how those work, for example I’m going to have an ability which exhausts a unit for a single turn, and I’m not quite sure where to get started on that, even though I understand the exhaust function.


Sure, something like that could be done with a status effect.The basic function of status effects is relatively straightforward. They are added using the AddStatusEffect function in BP_AbilitySystem (of the unit you are adding the status effect to). When a status effect is added this way, the Activate event on the status effect is immediately called. This is a good place to queue any visual indicator of the status effect or any other immediate effect (expanding on the AnimateActivation event which is queued here by default is a simple way to put the visual part of the activation).

Two central events are RunOnTurnStart and RunOnTurnEnd. These are blank in the BP_StatusEffect parent blueprint which you can override in your custom child blueprints. These are the events you probably want to use for ongoing effects such as applying poison damage every turn etc.

The last event is Disable, which by default calls the Destroy action on the status effect (which by default turns it invisible. You can expand on this as needed) and sets a queued timer to destroy the actor itself.

For your use case you probably want a status effect which holds a reference to your ability. You set this reference when you add the status effect and destroy it on RunOnTurnEnd. You should not straight up destroy it instantly, though, as the destroy command could happen before any actions using a reference to the status effect have animated, so use the QueueDestroy macro so that it is first actually destroyed when it is no longer used. To make it appear destroyed before then, remove the ability from the abilities and abilityrefs arrays in BP_AbilitySystem. Come to think of it, you would want to do this even in the event of destroying the actor, as you would be left with empty array elements. Use RemoveIndex, not RemoveItem to prevent this.

RunOnTurnStart/End are called on slightly different times depending on what turn manager you are using. For BP_TurnManager_Initiative it is called on the start and end of the specific unit’s turn. For the other two turn managers it is called on the start and end of the current faction’s turn for every unit of that faction.

One thing I’m still struggling with is the RangeTrace and Pathfinding around the corner objects.

I tried to get it working in the most basic example I could think of, here’s two units using the Grenade function which uses the Find Tiles in Range and has Check Visibility set to true. Here are also the collision settings for this simple box which is offset X = 100 Y = 100 to be on the corner. Should it be blocking the Range Trace for this ability?

Basically what I’m trying to do in my game is very similar to this toy example, however I will also want to have some objects which block both Range Trace and Pathfinding for one faction but don’t block these for the other faction, which I anticipate could get complicated. But if I just get this toy example working with the Grenade and the two units it should take me pretty far. Thanks!