[SUPPORT] Advanced Turn Based Tile Toolkit

No need for clicking. That was just a quick way to debug it. UpdateTilesInRange can take either a location or GridIndex as input. So get the center of your multi-tile actor as location input. and add a range that will encompass it.

Hi ! Your message is not approved by Epic yet (takes a bit for your first post). Thankfully I can see it, since this is my thread.

So a movement cost of 0.5 is not possible with the current setup. However you can always double it, so that edges that would cost 0.5 cost 1, while those that would cost 1 cost 2. Default tile costs are set in the various ā€œAddTileEdgesā€ functions (there are one for each heightmap option). This is what you would modify if you want something that affects the movement of all units. I don’t know exactly what your end result is, so I cannot give you more suggestions than that without some more info.

For your second question of reducing AP per tile, that is a setting in the different included movement ability blueprints. It is the ā€œMoveCostTypeā€ variable, which is in BP_Ability. Choose ā€œFromPathfindingCostā€ is probably what you want. You would want to increase unit AP so they can move more than 2 tiles, and increase the cost of attack abilities as appropriate (or set bUseEndsTurn to true for these, if that is what you’re going for).

If you tell me more I can help you more. How would a unit turn from start to end look in your game? What edges should have a cost of 0.5 and which should have a different cost? What is the intention behind the cost differences here?

Thanks, I think I mostly get it now. This mostly comes down to array manipulation of the InitiativeOrder array. The devil is in the details, of course. Before I jump into this (will take some work) let me try to describe what you are saying back to you, so I’m sure I’ve got it.

Players will have different units. Some of these will be individual units not part of a troop (like the green units above), while others belong to a troop (the aliens). At the start of a player turn you choose what unit to move. After the unit has done its action, if the unit is an individual unit the turn will pass to the next player. If it is part of a group the turn will pass to the next unit in the group, controlled by the same player, until the last unit in the troop has completed its action, at which point the turn is passed to the next player. Is this the right interpretation?

A follow-up to that: should a player be able to choose the same unit or troop again and again, or do they have to exhaust all units and troops before they are allowed to choose freely on their next turn?

Also, love the paint job on the debug wall tiles :wink:

2.6 is out! Generally I sync ATBTT updates to UE4 updates, so the version you get from the launcher if you create a new project with ATBTT and select UE4.25 is 2.6. I see now that it says 2.52 in the description and comments, though… I decided last minute to change the version number to a full update, since it was more to the update than simple bug fixing, but seems like I forgot to give the project description the memo… That is just a number, though. Everything from the update is there.

no
1 you show but not ful description i not found the files from descriptin. i atach te image.
and the second is to enemy make a return atack i one turn.
i ad the video with fight on hmm3. https://www.youtube.com/watch?v=KB9Q7RV9oAs

I’m sorry if I’m replying in the wrong place!

Thanks for your reply. That movement cost type is much closer to what I wanted, thank you.

The cost of movement isn’t so much the problem like you said. A unit in my game should be able to move freely at the cost of AP without ending their turn. For example, I could move, cast an ability, and move again if I have AP left over, even if its 1 tile of AP left. I would like to convert the move_attack ability but maybe there’s an easier way to set this up?

I want it to be the default action (or unit ability) whenever you select a unit without having it in the ability bar.

​​​​​​​Edit: Looks like that movement type was enough! For some reason though when I get down to 2AP I lose the ability to move, even though I should have 2 tiles left. Must be some conditional somewhere I haven’t found yet!

Easiest paint job ever, just had to turn the camera and it’s like magic! Haha :smiley:

You nailed it, man. What you described with the solo units and the groups is what I meant and pretty much exactly what I’m going for!

As for the follow up question, if possible I’d like to be able to limit which units take turns instead of letting them be picked freely when the turn is passed to the player. The idea is that the turns would already be predetermined in a given round and then play out in order. I’ll lay out the game sequence just to give an idea of how I’d ideally like things to run.

  1. Game Start
  2. Players place their team’s units where they want them to start within their home base hexes
  3. Some sort of dice roll RNG to decide who goes first in the round
  4. Round 1 turn order phase: players will have 3 turns in a round and will pick either a solo unit or a group unit to take those turns in a set order of 1, 2, and 3. The solo unit or group picked for these turns can be the same for all 3 turns. This is where I was thinking to set the initiative since we’d know who is going first and then it’s just a matter of bouncing back and forth between units 1, 2, and 3 of either player. Once both players have selected the units for turns 1, 2, and 3, the turns begin.
  5. Player 1 turn 1
  6. Player 2 turn 1
  7. Player 1 turn 2
  8. Player 2 turn 2
  9. Player 1 turn 3
  10. Player 2 turn 3
  11. Round ends
  12. Repeat steps 3 to 11 until game has ended

So in theory it doesn’t seem that complicated, but I’m not sure how intricate things would need to be in a setup like this with the toolkit. If it’s too tricky I can always try to make something else work, but let me know what you think. Thanks!

​​​​​​

What files are you struggling to find? For counter-attacks this has been discussed a while ago in this thread. Try to replicate what @ made and see if it works for you. If you have any issues, get back to me. The start of our discussion starts here. Then it goes back and forth for a few pages.

Glad to hear that was enough! The 2AP issue is probably because of specifically how BP_MoveAttack is set up. If you check the PlayerActivate event you’ll see how it switches based on the owning unit’s AP. This is the bit you will need to modify, I believe.

Really, just the angle? Well, my color vision was never great.

Working on this question now, but got interrupted. I’ll update this post once I have a solution.

Edit: This turned out to be more challenging than I expected. Going to need to put this on hold and get back to it in a couple of days.

So, been struggling with multi-level and understanding the meaning of the different settings (yes, watched this https://www.youtube.com/watch?v=e-YG…15jXKF&index=8 many times).

For my case, I’m looking at creating 150 height hex meshes, that can then be stacked on top of each other. Using general map as a starting point, I set the max grid to 1000, and height between levels to 1000. Basically, you can’t go underneath.

The height impassable is 200, and height slow is 200.

This seems to work, and I can create a stairs of 6 each incrementing by 150. And that works. However, using height impassable of 150 only allows climbing the first stair. Looking at the code, its not quite obvious why although I’ll note that the code description for the GetEdgeCostFromZDifference comment doesn’t seem to match the flow. Oh and heightmap is set to 1 level

Also, it sounds like that the height between levels is only really useful if you are allowing the setup to automatically figure out levels… I did try the above with heightmap both at 1 level, as well as multi-level.

Thoughts?

Hello! I am fairly new to UE4, and I can’t seem to find where certain variables are utilized in the Unit blueprints. I am trying to generate randomized stats for each character in combat, so things like movement speed, max health, melee damage, etc. are varied. I’m not having trouble with generating the values I want, I’m having trouble finding where to put them. For example, I can only find references to the ā€œCurrent Healthā€ variable, when I want my random values to be manipulating the ā€œMax Healthā€ variable instead.

I want to be able to run randomized units in the code, rather than just manually modifying units via the details tab in the editor. Where can I plug my numbers in?

(Thanks for the incredible toolkit by the way, it will truly shave years off of the work I need to put into this project. Absolutely stellar!)

Sorry, but I’m not really able to visualize the desired end result here, which makes it difficult to come up with suggestions. How does the game look and play? Are you stacking the tiles during gameplay? How are units intended to move between tiles?

MaxHealth is a variable in BP_Unit. Perhaps you are modifying one of its child blueprints and have forgot to check Show Inherited Variables? Where it makes sense to put the code for modifying attributes depends a lot on the needs of your game. Want to modify unit abilities by clicking on them during gameplay? Use an ability. Want to assign random stats when a unit is spawned, do it at EventBeginPlay for BP_Unit.

Glad you like it!

Hi ,

I am having a hard time with AI - I often get hung up with an infinite loop in my move_attack ability right after the AI activate AP > 1 conditional false evaluation. I believe its due to evaluation of abilities tying for 0 maybe? I honestly can’t figure it out. I have all of my AI logic in BP_Ability except for the AI Activate in move_attack. I changed my move_attack ability to cost 0 to move and using the units move cost, but cost 2 AP when the unit attacks - and I subtract that AP in the execute ability function after a conditional.

For some reason when using other abilities though, in move_attack I had to change the AP > 1 evaluation to .005 which seems to do the trick, but my enemies get away with moving and not spending any AP sometimes. I am logging the abilities they activate, and they can move without activating the move_attack ability. I can’t do the same thing with my player controlled characters. These issues don’t seem related but I can’t figure out whats going on. And why the value of 0 in the evaluation loops forever I’m not sure.

Thank you for posting this!! I’m working on integrating this into my project/experiment and before I completely destroy everything lol, I’m wondering how you would approach adding time-based ticks for execution… I’ll try to explain what I mean here.

3 players on the grid - A, B, and C.

Player A chooses to move 6 tiles away, costing him 6 AP (1 move per AP)
Player B chooses to move 3 tiles away, costing him 3AP
Player C chooses to move only 2 tiles , costing him 2AP

No additional players are idle so the turn begins ticking and players begin moving, 1 move increment at a time, simultaneously.

2 ā€œticksā€ in - Player C is done moving and becomes idle. Gameplay pauses and Player 2 can choose a new action - he moves 4 tiles away.

No additional players are idle so the turn ticks and players move one more space.

Player B has now completed his 3 movements and is idle - Gameplay pauses and he may select a new movement.

EDIT: Just wanted to add that I’m not expecting a full-blown ordeal like you’ve done above - just generally what I would want to start modifying. I’m guessing it would be the turn manager and the new simulmove ability that I make mainly?

EDIT2: Yikes, pausing all moving units while the available unit takes his turn is proving to be a real challenge. - @****This is what I’m trying to do - When the first unit stops moving, all other units should stop on their tile, preferably freezing in place, while the available unit makes his next move. When he chooses his next tile, everyone unfreezes and continues moving.

It really IS that simple, okay then! I’ve been overthinking the programming all weekend, it seems. Thank you for the help, much appreciated!

Hi @
I am trying to implement using each move as a AP point (which I did), for the player works fine, but for the AI, the movement animation is not playing correctly.
What I did was:
Created a blank project (unreal 4.24)
Added two BP_Unit_Anim, one player and one enemy (AI)
Added ability system with Move and Attack abilities
CHanged the Move Range on Move ability (as below image)


Changed the cost to be Custom (1) and set the UseEndsTurn to false on the move ability.

When it is the AI turn, the first time it uses move, works fine, the second and third times (the unit have 3AP) the animation does not start from the previous location, it starts from someplace else.
Couldn“t upload the gif here, so here is a link to it

Also, if the player unit is 6 or less indexes away, the AI will seem to use a single Move_Attack with 6 move points (even though it does not have the Move_Attack ability)

any idea on how to fix this?
also, is there a way to force a delay every time an AI unit spends an AP point to sort of simulate the AI ā€œthinkingā€ before making every move?

ps: sorry if it was asked and answered before

Hmm yeah this is a challenge alright. I can give you some places to start, but not sure if it is the best approach. This will require a lot of experimentation, I think. I guess what you could do is to store the length of the path of each unit in each unit. Then when all units have chosen their move and a new turn starts (the one that starts playing all animations automatically) you would first loop over all units and find the shortest path.

You could store this in some place all units have access, like the game state. Then when the units activate their abilities you would find this value. After finding the path to an index using the stored target index you would loop over the output PathIndex array and only keep the amounts of indexes equal to the length of the shortest path, take the last index of this cut down array and use it as the new TargetIndex for the ability. Then you would keep the old target index as the target index stored in the unit, so it will keep going the next time it is activated.

Those are my initial thoughts, at least. You are taking the toolkit in a pretty different direction than what it is meant for, so my suggestions will have to be a lot more tentative than usual.

Happy to help!

Hey, sorry, but I’m a bit unsure of what to do here. It is simpler if you could give me the desired outcome in more detail, which would make it simpler to find the best solution. How do you want this to play out in your game? How do action points/movement work in your game and how would you expect the turn to play out if everything worked like you wanted it to?

No problem, thanks for taking the time to look into it!

Thanks! - any ideas that come to mind are greatly appreciated. For now, I’m focusing on learning everything you’ve created so far with your youtube videos and whatnot, then I will probably have to gut everything that doesn’t apply to my vision/idea.

Generally, I had only worked on FPSs with UE4, so I needed something to get my brain going in the turn-based direction and your template is gold for that! Really impressive what you have done and the amount of time you’ve put into the project as well as helping everyone!

What an impressive template! I’ve watched most of the videos and I have a few questions:

  1. One video changes animations by swapping for the new one. If I want to use animations that aren’t currently in the anim blueprint, is it difficult to add without breaking everything else?
  2. I didn’t see a video describing how you added cover points; is it a simple process?
  3. The level ā€œJungle Raidā€ looks approximately what I’m after. Can this system be used on terrain, or are you constrained to simply using a static mesh as ā€œthe groundā€?
  4. How does this system handle both indoor and outdoor locations on the same map? Can units enter buildings, and if yes, how is the grid handled?

Thanks.

Have not had time to return to this yet, sorry, but I’ll get to it at some point!

I’m glad you think so, and I hope you’ll find the toolkit flexible enough that you are able to achieve your desired results without too much hassle.

Hi Dijon, glad you like the template :slight_smile: I’ll do my best to answer your questions.

  1. Adding new animations is not that difficult. You can follow the same approach that the other animations are driven by. The animations in BP_Unit_Anim are generally triggered by setting bools in the animation blueprint event graph. These in turn trigger transition in the animation graph. The bools are set through the AnimateAbility event, which is called from BP_Unit whenever BP_Unit receives a QueueAction with it as an executing actor for which it does not itself have a definition in the name switch of AnimateAction.

To give you the order: Any QueueAction with a BP_Unit class actor as the ExecutingActor which has an ActionName not defined in AnimateAction for the unit will get passed to its animation blueprint. There you can use the name of the action to choose some course of action. You could for instance set a bool to trigger an animation in the animation graph.

Hope that made sense.

  1. Yeah, I have not made a video on that. To add cover you add the BP_CoverSystem component to your GridManager. At begin play this component does line traces in all straight directions for each tile, using the custom CoverTrace channel. There are two height it checks, which determines whether to grant half or full cover. Utilizing this data must be defined within the abilities you are using (as they are in BP_Ability_Laser)

  2. The ground in JungleRaid already is a terrain Landscape, so yes :slight_smile:

  3. Sure, you can do buildings. Single-story buildings are simple. If they need a roof you can use BP_GA_Platform actor for the roof, which turns translucent and click-through if you zoom close enough. Check out the platforms in JungleRaid to see how this works. Multi-story buildings also works. Just set the Heightmap variable in BP_GridManager to Multilevel

@

Can I set the height for what is considered hull and half cover?

So the grid will display on top of whatever you want (mesh, terrain)?

Does this require a separate grid?

Thanks for taking the time to reply.

Yep, it can be set within the cover component.

Yes, anything within the bounds of the grid that blocks the PathTrace channel will be added to the grid.

You just need the one grid.

Hello,

I’m still running into issues where the AI never stops assessing abilities. The error says it is thrown in update attributes, but I think it is constantly comparing it with another ability of equal value. I’ve logged the assessed value and it is 0, so I would assume the AI would pass its turn. But it just reassesses. How can I ensure they stop their assessment loop?

Edit: I verified all of the abilities it considers tie for 0. I guess it would still prefer to do one over the other, and continues to loop. Is there a good place in the BP_Ability BP to address this globally?


This will cause them to do nothing when they could but it does stop my error I think. I actually moved it directly after the branch.