Ok, sorry for taking a bit longer to reply now, but now I have the time to give you the steps.
First make a new map and add the ability system component to the units (or use the Advanced map, which has this by default, though it also has some stuff you don’t need). Make one unit have the Enemy faction and be AI controlled. Set their Move to 1. At this point if you play, the AI unit should move towards the player one step at a time, but we have no way to place bait.
Next we make our bait. I’m using a pretty simple blueprint for this. I create a new blueprint based on BP_GridActor (which comes with some functionality for interacting with the grid) that I call BP_GA_Bait. I add a static mesh (with collision disabled) just to visualize it. On BeginPlay for this actor I add a reference of it to the GridManager at its GridIndex, like so:
This doesn’t do much in itself, but it will let us discover it later by querying the grid.
Next we make our ability for placing bait. I create a new ability based on BP_Ability. On PlayerActivate I tell it to find all tiles within the ability’s Range that can be seen by the unit and add them to a Set. I also tell the Ability’s GridUI to display this to the player:
In ExecuteAbility I add functionality for spawning the Bait:
Note that this will happen instantly when clicking a tile, which you might know isn’t the way I generally do things in ATBTT (because of the action system), but since we probably always want the actor to be shown immediately after click it should be fine (if there will be cases where ExecuteAbility will be called while actions are currently playing, such as if you add AI that can use bait you might want to start the bait off invisible and have it spawn an action to turn itself visible on begin play)
Anyways, now we have our bait spawning ability. But the AI doesn’t care about it at all. To do this we will need to modify the movement AI, which is contained in whatever move ability the AI has. I’ll make a new move ability by duplicating BP_Ability_MoveAttack.
Now I’ll modify FoundNoValidTarget event, which is what is normally called when the AI finds no enemy in attack range (which will be common in a game with a move range of 1). Normally this would cause the AI to search for the closest enemy unit and move as far towards it as it can. We want to add code so that it will move towards Bait instead if it exists on the map.
For this purpose I create the FindClosestBait function for this ability:
Then I implement it in the FoundNoValidTarget event (thank the gods I bought an ultrawide monitor):
Okay, we are basically done, but just in case you might want units with longer move ranges later I’ll add a similar modification for when there actually are enemy units in move range. For this I override FindPotentialTargets so that we also find Bait along with units:
And I modify FindTargetValue so that non-units (which are always bait unless we add more such actors) will always be prioritized as targets over units:
And there you have it. If you follow the steps above you should hopefully get the result I added in the video in the last post. There are a lot of steps so it could be that I missed one, as I had to do this writeup a couple of days after coding this. Let me know if it works or not and if it gives you the result you want.