[SUPPORT] Advanced Turn Based Tile Toolkit

Hey, !
Sorry, I was not able to answer to you yesterday, because it was well past midnight, and I have to go work 5 hours after. So, lets go step-by-step.
This is what I was trying to do:

Change the “BP_Unit”
[SPOILER]
bp_unit_mesh.png


[/SPOILER]
Injection in the “BP_TurnManager”:
[SPOILER]


[/SPOILER]
[SPOILER]


[/SPOILER]
So, that is how my code looks like. But collisions doesn’t work, however if I try to do whatever I want to this mesh, it works (changing size, material - whatever). Finally, I switched my attention
in another way.

I turned on “Pregenerate gameplay” and “Display tile edges” booleans, and saw this (as in the one of your videos):
[SPOILER]


[/SPOILER]
So I release that this is what I am looking for. In simple terms, my new idea is every unit must “think” that the tile (on which unit’s standing) IS the “last”, and it must always be the “last” according to unit’s back.
As far as I could understand your yesterday’s idea, our thoughts about it are the same. The problem is I cannot get in what BP do I need to add/modify code? I don’t want to harsh you in any way, but would you be so kind to be more detailed with explanations, because, unfortunately, your yesterday’s suggestions helped me not? Yes, I do understand an idea (as I said, I thought about it before), but I don’t know from where do I need to start (what BP do I need to dig)? After all, this question may arise in the future for someone else. Thank you.

PS: Forgive me, please, my ill English - it’s not my native language.

[USER=“908991”]kup guitarplayer[/USER]: No worries, I’ll give you a more detailed description when I have the time (hopefully tonight). But before that I’ll explain briefly why your solution does not work:

The locations of tiles and edges between tiles are set at the start of the game. If you change the collision of anythin during the game it will not affect pathfinding. To do this you will need to manually tell the grid to update part of the grid. It is also risky to do any operations outside of actions that are based on where the current location of a BP_Unit actor is in the world, since the action system is asynchronous (EndTurn and RunOnActorDeselected might be called before the unit actor has completed its move action).

I don’t think constantly updating the grid makes sense in your game in any case, since you want the connections between your tiles to be the same for the whole game. My suggestion does it all in the first tick of the game. Like I said I’ll get back to you when I have the time so I can give a more detailed explanation.

[USER=“908991”]kup guitarplayer[/USER]: Ok, here we go. I played around with it a bit and found a simpler solution than the one I outlined.

So first we make our board. I fill the center with impassable tile actors first and set bDiagonalMovement in the Grid Manager to false. Next I create a couple of actors based off BP_GridActor. They have no functionality other than the standard GridActor functionality, but I have added a static mesh plane and some text to designate the start and goal. Lastly I add an invisible wall between the two. This is how the end result looks:

At this point we have a board where we can move around the edge, but we can move both ways. So lets remove all edges on the board pointing backwards towards the start.

I create a new function that I call after grid setup (when the original edges are added). I run pathfinding from the Start location with a range that is as long or longer than the distance to Goal.

Next I loop over the output PathsMap, which holds the Grid Index of each tile on the path, the cost to get there and the “parent” of each tile. The parent for each tile is the previous tile on the path, which in this case will always be one tile closer to Start (since we ran pathfinding from here). Knowing this we can loop over the tiles in our pathfinding map variable and remove the edge between each tile and their parent (in the direction of the parent).

We are almost there. Only thing missing is to add a new edge from Goal to Start (since we blocked this with an invisible wall, removing the edge). So we add this manually at the end:

Et voilà:

Hello again,

I would like to change the hover decals to new meshes, but nothing I change seems to have any effect. Do I change this on the grid manager or the ability? Both? I’m certain I’ve tried it all and hunter down any mentions in the BP. Any help is appreciated. Thank you!

Hi, you can override it directly in the components of the ability. Like this:

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

hello!
1、The design of the evaluation system is great, but it’s a bit difficult for a novice like me,so I want to change the existing AI mechanism into a simple board game-style drawing card system.
How can I safely change the BP_AbilitySystem evaluation system to sequential execution of Ability

about evaluation system ,I watched the youtube and said that would explain it in the following video, but I waited for a long time and didn’t see the follow-up, including big units. It’s sad :D.
I don’t understand the principles of big-scale units.

2、I am modifying pathfinding, what should I do if I want to achieve the following effects, I am now using passthroughfrindly to modify, I don’t know if there will be any problems,In other words, the player may not be able to move in because a unit occupies the tile. Can AI ignore the unit and force it in?
“Take the red circle as the target, ignoring the unit on the targetindex will also move in and knock it back”
2.jpg
there may be a BUG problem (or I may have made it myself). When the unit uses pathfindingtype “Pass throughfrindly” to traverse two units, it will cause one of the grids in the path to become an accessible area.
1.jpg

3、What does “use tile values ”​​and “use slow loop” in AI-Assess ability value mean?How does suggest target (custom event) trigger?

Thank you very much!
There are a lot of questions, sorry

Hi, !

First of all, I want to thank you for your support and suggested decision: it almost works like a charm (however, has the small issues, but we’ll speak about it a little bit later).

So, since I was not able to write to you past 2 days (I’m very sorry :slight_smile: ), I want to share with you some “undone” code, which was done on my own:

https://i.ibb.co/YyhRXwk/backward-tiles-in-range.png
](backward-tiles-in-range hosted at ImgBB — ImgBB)​

(if this thumbnail would not open properly, here’s a full-sized screenshot at the Google Drive).

What I was trying to do:

  1. find, in what direction an active unit is watching;
  2. find, what tiles with what indices lies behind the active unit;
  3. remove those found tiles (or indices).

So, the articles “1” and “2” was done (you can see it on the screenshot), but I couldn’t found out, how to execute the article “3”. And this is where I stopped for now. I’ve tried to use “Remove Tile Edge” function, but I was doing it wrong, because of the buggy result.

https://i.ibb.co/YBLKH7L/remove-tiles-arr.png
](remove-tiles-arr hosted at ImgBB — ImgBB)

Why I decided to choose a “directional/compass point” system (operate with a function “Get actor forward vector”):

  1. there is no any necessary in creating some additional actors;
  2. in my case, unit’s movement cannot be more than the 6 points (tiles) per move;
  3. a structure of my main plane (GridManager) is almost the same, as it was in your previous answer (like in “Monopoly” game, if I can say).

What about the “small issues” with your suggestion. I repeated your code, it works, yes, but units can go though the walls, despite a “bTraceForWalls” bool in the GridManager was set to “true” (“Heightmap” was set to “One Level”). I’ve placed a “Cube” static mesh as a wall, and I’ve got this issue, even with its changed collision profile to “BlockAll” (clean project, working with UE4.25.3 - maybe, this information might be useful).

The next issue is when I switch from one unit to another, your suggested code become a half-working: one unit has a straight-forwarded movement, yes, but the other still has a bi-directional moving ability.

Both of this issues you can see on the screenshot:

https://i.ibb.co/YPYTzt1/issue-after.png
](issue-after hosted at ImgBB — ImgBB)

(if this thumbnail would not open properly, here’s a full-sized screenshot)

So, in the end, I have two questions:

  1. what function(s) do I need to add to remove all the tiles that lies behind the unit’s back (talking about my code);
  2. are those issues (ignoring walls and not so correct movement) are really issues, or am I just dumb?

Thank you!

@猫狗乱舞 and [USER=“908991”]kup guitarplayer[/USER]: Between you this is quite a lot to answer, and in many cases questions I will need to do some testing to figure out the best answers to. I have a very pressing deadline at work by the end of this week, so I cannot promise to answer these questions in depth before early next week. Sorry about that, but deadlines + having a small kid = very little time remaining. But I have some follow-up questions to you that will make it easier for me to help you as soon as I get the time:

@猫狗乱舞: I don’t understand your first figure. So the two blue circles are friendly units and the red circle is an empty tile that the player clicks to move to? And when you say that the units are pushed, where do you want each of the two units to end up?

and sorry about the lack of tutorials on the ability system. I hope to make a lot of new tutorials for all sorts of things as soon as I’m done with the next update.

“use tile values” means that the ability will calculate a value for each tile in move range (determined by things like if they have cover, if they are close to a lot of enemies etc.) and take this into account when deciding what to do. “use slow loops” is for optimization. Determining the value of all tiles relative to all targets is a costly operation, so using slow loops allows the AI to calculate it over multiple ticks.

As for big units. the underlying code there is pretty complex. I generally suggest people not use big units unless they really need to, since it is the sort of thing that makes everything else more complicated. If you are determined to use them anyway, please specify what parts of the system you are struggling to understand and I will try to explain.

[USER=“908991”]kup guitarplayer[/USER]: The suggestion I came with only works if the map consists of paths that are 1 tile wide (like the path along the edge of a Monopoly board). In your screenshot it seems like all tiles are open to be moved to, and it will not work. If you are not making a game similar to Monopoly I would appreciate if you could explain your game in detail so I know what assumptions I will have to keep in mind. Is there a game with similar rules you can point to? How exactly does the board look? What can a player do during their turn?

For your first question you do not want to remove tile edges when you simply want to remove tiles from a specific unit’s pathfinding result. Removing edges will remove these tile connections from the grids permanently, not just for the current unit. But if you already have a list of all the tiles you do not want the unit to reach, put the Paths output of RunPathfinding in a local variable, loop over the keys and check them agains your list of tiles to remove and remove these from the local variable when you find a match.

unitA chooses unitC as the target of attack, so unitA ignores the existence of unitB and enters his position, and Knock unitB back several Grid (by the way, is there a preset function to determine the direction?For example, front, back, left, and right based on the character coordinates, backstabs can be achieved)

The unitA pathfindingtype I use now is “PassThroughFriendly”, but since unitA is controlled by AI, I am not sure if it will enter the Index of unitB

unitA is an AI enemy, unitB and unitC are player characters, they are from different factions
2.jpg

I found the triggering method of the following content. It was actually in “moveattack-click”. Is this a player behavior? I thought it was related to AI. I will read and learn.

“QueueAction” works great and reasonable, but I don’t understand a problem. I set a QueueAction and select Queued as QueueType. How to send it from Actions to CurrentAction? I use “signal ability executed”. He executes it, but I think as a phased action, maybe I should choose “immediate”, whether your idea is Queued is to “signal ability executed” to execute

Thank you very much, it is really hard for a child:D

This is the ability range1 of the size2 unit.
I don’t know why the big unit modifiy doesn’t take effect.
1.jpg
The correct size2 and range1 should be the blue area of ability_move.I want to combine them.

2.jpg

But this is from the player’s view. The point is that the big unit is AI, so it seems that the range of it is different from the player’s range. I don’t know if he will find the target correctly.

It seems that the AI activate range of ability has no big unit modify,
Functions such as “find closest unit in move range” seem to be searching for targets based on a single grid

for example,If my move is 1, range1, then AI should be able to target the unit in the red cross instead of based on gridindex4003 move+range(Find PotentialTargets-Find Unit in Range)
QQ图片20201027214211.jpg

I imagine that the AI’s mov1,range1,current target range ,this is wrong.

3.jpg

Sorry, the question is more complicated, maybe my understanding of the operation mechanism is wrong

Thanks for the detailed description. That will be very useful when I try to solve this for you. As I mentioned I have a deadline at work coming up this weekend, so I will not be able do test this out personally until early next week. These questions are complicated and not something I can answer without doing some testing, so I hope it is fine for you to wait a few days until I can get back to you.

Thank you very much, it involves basic logic, so I am confused

Hi, !

It’s alright, no worries, answer as soon as you’ll have some free time. As for me, your answer’s delays gives, at least, me an additional time to think :wink: .

Yes, you’re absolutely right: your suggestion works for the game like “Monopoly” (so, my project has almost the same mechanics and closely looks like the “Monopoly”, but a little bit different).

So, as I said before, my project almost the same, as the “Monopoly”. And what am I trying to create is an universal, code-based only function. “Universal” means: using it for the all types of games, based on ATTBT, without any additional meshes at all. And it almost works, but the last and the only thing I need to goal is to mark unwanted tiles as unreachable. Here I did some pics for better understanding (hope it helps):

Doesn’t matter what wideness of the grid is using:
https://i.ibb.co/yRz6mgk/want-to-goal.png

OR

https://i.ibb.co/dPBqMCV/want-to-goal-2.png

As you can see, I’ve already got a map with unwanted tiles, separated them, and I’ve already got a map with needed tiles (they’re printed on screen). The only thing I need is to mark unwanted tiles as unreachable. It’s a pity, but the last part of your suggestion:

was a little bit confusing to me. I thought about using “RemoveUnreachableTiles”, tried to changing it, but, unfortunately, I failed in my tries.

So, the main question is: what function/macro - whatever - do I need to use to reach my goal (the goal is - let me repeat myself - to mark unwanted tiles as unreachable)?

Starting from the “RunOnACtorSelected” event:
https://i.ibb.co/qphtxcj/starting-from-roas.png

Getting all the tiles, according to the unit’s move range:
https://i.ibb.co/jD5D5C9/remove-backwards-move.png

“PreventBackwardsMove” macro:
https://i.ibb.co/t838248/remove-backwards-move-function-needed.png

By the way, I’m starting from the “RunOnActorSelected” event, because when I try to refer to the “ActiveUnit” var of the “BP_TurnManager” from the “BP_GridManager”, it returns nothing. Seems to me, when the game starts, a unit has no direct player controller focus (it’s a little “broken”). You can try it by yourself: place some units to the map and try to press “E”, “Q” or event “Tab” buttons right from the start, and you’ll see no result. But, when you click anywhere, all of the controls becomes active. But, again: maybe, it’s just me a clumsy dumbass?

Note: I’m using UE4.25.4 (if it matters).

Thank you!

Finally, seems to me, I’ve found what I was looking for:

https://i.ibb.co/2j5KTt3/impassable-to-go.png

I changed the code of my macro “PreventBackwardsMove” a little bit, so now all the tiles I want to be as “unreachable” becomes marked as impassable, according the function (how ironic, isn’t it :smiley: ). The only problem is now no any decals drawing on the impassable tiles. I suspect, it’s all about a “RemoveTileEdges” function, situated inside the “MakeTileImpassable” function.
So, the question is: am I using this function correctly (for now, I don’t see any other variations of this problem solution), or what do I have to do to change its behaviour (marking tiles, but not removing underlying edges)?

I’m sorry I have another small question

I made a Fear Status,in enemy turn gave the target player a Fear Status Effect to move it to the farthest Index.

An error was reported when running.

In this Fear Status BluePrint, use “Run pathfinding” to find the range that the Player can move


Since I turned on the big unit, the player unit size is at least 1, and pathfinding is forcibly set to “big”

The error appears in this “Branch”

I guess it’s because the role currently executing the action is not the “ActiveUnit” of this round(in enemy AI’s Turn)

I’m not sure how to fix this, I can even break this branch without any problem

even if there is an error report, I can still get the correct result in the end:eek::eek::eek::eek:

Hello! I ask for help! Sorry in advance for my english. The path of the character’s movement is not shown for me, from this error (as it seems to me). Also, the characters do not move along the designated path, but somehow randomly. I recorded a video and showed errors.
https://drive.google.com/file/d/1HZm…ew?usp=sharing

Hi, orlovpavel!

Are you using UE4.24?

hi! UE 4.25.4

ERROR:
Blueprint Runtime Error: “Attempted to access NODE_AddSplineMeshComponent-0 via property CallFunc_Array_Get_Item, but NODE_AddSplineMeshComponent-0 is pending kill”. Blueprint: BP_Grid_Manager Function: Destroy And Clear Previous Spline Path Graph: Destroy and clear previous spline path Node: DestroyComponent

Hm-m-m… All the input/output pins connected correctly to all the nodes? Check if you’ve missed some?
By the way: seems to me, you’re using a “BP_Unit_Anim_Debug”? If so, AFAIK, it’s not a really good idea ( will correct me, if I’m wrong).

ok, sorry for the long abscence. The last week has been a bit crazy, but things are better now. I’ll answer your questions in the order based on how difficult they are to answer, so I’ll do orlovpavel, then kup and then 猫狗乱舞.

from the names of the folders and blueprints I see that you are using a really old version of the toolkit (several years old). If you open such an old version of ATBTT in the most recent version of UE4 you are bound to get issues. I would recommend creating a fresh project with the latest version of the toolkit.

Create a new ATBTT project from the Vauld in the Epic Games launcher and choose 4.25 as the engine version and that should resolve your issues.