Adding Extra Player Slots

From OPU Wiki

You don't need any of this for single player missions, only multiplayer.

When adding one or more AI players to a multiplayer game, you need to use this code for them to work properly. Just insert it under the mission info.

struct SDescBlockEx {
   int unk0;
   int unk1;
   int unk2;
   int unk3;
   int unk4;
   int unk5;
   int unk6;
   int unk7;
};

// The code below adds one extra player slot. If you need more extra slots than that, just change one of the other values to 1.
SCRIPT_API SDescBlockEx DescBlockEx = { 1, 0, 0, 0, 0, 0, 0, 0 };

Here's how La Corrida figures out which slot is the extra one added.

int InitProc() {
   // Determine the number of humans in the game
   for (int numHumans = 2; numHumans < 7; numHumans++) {
      if (!Player[numHumans].IsHuman())
          break;
   }

   // Set up the AI base in the next available slot
   // (The last human player would be numHumans-1, so the first empty slot is numHumans, second is numHumans+1,...)
   Player[numHumans].SetOre(10000);
   Player[numHumans].GoEden();
   Player[numHumans].SetTechLevel(6);
   // and so on... La Corrida does not use Player.GoAI() at all.

   return 1; // Return 1 on success, 0 on failure
}

As for using it with BaseBuilder for a unique AI base (you can't really use this when using RandomizeLocations()):

startLocation[numHumans] = startLocation[X]; // X would be 4 if the AI uses ___Set5, for example
Personal tools