Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: Sirbomber on February 08, 2010, 08:45:19 PM

Title: Getting The Ai To Rebuild Mines
Post by: Sirbomber on February 08, 2010, 08:45:19 PM
Remember how I was having trouble with this?  Here's code that works:

Code: [Select]
void SetupRebuildMines()
{
    // Create the building group
    RemineGroup = CreateBuildingGroup(Player[1]);

    // Add the units to the group
    MAP_RECT MinerBox(240+31, 78-1, 244+31, 81-1);
    RemineGroup.SetRect(MinerBox);
    RemineGroup.TakeUnit(AIMiner);
    RemineGroup.TakeUnit(AICommonMine);
    RemineGroup.TakeUnit(AIRareMine);
    RemineGroup.SetTargCount(mapRoboMiner, mapNone, 1);
    RemineGroup.SetTargCount(mapCommonOreMine, mapNone, 2);

    // Record the mines
    RemineGroup.RecordBuilding(LOCATION(241+31,  89-1), mapCommonOreMine, mapNone);
    RemineGroup.RecordBuilding(LOCATION(245+31, 112-1), mapCommonOreMine, mapNone);
}

Remember: Never use "mapRareOreMine"!  It's buggy!  Use mapCommonOreMine, even for Rare Ore Mines.

Minor quirk:  The Robo-Miner likes to pretend it's a ConVec and will move one space down and to the right of where the mine should be before it deploys, but the mine structure will be in the right spot.