Moogle's Ore Route Code
From OPU Wiki
A tutorial on makeing a very simple mineing Ai base that has cargotrucks routed
void MineRoute(int player, int x, int y, bool common)// x any y are the location of the command center{
Unit cc, mine, smelt, ct1, ct2;
MAP_RECT rectMineGrp(LOCATION(x-3, y-11), LOCATION(x+6, y+4));
// the x-3 , y-11 and the x+6, y+4 can be swiched, meanign you can start ware you want
// for this box
// rectMineGrp tells the mining group ware you want the cargotrucks to be abble to
//go, its a constrainging box, the cargotrucks wont go outside it
// be shure to make this has the mine and smelter inside it
TethysGame::CreateUnit(cc, mapCommandCenter, LOCATION(x, y), player, mapNone, 0);
// with out a active Command center, smelter or mine the cargotrucks will just
//sit around posibly pick up ore or move every once and a while
TethysGame::CreateBeacon(mapMiningBeacon, x+5, y-3, !common, Bar3, 1 /*variant*/);
TethysGame::CreateUnit(mine, mapCommonOreMine, LOCATION(x+5, y-3), player, mapNone, 0);
// mapRareOreMine is for the enumerators only!!! will cause crash at load if used!!!
if(common)// is the mine base a commonone or rare?
{
TethysGame::CreateUnit(smelt, mapCommonOreSmelter, LOCATION(x, y-4), player, mapNone, 0);
// it is a common mine base build a common smelter
}
else
{
TethysGame::CreateUnit(smelt, mapRareOreSmelter, LOCATION(x, y-4), player, mapNone, 0);
// it is a rare mine base build a rare smelter
}
MiningGroup miningGrp = CreateMiningGroup(Player[player]);
// create the mineuing group before you set it up or the game will crash
miningGrp.Setup(mine, smelt, rectMineGrp);// do this after the mine and smelter are built
// mineing groups need cargo truck to be aded to work
TethysGame::CreateUnit(ct1, mapCargoTruck, LOCATION(x,y-6), player, mapNone, 0);
TethysGame::CreateUnit(ct2, mapCargoTruck, LOCATION(x,y-6), player, mapNone, 0);
//they should be added after the group is created
miningGrp.TakeUnit(ct1);
miningGrp.TakeUnit(ct2);
}
To use this code on your map find a nice spot on the map you are useing then simply call
MineRoute(1,156,65,1);
