If actor is walled in, attack walls responsible for barrier

Currently I have a “does path exist” decorator that will determine if my AI is unable to reach a destination and if not this will be due to walls that the player has built. Now I’m trying to make code that determines which walls are responsible for the barrier so they can be attacked.

My first thought is something along the lines of each time a wall is placed, discover adjacent walls and add them all to a shared group. then, when the actor being sought is not reachable, fire line traces in a radial pattern at the actor location to discover the walled group that’s responsible. The walled group will have to be discovered(line hit) on all sides of actor otherwise it could just be a lone wall sitting inside the walled in area and thus not responsible for the barrier. However, there are other checks that would have to be done and it’s getting complicated and I’m curious if there is a simpler way.

So I took an easier route. When an AI is blocked off from reaching it’s destination it will proceed with the path all the way up until getting stuck on the barrier. I used this behavior in my solution. The slightly trickier thing will be managing ranged units but I have a solution for that that should work.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.