[SUPPORT] Advanced Turn Based Tile Toolkit

Thank you. I’ve applied the changes you have suggested and works the same but I am sure it is more efficient now. Looking forward to the changes in the next version. For now, back to the game.

Happy to help! Too bad you still have a remaining issue. Let me know if you are not able to solve it. I try to correct for the grid manager’s transform in everything I add, but the maps in the experimental folder will generally not be as polished as the core toolkit, so some issues like this might crop up when you try to modify them. I play it a bit more fast and loose with the experimental maps, which enables me to demonstrate possible features quickly.

Yep, the results will look the same. I’m not always this ■■■■ about performance, but the inner pathfinding loop is the part of the toolkit which is by far the most affected by inefficient code, since it is run so often. If your game does not have extremely long movement ranges it is unlikely to be an issue, but I couldn’t help myself in suggestion a more performant option in this case.

Hello, I’m just curious, what is the idea behind Action System? I just want to know its pros and cons, especially as part of the multiplayer system.

I was not able to solve it I really Tried I assume there is a fix to be found in the bp manger or the grid camera hybrid but I was unable to find one

Originally posted by codeyhanson View Post
Hello ** that worked almost but now anytime I move the camera that snaps camera back to location 0 going to try and see if I can find the camera in the blueprint and convert that with the same node

Note I was not able to find it for the hybrid again thank you so much for your help plan to show a small demo video of what I have so far all thanks to you.**
Happy to help! Too bad you still have a remaining issue. Let me know if you are not able to solve it. I try to correct for the grid manager’s transform in everything I add, but the maps in the experimental folder will generally not be as polished as the core toolkit, so some issues like this might crop up when you try to modify them. I play it a bit more fast and loose with the experimental maps, which enables me to demonstrate possible features quickly.

ok sooo im back with kind of a dumb issue, and seeking some advice. before you ask, yes i have been looking at tutorials. now on to the issue in question.

first is the goal
Goal: make a delay based on faction and display a count down timer to match it.

so far i created a working delay. its not pretty but it works.
[SPOILER]


[/SPOILER]

the function works like this

[SPOILER]


[/SPOILER]

the issue i am having tho is with trying to make a ui widget to call for the seconds left in the delay
[SPOILER]


[/SPOILER]

it gives me this error

[SPOILER]


[/SPOILER]

i have also tried this to make it work buuuut, it dosent display anything
[SPOILER]


[/SPOILER]

lastly: i looked into world settings and tried to make sure i was calling correct sections. i have tried with your hud and with a hud i made. clearly im doing something wrong

[SPOILER]
world settings.jpg
[/SPOILER]

Sorry for the late reply, people. The last couple of days were very busy. I’ll get to your questions now:

Hi SpamBotWinner, there are several benefits to the action system, both in regards to multiplayer and otherwise. Firstly it is a tried and true way to design turn based games. Games like Hearthstone, XCOM and Gears Tactics work like this under the hood (hints to this is how the EndTurn button in Hearthstone is immediately disabled if you initialize some RNG based spell which eventually results in a player death, or how you get an achievement in XCOM for killing a new type of enemy right at the start of the AI’s turn instead of after you hit it with an overwatch shot seconds later).

One benefit can be seen in considering how you would have to structure your code without an action system. Say you have an AI unit who wants to move to a tile and attack a unit. Without an action system you would need a function or event dispatcher to make a call to the attack system after movement has ended. Then the attack system would have to make a call to a damage dealing system etc. You can quickly end up with spaghetti code where all sorts of objects point and execute events in other objects, which becomes confusing and requires manual setup for every single thing you want to be able to call in sequence. The action system provides a standardized way to call events in sequence, which can call an arbitrary sequence of actions.

The action system is also effectively a sectioning off of gameplay logic and what is visually transmitted to the player. A benefit of this is that all the gameplay logic would work the same if you changed everything on the visual layer, which makes it easier to do extensive modifications of the toolkit.

The fact that all the game logic for a turn (or indeed several turns) can be carried out over a single tick (instead of waiting for animations to finish) opens for many advanced possibilities. You could in theory have an AI test out several different options before deciding on the best one, and only then queueing the resulting actions. You could even do this for multiple AI units to enable coordination (Gears Tactics does this). Knowing before the turn starts animating all the things that will happen during the turn opens up for many possibilities, such as guiding the camera in a way that will best capture the action etc.

So for these reasons, even if it did not improve multiplayer, I would still want to have an action system. However, another benefit is that the action system essentially takes care of replication for you. You generally want all game logic to happen on the server, while still showing to the players what they need to see. This distinction is built into the action system, and any variable passed through an action is automatically replicated, meaning you don’t have to mess around with manually replicating variables and calling RPCs. Each client is also responsible for their own action queue, which results in lagless animation within each action. In a real time game you will have to continously update the location of a moving actor to all clients (and often build in prediction algorithms for when transmission is slow). For actions the client gets a single command once and then it takes care of the entire animation itself, meaning that you will never see a unit lagging during movement.

I hope that made things clear. Note that I am making some major changes to the action system in the coming update. Although the current system is functional, it feels a bit hacky, and it is easy to make coding mistakes in forgetting to end an action or ending an action twice, which causes many strange issues. The current setup also creates quite a bit of circular dependencies and runs into many of the problems related to OOP (you have to inherit from an actor in order to access its action). I’m moving to a system of encapsulating actions within actors, which makes everything a lot cleaner.

No worries, I’ll see if I can solve it. I’m not exactly sure what the problem is, though. Could you give me the exact steps to reproduce the issue you are seeing?

Ok, so I see a few mistakes here. I will point out the obvious mistakes I am seeing, but cannot give you more specific suggestions, since I’m not sure exactly what you are trying to achieve? Do you want a timer displayed on the screen that counts down from 5, once per second, before the goblin turn starts?

The PlayerInputCountdown function looks a bit weird to me. You are aware that delays don’t work within functions? The DelayAllActions isn’t really a delay, but rather a command to have the action system delay continuing the action queue. From how I read it I think this function would print 12345 immediately during the same tick and then you would have a five second delay in the action queue based on five one-second delay actions back to back. I think this is probably not what you’re after?

From the last two screenshots it seems you have misunderstood how casts work. The game mode is not of type turn manager, and casting it won’t make it so. Similarly the Owning player is not a turn manager. Casting is a way to check if a reference is of a specific class, and if so you are able to access its variables. So, for instance, you can have a reference to a unit in a blueprint. The reference is of the type BP_Unit. However, the unit stored in this reference right now is actually of the class BP_Unit_Anim. You want to have access to the variables and functions that are specific to BP_Unit_Anim, but UnrealEngine does not know that your variable is of this class (since the reference variable is of type BP_Unit). This is when you cast it to access the child class. I recommend checking out the documentation on casting here: https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/CastNodes/index.html

Here are the steps to reproduce the issue basically the hybrid map move the grid from 0,0,0 the character and the camera will teleport to 0,0,0 applied your fix and it kind of works but if you try to move the camera the camera teleports back to 0,0,0 here is a video for a step by step

Sorry to be so much trouble but you really are the best.

I assume the fix is to be found in BP_GridCamera_Hybrid

No problem at all. Questions like these help me sort out issues with the toolkit. Seems like this is not specific for the Hybrid map, but rather a bug in the code for constraining the camera to the grid, which was added in the last update. I will work on a fix for this, but for now set bConstrainCameraToGrid to false in BP_GridCamera_Hybrid.

Edit: Ok, fixed it. If you want to keep ConstrainToGrid active, here is how you fix it (changes are the conversions back and forth from grid space):

https://i.imgur.com/2wopOdJ.png

soo the 5 second rule was just for testing. didnt want to wait a long time to see if it workied. yes i do want a timer for when the goblins turn starts. not each goblin, just the faction

ok soo it seems like im looking in the wrong section basically im trying to give time for the players to input what they want to do.
for example:

players watch game > delay + countdown begin > players type in chat > outside program handles chat > outside program translates chat > outside program saves chat input into files > ue4 reads files > timer finishes > ue4 reads new information > ue4 saves new info as variables, arrays, etc… > ue4 follows normal ai process while overriding final decisions with the new variables > enemy ai procceeds as normal > rinse and repeat.

i have found many tutorials for explaining various methods of how to update the game at runtime but before i can get there i need to find a way to delay the combat so i can give players a chance to enter their commands

i probably have misunderstood how they work. i have only been successful once with it.

honestly and probably really shameful, i keep the ue documentation open on my second screen the entire time im working. on this. i try to look at as many tutorials as possible so i dont bug you. as a result i end up here anyways cause its something i havent seen anyone else do before although, i dont feel like its anything new.

@LuxJahi: Ok, try this on for size:

do you have a donation section?

Nope, but thanks for the offer :slight_smile: You having bought the toolkit is enough

Hello!

Longtime designer, just bought the toolkit, watched all the tutorial videos (some more than once), and am loving it!

I have a few projects in mind and want to start with the simplest one, which has some rules like classic Chess:

  • Each player can only move one unit per turn
  • Each unit’s movement is defined by a pattern instead of pathfinding on a range

I looked into the TurnManager and Move ability but there are a lot of assumptions that I’m not sure how to break.

Any help greatly appreciated!

Cheers

Hi, glad to hear that you’re enjoying the toolkit :slight_smile: The things you mention are indeed built with some assumptions, but they are easy to swap out. I designed the turn manager and abilities to be easy to replace and overwrite for precisely these sorts of reasons.

For your first question on initiative I would use the strategy turn manager (BP_TurnManager_Strategy) and make the following change:

https://i.imgur.com/CZPOtOS.png

Note that this will not make too much sense for the AI, which will always use the first unit in initative. If you are using AI and want it to intelligently choose the optimal unit to use it will require some more work. Let me know if this is what you’re going for, but first see if the above suggestion fits what you are after. To choose to use the strategy turn manager set the game mode to BP_ATBTT_Strategy (or simply change the turn manager class variable in whatever BP_ATBTT based game mode you are using)

For your second question, this makes sense to set up in an ability. Patterns can be generated in many ways, but you need to figure out the appropriate algorithm. The GetTilesInRange function in BP_GridManager is a pattern function that finds a square or diamond shaped pattern. You can follow its example to create patterns of your own.

A quicker but somewhat less performant option is to use the output of GetIndexesInRange and filter it to the shape of your pattern. You could for instance create a cross by taking the array output by GetIndexesInRange and only keeping indexes that are an equal distance away from the center grid index in the X and Y axes.

Note that if you use GetIndexesInRange, it does not do any checks on the output grid indexes to ensure they are real tiles on the grid, so before using them for gameplay loop through them and check a grid sized array like GridLocations to only keep the valid ones. FindTilesInRange is set up to do this already.

Hello, I am relatively new to Unreal Engine, but stumbled on your toolkit, and it really answered basically every need for our combat system. One thing I have been trying to figure out is how to have the turnbased system deactivate and allow free movement, then when combat is initiated to activate the turn based toolkit. I see the Hybrid map and can get an idea of how the trigger zone starts the combat manager, but the nature of 3rd person then top down for the camera wasn’t really what we were looking for, so I didn’t want to just iterate on that map alone (plus it is listed as experimental, so I wasn’t sure if that meant that the camera perspective change was experimental, or if the changing between having the manager run and having it not was the experimental piece).

Hi, glad to hear that my toolkit is useful for your project. The experimental folder is where I put systems that I am experimenting with and that can serve as a starting point for devs wanting to implement those types of features. In the experimental folder I do not try to integrate each feature with every other feature in the toolkit and rather try a more local and less generic solution. The folder still contains blueprints that should be well optimized and decently organized, though not commented and cleaned to the same degree as the rest of the toolkit.

For the hybrid map I am working on an updated and improved version for the next toolkit update. What about the current implementation is not a good fit for your game? Let me know precisely what you are after and I might be able to help you.

I appreciate the response! We wanted more like Wasteland, where you have a top down movement style (just like the tile based movement the toolkit creates) but to have completely free movement outside of combat. I didn’t see anything (and I might not have looked hard enough) that disabled that turn based order when you put the grid manager on the map except in the hybrid map, which is the exact playstyle we are looking to create, minus the third person WASD movement. If that makes sense.

Yep, makes perfect sense. It should be simpler to set up than the current hybrid map. You can scrap all the code for switching between cameras, use the Grid Camera’s follow functionaility for following your character during real time movement, and transition to and from combat in the same way otherwise.

Thanks! Is there somewhere I can learn about the different Game Modes and Turn Manager classes?

The tutorials on YouTube concerning the turn manager is a bit outdated, so it does not describe multiple types of turn managers.

The game modes are essentially identical, with the only difference being what turn manager they are using. The default BP_TurnManager has turn order based on each faction, with a predefined faction order and the turn order within each faction determined by the individual units’ initiative variable values.

BP_TurnManager_Strategy is the same, only that new units are not automatically selected when a unit ends its turn, but have to be manually selected by the player.

BP_TurnManager_Initiative ignores factions and orders unit activation solely based on their initiative values.