[SUPPORT] Advanced Turn Based Tile Toolkit

Thanks for giving a thorough explanation. It seems like there are many similarities to our solutions, though I’m wondering where exactly you are running the code relevant for each skill. Are you spawning skill actors in the world and running the nodes contained in the skill actor or are you doing something different?

  1. The UI consists of three nested widgets, where the lowest ones in the hierarchy are buttons for selecting the skills. These are chosen at the start of each unit’s turn by looping through the skills array, which is an array of Skill classes contained in the unit. The icons for each skill is contained in a Button Style variable in each skill actor.

  2. When a skill button is clicked an actor from that skill class is spawned in the world at the location of the current unit and the Activate Skill event is run on that skill actor.

  3. The Activate Skill sets things up for the skill more generally and displays to the player what can be done. For instance the laser skill runs Find Tiles in Range to display any possible targets.

  4. Skills generally have an On Input Click event to handle player interaction that functions similarly to this event in ATBTT_PlayerController.

  5. Some skills are more like passive effects, though, and are stored in an Active Effects array of skill actors in the relevant unit. This array is checked every time a unit activates or ends its turn to see if any of them should do something/be destroyed.

  6. After a skill has been used and it has run through all the relevant node it calls the Deactivate Skill event, which removes it from any arrays it is stored in and destroys the actor.

Worth noting is that the Activate Skill event contains its own nodes for when AI units activate its skill, which is similar to the nodes for finding and choosing a target in ATBTT_AI_Controller. The end result is that the event graphs of the Player and AI Controllers are almost never used and that the stuff that was previously handled by these blueprints are handled by the various skill blueprints in a much more modular fashion. I’m uncertain if I will be converting the entire toolkit to using this method or to contain it within an example map and example child actors. It will be the latter for the next update, but if the feedback is good I might make this solution the standard for the update after.

Hope I explained things clearly. If you have any questions or ideas for improvements let me know :slight_smile:

Regarding your first question:

At game start, I check the GameSparks ID of the connected player. Then, I take the associated pawn ID array (user can select his troops on the menu before the game start) by querying the cloud backend.
After that, I’m able to spawn in the first phase of the GameMode (all at location 0,0,0: it is not important to place a skill in a particular point) all the skills linked to the in-game troops.
In this way, I don’t have to spawn additional skills in runtime: I already have all the possible skill spawned on the Map.

The general code is running on the parent (Skill parent), as I have explained on the above post, meanwhile the particular implementation (for example, the cone of fire implementation) is running on the skill blueprints based on the parent.

Regarding the passive effect skills, in my case I have created another Parent blueprint: Altered Status Parent. An altered status is whatever influences the pawn stats turn by turn (ex. Poison is an altered status that removes 2HP every turn start). I’ve implemented a cycle through the active altered status in the GameMode after “Choose Next Pawn” where I decrement by one the duration of the altered status and I apply the effect, until it’s over.
So, basically I’ve separated all the active skills (the ones you need to activate with a target selection) from the passive abilities and/or altered effects.

Regarding the arrays: I’ve also created a Skills Array and an Altered Status Array inside the Unit Parent blueprint.

Anyway, I fully understood your six implementation points. I think that our skill systems share a lot of similitudes.

Thanks for clearing things up. Seems like there are indeed a lot of similarities. I’ll be looking forward to hearing your thoughts when I’m done with the update.

Hi,

I noticed a few people mentioned using GameSparks with your toolkit earlier in the thread so I thought I’d pop in and offer some support from our end. We’ve just added Real Time support to our Unreal SDK. A guide on this can be found here. If anyone plans to use GameSparks with this toolkit and runs into any problems we’ll be happy to help. We have a dedicated support page here if you guys don’t want to clog up the thread :slight_smile:

Thanks !

Thanks for sopping by, . GameSparks looks like a great platform and I’ll surely look into it when I implement networked multiplayer somewhere down the line.

Hi there!

My name is Hendre van der Walt. I bought your Advanced Turn-Based Toolkit and it’s incredible! The amount of work you put into is absolutely astounding.

The game that I am looking to develop with the toolkit needs to follow a control scheme similar to a game called Duelyst. This is basically what it needs to do:

  • There is no initiative order, but rather that you select each unit that you want to move.
  • After a unit has moved, it can attack or choose not to.
  • The unit does not need to move before it can attack.
  • If the unit hasn’t attacked this turn and the player selects and moves another unit, they can go back to the first unit and still perform that unit’s attack.
  • Turns end when the player decides to end it, not based on whether they still have units that haven’t performed any actions this turn.

I think that’s the gist of it. Any advice that you can provide as to how I would achieve this would be greatly appreciated!

Thank you for making the toolkit and I look forward to hearing from you!

Regards

UE4.14 is out! I have updated the toolkit to be compatible and sent a new version to Epic which should be available in the launcher soon. Until then there is almost nothing you need to change if you want to use the 4.13 version of ATBTT with UE4.14. The only issue I found was that the materials for the tilemaps in Content/AdvancedTurnBasedTileToolkit/Maps/2D_Game_Example/Tilemaps have been set to none. If you want to play my 2D game example in a 4.13 ATBTT project opened in UE4.14 you need to set the materials of the tilemaps to MaskedUnlitSpriteMaterial. There, that’s it!

@DarkRa88iT: Hello! I’m glad you’re having fun with the toolkit. I’ve played a bit of Duelist and it is not very difficult to get ATBTT to follow a similar control scheme. Before going into how to change the toolkit to work similarly to Duelyst I’ll quickly describe how things work in ATBTT by default:

ATBTT_GameMode contains an array called InitiativeOrder that by default contains all the units placed in the game. This array is ordered so that the currently active unit is stored in index 0, the next one in index 1 and so on. When a unit’s turn ends it is placed at the last index of the array while all other items are shuffled forward one step. After a unit ends its turn the value of HasActedThisTurn of that unit is set to true. When a new unit is activated we check if HasActedThisTurn is true. If it is, this means that we have gone through a full round of all units acting, so we reset HasActedThisTurn for all units.

I have also included an option of switching between multiple units of the same faction by clicking them. This is enabled by setting Can Player Switch Pawns to true in the public variables of BP_GridManager. The logic for switching between units is contained in the event tree of ATBTT_PlayerController. When a unit is clicked we check if it is the same faction as the current unit. If it is we check if it has acted this turn already. If it hasn’t we want to switch to this unit. This is done by putting that unit first in the initiative array and activating that unit. This only works correctly if different factions do not have overlapping initiative values, but act one faction after the next, since we can in principle switch to a unit that has a lower initiative value than a unit of a different faction.

Also by default HasActedThisTurn is set to true whether a unit moves and attacks, attacks or just moves, so if you have done any action with the current unit before switching you will not be able to switch back to it later.

With all this in mind I will tell you how to achieve a control scheme similar to Duelyst. This also assumes that units of different factions act one faction after the next (e.g. all units of one faction having higher initiative values than all units of the next faction and so on).

First in ATBTT_GameMode you will want to prevent the current unit to be activated automatically. Also we set Local Current Unit in ATBTT_PlayerController to be false. Normally this would be identical to Current Pawn in ATBTT_GameMode (I see that I need to do some cleanup on my naming conventions: P ) and is just there to prevent unnecessary casting. We can however exploit this so that there is a current unit in ATBTT_GameMode, but that the player controller does not act as if there is currently one. Also we set the current marker to invisible.

At the very right end of the Event Graph of ATBTT_GameMode:

Then we make a small change to the event graph of ATBTT_PlayerController so that the current unit does not get Has Acted This Turn set to true if it has only moved and not attacked. Just skip this at the beginning of the Initialize Movement - Step 2 comment box:

Instead we add a new node setting Has Acted This Turn to true when End Unit Turn is called:

In addition we do a small change in the nodes just to the right of Touch Input where we decide what action should be executed depending on the faction of a clicked unit. Here we check the faction of the clicked unit up against the faction of the current unit and not the local current unit. This is to prevent a different chain of events from firing when clicking the “current unit” when the player has not actually selected a unit yet.

Also we want to make the current pawn marker visible when we actually activate a unit:

Now for the most complicated step we want to add the option of ending the turn for the entire current faction by pressing an End Turn button in the UI. First we create a new function in ATBTT_GameMode that loops through all units in the initiative array and puts each of them at the back of the initiative order unit it finds a unit of a different faction to the current unit. When one such unit is found we end the turn of the unit before this one as normal so that the following unit is activated normally.

Then create a button in HUD_Faction_Turn. Add an OnClicked event to it and have this call our new Skip All Units Of Current Faction function in ATBTT_GameMode:

Also if you want to have a static camera like in Duelyst you might want to set EnableFollowCam to false in BP_GridCamera. If not then you want to prevent Follow Cam from activating when it is the Player’s turn so that the camera does not follow a unit that has not actually been activated yet. This can be done in ATBTT_GameMode like so:

That should hopefully give you a good foundation for building the sort of turn ordering you are interested in. I hope it was easy enough to follow. Good luck on your game and let me know if you have any other questions :slight_smile:

Hi
I just bought the toolkit and am very impressed. Also, looking through this thread I see you give excellent feedback and help.
Like all here I’m sure, I have plans for a game, but being a programming amateure I figured Unreal was the way to go.
How easy would it be to add scrolling to your kit (ie mouse to edge of screen moves map) as my game will have large maps. I want through your tuts - in #6 I think it was, you show updated tiles vs decals vs landscape/terrain. In your experience, for large maps which would be the best way to go? (memory/performance-wise).
Thanks in advance
Mark

Thank you so much for the insanely detailed answer! I was able to follow along and perform all of the steps. I am, however, running into some errors which I believe is messing up the pawn behavior. This is the error:

The ‘Branch’ in question is this one:

I know ‘Accessed None’ errors usually come from variables or objects not being properly referenced, but with all the reference variables that you have in place, that shouldn’t happen. Plus, the area where this error is occurring now isn’t even one of the pieces that I changed following your instructions. Could I have just messed something up or are you getting this error too?

As per usual, any advice would be greatly appreciated!

I might have forgotten to include one small change I made. I cannot check until I’m back from work, but try getting the faction of the current unit from game mode instead of local current unit at the part of the graph directly to the left of your screenshot. See if that fixes the problem.

Thank you! I’ll give it try and let you know.

Hey dude, this toolkit is pretty sick. I just started playing with it a couple days ago. I’m still trying to get a handle on these blueprints, but right now I’m specifically trying to change how it displays squares that can be attacked by a unit. Right now unless there’s a unit specifically within another unit’s movement range it won’t highlight attackable squares with red, when you select it all the edges of its move range are empty, and it’s not until you finish moving a unit you can see the units it can attack.

I’d like to know where I should be looking if I want it to function like this, where if you click a unit it shows all squares they can possibly attack:
e: nvm found it, still would like to know how to show it for enemies tho

https://i.sli.mg/WDXtdB.jpg

And also how to make it so the same function is available when clicking on an enemy:

https://i.sli.mg/Cirbhq.jpg

Glad you figured it out, Selentic! Let me know if you have any additional questions. For anyone else wondering what you need to do is to either set Find Only Pawns to False for the Find Tiles In Range function in the Begin Player Turn section of ATBTT_PlayerController’s Event Graph. Alternately set Show All Possible Visible Tiles to true for your units if you want to achieve a result like the one above, for displaying all tiles that can be attacked by a unit when its movement is taken into account.

Awesome pixel art, by the way! Have you drawn it yourself?

I’d still like to know how to handle that function for enemies. (not sure if that’s been covered elsewhere in this thread, unfortunately the search function is really poor at finding relevant things :frowning: )

Also no, those screenshots are from Fire Emblem: Sacred stones which is just a quality example of the mechanics im looking for :stuck_out_tongue:

Hi
I think you missed my previous post.
I just bought the toolkit and it is great.
How easy would it be to add scrolling to your kit (ie mouse to edge of screen moves map) as my game will have large maps.
I went through your tuts - in #6 I think it was, you show updated tiles vs decals vs landscape/terrain.
In your experience, for large maps which would be the best way to go? (memory/performance-wise).
Thanks in advance

Hello, and sorry for not replying to your previous post. I did indeed miss it. I must gave gotten caught up in answering DarkRa88iT and must have filtered it out. Terribly sorry about that. Mouse scrolling is in fact something that will be included in the next update. I have implemented it fully. I will show you the blueprints I use as soon as I’m able (though I’m heading straight to town after work today, so probably tomorrow). The general idea is to get the 2D position of the mouse, comparing it to the size of the screen and using this information to adjust the panning events in BP_GridCamera. I’m not exactly sure what you mean by using decals to display large maps. Decals are generally not very performant and should be used fairly sparingly. If you are thinking of displaying tiles, using hierarchical instanced static meshes is the best solution, which is the one I use in the toolkit. Using landscape/terrain can also be very efficient, depending on how you do it. If you are thinking of the tiles that are displayed to indicate move range, either decals or HISMs should be fine, unless you have truly outrageous movement ranges.

Ouch. Right in the TBS credentials. I should probably know that, but I’ve only played the newer Fire Emblem games. To be fair, it would have been pretty easy to replicate those screenshots using ATBTT, though.

[QUOTE=Selentic;625063]
I’d still like to know how to handle that function for enemies. (not sure if that’s been covered elsewhere in this thread, unfortunately the search function is really poor at finding relevant things :frowning: )

The thread is a pretty long read at this point, so no worries. I have not discussed that before anyway, so searching would not have helped you much. I’m guessing what you want to do is to display what tiles can be attacked by the AI during the player’s turn, so that this can be used for tactical decisions? What you need to do is to run the Pathfinding function using the index and move range of the AI unit and then run the Display All Possible Visible Tiles function (the name might not be entirely correct as I cannot check at the moment). Note that this will override any other pathfinding you have run before that same turn, so that you would need to rerun pathfinding for the current unit after you are done displaying tiles in range for the AI. That is the general idea. If you find this difficult to implement I’ll test it out myself.

rip street cred, the old gba fire emblem games are pretty sick, if you’re into that kinda thing you should definitely give them a play.

Just you wait until I get mechanics setup :wink:

Thanks! I’ll start working on that.

Hey, I tried following along this, and while it seems to work at first, after I order a unit to perform a an attack I can’t select any other units, even after I end my turn with that button. Additionally if I attempt to select the unit that would normally already be selected first with the vanilla system, it just shows the attackable spaces around him (However if I select another unit and then select him he has the expected functionality, as long he has remained unselected before). I’m guessing this happens because your changes don’t actually provide the system with a state where no units are actually selected and it just selects what it would normally select, except with the related ui hidden, idk im still trying to wrap my head around all this.

Any idea what I may have missed that’s causing my units to be unable to continue their turns properly?

Also I’m trying to work around the no unit issue by having a dummy player pawn that gets selected whenever the player hasn’t selected anything, or deselects one of his units. Is this a good idea or did I just miss something important in your example?

Seems like there were a couple of things I skipped when making the explanation. My bad for not taking notes while I experimented. To fix your issues, first set Disable Player Controller Input (contained in ATBTT_PlayerController) to false at the far right of the Event Graph of the Game Mode (same place where I set Local Current Unit to empty). This should prevent input from being disabled after you have attacked:

Also in the the player controller in the End turn if the current unit is clicked comment box check the local current unit instead of the current pawn from the game mode. This prevents the issue where you click an inactive unit which is stored as the current unit and it skips straight to showing attack range:

Having a dummy unit could of course also work, of course. That basically comes down to preference.

Worked flawlessly. Thanks a bunch!