davidlallen
Deity
I have worked out a mechanism for units that use fuel. It is simple and specific for a "precious fuel" application (see my sig). In this mechanism, fuel trucks are produced in cities with refineries, and when a gas powered unit is low on fuel, you can "use up" a gas truck to refuel it.
For the human player, this is working fine. For the AI, not so much. The AI will build gas trucks and gas powered units. Then it sends out the gas powered units to attack while leaving the gas trucks at home. The attacking units run out of gas and get stuck.
I am not using SDK and I don't want to get involved in it. I know there are mods, like Final Frontier, which do quite a lot of the AI in python. I have a few hundred lines of python already and I am using the onBeginTurn / onEndTurn hooks for some other, simple AI behavior. I have designed the algorithm to look at gas truck locations vs gas powered unit locations and decide which truck to move where.
The one critical thing I am stuck on is, how can I tell a unit to move "towards" a location in python? Depending on terrain, roads, etc I cannot easily tell how many plots it can actually traverse. I just want to give it the destination and have the engine work out moving it there. I could set the x,y location but then if the path is visible to the player, the truck "teleports". This is undesirable; for example, it could teleport past player units.
Is there any way to give a destination to a unit in python?
For the human player, this is working fine. For the AI, not so much. The AI will build gas trucks and gas powered units. Then it sends out the gas powered units to attack while leaving the gas trucks at home. The attacking units run out of gas and get stuck.
I am not using SDK and I don't want to get involved in it. I know there are mods, like Final Frontier, which do quite a lot of the AI in python. I have a few hundred lines of python already and I am using the onBeginTurn / onEndTurn hooks for some other, simple AI behavior. I have designed the algorithm to look at gas truck locations vs gas powered unit locations and decide which truck to move where.
The one critical thing I am stuck on is, how can I tell a unit to move "towards" a location in python? Depending on terrain, roads, etc I cannot easily tell how many plots it can actually traverse. I just want to give it the destination and have the engine work out moving it there. I could set the x,y location but then if the path is visible to the player, the truck "teleports". This is undesirable; for example, it could teleport past player units.
Is there any way to give a destination to a unit in python?