I'd suggest using the MoveOrder event:
Code:
|
HandleEvent(MoveOrder) 'FinishImprovementsOrder' post {
unit_t tmpUnit;
int_t i;
for (i=0;i < army[0].size;i=i+1 ){
GetUnitFromArmy(army[0], i, tmpUnit);
if (tmpUnit.type == UnitDB(UNIT_WORKER)) {
FinishImprovements(tmpUnit.location);
}
}
} |
You put the improvement down as normal and then move your Worker (whose on an adjacent tile) on to it. The next turn, you move the Worker off the tile and, presto, there's the improvement. (I tried it using a Hoplite to stand in for your Worker.) This works fine for the Human and it should 'work' for the AI, too, in the way you described. To get the AI to actually try to do this would be much more difficult, if possible at all.
Note: You don't need "unit[0]=tmpUnit". Once you've declared "tmpUnit" to be a unit type variable you can access the members of the unit array in the same way as with a builtin variable.