/** ** Assign free units to force. */ void AiAssignFreeUnitsToForce(int force) { const int n = AiPlayer->Player->GetUnitCount(); AiRemoveDeadUnitInForces(); for (int i = 0; i < n; ++i) { CUnit &unit = AiPlayer->Player->GetUnit(i); if (unit.Active && unit.GroupId == 0) { AiPlayer->Force.Assign(unit, force); } } }
/** ** Wait for a force ready. ** ** @param l Lua state. */ static int CclAiWaitForce(lua_State *l) { LuaCheckArgs(l, 1); int force = LuaToNumber(l, 1); if (force < 0 || force >= AI_MAX_FORCES) { lua_pushfstring(l, "Force out of range: %d", force); } if (AiPlayer->Force[AiPlayer->Force.getScriptForce(force)].Completed) { lua_pushboolean(l, 0); return 1; } #if 0 // Debuging AiRemoveDeadUnitInForces(); Assert(!AiPlayer->Force.getScriptForce(f).Completed); #endif lua_pushboolean(l, 1); return 1; }