Page 1 of 1

Find a path length by Lua

Posted: 03 Jun 2009, 09:13
by Anarchid
I've been thinking of ways to make a certain Lua ai smarter - like not send ground units to conquer sectors that are either inaccessible to them, or obstructed by difficult terrain.

The obvious way to do that would be to make it check the path length to a candidate sector for the ground units, but the only way to do this that i found, seems to fetch the Path UserData Object, get a whole list of waypoints, and then manually calculate distances.

Is there perhaps anything easier?

Re: Find a path length by Lua

Posted: 03 Jun 2009, 09:26
by lurker
Easier... Can't you fit the math to calculate length from the path it returns into a piece of code that's shorter than my post?

Re: Find a path length by Lua

Posted: 03 Jun 2009, 18:32
by Tribulexrenamed
Pythagoras has been around for a while, no?

Re: Find a path length by Lua

Posted: 03 Jun 2009, 19:17
by Anarchid
Easier... Can't you fit the math to calculate length from the path it returns into a piece of code that's shorter than my post?
Äh, i probably should have written "faster". Anyway, if the obvious way is the only one, then the only way is the obvious one.