Download

[SUPPORT] Advanced Turn Based Tile Toolkit

hi knut

For some reason, I find it difficult to apply something that I thought will be simple enough, I hope that you may be able to direct me to the right place.

I tried to create the effect of the outline for the tile marker (similar to your 2d example)

I used the PostProcessVolume in the level and used the PP_Outline but its not working.

can you explain the steps I have to do to make it work?

By the way, the last upgrade you did to the turn manager really fixes a lot of the difficulties that were in the past (I have not checked it In depth)

thanks in advance

leo

leo

Hey all, after looking into the big unit stuff for @jh0620 I realized that I’d forgotted to fix something in the newest update, causing marker meshes to not resize and reposition appropriately for big units (this is unrelated to @jh0620’s reported issue, which I have not been able to replicate). I also tested out a few other things and realized I was a bit quick to send out the last update without doing some more testing. Just some very minor changes related to the example maps (Hydra’s Lair and JungleRaid). See my Trello for details (see the v.2.31 card). I have sent a new update to Epic already.

Here are the steps:

  1. Copy the PostProcessVolume from the 2D map
  2. In whatever ability you are using select the TileMarkers you want to render in custom depth. Set their material to something non-translucent (DefaultMaterial, for instance) and in its rendering settings set RenderInMainPass to false and RenderCustomDepth to true.

That should do it. Note that it can often look a bit wonky in a 3D-world, though, but it depends a lot on your levels.

thanks knut, didn’t put RenderInMainPass to false. its working fine

cheers

leo

I’ve tried this method a couple times and despite the output log verifying a random index from said array per iteration on the forloop, the entire grid’s tiles still instantiate from one sole element from the array. Any idea why this may be?

output log

modified bp

Thank you for responding. I hope to achieve multiple effects such as allowing a unit to move again, giving them an ability and/or to do damage around them. Also when tested out my current panels it should give them an ability however it seem that instead of the unit’s hitbox registering it hitting the camera hitbox instead for passing on an ability.

Jolly good

You have not fully understood how instanced static meshes work. When you create an instanced static mesh component, all instances tied to that component must use the same mesh. You are changing the mesh of the component, which causes all instances tied to that component to change. If you want different tiles you need multiple different components (one for each mesh). You can use multiple AddInstancedStaticMeshComponent nodes, set the static mesh of each and store the output (of AddInstanced…) in an array of instanced static mesh components. Perhaps you have three instanced (grass, dirt, stone). When you want to add a stone tile you would get element 3 from the instanced static mesh component array and add an instance of this component to the world.

I recommend checking out the 2D example (in the Maps/2D folder). In this map there are examples of picking up weapons, healing potions and trigger plates.

Hello, been following this since i purchased it some time ago. I like that it keeps getting updates and improvements. I would like to make a hex grid that is not rectangular in shape, but “hexagonal”, that is, it extends out a radius of hexes from a central hex. Does ATBTT currently support this and I don’t see it? If not, is this something that is doable with minor tinkering to the hex grid BP?

Hey Luthervian, you could do this by using a rectangular grid and just not spawning tiles on the corner locations. This is what I have suggested before, but I had some free time today, so I threw together something a bit more elegant.

First in BP_GridManager_Hex I set GridSizeY to always equal GridSizeY, as this would always be true for a hexagonal shaped grid:

Next, in the CreateGridLocations function, I use GetIndexesInRange (which is overridden to use hex math in BP_GridManager_Hex) to get grid locations in a hexagonal shape. I use some simple math to find the center and radius of the hex grid (note that I’m just replacing the code for a flat grid in the example below, but the same should work for the heightmap setup in the same function):

Next, in SpawnTileGrid I spawn the tile instances using the output of CreateGridLocations:

Finally, I make sure CreateGridLocations is run before SpawnTileGrid in BP_GridManager’s Construction Script:

Et voila:

Fast reply and extremely helpful and informative, thank you! I’m struggling with figuring this stuff out so this was very useful - again, thank you.

Hey Knut - still unable to figure out the initiative problem but we got something different to bother you with :(:smiley:
For some reasons the walk path spline and the cover markers when hovering over tiles are only displayed when holding the right mouse button - have you ever experienced something like this?

Happy to help!

What was the result of my last suggestion for the turn order stuff? What is the last action printed?

For the right mouse button stuff, what you’re seeing is probably the suggested path. In MoveAttack and some other abilities I added the option to display a suggested path (using the AI functionality of that ability). So I guess that part is working as intended, but you’ve somehow broken something in the regular hover functionality? I’d recommend printing strings along the hover execution chain (starting in the player controller, through Ability_Base, Ability and the specific ability you are using to see where it breaks.

Thanks for your reply - will check out your hints tomorrow - one more issue we found: AI controlled units somehow start their attack animations way too early - during the first moments of movement towards player faction units - seems like we broke a lot here :smiley:

Hi, Monokkel

I’ve been I’ve purchased your plugin and I have been trying to go through the tutorials and the example maps but I am having a little trouble. First off I can’t find the map Bunkers or the Heightmap_example folder. Also in the Jungle Raid demo map, when I play it, no UI shows up on the screen and once I move the first unit, all the units just start moving themselves in a never ending sequence, even my team. What am I doing wrong?

Thank you.

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.