Author Topic: Placing Units For Multiple Players?  (Read 1656 times)

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Placing Units For Multiple Players?
« on: November 22, 2005, 11:52:21 PM »
I made this code to test adding in a AI but something doesn't work right. I want to make the AI have units of their own and have more or less units. But any changes I make to struct VehicleInfo unitSet2[] =  never show up?  can anyone give me a little help here?


here is my basedata.h

Code: [Select]
#ifndef BASEDATA_H
#define BASEDATA_H

#include <OP2Helper.h>
#include <BaseBuilder.h>

#define numof(array) (sizeof(array)/sizeof(array[0]))
#define autosize(array) numof(array), array

struct BeaconInfo beaconSet1[] =
{   { 10,  17, mapMiningBeacon, 1, 0, -1},
{  5,  17, mapMiningBeacon, 1, 0, -1},
{  -5,  17, mapMiningBeacon, 0, 0, -1},
{ 0,  17, mapMiningBeacon, 0, 0, -1},
{ 15,  17, mapFumarole, -1, -1, -1},
{ 20,  17, mapFumarole, -1, -1, -1},
};

struct VehicleInfo unitSet1[] =
{
{  14,  14, mapConVec,   mapCommandCenter, 2},
{  13,  14, mapConVec,   mapStructureFactory, 2},
{  14,  13, mapConVec,   mapTokamak, 2},
{  12,  14, mapConVec,   mapStandardLab, 2},
{  12,  13, mapConVec,   mapAgridome, 2},
{  13,  13, mapConVec,   mapCommonOreSmelter, 2},
{ 9,  9, mapCargoTruck,  mapNone, 2},
{ 10,  9, mapCargoTruck,  mapNone, 2},
{  9,  10, mapCargoTruck,  mapNone, 2},
{  10,  10, mapCargoTruck,  mapNone, 2},
{ 10,  13, mapRoboSurveyor,  mapNone, 2},
{ 11,  14, mapRoboMiner,  mapNone, 2},
{  11,   13, mapEarthworker,  mapNone, 2},
{  10,  14, mapRoboDozer,  mapNone, 2},
{  15,  10, mapLynx,  mapMicrowave, 2},
{  16,  10, mapLynx,  mapMicrowave, 2},
{  15,  9, mapLynx,  mapMicrowave, 2},
{  16,  9, mapLynx,  mapMicrowave, 2},
};
struct VehicleInfo unitSet2[] =
{
{  19,  19, mapConVec,   mapCommandCenter, 2},
};

struct BaseInfo base[] =
{
{ autosize(beaconSet1), 0, 0, 0,0, 0, 0, autosize(unitSet1) },
{ autosize(beaconSet1), 0, 0, 0,0, 0, 0, autosize(unitSet2) },
};

struct StartLocation startLocation[] =
{
{ 49,  14, &base[0]},
{ 29,  14, &base[0]},
};

and here is my main.cpp

Code: [Select]
#define WIN32_LEAN_AND_MEAN  
#include <windows.h>

#include <Outpost2DLL.h>
#include <OP2Helper.h>
#include <BaseBuilder.h>
#include "BaseData.h"


char MapName[]   = "cow.map";
char LevelDesc[]  = "easy colony plymouth. or Sandbox game";
char TechtreeName[]  = "multitek.TXT";  
SDescBlock DescBlock = { Colony, 2, 12, 0 };


BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
  DisableThreadLibraryCalls(hinstDLL);
}

    return TRUE;
}


int InitProc()
{
int i;

RandomizeStartingLocations(autosize(startLocation));
Player[0].GoPlymouth();
Player[1].GoEden();


for (i = 0; i < TethysGame::NoPlayers(); i++)
{
  InitPlayerResources(i);

  StartLocation &sLoc = startLocation[i];
  CreateBase(i, sLoc.x, sLoc.y, *sLoc.baseInfo);
  Player[i].CenterViewOn(sLoc.x, sLoc.y);

}


// Misc initialization
TethysGame::CreateWreck(20, 20, (map_id)11999, 0);
    
    TethysGame::ForceMoraleGood(-1);
if (TethysGame::UsesMorale())
  TethysGame::FreeMoraleLevel(-1);
TethysGame::SetDaylightEverywhere(TethysGame::UsesDayNight() == 0);
TethysGame::SetDaylightMoves(-1);
GameMap::SetInitialLightLevel(-62);

    
Trigger population = CreateResourceTrigger(1, 1, resColonists, 400, 0, cmpGreaterEqual, "NoResponseToTrigger");

CreateVictoryCondition(1, 0, population, "Have 400 Colonists.");


return 1; // return 1 if OK; 0 on failure

void AIProc()
{



}

void __cdecl GetSaveRegions(struct BufferDesc &bufDesc)
{
bufDesc.bufferStart = 0;
bufDesc.length = 0;  
}


int StatusProc()
{

return 0; // must return 0
}

SCRIPT_API void NoResponseToTrigger()
{

}
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Placing Units For Multiple Players?
« Reply #1 on: November 23, 2005, 01:21:43 AM »
Lol, easy to spot error. :)

Take a look at:
Code: [Select]
struct StartLocation startLocation[] = 
{
{ 49,  14, &base[0]},
{ 29,  14, &base[0]},
};


Change the second line to &base[1].

You've built two base layouts, but only ever used one. That, and the only difference between the two, was the units.

 

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Placing Units For Multiple Players?
« Reply #2 on: November 23, 2005, 11:01:58 AM »
Quote
Lol, easy to spot error.

great thanks  :)

Quote
You've built two base layouts, but only ever used one. That, and the only difference between the two, was the units.

yea and the difference between us is that you can see the errors and I can't  :P  
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
Placing Units For Multiple Players?
« Reply #3 on: November 23, 2005, 11:48:55 AM »
Using my code above, How would I make it so the human player is always player 1? and is always eden?


Edit: it looks like all I need to do is take out
Code: [Select]
RandomizeStartingLocations(autosize(startLocation));  
but it does seem to keep me from making the human player just have the units and not the base

Edit 2 :  I think I need to add a start location in but I don't know how to do that yet. If anyone knows how to do it I would be thankful for the help


Edit 3:  I don't know quite how I did it I just changed
Code: [Select]
struct StartLocation startLocation[] = 
{
{ 49,  14, &base[1]},
{ 29,  14, &base[0]},
};

just a little and I got it working so thanks for the help with the other problem
 
« Last Edit: November 23, 2005, 12:35:36 PM by spirit1flyer »
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter