Kailric
Jack of All Trades
I have to admit, I'm skeptical about designing decent supply lines for units.
I mean, part of the problem is that a plot in enemy territory is not considered to be connected to your cities. When the game checks if a tile is connected to a particular city or your larger trade network, the game isn't checking the tiles between it and your city to see if there's a route connecting them. Each time a route is built (or destroyed) on a tile, the tile is added to a "plot group" that contains all the tiles that are connected to the trade network. If two tiles are in the same group, they're considered to be connected.
So if you want to have units on foreign plots considered to be connected, then you are going to have to check for valid paths back to your territory. I've toiled over this subject and found it very frustrating because it seems like a good check for a unit's valid supply line is going to eat up a lot of processing time for each unit.
Yeah, I found out exactly what you are talking about there.. but I seemed to have added Zone of Control with no problem.. it works like Blockade does in the game. I just simply added code similar to the Blockade code. If a friendly unit is in enemy territory and has the roads under his ZoC then the plot group of those plots are changed so that player can use them for trade. If the unit moves from that spot or cancels ZoC those plots are removed from that group. It should use no more processor than Blockade does.
The kind of Supply I am working on will have 3 levels.
1st Level. Direct connection to a City by route.
2nd Level. Clear path to a city.
3rd Level. No clear path.
Now checking for just a clear path with ZoC factored in has proved to be a bit of a problem. But what I have on the drawing board to do is two checks. The first checks to see if each city's plot group is connected to the units plot group, if so then it can heal at 1st Level. Then if not, I may can do a "generatePath" check and if that turns up true then thats 2nd Level. If those two checks fail then its Level 3.
Thats what I am attempting to get to work now.
Actually, when you think about it there is already a simulation of "Supply Lines" in the game as units heal different when in friendly, neutral, and enemy territory. We are just trying to add checks to see if the unit is actually connected to a supply source.