[SUPPORT] Advanced Turn Based Tile Toolkit

Great to hear that it works! This was a very tricky bug to fix and I might not have discovered it at all if not for your help, so thanks to you as well!

As for your deployment phase, the first thing you would want to do is stopping the start game event in the turn manager from automatically running at startup. It can be called manually whenever you want it to, through a UI button or when a certain number of units have been spawned or whatever.

For spawning units during the deployment phase I’ve made it so that units are automatically centered on the closest tile and assigned a GridIndex value when you use the regular SpawnActor node, so that is the only node you need for that. The easiest place to add this is probably within the click and hover nodes in the player controller. I’m thinking of in the future to add a new ability blueprint that is used by default when there are no active units, which would might an even better place for this sort of functionality, but as long as you make sure the spawn nodes are run server side you should be good.

As for only allowing certain tiles to be selectable for deployment I would add a new Set to BP_GridManager containing the allowed grid indexes. When you attempt to spawn a new unit you would use the “contains” node on this set to see if it is allowed.

Those are the first steps I would do to add the features you are talking about. Let me know if you have any difficulties implementing them.

Hi HaxorViper. You are correct in assuming that the new update makes making simultaneous turns a lot simpler to implement. The devil is in the details, though, and certain forms of simultaneous turns are a lot simpler to add than others. If the “simulated” server-side actions are still run in sequence and they are just animated in parallel this is quite easy to do. You would just need to make sure that the actions are added to the action queue in the order they should be happening and set any actions that should happen alongside other actions to “withPrevious” in the QueueAction macro.

However, if things are happening simultaneously also when it is simulated you run into many of the same difficulties as in previous versions of the toolkit. For instance if you want a unit to move to an index and that unit can potentially be killed by another unit which inputs its action “after” this unit. but kills it midway though the movement you will need to make a lot of modifications to how actions are simulated. You would probably want to have a second step of simulation after the initial simulations where you look at everything that will happen one turn and modify what is happening based on how the simulated actions interact. This is quite tricky, but depending on just how interdependent everything is it should still be possible without completely altering the core of the toolkit.

In any case this is a pretty advanced modification, though, and one that I have not attempted yet, which means there might be other issues I am not seeing a priori. Since you are new to UE4 I would recommend you not to tackle this as your first task. Which is why it is great to hear that you want to make Fire Emblem style fan games first. If you complete and release a Fire Emblem style fan game you should have acquired a lot of knowledge both about the toolkit and UE4 more generally, and you should be well equipped to tackle challenging modifications like this.

Thanks man, you are right, I am not ready to tackle something that big, I just wanted to make sure that it would be possible to do in the future. I am relieved to hear that it is and I just need to learn how to heavily modify the system. Thanks for the information and I will let you know when I am ready to tackle onto something like this. Cheers!

Sounds like a plan! Best of luck, and feel free to ask if you run into any problems along the way.

I am a bit puzzled as to how to add a multiple weapon functionality. What I did was make the weapon stats as a separate component and then made a bunch of actors for each weapon with the separate component as their stats. But when I tried to get the extra component information in the moveattack ability I wasn’t able to do it. I referred back to previous explanations on how to add weapons to this, but they are old and I don’t know if there is a better way in the new update using abilities. Even with tutorials, I don’t really understand the specifics of casting to other objects, getting child components, referencing, and all that stuff. I reverted to source control to get a fresh slate and I forgot to screenshot, so I am sorry if I am not clear. What is the best way to implement a weapon system in this current version: as different skills, as different actors, as different components, or something different?

It depends somewhat on the game and what the weapons do, I would say, but I’ll give you one pretty general and powerful solution.

Create a new blueprint class for your weapons. This class should have designating all the important stuff that differentiate weapons, like damage, range, damage type (if this is in your game) etc. It would probably also contain the mesh of the weapon.

If the weapon in your games differ significantly in how they work mechanically it would probably also be good to have an ability class reference for what ability this weapon should use (you would probably not need an entire different ability for each weapon, but something like a rocket launcher and a sword would be different enough that creating two abilities would be simpler than making a shared ability general enough to work for both. Also you would probably want a tag or enum for the weapon class that the unit animation blueprint can look at when attacking to know how to animate the attack.

While answering your question I’ve thought of another possibility that could also work. Have the weapons use the ability class and themselves be abilities. You would likely want to create a weapon master class that inherits from BP_Ability which contains functionality used by all or most weapons and then have weapons be child blueprints of this master class. Weapons could play an equip animation when activated and would otherwise function just like abilities. The more I think about it the more I like this solution. I don’t think I’d do something like this in a game with very simple weapon rules, such as for example Fire Emblem, but for something like Fallout or XCOM I think it would work great.

I’ll try to give you quick explanations for the UE4 features you are uncertain about:

Casting is something you do when you have a reference to an object, but the reference variable is of a more basic class than the one you want, so you cast to get access to properties that are unique to the child object. For instance, the GridUnits map in BP_GridManager contains references to all the units placed on the grid. Say that you get one of these references and want to deal damage to it. However you have a child blueprint of BP_Unit that has an armor variable which you want to subtract from the damage dealt. UnrealEngine does not know what type of unit it references when you get a reference from the GridUnits map, only that it is a unit, so you do not have access to the armor variable. To get access you need to cast, which is essentially asking Unreal Engine “is this unit a unit_armor type unit?”. If this is true you can use the access pin to get access to the armor variable. A pretty bad example, since using interfaces or simply handling the damage reduction within the unit itself would get the job done here, but I hope it helps you understand. Know that casting is a costly operation, so try to avoid using it whenever possible. Interfaces can generally do the same thing and better.

Im sure i remember seeing an example map with the multi-tile units, was that removed in the 1.8.1 update?

Anyway, just about to start a big project using the toolkit as a base. How far off is the 1.8.2 update? Only thing that is worrying me about starting now is the nativization bug you reported.

Thanks, I am doing it for a Fire Emblem system so I only need a basic system of getting their weapon stats, their weapon triangle position, and their effectiveness. I managed to recreate the situation I was in, and knowing that I did most things wrong, I want to know what I should do instead. This is the way I did it (It didn’t work):

The problem is, I couldn’t reference the weapon attributes, I don’t know how to communicate between blueprints correctly. And when I attempted to reference the combat data for the attack ability, I didn’t know where to put it. Since I am new to UE4 I have comprehension issues, I sometimes misinterpret directions as the wrong things, which is what I think happened with the weapons. I’d appreciate if you could check it out and see what I did wrong and where I could put the find data function. Thank you for your time.

Will probably be a little while until 1.8.2 is done since I’m very busy these days, but I try to work on it whenever I can. 1.82 will be very similar to 1.81, though, so if you keep track of the changes you make it should be easy to port it over. The nativization bug is annoying and one of the things I am working on fixing. I’ve narrowed down the issue to a couple of functions, but these are very central to the toolkit and are difficult to alter. The issue is an engine issue and I am in conversation with Epic in order to get it fixed. I suspect it will take a couple of engine updates before it is fixed though. Worst case I plan to manually program C++ versions of the functions that do not work with nativization for developers who have games in need of the performance boost from nativization.

Edit: Whoops, forgot to answer your first question. Big units are a work-in-progress and won’t be fully implemented until 1.9, However there is experimental support already in the version currently on the marketplace. Only recommended for people with a very good understanding of the toolkit at this point, since you will probably need to modify it quite a bit to fit your game. To make a unit multi-tile increase its size variable under grid options. Then in the grid manager set max unit size. Max unit size currently supported is 5 and only for square, single-level grids.

I don’t believe you can add meshes to blueprint components, as I think you’ve also discovered. So if you want your weapon components to be associated with a mesh you would either make them actors or have a static mesh variable as one of the variables contained in the component and spawn an instance of this mesh when the weapon is equipped. If you go by it this second way you can keep using components which are simpler to access than child actors.

You’re going to need to do some reading up on Unreal Engine features. Read the UE4 documentation and do some tutorials. I googled “unreal engine get child actor reference” and this was the result, so the information is there if you search for it. I know that these things are frustrating when you are learning the engine and that it is tempting to jump ahead to add the specific features you want, you need to build up the fundamentals first. If you use the component method I suggested above, though, you can just use the get component nodes, which are simple and efficient.

The attack action is called whenever an attack is performed, not just when a unit is killed, so you must have changed something on your end. What exactly is your function supposed to do? The resolution of the screenshot you included is too low for me to read it. In most cases I think it would be best to call it somewhere after ExecuteAbility. If it modifies any of the information that is passed to the attack action or deal damage you would want to call it before any of these.

​​​​​​​

As mentioned, the documentation and various tutorials on referencing and casting will do a better job of describing all of this than I can. So to sum up, right after ExecuteAbility is probably a good place for your FindData function. For accessing components use the GetComponent functions. For accessing other variables contained in the blueprint itself get a reference to the blueprint and use a cast if you want to access variables contained in a child blueprint where you only have a reference to the parent. To access variables in child actor components first get a reference to the component and then use GetChildActor. Cast if needed. Also, check out some tutorials on interfaces, as they are very useful for these sorts of things; especially in cases where you have multiple different objects with shared functionality.

I was actually able to get the mesh when using my iron weapon child actor, but I couldn’t change the parent socket, so I just had a floating sword following the unit actor. Your option sounds easier to implement.

I have actually been watching tutorials and documentation for months, but everything blends together because there are so many different ways to do the same thing. And due to my inexperience my comprehension is pretty bad when reading these things. I feel like I don’t understand things unless I try them, so I wanted to build my fundamentals with experience. It is pretty rough, and I understand when to use them, I just need to learn how. Thanks for the links, I feel a bit stupid not googling it :stuck_out_tongue:

My function is the one pictured in 4, it’s basically just a bunch of float additions and substractions taken from the unit stats and weapon stats to get the combat data of an encounter (Chance to hit, critical hit chance, and damage). What I screenshot in 6 is the move_attack function that came with the package, I just wanted to know the general location of where I’d put the combat data function so that I can roll numbers against the hit chance and critical chance and get an updated damage value.

And on move_attack’s behavior, I just debugged it and it seems like the execution is actually passing through it when frame skipped, but when I checked it in real time it doesn’t flow through it. It seems more like an unreal engine 4 bug, the flow only appeared when the game ended by killing the last unit. I was thinking that I broke it so I deleted what I’ve done and got a fresh slate of move_attack, but it was just the execution flow being glitched. :confused:

Thanks man. I hope I am not frustrating you or anything, I know I shouldn’t tackle something like this when just starting out. While I watched a bunch of documentation and tutorials, what I read isn’t retained in my head because by just reading I didn’t have anything to apply it to and remember. I want to learn the engine by using your package because of my love for tactical role playing games, and I feel that whatever I learn here I am going to remember more easily.

Could the GridActors be used to snap onto each other / other grid actors? Example: Stacking a BP_GA_Tile_Wall on top of itself to make a modular wall.

Hi Monokell and felow toolkit users, I want to create a trap tile were if a unit moves over it, it will stop on the trap tile and take damage. I know the damage part but the unit keeps on moving and then take the damage but i want it to stop. Is this possible?
Thanks in advance :slight_smile:

Hey man!

I will get to your ideas on how to make a deployment phase and I’m sure they will work great but I realized before I get to that I would like to use some placeholder Characters instead of the default mannekins to be able to differentiate between the different players aswell as having the option from the selected character from the lobby carry over into the game.
My first issue I’ve run into is that the character, even though rigged and retargeted, only takes the idle state in the game and never animates hits och animates taken hits. I know previously you’ve talked about this issue, just wondered if you have the time to go over it again in some more detail? I could not really understand the previous answer (to another forum user, not me).

Thanks man and hope all is well!
Cheers,
Mivke

No worries, we’ve all been there. Sometimes one just gets stuck in a rut. It is all part of a learning process, though.

Ok, I assumed it did something like that. Then I stand by my suggestion of putting it at the beginning of ExecuteAbilitiy. You need the information both for simulating and animating the damage, so it should be done before any of these.

You’re talking about when the connection wires light up while your running the game? Yeah, those are not very accurate. Use break points or PrintString nodes to be sure of what happens.

Like I said, don’t worry about it, we’ve all been there. Sorry if my tone came across as annoyed; that was not my intent. I agree that it is often easier to learn stuff while you’re working towards a goal.

There is no such functionality included in the toolkit, so I’m afraid you would have to add that yourself.

Sure, it is possible, though there are a few steps to it. Movement in the toolkit works by the unit first simulating movement by essentially moving a reference of the unit from cell to cell in the GridUnits map. After this the grid indexes are converted to actual in-game locations and the unit actor is moved between these locations using a spline.

So for a trap you would want to add a check to each step of the movement simulation that sees if anything happens on that specific tile before proceding to the next. If a trap is found and that trap is supposed to stop the unit you need to make sure only the grid indexes up to the index of the trap are converted to locations.

There is an event dispatcher in the toolkit created for just this sort of thing. If you look in the SimulateMove function of BP_Unit you can see that the “OnEnterTileSimulate” event dispatcher is called whenever a unit enters a new tile (during simulation).

You can bind an event in your trap actors to this event dispatcher. When the dispatcher is called, compare the grid index to the trap to the grid index output from the OnEnterTileSimulate dispatcher. If they are the same that means that the unit has entered the tile of the trap.

At this point you deal damage to the unit. Then, if you want movement to stop you first want to stop the simulated movement. In the SimulateMove function add a branch that exits the loop if true, similar to the “contains” node for the GridUnits map that is currently in the SimulateMove function. Set whatever variable is input to this branch to true when the trap is entered to stop the simulated movement.

Now you need to make sure to only pass the locations up to the tile index of the trap into the QueueAction macro, instead of the entire path. You can do this by storing the index of the trap when it is triggered, using Find on the PathIndex array to find the array index of this grid index and use this to create a new array of locations from the PathLocations array stopping at the index found in the last step and feeding this into the move action. You would then want to queue an animation for displaying the unit being hurt by the trap right after the move action has been queued (as it happens right after movement stops).

Those are the steps I would go through to create something like this. It is a bit complex, I know, so let me know if you have any questions.

There might be several reasons for this depending on what you have done. Check the event graph of BP_Unit_Anim and compare it to the event graph of your new units. Are there any differences? What about ABP_Unit compared to your new animation blueprint? Maybe you have forgotten to add notify events to the new animations? Let me know what differences you find and I’ll try to figure out what has gone wrong.

I will check but all I have done is imported the new characters (from Mixamo) and retargeted the ABP_Unit_Melee (which took with it both ABP_Unit aswell as all the used animations). I also did a new child class based on BP_Unit_Anim_Adv (since my project will use alot of abilities) but I have not changed anything regarding the animations or the character in the blueprints. I realize it’s a very “lazy” way of expecting it to work out of the box, but I’m just trying to understand how it all fits together. The unit can move fine, floats in the Idle animation and the engine never realizes that the unit has hit or taken a hit.

Cheers man and as always thanks for the quick replies!

P.S I’m looking through your most recent tutorials again to try to understand. I think the problem is that I’m not animating my unit, but since I didn’t change anything I’m wondering why it does not “inherit” this automatically? (I am at work atm so can’t look at the BP for it right now, maybe it’s obvious :slight_smile:

Hey man,

I solved this issue. Not 100% sure what was wrong since I still don’t understand all the basics but when I redid the overides you do in BP_Unit_Anim with regards to the ABP_Refs it started working. I guess since I’m using another mesh the cast to BP_Unit became null or something to that effect.
IF you have the time and will you are more than free to let me know by text what I did, otherwise simply ignore this last strand of issue :smiley:

Back to work on the deplyment phase :stuck_out_tongue:
Speaking of which, do you have some kind of round counter or round start or something to that effect? Basically something that does what Start Match does but get’s called after every unit has had one turn.

Cheers man!

Hey man, sorry for the spam but just had a very good day of working on the project and wanted to get this question out before having to go pick up my kid :stuck_out_tongue:

I’ve started implementing the DeploymentPhase and it’s going really good. I have run into a problem though that I think is due to some behaviour of the Grid Manager “under the hood”. I will try to explain with text and some screenshots.

So basically, I’ve made a custom event i BP_ATBTT called DeployCharacter (this gets called from BP_PlayerController_ATBTT) that loads my settings from the Lobby and then spawns a character on a tile (like you said earlier). This worked wonderfully. I then added a boolean called bDeployable to the BP_GA_Tile_Hex, set to false by default, and changed it to true on the tiles I wanted to be deployable. However, none of the tiles with bDeployable set to true can be deployed and neither can the default tiles with ONE exception with allows the spawning of the character. I get an error on the Branch where I’m checking if bDeployable is true or not in the DeployCharacter event, the error says

“Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item3 from function: ‘ExecuteUbergraph_BP_ATBTT’ from node: Branch in graph: EventGraph in object: BP_ATBTT with description: Accessed None trying to read property CallFunc_Array_Get_Item3”

Below are screenshots of all of the things I can think of that I’ve modified. If you have the time and will to help I will as always be super grateful, let me know if you need any more clarification.
Hope all is well!

(there is one more picture that is too large to be uploaded, let me know if you need it and I can try to make it smaller or mail it).

Hey Mivke, sorry for the late reply. You caught me as I’m in the process of moving back to Norway after my stay in Canada, so I haven’t had time to check this thread. Happy to hear that you got the animations working. It is still hard to know exactly what went wrong the first time, as it could be any number of things. Generally for making custom units for your game I would not recommend making a child blueprint of BP_Unit_Anim or BP_Unit_Anim_Advanced as it makes it more awkward to work with when you need to jump between various child and parent blueprints all the time to setup functionality. Rather I would recommend duplicating BP_Unit_Anim instead (unless you are making a unit without a skeletal mesh, like a tank or something, where you’d probably want to create a new child blueprint of BP_Unit instead). What animation blueprint are you using? Is it the regular ABP_Unit, a duplicate, a child blueprint or something scratch built?

Don’t worry about spamming the thread if you have new questions. Glad to hear you have come a long way on the deployment system. The problem you are having with spawning I believe is due to you confusing grid indexes in ATBTT with array indexes in general. The grid sized arrays and maps in the grid manager are set up so that each array index (or integer key in the case of the maps) corresponds correctly to a tile on the grid. When you get all actors of the class BP_Tile, however, the indexes will not correspond to the grid.

Say you have 6 actors of type BP_GA_Tile_Hex placed in your game. If you used GetAllActors of type BP_GA_Tile_Hex this will return an array of length 6, with the array indexes 0-5. Now when you use the GetHitLocationAndIndex function you get the grid index of the tile under the mouse and try to use this to get a tile from this other, small array. To get the grid index of a tile using a similar method to what you are using you would need to loop over all of the actors in the array and check their GridIndex variable agains the grid index output from GetHitLocationAndIndex.

This would work, but it would not be very performant. Not a big issue here, as you are just looping over a few actors and not very often. I would instead suggest to create a new set of integers in BP_GridManager holding the grid indexes of all deployable tiles. If you want to define which tiles are deployable by manually placing these in the viewport like you are doing now you could fill this set by looping over all these spawning platforms during the setup of BP_GridManager, getting the GridIndex of each and adding these to the set. That way you only need to loop over all the actors once, and not while the game is running. You could also fill this set by any other way you wanted and would not be dependent on manually placing spawning points if you do not want to.

You are really close to have a working setup, and I hope my explanation will allow you to get it working how you want it to.

Hey!

Yes, when I wrote that first question I did not really have any experience working with Skeletons/SkeletalMeshes/Animations etc. so I was basically just shooting in the dark. Maybe I will redo my characters with BP_Unit_Anim as parent since as you said, it get’s quite tediuos with so many levels in the hierarchy. I chose BP_Unit_Anim_Adv since that is what you are using in the Advanced map with the abilites so I figured it would be the closest to what I need in the end. Is it “easy” to implement the abilities on BP_Unit_Anim or subsequent children of that class?

As for the animation blueprint I’m using ABP_Unit and ABP_Unit_Melee as “parents” to my different animation blueprints for my characters. Since they will all not share animations as much as you have it in the toolkit (due to alot of different skeletal meshes) I figured making a new “base parent” directly below your animation blueprints was a good idea.

Ah, of course! Yeah, I felt the behaviour was so strange that it must mean that I missed something fundamental. I can’t tell you how awsome it is to have you answering these questions, I would probably have solved it eventually but it could have taken me 2 weeks for such an “easy” mistake.
Your solution with adding it to the GridManager is along the lines I was thinking. Do you have any of your existing setup functions in the GridManager where I could get some “inspiration” for how to loop through these at the setup of the GridManager? It feels like a very good solution and this thing with deployable tiles will be very reaccurring in my project so I think a good general solution rather than a “hack” is worth investing in early.

Again man, jesus f-ing christ thanks for the feedback! :smiley:

No worries :slight_smile: BP_Unit_Anim_Adv is just BP_Unit_Anim with the stealth and ability components added. Add these to your own unit blueprint and it should work just as well.

As for animation blueprints, unless you are doing something extremely similar to what I am doing I would recommend duplicating ABP_Unit instead of making a child blueprint. Same reasoning as for making a duplicate of BP_Unit_Anim. I think the only place I reference the animation blueprint is within BP_Unit_Anim anyway, so if you’re making a duplicate of this you might as well do the same with the animation blueprint so you do not have to code around the constraints places by my animation blueprints. I’m not saying that you should make a duplicate of any blueprint you want to modfiy, but BP_Unit_Anim and ABP_Unit are to a larger degree than the rest of the toolkit intended as examples of possible ways to set things up, but which I assume would require extensive modification to fit with any specific game.

Most bugs are caused by some annoying little thing I missed, in my experience. Glad I could help you find it in this case. In the setup of the grid manager is one function for looping through all units and adding them to the GridUnits map. I believe it is called AddViewportUnitsToGrid or something like that (cannot check as my UE4 laptop is in my luggage) and it is run near the end of the grid setup. Just like what I suggested for you, it loops through all actors of a class and adds them to a map based on their GridIndex value. You would do the same thing, but probably use a set instead of a map, since I don’t see why you would need to store a reference to the tile actor, only its grid index.

Alright, I think I will redo the characters and animation blueprints then. I think now that I know more how to do it, it won’t take too long. Always worth to take the longest but best route specially in the beginning I think :slight_smile:

Yeah, I actually found that exact function but couldn’t really get it working until I read your message here. I did it like this now

Since I have my bDeployable inside the BP_GA_Tile_Hex I still do need the reference, correct? To be able to make the check if bDeployable is true or not. As I’m writing this I see that I’m doing that check (of course) before even creating the map so you are correct, the set would do fine and then just check contain versus the hit tile index… It’s so useful “talking” about this stuff, then you realize where you are making your thought error :smiley:

Thanks man, got it working now!
Will be back on the next day I get a few hours or mins to keep working with alot more questions, I’m sure of it :stuck_out_tongue: