Hello again, I am trying to figure out how I might implement a rather complicated concept within the toolkit. In my game, there are certain tiles that have to be occupied by a player unit. For instance, in my first level there are three tiles that the player must control on the board. These are “city” tiles, that the player must control within a limited number of turns. The AI is charged primarily with defending these tiles, and the player must wrestle it away from them. This presents three problems: (1) how to create a new place-able tile-type (I thought perhaps something like the Tile_Hex_Cost tile type in the example game) within the toolkit that (2) the AI will defend to the death and/or attempt to (re)capture, and (3) how to limit the number of turns the player has to capture all the city tiles on the map. If the objective tiles are not controlled when the number of turns runs out, the player loses the match. I was hoping that you might have some ideas how to implement this in blueprints, as nobody knows the toolkit as well as you do. Whether you can help me or not, thanks for this amazing toolkit!
Hi,
I’ve been checking your toolkit from time to time, how is the dungeon crawler features progress going?
Also, what about multi-character tiles, is that possible? Like in many dungeon crawlers that 4 monsters share the same square space.
@MicahM: Hi! Some of what you are asking is easy to achieve, while some of it is a bit more difficult. To create a city tile I would create a child actor of Tile_Actor. Tile_Actor is an actor I made specifically for the purpose of creating new sorts of actors that can easily be set up to interact with the grid. Essentially all this does is to give the actor the appropriate index and allow it to snap to the custom grid. Ending the game when a certain number of turns have passed is simple. There is an integer variable which is increased by one each time all units have acted (designating the start of a new turn). I did however discover a bug with this counter while I was testing this stuff out. It increases by the number of remaining units each turn instead of 1. I had not discovered this bug before since I do not use the counter for anything. This is fixed in the graph below. You should check the value of this variable in ATBTT_GameMode and end the game if it has reached an arbitrary amount. Here is how I check whether all cities are occupied by players after time has run out (In ATBTT_GameMode):
Above I check whether we have reached the max amount of turns and run Time Is Up if it has. You would probably want to use a public variable instead of an integer entered manually.
Above I check if any of the tiles with GA_City actors on them are not occupied by player units. I end the game and display the appropriate message depending on the outcome of this check.
The trickiest part of what yo are asking is getting the AI to defend the cities, though this is certainly doable. It is harder or easier depending on how rigid you want the bahaviour to be. If you want the AI to always move to a city tile if there is an unoccupied one in move range it is realively straightforward. What I would do after an AI unit has run Pathfinding is to get all actors of type City and check their index variable against the value of Pawn Array at that index. If this index returns empty order the AI unit to move to this tile. If not, proceed with AI behaviour as normal. Here is how I have solved it:
In ATBTT_AIController
After pathfinding I check if there are any cities in move range. If there are I want to move to one of these instead of towards a unit.
Afterwords I choose a city in range at random to move towards (you could add some nodes to choose a city based on any number of paramaters, of course. Maybe do a check to see which cities in range have player units in attack range).
In BP_GridManager (new function)
Here I look at all GA_City actors and see if any of them are unoccupied and withing move range.
In Unit_Parent
Somewhat lazy addition, but it works. This reactivates the unit after movement has ended if there were cities in move range when this unit was activated. As it currently stands the unit should always end its movement on a city if it found one in move range, so that the array is larger than 0 means that the unit must be standing on a city tile. If you make changes so that this is not always the case you would need to change this to something more robust. If not for these nodes the unit would not try to attack any units in range the same turn as it moves to a tile. This is a quick fix to prevent this.
I hope this is enough to get you started. AI is often the most difficult part of TBS games and I hope this helps you understand how you can work on AI within the framework of my toolkit. These solutions are not the most elegant as I thought them up pretty quickly, but they should do the job well enough.
Edit: I had to add some nodes to make sure a ranged unit with a preferred range other than Least Move does not leave a city it is standing in. Also in ATBTT_AIController:
Also you should add a delay macro after checking for cities in range to make sure turns move in the same pace when cities are in move ranges as they usually do:
@masterneme: Hi there! That depends a bit what you mean. In the newest version of the toolkit I have included a 2D dungeon crawler example, though this is closer to a simple roguelike than something like D&D.
What dungeon crawler style features are you most interested in? Having 4 monsters sharing the same space is not very hard, and can be done by adding four skeletal meshes to the same unit. Going the other way and having a single creature occupying four tiles is significantly more difficult, but certainly doable. I have experimented with this before and have found some solutions that work pretty well, but it becomes more difficult depending on how flexible you need it.
Having a single category of big units that is only controlled by the AI and only function on single-level grids is fairly easy to add. Having units that can occupy an arbitrary number of tiles in any direction, which work with both multi-level grids hexagonal grids and whose tiles in move range are displayed in an aesthetically pleasing way when controlled by a player is much more difficult.
Again, thank you! I wish there was a way to add a half dozen more stars to the review. Your toolkit and your support have gone a long way to making this project of mine a commercially viable product.
Happy to help! I had though about how to add this sort of thing before and this gave me an opportunity to test my ideas out in practice.
I’m interested in something like Grimrock, there are some enemies attacking in groups:
And another feature would be that enemies could turn 90º or strafe to face the player on the same line and/or attack from the distance with magic or arrows.
Hey there.
Thinking on the lines of multi-tile actors.
I have a base mesh thats bigger then one tile, but I only want one tile to its interaction and the rest of the tiles it covers just to be spaces the player cant go to.
Essentially with edge costs of 0.
So im thinking of the best way I can set all other tiles within its shape apart from the one to have edge costs of 0.
I could hard code it, as all four of my bases have the same silhouette but just wondering if you can think of a better way before I attempt it.
If i had to hardcode it I would get the rotation of the tile to start with, and from there set the relevant tiles one by one to unwalkable with math for the grid size.
Thanks!
@masterneme: I have described one way of having a unit with multiple skeletal meshes here. This is a pretty basic implementation, but it should provide a good starting point. I have experimented with creating a Grimrock-style dungeon crawler with the toolkit before, and it works okay, but would require a lot of work to function well enough for a complete game. If I pursue this avenue again at a later point I will probably do so as a standalone marketplace assets as the differences are too big that it would make sense to build it on top of ATBTT’s framework. A lot of ATBTT stuff would not be of interest to someone making a first person dungeon crawler and the other way around. I think it will be better for the user to have a marketplace asset focused on the sort of game they are actually creating.
@: Are you using heightmaps from tracing? If you are you can have the area you do not want to be walkable to ignore PathTrace in the collision settings to prevent it from being walkable.
I see, thanks for your attention.
Hey they, got the collision things added (not sure what happened there) and did a test to follow your advice, however for some reason my unit can still walk on some parts of the mesh?
Sending over grid settings and mesh collision to make sure im doing it right.
If the ground underneath the buildings has collision the traces will still hit it and mark the tile as walkable. I’m guessing that the units will walk inside the meshes and not on top of them when you click to move? You can avoid this by making the grid itself not block PathTrace and place collision volumes manually, but the easiest solution here is probably to place invisible wall tile actors along the edges of the camp.
I have a question, which might be more of a general unreal question, but is also somewhat related to creating this grid setup.
I’ve been recreating your blueprints from the ATBTT-package in order to learn how it’s working. I noticed that in my version, the grid_manager-blueprint will make the level take up size in proportion to the tiles used on the blueprint (when grid is placed on level). A grid with 2x2 is ~2mb and with 20x20 it’s about 187mb (!) - while I noticed in your grid it pretty much stays the same even with far more tiles. So I guess my question is; what did you do in order to make the grid more efficient in terms of space? I’ve tried to use your grid with both meshes, instanced meshes and texture but it pretty much stays the same size.
I thought maybe it was the lightmap or meshes which took up space, but it appears not. I’ve been trying to find documentation that could explain what makes blueprints affect level size so much, but haven’t been able to find anything. Is this anything you’ve noticed, and fixed, in your grid? or did I manage to create this issue all by myself?
Hi potoo, that is very puzzling. I have not encountered anything like that while working on the toolkit, though it is not something I have tested actively. Though I have little knowledge of how Unreal Engine stores whatever is contained in maps I do not feel it makes sense that you would see such a large increase (or an increase at all). What you are doing is essentially to create a bunch of instances of the same mesh and fill a number of large arrays. I guess you might see something like this if you have extremely large data arrays, but it would have to be way more than 20x20. Perhaps you have made some small error when adding values to the grid sized arrays and increased them to insane sizes? I would suggest trying to print the size of your arrays to see if that might be the culprit. Also, take a look in the content folder to make sure you’re right about what takes up space.
You were right about the arrays
Appears that edgecost and vector field array had 10000 (!) elements. I added a resize for both vector field array and edgecost array to make sure they were empty before adding/filling them, and now it’s saving the level with normal size similar to yours.
The issue was that it kept adding/incrementing the arrays every time I changed the grid size in the editor, instead of resetting it for every change. So I ended up with a lot of blank elements that didn’t occupy any tiles because it would continually add new elements in the construction script whenever it was changed (in editor/level). Couldn’t find a resize in your blueprint, so I’m not yet sure how you solved this.
But now it works! Many thanks!
Hi ,
How would I be able to add a win/lose state in the kit? I’ve created 2 Integers, casted them to each faction characters, and then made the characters add 1 to their teams integer when destroyed.
Once a factions integer reaches 4 (when all 4 characters die) then the win/lose state happens. The question I have is where do I put this? I’ve looked through all the blueprints but wherever I place it, it either breaks something or does nothing. I’ve used a sequence to run through the two integer checks, with “Then 0” making it continue through the blueprints. I tried to put this in a number of different places in between blueprint nodes such as “ChooseNextPawn” and “End Unit Turn”. I’ve also added some print strings to make sure it does go through the sequence but it does not seem to. Please let me know if you need screenshots of what I’ve done so far.
Thanks!
Glad to hear my guess was correct. Couldn’t think of any other possibility. Good luck replicating my blueprints! It’s hopefully a great way to learn some of the ways to work with blueprints. Are your edge arrays public variables by any chance? That will cause new elements to be added each time the grid manager is compiled if you do not clear the array first.
How hard would this be to port to C++?
Have you considered making this code open source? I would love to contribute to the base library because I too love this genre and have built similar toolkits for other engines but I’m starting with UE4 now. If its a financial thing would there be a money amount that could be donated to you to open the source?
I’m still familiarizing myself with UE4. How hard would this be to port to C++? I feel really uncomfortable programming visually.
Have you considered making this code open source? I would love to contribute to the base library because I too love this genre and think it would be great to help speed up development so others can make great games.
I have built similar toolkits for other engines but I’m starting with UE4 now so my options are to find existing projects to contribute to are start from scratch.
Hi,
How would I go about ending the game once a certain unit is destroyed?
I’m still familiarizing myself with UE4. How hard would this be to port to C++? I feel really uncomfortable programming visually.
Have you considered making this code open source? I would love to contribute to the base library because I too love this genre and think it would be great to help speed up development so others can make great games.
I have built similar toolkits for other engines but I’m starting with UE4 now so my options are to find existing projects to contribute to are start from scratch.
[/QUOTE]
Its open source if you can read Blueprints, which is C++ wrapped in nodes. I’m not a fan of Blueprints either and would buy it again if someone did a C++ port. Your other option is SkookumScript. It can call into Blueprints seamlessly and would be a lot faster to work with than C++.