I had the jitters for a while there and nearly abandoned this project because I couldnt decide on a direction but I’m back to it.
I was looking at all kinds of things such as simultaneous player and AI movement and first person views but I couldn’t get anything to work well. The reason I was looking at first person was because I miss line of sight in xCom. I really like xcom but one thing I don’t like is the way line of sight works, or rather doesn’t. You just have to get in range and they pop up on screen or at least thats how it appears to work. This stops you from being able to creep up on things or have the enemy come up behind you which removes certain stealth elements. They’ve come up with a partial solution for this in xcom2 from what I’ve seen (not played it yet) but its not really what I was thinking for this project.
I made a recent purchase of Breach & Clear which is more where I think this project is heading (ie more human on human and not aliens). I was very impressed with the way it handles the turn based action in that you assign waypoints with look directions for all your characters and then hit play and you and the AI take a 5 second turn together.
This is the approach I’ve decided to take for my TBS. I’m using A* Pathfinding Project Pro as the basis for my path finding which I highly recommend. It comes with the source so I can make modifications if I need to but as I found out yesterday there is a learning curve.
I’m not using multi-threading for pathfinding as you only plan one unit at a time so that makes my changes a little easier. Previously I added a defensive calculation to the nodes so it knows when a tile gives you cover. Easy peasy. I’ve also added thin walls, so I don’t need to have a full tile unwalkable, I just disable the connection between the grid nodes. Again, pretty straight forward.
Yesterday I made a modification to add a second Penalty type to the Nodes which decreased on every movement. The idea behind this is that I can make a Unit go to a position and perform an action.
e.g. Say it takes 1 second to get to the position and 2 seconds to perform the action such as lock pick a door (3 seconds in total). Now another unit is 2 seconds from the door, the unit can move to the door, wait for one second and proceed through the open door (again 3 seconds). I know exactly how far the second unit can move because of the new penalty type. If a third unit is 4 seconds from the door the door will be open and no hold required. The whole point of this is to try and make the path finding as intuitive as possible and allow for more complex actions than is available in Breach & Clear.
While doing this I added a bug that caused Unity to crash at 11am and I didnt resolve the problem till 10.40pm. I got my maths a bit wrong here and kept blowing the allocated Heap for A* pro. Not the most productive day I’ve ever had but it was one of those things where I was too bloody stubborn to rip out my code and start again.
Anyway that appears to be working as planned now so I can get to using the hold penalty time to add hold points as well as reducing the total move distance. When that is done it should be a simple case of adding new actions to the project such as lock pick, blow door, climb ladders etc and path finding for action unit and other units should work together happily. Well, thats the plan.