Author Topic: Getting The Ai To Rebuild Mines  (Read 1722 times)

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Getting The Ai To Rebuild Mines
« 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.
 
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials