So I've been helping out with the Lua AI for Conflict Terra. And I need a way to detect what (if anything) a constructor unit was building when it dies (perhaps in the gadget:unitDestroyed function?), so that it's job can be rescheduled to another builder.
Since it is for an AI, you might find it simpler to store in table when the order is given, and check that table when it dies.
Like:
local BuilderOnMission={} -- table indexed by unitID local DoItAgain={} -- table indexed by 1...n
...
function gadget:GameFrame(n) ... Spring.GiveOrderToUnit(... BuilderOnMission[UnitID]={some data that will help you know what and where it was building, like the cmd id and cmd parameters} ... for Index,OrderToGiveAgain in ipairs(DoItAgain) do -- type here some code to find a suitable builder and reissue order ... table.remove(OrderToGiveAgain,index) ... end end
function gadget:UnitDestroyed(... if BuilderOnMission[UnitID] then table.insert(DoItAgain)=BuilderOnMission[UnitID] BuilderOnMission[UnitID]=nil end end
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum