Download

[SUPPORT] Advanced Turn Based Tile Toolkit

hi samtsion](https://forums.unrealengine.com/member/403687-samtsion)

1.the map Bunkers or the Heightmap_example [FONT=Helvetica,Arial,Verdana,sans-serif]is not in new build, only in the older version .
2. in the the Jungle Raid demo map if I remember correctly, I think the player on the map all set as aicontrolled that’s way they are moving by themselves - just unchecked the aicontrolled box in each of the player you want to control.
hope its help

leo

​​​
Hey samtsion, you’re not doing anything wrong, as both of these things are not in the current version. The bunkers map was removed several updates ago as the JungleRaid map demonstrates click through platforms as well, so I felt it was a bit redundant.

The initiative bar was disabled in JungleRaid in the most recent update. This is because I made changes to the initiative system and felt an initiative bar does not make much sense for a game set up with initiative grouped into factions. If you want to change that map back to how it was before, change the game mode in JungleRaid to BP_ATBTT_Initiative and set bUseInitiativeBar in BP_GridManager to true.

The player units being controlled by the AI is a mistake on my end. I like to test for bugs by watching combat between AI teams when I make a new version. I just forgot to turn it back to normal. I sent a new update to Epic a couple of days ago where this was fixed. Just select the player unit and set bAiControlled to false for the same result.

Edit: Thanks, [USER=“641905”]leo bar[/USER]. Seems we started writing at the same time.

hi knut

Lately, I’ve had some time and made some changes to the toolkit. These changes led me to a clear understanding that I needed to split some of the functions(SetupGridArrays and RunPathfinding) to work over few ticks. (Especially after I tested the system on computers much less powerful than mine - the bottlenecks get a lot more emphasis).
Since I don’t want to use c++(It just makes me very sad to use it :)) I looked and saw you have some macro for this kind of things (like the ForLoopPerTick ect…). The problem is that I probably couldn’t quite use these macros correctly and couldn’t get the results (the truth is that I mostly got the computer stuck :).

So what I really need is your Guidance. I understand this is a little abstract and big question and not very urgent either, so I would love to have some directions when you have time.

thanks in advance

leo

Ah that was the problem, got it to work now thank you. I should read up more on ISMs. Sorry for the inconvenience.

Thank you for your answer. I got the latest version(v2.2) and tested it, but the big unit still has a problem. After placing the Grid Manager at the level, you changed the value of the Diagonal Movement variable value to false. After that, the range of movement of the unit is not displayed. The result is the first screen shot.

Identifying the cause of the problem does not proceed with the corresponding node of the second screen shot in GridManager’s SearchAndJacentTilesBig function.

Afterwards, we modified the function like the third screen shot, and it comes out of the wrong way. The cost of obstacles within the range of travel, such as a fourth screen shot, is not taken into account.

I want the same pathfinding as the fifth screen shot. What should I do?

Hello all,

I am having a little trouble finding something to help me understand how this toolkit works, I have watched the tutorial series but I get the sense that some of the older ones do not reflect all of the changes in the toolkit.

I’ve been reading through this thread, but have been unable to find what I need so I figured I’d ask here. If I missed something obvious, I apologize and hope that you can point me to where it was answered.

My question is “where are the rules that dictate how the game is played are?” I know that is cryptic so let me explain: I have found the parts that handle actions, movement, things like that. But I have been unable to find the part that manages “here is how damage from an attack from player A to player B effects player B’s health”.

What I expected to find is perhaps an Attack_Action, Move_Action, that has some logic in it that says how this is done.

If that isn’t clear enough, let me try an example. I would like to modify the game so that a player can move or attack in one turn. They cannot do both, they have to choose. Additionally, I would like to make attacks have a chance to miss.

I hope I was clear enough, and I hope this isn’t too obvious for you all.

Thanks for your time.

Hey Leo, too bad you’re seeing performance issues. I’m curious to know about what it took to run into the bottlenecks. What sort of hardware are you testing at, what functions seem to be too slow and what paramaters are you feeding into them (move ranges etc.)? The macros I’ve made for splitting stuff up into multiple ticks were mostly made early in the toolkit’s creation. While I was learning blueprints I struggled a lot with performance, and they seemed like a good solution. Later on I was able to speed the hungriest functions up significantly, to the point I felt delayed loop functions were not needed for most types of turn based strategy games. There are of course exceptions to this (especially if you want to generate a new edge map during gameplay), but I hope what I have is sufficient for most peoples’ purposes.

Also be aware that Unreal Engine runs much slower during Play-In-Editor. Play standalone is quicker, playing a packaged developer build is a lot faster and a shipping build is faster still. I’d try your game on a shipping build before prematurely optimizing if you have not done so yet.

All that being said, if you still need to improve performance and you’re allergic to C++, splitting up heavy functions over multiple ticks is certainly a solution. I recommend using the macros I’ve included ending in “_Delayed”,as these are newer and simpler to work with. They can for the most part be used just like regular loop macros, only you need to specify how many iterations you want per tick. The issue with them is that macros with delays cannot be included in functions, so if you want to use a slow loop in say RunPathfinding you’ll need to create a new macro where you copy-paste over all of the RunPathfinding code and replace the relevant loop(s) with the delayed macro.

Another problems is that macros unfortunately cannot be called from other blueprints. You can solve this by tying a macro to an event in BP_GridManager’s event graph. If so you’ll need to make sure the macro has run through before continuing the execution chain on whatever blueprint you called it from. This can be done with event dispatchers (see examples of how to do this in my blueprints. For instance the AnimateAction nodes in BP_Ability_Laser).

Hope that helps!

No problem. It took me a while to understand ISMs when I started out as well. Very useful thing to know about the engine, though. Especially in the old days when UE4 did not do all the fancy mesh instantiation under the hood.

So let me see if I understand this correctly: You want to have big units that cannot move diagonally? As you found out the big unit setup code does not work if bDiagonalMovement in BP_GridManager is false. However, you can get the same result by modifying the pathfinding code. In SearchAndAddAdjacentTiles_Big add the following to prevent diagonal movement:

This seems to work fine on my end:

I hope this gives you the result you want.

Hey angelbane, I’m sorry that my old tutorials can be a bit confusing when using the new toolkit. I’m making new ones and I have several fairly new tutorials that are up to date, but there is still loads more to make when I get the time. For now feel free to ask here about anything that confuses you. No need to apologize as this is what the support thread is for, and I’m happy to help :slight_smile:

When you ask about how the rules of the game are dictated, for the most part that is done in the various abilities and in BP_TurnManager. These blueprints are made to be highly modular (this includes the turn manager in the latest update) to make changing the rules of your game relatively painless.

The turn manager starts the game and has events and functions for starting and ending the turns of units etc. Abilities are what the player uses to interact with the game (the player controller sends input to the abilities which interpret the input and decide what to do).

To give an example related to what you’re asking, when a unit ends its turn it signals the turn manager, which (by default) deselects this unit and selects a new unit. SelectActor is run for this unit, which causes it to activate an ability, telling the player controller of the player that owns this unit to do this. The player controller sets this ability as the active ability and runs ActivateAbility (which often runs code for finding and displaying relevant targets for that ability). From now on, mouse hover events and clicks are taken by the player controller and funneled into the active ability, running first through the BP_AbilityBase and BP_Ability code (unless this is overriden in the ability itself) and finally in the main ability.

In BP_Ability_MoveAttack, for instance, the cascade of events following a click ends up triggering EventServerInteract, which then checks if the clicked tile contains a unit, which it uses to decide if the active unit should move, attack an enemy, swap to another unit or do nothing. For damage, in this ability if an enemy in range is clicked, it runs the ExecuteAbility function, which for BP_Ability_MoveAttack results in calling the TakeDamage event on the enemy unit (causing its CurrentHealth variable to decrease) and queue the Attack action, causing the active unit to animate an attack and animate the enemy’s health bar depleting (Which is done in EventAnimateAction in BP_Ability_MoveAttack, as called from the action manager blueprint).

To answer your specific questions, if you want your units to be able to either attack or move, but not both, you can change BP_Ability_MoveAttack so that moving sets the units Action Points to 0 (instead of subtracting 1, as is currently done). For having a miss chance, I recommend looking at how I did this in BP_Ability_Laser.

I recommend checking out my tutorials on the action system and ability system, as they are pretty much up to date and covers important topics needed to understand the toolkit. The turn manager videos might also be useful, but these are unfortunately outdated as of the last update, where I made some serious changes to the turn manager code. They might still be informative, though.

I hope you learned something from my description, and let me know if you have any further questions.

hi knut

Thanks so much for the detailed explanation …

all my testing is done in the standalone mode or in a packaged developer build

It is important for me to emphasize that I am really happy with optimization of the toolkit as it is, its perfectly fine. On a reasonable computer everything ran wonderfully. The reasons I wanted to make the changes and use loop per tick are:

  1. I deliberately tested my project (at least what I have done so far) on a much weaker computer than mine ( intel core 2 duo e4700 2.6 GHz ), just wanted to test the limit of the hardware people can use.It’s important to note that on this processor too, everything ran quite smoothly except for a little bit of delay when the run pathfinding was running (I also have a range of 14 tiles).

  2. The second reason is because my tiles are smaller and have quite large maps and I get into the problem of max loop iteration count. on the weaker computer the problem is of course more serious.

The solution to the problem is easy (changing the number of the loop iretation in the project settings ) But I do not feel so confident that the values there are so high (they put this limitation to avoid potential problems)… Apparently I’m just too strict but I still wanted to see if I could solve both of those things. I will try what you have suggested.

again if there is one thing I learned during this testing is that blueprint and your toolkit can handle this type of game very well (Contrary to what many people think or claim )

cheers

leo

Sorry if this more work than I’m expecting, but I have a question about the controls in the 2D version of the game. How would I modify them to keep the grid/turn based movement, but have the character move around with the keyboard keys instead.

To further explain, there’s a Madoka Magica game for the PSP that plays exactly like what I’m describing. here’s a link: https://youtu.be/8STFz7lbVS4?t=702

And I will describe what I’m trying to achieve with my controls here:

With WASD, you can move forward, backwards and sideways one tile at a time . You use IJKL to turn the character making them face one of the directions above and you use the mouse to have a “free look” cam where you can look around without turning the character. Lastly, you press Z or Mouse-Click to actually attack the enemy.

So far, this is all I have:

You can check the vid to see how it compares to the Madoka Magica game I’m trying to replicate.

Thanks for the response. I will check this out and see what I can do.

One problem I am having is I try to put in a breakpoint to see how these things run, but by doing so I think I interrupt the mouse hover location and it doesn’t run properly. Any advice on where to put a breakpoint to trace moving and shooting actions?

Let me try to rephrase my issue here.

When playing the game, I am moving the mouse around on the grid to have a character either move or attack (or end the turn). When I click on the grid, I expect some “action” to fire; like “move” or “attack”. From what I have been able to see, that action is “moveAttack”.

My question is, where in whichever blueprint is the logic that handles “they player just clicked here, so perform action moveAttack”. What I am expecting is something along the lines of click > determine action > fire action.

I hope this is clear.

I am really trying to figure out how actions are handles so that I can customize them, but I am struggling because it seems that whenever a player’s turn is up it is “activated” without the player deciding to do anything. I don’t really know how else to describe it.

Edit: After thinking about it, I think what I am looking for is which blueprints handle the main game loop.

I assume it goes something like
While( game not over):

  1. Go through each character - the turn manager does this
  2. Take input from the character’s controller - I don’t know where this is done
  3. Determine an action for that input - I don’t know where this is done
  4. Execute this action - BP_Ability_MoveAttack seems to be doing this, as it’s the only ability I can do
  5. Check if the game is over - I don’t know where this is done

Steps 2) and 3) are where I’d really appreciate some information.

Thanks!

Oh this is the function that I want.
Thank you, but there is still a problem.
If you look at the attached screen shot, the index that fails to move because Unit Size is 2, is still displayed as a movable area. Tell me how to fix it.

Hi, Monokkel! I have bought the Kit around a year ago but only got to play with it recently. Yours is perhaps the best offer in the entire marketplace!

Anyway, do you have any general tips on how to implement the knock off effect? Like a grenade shockwave that pushes the enemy 1 tile away from the explosion. Or something like a pull effect which pulls enemy to a specific tile? Maybe something like a Roadhog’s hook from overwatch

Whoa, lots of questions since yesterday. I’ll get to them.

Ok, thanks for giving me the details. If you’re running pathfinding at such extreme distances that you’re hitting the max loop iteration count, I would seriously consider converting RunPathfinding to C++, but if you want to test out splitting up loops I’ve given you the way to do so. Let me know if you run into any issues on the way.

The game looks similar to the old Eye of the Beholder games or Grimrock. I did play around with adding movement like this a couple of years back. This is the sort of game where you would want to throw away a lot of the toolkit’s code. You could still use the general grid system, of course.

For movement you would disable the camera controls in BP_PlayerController_ATBTT and instead send the WASD input to the unit the player is controlling. When pressing W, for instance, you could then get the location one tile-length in front of the player unit (using the forward vector of the unit or camera, perhaps) and converting this location to a grid index (by using ConvertLocationToIndex in BP_GridManager).

With this index you could check if GridUnits is occupied. If so you can trigger your attack event or function. If the tile is empty you can check if the current tile you are standing on (you could get this through GridIndex of the unit) has an edge in GridEdges connected to the tile in front of you. If so you could move the unit by lerping to that location.

For free camera look there are several tutorials on this for Unreal Engine other places, and this would not need to be altered for the toolkit.

Beware that this conversion will be a lot of work and I would not recommend attempting it unless you have a really good grasp of blueprints. If you want to try this, though, let me know if you run into any difficulties.

That is a bit tricky if you need to test out hover events, but for click events it should not be an issue. Try adding a break point to the Set node right after InputActionClick(Released) in BP_PlayerController_ATBTT and step through the event graph from here.

Follow my suggestion above with the break point and you’ll be able to see the whole execution chain, which should hopefully clear up the ambiguity. MoveAttack is the ability units have by default in the toolkit (defined in the units’ DefaultAbility variable). When a unit is activated its default ability is activated by the player controller (called from the unit), which spawns an instance of that ability if needed, calls the Activate event for the ability and sets the active ability of the player controller to that ability, causing further input to be sent to the ability. Explaining every step of the process would be very cumbersome, and it is probably more helpful to step through it yourself with breakpoints as suggested. Also make sure to watch my ability tutorials if you have not done so already.

Hmm, I see. This seems to be a problem with the default big unit stuff, as well (without the modifications we have discussed). I cannot immediately see what is causing this, but I’ve put in the bug list and will try to fix it in the next update.

Once you know what tile you want to push/pull to, the effect is relatively simple to implement. For the game logic all you need to do is to remove the unit from the grid and re-adding it on another tile (you can use the RemoveUnitFromGrid and AddUnitToGrid functions in BP_GridManager). To animate the push happening you can add a new AnimateAction name option to BP_Unit, which takes the end location of the push as input and lerps the unit from its current location to this location.

Finding the appropriate tile can be a bit more tricky, though, and your approach here will depend on the specific effect. For a pull effect you could for instance take

( Location(PulledUnit) - Location(PullingUnit) ) to get the distance between the units. You can then normalize this vector and multiply it by the width of a tile (200 by default) to get the location of the tile adjacent to the pulling unit which is between the pulling and pulled unit. Then you could convert this location to a grid index with ConvertLocationToIndex in BP_GridManager and use this as the grid index you add the unit to when you pull it. This could for instance be done in ExecuteAbility for a pull ability. Hope this gives you some ideas to build upon.

In other news, a game that used ATBTT in its creation was released on Steam today. It is called Forged of Blood and is a deep tactical turn based strategy game, which includes a lot of interesting systems such as spell crafting, a strategic map and extensive skill trees. A lot of work has clearly been put into this game and I recommend checking it out! I’m not being paid anything to market this or anything like that, but I just love keeping up to date on the various games that have put my toolkit to use and I’m super stoked to see this one released :slight_smile:

Here is a link to steam for those interested and their trailer:

https://youtube.com/watch?v=6Jr7ZCM8Y9E

We changed game design to not involve more than one combat per level for now as we’re working under heavy time pressure - will look into that later on. Yeah we broke something with the hover code, trying to find out via breakpoints.

One more questions about abilities: we implemented a weapon switch functionality which changes the abilites in the unit’s ability array - it works game play wise but the icon in the ability bar is not updated accordingly, some hints on how to achieve that?

Okay, though let me know when there is something else I can give input on. I thought about the issue you were reporting with the units seemingly attacking before moving. This is generally caused by passing an action to the unit that is not defined in the name switch after AnimateAction. For BP_Unit_Anim any name not in the switch is immediately passed along to the animation blueprint. The default behavior of the animation blueprint is the attack animation. It seems that your two issues might be related, as passing undefined actions to the unit can also cause the action queue to halt, which prevents you from animating new units once the new turn starts (which is what you saw with the game being stuck in WaitForOngoingActions).

To update the ability box after switching weapons, queue the UpdateAbilityBox action in BP_Unit (and InitializeQueuedActions in the action manager if this is not called otherwise)

That’s a good hint - we’ll check the switch thanks! Ah - as we’re using child classes of BP Unit Anim I simply missed there’s such a function in the parent class although it’s still not working the desired way - will get in touch later

Hi, I just purchased the Advanced Turn Based Tile Toolkit and am working to integrate it with my project. For my project I would like players to be able to explore/craft/etc… without being in turns and use the turn-based system for combat. I was reading through this thread about how to implement this and am undecided on how to proceed. Is there a tutorial somewhere on how to implement these changes? Thanks

The new version , especially the turn manager (strategy mode) is fantastic!
Again I’m wishing climbing could come to us very quickly, hope it comes true :slight_smile: