[SUPPORT] Advanced Turn Based Tile Toolkit

I’m trying to make one with more-generic turns, where Player X uses any number of units (who haven’t already gone this turn), in any order. Then the next player goes.

I think it lets me do this by default by turning off the initiative bar, but it also lets me (for instance) move Unit_1 without attacking, click Unit_2 and move Unit_2 without attacking, click Unit_1 again and he has full move again on the same turn.

In addition, when I have Unit_1 active and I click Unit_2, sometimes it moves Unit_2 one tile away in the direction the camera went (with one fewer action). Perhaps the camera movement is moving the mouse cursor?

Two more tutorials are up! One on the Turn Manger and one on the Ability System. The three new videos have a total runtime of over 2 hours. And here my original idea was to create smaller, bite-size tutorials, but oh well. These tutorals, named ATBTT Blueprints - [blueprint name] are my attempt to make something similar to my old, huge blueprint video from 3 years ago, but split up into different videos for each subsystem. These videos are pretty dry and not very creative, but they give a detailed walk-through of the blueprints which will hopefully be useful. I intend to eventually complement these videos with other tutorials that have practical examples of how to use the systems to add your own stuff to the toolkit.

Turn Manager:

Ability System:

Ok, cool. I’ll join the discord, but cannot promise to spend much time there in the coming months.

Hmm, what you are describing should work by default, so something is not right here. Could you give me the steps to reproduce this bug? What ability are you using? What are the factions of the unit placed, what are their initiative values etc.

I’m in the default setup, map name: Example. I have Use Initiative set to off. The 6 default guys are set to: 3 CPU enemy faction, 3 Player Controlled. Players are set to 101 or 100 init. AIs are set to 0. I can take infinite moves by not attacking. I’m not sure if moving is set as an ability?

Hi, I’m using the latest version of UE and when I use the Jungle Raid map there are no cover system icons. Is there a way to enable them to inform the player the cover system is active?

Hey man, thanks ALOT for the new tutorials! Will certainly be spending some time with these, 2 hours of packed logic might take some time to sink in :smiley:
Cheers man!

Hmm, I’m not seeing what you’re seeing. The initiative bar should not affect initiative order at all. There is no “Use Initiative” variable, only one for using the initiative bar, which is just for displaying the order. You are using the latest version and have not made any other changes to the example map? This is what I’m seeing:

https://media.giphy.com/media/lzQgDqvh2Ysq5gLLJQ/giphy.gif

Hmm, again not what I’m seeing on my side. Everything seems to be working fine. You’ve created a fresh ATBTT project and chosen 4.20 after CreateProject?

No worries :slight_smile: Still need to make plenty more, but hopefully this will be enough for a while.

Yup, I redownloaded and the problem disappeared. Sorry for the trouble. I must have had an old version.

Speaking of which, since there are new updates on the way, how can I best integrate them as they come?

I am sure it will!

A quick question, has the functionality for moving in sections in one move been readded? (I mean, say you can move 6 tiles, you move 2+1+2 then end turn all in the same movement turn).

Cheers!

Hey ,

I am looking to spawn the grid then have a different camera possessed so I can move around in the first person before entering the turn-based grid via a key press.

I’ve looked around and can’t find the best place to spawn my new camera in the Player Controller blueprint. Any clues?

Kind regards,
Drewbie.

Ok, good to hear :slight_smile: You won’t have to worry about any big updates coming for a long time, though I may add some minor ones; primarily with bug fixes. Since I will probably only add minor, additive features if any, the best idea is probably to copy these over by migrating and copying nodes. For larger updates I usually recommend migrating your own additions over to a fresh project, since you know your own additions best. But as mentioned, that would not be needed for a long time, since I’m unlikely to find the time to do serious work on the toolkit until after Christmas.

Yep, though it has been added a bit differently. Splitting up move used to be defined within each unit. It has now moved to be part of the ability system. If you want a unit to be able to split up its move, you design the ability so that it interacts with action points the way you want. If you look at BP_Ability_Move it is set up by default to work the way you are describing. You could duplicate this ability and use it as a base for your own.

Ok, this was a fun little challenge. Turned out to need a few more steps than I assumed. First in BP_ATBTT set the default pawn class to whatever pawn you’re using for your custom camera. You can use the built-in DefaultPawn for testing. Then, disable ActivateATBTT from activating at begin play in BP_ATBTT. Next enable tick events in BP_PlayerController (in class defaults) if you use tick events in your pawn (this is the case for DefaultPawn). Lastly disable the BeginPlay event in BP_ATBTT and instead have it trigger on a custom event, in which you also spawn a grid camera, possess it and run ActivateATBTT. Here is an example in BP_PlayerController_ATBTT in which I go from the free camera to turn based combat and the grid camera by pressing X:

https://i.imgur.com/7UNUDsj.png

Hope that gives you your desired result :slight_smile:

Hey @, I’m doing a bunch of client-side only things like planning moves for simultaneous turns.

I want to do as much as possible client side before sending things to the server. However since gridmanager only keeps gridUnits on server side, this requires constant back and forth between server and client, on every click, and potentially every hover.

Is there a way to simplify this? Can I get GridManager to RPC the ActivateGridManager call so both client and server have the same data to use? Don’t really care about cheating as I am just prototyping.

I’ve tried making ActivateGridManager multicast (or replicated on owner) and neither works. This only ever gets called on server.

Hi mflux, replication in UE4 takes some getting used to, but is structured to be both efficient and cheat-proof. As I’ve discovered myself, trying to fight against the way UE4 wants to do replication is very difficult and frustrating, and there is always a good reason why things work like they do. You should try to keep only input and what is displayed on the screen client-side, while the server should handle all important game logic. Even if you’re prototyping I would recommend doing things the right way from the start rather than finding out that a lot of your replication hacks do not function when you refactor later. And yes, this involves using RPCs quite a bit to pass information back and forth between the client and the server.

I agree that there are some parts of the grid manger that might benefit from being exposed to the client, though. Specifically I think hover events in abilities is a good candidate, since it can potentially fire several times a second if the client quickly moves the mouse over multiple tiles, which can make the response look less smooth if every new tile hover has to be passed back and forth, for something that is only for client display and does not affect the game. However, TMap variables, such as those generated by the RunPathfinding functions, cannot be replicated in UE4. You would want to pass all the information in the pathfinding map to the client when the client activates the ability so you only have to do so once, but you would first need to convert it from a map to two separate arrays or something similar and then pass it through a RPC.

There are a few things that can only be done on the server in UE4, so I’m not surprised that ActivateGridManager does not work on the client, without being able to point to exactly what part of it does not work. In any case I would not want to store all the grid sized maps etc. on all clients as it is a waste of memory and insecure.

Perhaps you can tell me of the specific things you are having trouble implementing using RPCs and I can suggest how to solve it in a way that works both with my toolkit and UE4 replication?

By the way, if you have not read it already I highly recommend the guide by @eXi which explains in detail and in an understandable way all the most important stuff about networking in UE4. You can find it here.

Another 40 minute tutorial video. A result of procrastinating from the stuff I should actually be doing, but I think this one will be useful. This is another one of the dry, thorough blueprint-videos. Though I feel these are the most necessary to make I do plan to make some more hands-on and fun ones when I find the time.

This video is a continuation on the video about the ability system. In this I show how the AI uses abilities to drive behavior. Hope you like it!

Hey @ !

A question now regarding the new flow of the blueprints. In my game the monsters (AI) will spawn based on the number of connected players. The player will also spawn based on a selection of tiles defined by the level creator. This you have helped me with a few months ago. My question is now:

Where makes the most sense to put this logic? Earlier I had it in the BP_ATBTT (GameMode) which made sense due to how UE4 Docs says GameMode should handle spawning of characters/pawns, score of the game etc.

Also, just a question out of curiosity: Why is the Turn Manager an own Actor instead of using the GameState for all the Turn Manager logic? (Just wondering cause when I think about a Game State, I think about all the logic the Turn Manager handles).

Will dive in on your latest tutorial soon, just need to let the previous ones sink in first :slight_smile:

Cheers!

Don’t have any big recommendations for where to spawn units from, really. The game mode has some benefits in that it can only ever be owned by and exist on the server, that it cannot be destroyed and that you have access to it from anywhere. But as long as you are careful about which clients you give access to what actors I think any event called from the server in any graph should be fine. I’m by no means an expert on all things networking, though, but that is my answer based on what I know.

As for using the game state as a turn manager, that is actually precisely what I did when I first started experimenting with the big toolkit refactoring. I did this based on the suggestions I had, like you, read about it being a good place for handling the current turn etc. However, after a lot of back and forth I decided to use a separate blueprint for a number of reasons. The game state is mostly an extension of the game mode for stuff that all clients need to have access to, and there is a lot of stuff in the Turn Manager that is just for the server, so I felt it was a bit misplaced. Also, I wanted to have access to things like having a current unit marker controlled by the turn manager and running animate action events, which does not work in the game state. So a number of small reasons made me switch from using the game state to instead use a custom blueprint spawned by and referenced in the game state.

Hi ,

Thank you very much for the awesome framework!! It’s so much it get’s overwhelming pretty fast :smiley:

I am trying to make an ability for a player that after he moves he needs to build blocks on a tile. The player can never build more then 3 blocks high and can never “jump” from the ground to a 2 level high block. So has to be from the ground to 1 block on to the second etc… when a player reaches the third block the game is over.

Do you have any pointers how I should start this please?

Thanks a lot.

Hi Studder, happy to hear that you’re enjoying the kit :slight_smile:

What you are talking about essentially boils down to modifying the GridEdges array in BP_GridManager, as well as GridLocations.

The toolkit is represented by a bunch of arrays. Grid locations holds the in-game location of each grid index. If you have a 3*3 grid, then the top left index will be 0, the next to the right be 1, the one below 0 would be 3 etc. Like so:

0 ] 1 ] 2 ]
3 ] 4 ] 5 ]
6 ] 7 ] 8 ]

so that is a 2D grid. When adding multiple levels, the tiles on the second level would equal the tile below it plus (GridSizeX * GridSizeY), so the tile directly above tile 2, for instance, would be 11 in this example. However, from your description it sounds like you do not need multi-level grids. Rather it is really just a single “level” in the sense that a unit can never stand on a tile directly below another unit (am I right?).

If so it makes things a lot simpler. So to start with you would have a grid like the one outlined above, where each tile would be connected to each of the others as defined in the edge array. The edges represented like lines would look like this:

0 ] - 1 ] - 2 ]
…|…X…|…X…|
3 ] - 4 ] - 5 ]
…|…X…|…X…|
6 ] - 7 ] - 8 ]

So if we looked at index 3 of the GridEdgesArray we would find that it would have 5 elements, one for each edge. If we looked at their values they would be 0,1,4,6 and 7, with edge costs of 1 by default. This is our starting position.

Now lets say a player wants to raise the tile at index 4 to the next level. This would first entail placing the block mesh, of course. After that you would need to modify the GridLocations TMap in BP_GridManager so that the index had the appropriate height, or units would just more right through it. So you would remove index 4 of the map and then add a new vector at index 4 with the same X and Y as before, but with Z at the same height as the top of the box.

Since we’ve just gone up one level the edge array won’t be affected in this particular case, if it is, as you say, where tiles at the ground level can always move to level 1. However, it might be that index 5 has already been raised to level 2, in which case we would want to modify the edge array, so whenever we add a new block we want to check if the edge array should be modified.

Now how do we do this? Pretty simple, actually, thanks to a couple of functions included in BP_GridManager. First use GetIndexesInRange with a range of 1 to get an array of all surrounding tile indexes. Then loop through this array and for each index get the associated value from the GridLocations TMap. Subtract the Z location of each tile to the Z location of the center tile and get the absolute value. If it is below an arbitrary threshold you want to add edges between the tiles (if there is not an edge there already). If it is above you want to remove the edges (if they exist).

To add and remove edges is simple. Use the RemoveTileEdgeBothWays and AddTileEdgeBothWays functions in BP_GridManager. There are already checks in place to make sure a tile is not added twice. For these functions input the grid index of the center tile and its neighbor. The order does not matter. You want to use the “both ways” function, as if you only add or remove one way you will still be able to move one of the directions.

Hope that helps!

Thanks for the explanation.

I have made a copy of the ability move.

I want to have each player to have two turns or actions it can do one to move and the other to build something. The player should always only be able to move 1 index. Now I played with the Max AP , Current AP settings but I can’t get it right to have two turns. Cause when I change the Current AP to have more turns it also changed the tiles it can move and I want only the player to move 1 tile.

Also what would be a good place in the click event graph to know when the move actions has been completed and to draw the ScaleMarkers again to be able to build something?

Thanks in advance!

How action points are handled is pretty much up to the ability to define. If you never want to have a move longer than one tile, then set the move input value of the RunPathfinding function that runs on ability activation to 1. That should solve the move range problem.

Now if I understand you correctly you want the player to be able to do two things: First move a maximum of one tile and then build a block. You could set this up using action points in a similar way to how I’ve done it in BP_Ability_MoveAttack. Set units up to have 2 AP by default. On ability activation add a switch on the current AP value of the owning unit. If it is 2, run pathfinding with a range of one, display the tiles etc. If it is 1, instead show the tiles you are allowed to build on. You could potentially do this in a similar way to how BP_Ability_Attack activates.

Then in the click event graph again check the current AP of the unit. If it is one, proceed with checking if the clicked tile can be moved to and move to it if it can. If AP is 1 instead check whether it is allowed to build a block on the selected tile and proceed with whatever code you have for doing this if true.

Good day, I’ve bought the Toolkit just a few days ago and I have a question/issue

I started a new project from the toolkit , everything is defaults, and it automatically opens the EXAMPLE map.

Now it this map I have 3 players (and 3 enemies, default)

My problem is that.

I move my first “character to a certain location” … after moving it then switches to the select attack tile… BUT when i do not attack and just “click” on another of my characters and move them (and also not use the attack) I AM able to click BACK on the first character and move IT (it is like it did not CONSUME its movement cost)… is this default behavior?

So i can pretty much use INFINITE moves as long as i do not use the attack function… is this default behavior or is ther something wrong?

I am using Unreal engine 4.19, and also used the “Create Project” button/link in the VAULT list.

also. where do i start on Customizing the Units?

i tried adding something on BP_Unit_Anim_Auto ( i added a floating widget that is supped to update its rotation to face camera EVERY TICK) but it seems like the Tick event is not even called?

can somebody point me to the right “way”. as the youtube tutorials seem to be very far off the current state of the toolkit.

also would using unreal 4.18 make things easier? (ive read that it uses the OLD toolkit)?