Author Topic: New code to create a mine route  (Read 2033 times)

Offline HaXtOr

  • Sr. Member
  • ****
  • Posts: 423
    • http://www.wtfmoogle.com
New code to create a mine route
« on: October 12, 2004, 05:57:10 PM »
Code: [Select]
void OreRoute(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)); TethysGame::CreateBeacon(map_Mining_Beacon, x+5, y-3, !common, yield_3, 1 /*variant*/);

TethysGame::CreateUnit(cc, map_Command_Center, LOCATION(x, y), player, map_None, 0);
TethysGame::CreateUnit(mine, map_Mine, LOCATION(x+5, y-3), player, map_None, 0);
if(common)
{
       TethysGame::CreateUnit(smelt, map_Common_Ore_Smelter, LOCATION(x, y-4), player, map_None, 0);
}
else
{
  TethysGame::CreateUnit(smelt, map_Rare_Ore_Smelter, LOCATION(x, y-4), player, map_None, 0);
}
MiningGroup miningGrp = CreateMiningGroup(Player[player]);
miningGrp.Setup(mine, smelt, rectMineGrp);
                TethysGame::CreateUnit(ct1, map_Cargo_Truck, LOCATION(x,y-6), player, map_None, 0);
TethysGame::CreateUnit(ct2, map_Cargo_Truck, LOCATION(x,y-7), player, map_None, 0);

miningGrp.TakeUnit(ct1);
miningGrp.TakeUnit(ct2);
}

basicly this code makes it much easier to make a automated mine. It is very effective for AI and big multiplayer maps, reduces large amounts of code.
tell me what you think?

edit by op2hacker: added code tags around the c++ code to make it easier to see.
« Last Edit: October 12, 2004, 07:23:06 PM by op2hacker »

Offline PlayingOutpost0-24

  • Hero Member
  • *****
  • Posts: 537
    • http://op3np.xfir.net
New code to create a mine route
« Reply #1 on: October 13, 2004, 07:28:18 AM »
nice, i will try it out...
Great news for OP2 fans... OP3 in progress.
Official Site
Outpost 3: A New Power progress
OP3:NP Discussion

Progress in OP3:NP[/size][/font]
PLANNING[|||||||||-]
GRAPHICS [||||------]
SOUNDS [|---------]
MAP DESIGNING [|||||-----]
CODING [----------]
Going slowly... Very slow.

Offline HaXtOr

  • Sr. Member
  • ****
  • Posts: 423
    • http://www.wtfmoogle.com
New code to create a mine route
« Reply #2 on: October 21, 2004, 11:23:12 PM »
Code: [Select]
void MineBuild(int player, int x, int y, bool common)// x any y are the location of the command center
{
Unit cc, mine, smelt, ct1, ct2,cv1,cv2,ew1;
TethysGame::CreateUnit(smelt, map_Common_Ore_Smelter, LOCATION(x, y-4), player, map_None, 0);

TethysGame::CreateUnit(cv1, map_ConVec, LOCATION(x, y), player, map_Command_Center, 0);
cv1.DoSetLights(true);
// TethysGame::CreateUnit(cv2, map_ConVec, LOCATION(x-1, y), player, map_Common_Ore_Smelter, 0);
// cv2.DoSetLights(true);
MAP_RECT rectMineGrp(LOCATION(x-3, y-11), LOCATION(x+6, y+4));
TethysGame::CreateBeacon(map_Mining_Beacon, x+5, y-3, !common, yield_3, 1 /*variant*/);

cv1.DoBuild(map_Command_Center, LOCATION(x, y));
/* if(Player[player].IsEden())
{
  TethysGame::CreateUnit(cc, map_Guard_Post,LOCATION(x-1,y),player,map_EMP,0);
}
else
{
  TethysGame::CreateUnit(cc, map_Guard_Post,LOCATION(x+1,y),player,map_EMP,0);
}*/
TethysGame::CreateUnit(mine, map_Mine, LOCATION(x+5, y-3), player, map_None, 0);

if(common)
{
    TethysGame::CreateUnit(cv2, map_ConVec, LOCATION(x+4, y), player, map_Common_Ore_Smelter, 0);
cv2.DoSetLights(true);
//cv2.DoBuild(map_Common_Ore_Smelter, LOCATION(x, y-4));
}
else
{
TethysGame::CreateUnit(cv2, map_ConVec, LOCATION(x+4, y), player, map_Rare_Ore_Smelter, 0);
cv2.DoSetLights(true);
// cv2.DoBuild(map_Rare_Ore_Smelter, LOCATION(x, y-4));
}
BuildingGroup &bldGrp = CreateBuildingGroup(Player[player]);
bldGrp.TakeUnit(cv1);
bldGrp.TakeUnit(cv2);
bldGrp.TakeUnit(mine);
bldGrp.RecordBuilding(LOCATION(x,y),map_Command_Center,map_None);
//bldGrp.RecordBuilding(LOCATION(x+5, y-3),map_Mine,map_None);
MiningGroup miningGrp = CreateMiningGroup(Player[player]);
miningGrp.Setup(mine, smelt, rectMineGrp);
               TethysGame::CreateUnit(ct1, map_Cargo_Truck, LOCATION(x,y-6), player, map_None, 0);
TethysGame::CreateUnit(ct2, map_Cargo_Truck, LOCATION(x,y-7), player, map_None, 0);
TethysGame::CreateUnit(ew1, map_Earthworker, LOCATION(x,y-7), player, map_None, 0);

//TethysGame::CreateUnit(ew1, map_Earthworker, LOCATION(x,y-7), player, map_None, 0);
int i;
for( i =0; i <=10;i++)
{
  bldGrp.RecordWall(LOCATION(x-4+i,y-7),map_Lava_Wall);
  
}
for( i =0; i <10;i++)
{
  bldGrp.RecordWall(LOCATION(x-4,y-7+i),map_Lava_Wall);
  
}
for( i =0; i <=10;i++)
{
  bldGrp.RecordWall(LOCATION(x-4+i,y+2),map_Lava_Wall);
  
}
for( i =0; i <10;i++)
{
  bldGrp.RecordWall(LOCATION(x+7,y+2-i),map_Lava_Wall);
  
}
miningGrp.TakeUnit(ct1);
miningGrp.TakeUnit(ct2);
bldGrp.TakeUnit(ew1);
bldGrp.SetRect(MAP_RECT(x-10, y-10, x+20, y+15));
CreateTubeOrWallLine(x-4,y-7,x+7,y-7,map_Lava_Wall);
CreateTubeOrWallLine(x-4,y+2,x+7,y+2,map_Lava_Wall);
CreateTubeOrWallLine(x-4,y-7,x-4,y+2,map_Lava_Wall);
CreateTubeOrWallLine(x+7,y-7,x+7,y+2,map_Lava_Wall);
}
bulds the mine from scratch
« Last Edit: October 22, 2004, 09:30:06 AM by Leviathan »

Offline PlayingOutpost0-24

  • Hero Member
  • *****
  • Posts: 537
    • http://op3np.xfir.net
New code to create a mine route
« Reply #3 on: October 22, 2004, 05:43:43 PM »
nicer... but i need to plant it into a mission or something...
Great news for OP2 fans... OP3 in progress.
Official Site
Outpost 3: A New Power progress
OP3:NP Discussion

Progress in OP3:NP[/size][/font]
PLANNING[|||||||||-]
GRAPHICS [||||------]
SOUNDS [|---------]
MAP DESIGNING [|||||-----]
CODING [----------]
Going slowly... Very slow.