[SUPPORT] Advanced Turn Based Tile Toolkit

Ok, I’ll show you what you need to do. I’m sure you’ve made some small mistake which will hopefully become clear now. You want to rotate the unit when it has ended its move and clicks a an empty tile. By default this ends the unit’s turn, so you want to have it rotate before the turn ends. The logic determining if the unit’s turn should end when a tile is clicked is held in ATBTT_PlayerController, so that is the simplest place to add the rotation code (though calling a custom “rotate unit” function in the unit blueprint might be more “correct”). I’ve added these few nodes to the event grah of the player controller, in the Initialize Movement - Step 1 comment box right before End Unit Turn is called. Here they are:

I apologize that it does not really make sense that End Turn is called within a comment box saying initialize movement, which is not really intuitive. This is one of the many things I’m cleaning up in the big refactoring I’m doing.

Let me know if it works like you want it to.

Hey . Have you played with the 4.16 preview at all? I’ve been working in it for a few days and I haven’t been able to trigger the bug where all blueprint actors in a map lose their non default values. Have you run into that issue at all on 4.16?

Yeah, most of the work I’m currently doing is on the 4.16 preview. I’ve seen the bug many times on my end, I’m afraid. I believe it wasn’t marked as resolved in the Unreal issue tracker either since Epic was not able to replicate the issue. Still a good sign that you are not seeing it, though.

I probably just got lucky, that’s disappointing to hear. I was really hoping they finally nailed it.

That is exactly it. I was close pretty close except for getting the “Vector Field Array” and calling everything in that spot in the graph. Thanks once again for your help.

The majority of the game is completly playable and done, but of course ONLY IN THE OLD ENGINE. (So around 80 maps: poland till stalingrad - for comparision: Panzer Corps 2, which is beeing developed now in the ue4 will have only 20 maps) Some Campaign “Sideways” f. ex. when you are **degraded and beeing transfered from russia to africa **have to be done, the invasion of the usa too, but in the old 2D Engine you could package the first three parts of the game. (if i release it someday with the ue4, i plan to release it in parts: 39,40,41 etc.)
Creating the levels in UE4 is no problem, but the ai, and the tb system will be difficult (surprisingly the old 2D Enigne of Panzer Corps 1 does relativly well reg. AI, Pathfinding etc) and I dont know if i will ever get the necessary programming skills for that ambitious project. Since i am more the artist, writer and design guy, maybe i will have to look for help. So to answer your question, the planning phase is long over, the game is ready to be sold, but only in the old engine, where i am not allowed to sell it. In UE4 i am in the learning phase, i did 60 tutorials and i will do additional 140. After that i will know, how far i can get with my ue4 skills.

So your ATBTT will be of great help, but first i have to become much better reg. blueprints. Then your work could be the foundation for mine.

Regarding the artillery example: It´s not that easy, ai has to plan future turns, because its not enough to be one tile away of the enemy. Idealy it should analyze which kind of enemy it is and if the enemy can reach it in the next turn. (tanks are fast f. ex.) Then ai should place defence units like antitank guns to keep the tanks away. In defence thats no problem, with the old 2D Engine, because i can set the arty to “hold position and just fire” and place anti tank guns in front of the artillery. And add a skript like "if enemy kills one anti tank gun, retreat to another prebuild def. pos. with anti t. guns).
But large counteroffensives with many units acting together, thats so much harder. Maybe its wise to combine the units of one pincer and treat them like one big unit. So the wedge formation f. ex., while moving, could be maintained, mostly. And when the pincer has contact with the enemy, every unit will be treated like usual.

Real learning ai in a tbs, that would be my dream. Hopefully i will see that before i die.

Master of Orion 2 is a special game. It´s the genre primus reg. 4x Spacecivgames for two decades now. Many companies tried to release a modern, better game of that kind and all failed. (Mostly because of dumb design decisions, like developing an rts battle system with nearly no depth and challenge, instead of a much improved turn based system, or its just autobattle what i regard as total fail) If you don´t know, go check the game Alpha Centrauri. Its a mixture of Civilization and Master of Orion and is still regarded as the tbs with the best ai ! Jagged Alliance 2 is in many regards like X-com. X-Com has the better grafics, JA2 the better gameplay, and a dynamic campaign. Those games are pearls, that every designer should know.

I am starting with a simple zombie game, which i have tutorials for. Second i try to recreate the orig. castle wolfenstein. (i should be able to create better grafics :slight_smile: )
Its a pity, that the tbs tutorial of epic games is no longer available. :frowning:

Last but not least, thanks for your answer.

Well, I have actually not encountered this bug again since I replied to you last. It only happened consistently and repeatedly with one old map I was working on. Maybe there is reason to be cautiously optimistic. Let me know if you encounter the bug again.

Glad it worked :slight_smile: I hope the reason it now works when it didn’t before makes sense. Let me know if you want me to clear up anything.

Ok, neat! Having a completed game to work towards replicating will probably be very useful. A common recommendation for new game developers is to attempt to recreate an existing game, and in your case you will have created the game you planned to make in the process.

I’m quite sure it will be very useful to you as a foundation. I’ve tried to keep it as flexible as possible so that it can be used as a base for many sorts of TBS games.

Ok, I see. Designing AI is both tricky and fun. One important thing to remember is that it matters more that the AI looks intelligent to the player than that the AI is super complex and carefully evaluates all possible actions it can do. There are often many ways to slightly fake it and use heuristics.

I am aware of all the games you mention and know what they are about, but have just not played all of them. It is on my to-do list, but the last couple of years playing games has taken a back seat to making games. I still play games when I have the time, though, and when I do they tend to be TBS games.

Seems like you have a good idea of how to best learn the engine. Watching tutorials and making simple games is a great plan. Best of luck, and when you begin making your TBS feel free to ask questions in this thread anytime.

My pleasure :slight_smile:

I’m hyped too. If you can pop out multi tile units on their own before the next major update that’d be awesome.

E: How do you calculate movement costs for large units currently? Take each cluster of four, add their costs, and then divide by four?

Movement costs is the one thing I haven’t really figured out yet. Partly it is because how this is implemented seems to differ from game to game. In some games big units are slowed down if any of its tiles enters a tile of difficult terrain, while in others the unit ignores difficult terrain unless all occupied tiles are difficult terrain. The other issue is that tiles in the toolkit can have varying costs depending on which direction they are entered from. This means that I cannot simply check all occupied tiles and see if they have a cost or not, but I have to check several different edges. This quickly becomes very costly, and multi-level grids makes this even more difficult still. I will try to find a way to precalculate these costs so that there is no performance impact during actual gameplay, but I still want something that is fairly performant during setup. I will find a solution and have a few ideas, but I’m not sure what I’ll end up with using.

One of the things I’m trying to do while refactoring is making the grid manager functionality independent of rotation, location and scale. This makes it easier to use the toolkit in games where the turn based strategy board is not the entire focus of the game, but could be a board game placed on a table in a fps, or something similar. It is also beneficial in VR games where having the possibility of rotating and moving the game board can help users with smaller VR playspaces play large virtual board games.

I’ve pretty much got it working at this point, but I thought I’d share a gif I made when I was still figuring things out and accidentally created a simulation of what being sucked into a black hole might look like :stuck_out_tongue:

My brain does this every time I look at your AI blueprints.

Hehe, yeah I’m assuming you’re thinking of the AI in the sci-fi game example. It is pretty complex compared to the AI in the base toolkit. The game examples are a bit of a playground where I experiment with adapting the toolkit to various genres and the solutions in them are a bit more experimental and often a bit more convoluted than the base toolkit functionality. One of the thing I’m doing in the next update is making the skill system a part of the base toolkit and in the process I’m trying to make it easier to understand and manipulate.

The general idea of the AI in the skill blueprints is to first identify all possible targets, then weight those target based on some criteria decided in the skill and assign a value based on this. Then either that value is stored to be compared to the calculated value of other skills or the skill is executed, at which point the AI unit also finds the optimal tile from which to use the skill, based on cover, distance from enemies and specific criteria based on the skill being used. That is a lot of stuff to go through, so I understand if it is a challenge to understand initially.

I think I’ve failed to mention that the toolkit works fine in UE4.16 preview. Just open a 4.15 copy of your ATBTT project in 4.16 preview and it should work without any errors (though let me know if any of you spot any). As per usual I won’t send a new version to Epic until the full release of 4.16 is out. If you decide to work in the preview make sure to back up your work as you should with any project.

Hey @, bought your toolkit a while ago but only just getting around to playing with it now. It looks incredibly robust! I can’t wait to see what can be done with it.

Currently, I’m trying to figure out multiplayer. I’d really like to do this using the UE4 SocketIO plugin, where I can send information to and from a remote Node.js server. From what I can see, I think this is the easiest way I could add multiplayer to this toolkit: if I can somehow just represent another player’s units as inert AI which moves based on some input from the server, I’ll have that set.

I’ve figured out right now how to get the index of the tile a player clicks on and send it to the server. I suppose my question is, what’s the easiest way to just tell a Unit to “move to” or “attack” a particular index? It looks like a lot of this logic is coupled to the player controller, of which there will only actually be one in the game. Thanks again for such a great tool.

EDIT: basically, the easiest way to do what I’m trying to do here would be if I knew some way to try and force, for example, a unit to try and move towards a particular index. I tried modifying the AI controller to do this, but I want some results that work irrelevant of trying to target other pawns on the grid.

Hi @Rockhopper, I’m glad you like the toolkit! Networked multiplayer is actually one of the things I’m currently working on myself. I’m not using any plugins and sticking with UE4’s built-in networking. I’ve got it more or less working like I want at this point, though it is still a bit rough around the edges. In general terms, what I’m doing is do most things on the server, including all calculations such as pathfinding, visibility, whether a clicked tile can be moved to etc. (this is essential to prevent cheating). Input is handled from the player controller, but unlike the version of ATBTT currently on the marketplace I do not do things like check the cost of the clicked tile, the move value of the current tile or anything like that. I just convert the clicked location into a grid index and do the rest on a server only event in a separate, replicated actor.

@ wow, that’s great! This toolkit just gets even better if the built-in multiplayer works.

Unfortunately, for this application I’m already using significant server logic a team member wrote for a SocketIO Node.js server and will need to stick to implementing multiplayer this way. The multiplayer isn’t that important though, what I can’t figure out is how to create something different from the AI Controller which is basically “scripted” motion.

For example: do you have any ideas for how I might be able to tell a unit something like, “go from your current index (3) to index 0, taking the path through 2 and then 1?”

We’re going to use the PlayerController from your toolkit and have one player just use it as it is. When one of their units move, it emits its path data to our server, is verified by the server, and passed down to other clients to move these “scripted controller” units accordingly. This way, as far as UE4 networking is concerned, our game is entirely offline. The motion of certain units just correspond to actions taken by a remote player. Hopefully this clarifies my actual question, thank you for taking the time to answer!

@Rockhopper: Thanks! It will be quite some time until the next update is done, so if time is of the essence using your own solution is the best idea anyway.

For having a unit go a custom path, here is a simple solution. In this case I’m calling it from the player controller, though it could be called from anywhere. You would probably use a less hard-coded way to make the int array, but you get the idea.

Your explained solution for networked multiplayer seems reasonable. I’m not sure if you have solved all the issues you were asking about, though. Do you have any remaining questions?

@ thank you so much! I’ve been trying to figure that out all day. I literally just got to the point where I figured out that I was never setting “Path Index Array.” I confused myself because when I searched your blueprints I could only ever find examples of that variable being retrieved, never set. Would you mind clarifying where that typically gets set, just in case I run into any other issues?

Also, with my current approach I’ve created a new ATBTT_RemotePlayerController holding this logic and added a new setting to select which controller to use. I think I’ve updated all references to the “AI Controlled” boolean to account for this possible third controller. I haven’t had enough time to dig fully through all of the blueprints or wrap my head around all of your tutorials yet, though. Do you foresee this approach having any fundamental issues with parts of the toolkit?

You’ve been a great help.

Happy to help! I apologize that it is sometimes unclear when certain variables are set in the toolkit. This is one of the thing I’m working hard to improve in the next update. I’m making it so that variables are very rarely set inside functions, but are instead added as output to the functions so that it is more transparent and so that users can more flexibly choose how to use function output.

For the time being, though, I recommend using UE4’s Find References functionality to find all instances where a variable or function is used. If you are not aware of this you can right click any variable or function and select Find References to find all such instances (unchecking find in current blueprint only is often a good idea as well). If you do this you will find that the only place the Path Index Array is modified is in the Find Path to Index function in BP_GridManager. If you again Find References of this function you will find that is called two places: In the AI controller and in the Find Path Within Pathfinding Array function. Once more we Find References of this function and… I’m not going to type it all out, but you get the idea :wink: Keep going and you will find all places the Path Index array is modified.

I’m not immediately seeing any issues with the way you are handling the controllers. I’ll let you know if I think of anything. If you run into any issues I’ll do my best to help.

@ Hi, I am back with more questions. Can you give me an idea as to what would be the best way to go about spawning a dynamic blocker for X period of time?

Say for example the player throws an incendiary grenade which sets a certain area on fire upon impact making it impassable for X number of turns. How would I designate that area is blocked from player/enemy movement until the fire has burnt out?