TestBuildOrder
Posted: 01 Apr 2010, 23:28
I'm laying the groundwork on a replacement for a Lua Skirmish AI that I was working on last year when it achieved sentience and committed suicide (or I accidentally deleted it while moving some files, I forget which).
Currently, to find a valid build location for a given unitDef, I start at some initial position (say, the current position of my Commander) then work outward checking every position to see if I can build there. When blocking = Spring.TestBuildOrder(ud,x,y,z,0) returns blocking>1, I know I've found a valid build position. I can then Spring.GiveOrderToUnitMap(comm,-ud,{x,y,z,0},{"shift"}) or something like that. I'm pretty sure this is how I did it before.
However, I noticed that some items in my build list (Kbot Lab, for instance) were not always getting built, so I added some debug stuff and found that sometimes TestBuildOrder was returning 2 for locations too uneven for such a large structure. The actual build order would fail (silently). In other words, TestBuildOrder was telling me that a location had passed the test build when it hadn't.
Has anyone else noticed a problem like this? Am I using these statements correctly? Is there an easier way to do this in Lua?
Currently, to find a valid build location for a given unitDef, I start at some initial position (say, the current position of my Commander) then work outward checking every position to see if I can build there. When blocking = Spring.TestBuildOrder(ud,x,y,z,0) returns blocking>1, I know I've found a valid build position. I can then Spring.GiveOrderToUnitMap(comm,-ud,{x,y,z,0},{"shift"}) or something like that. I'm pretty sure this is how I did it before.
However, I noticed that some items in my build list (Kbot Lab, for instance) were not always getting built, so I added some debug stuff and found that sometimes TestBuildOrder was returning 2 for locations too uneven for such a large structure. The actual build order would fail (silently). In other words, TestBuildOrder was telling me that a location had passed the test build when it hadn't.
Has anyone else noticed a problem like this? Am I using these statements correctly? Is there an easier way to do this in Lua?