I've updated the code to Hooville slightly. It now includes structure kits in the structure factories. It does this using enums to find the structure factories, and then uses the returned Unit object to add structure kits to it. This requires no changes to existing code in the OP2Helper folder and is a fairly clean way of doing it. This is probably the method I would recommend if you're already using the OP2Helper files (which most of you probably are).
The changes are placed in InitProc. I included a few lines after the new code (with updated comments), so you should be able to see where this code goes based on that. Basically, after the base creation (so the Structure Factories exist and can be found by the enumerators).
// Note: Here we will demonstrate a use of enums to find the Structure Factories
// created for each player and give them some initially stored structures.
// Note: Enumerators can be used to traverse a list of all units of a certain type
// but in this context, we only want the first one returned. Normally you would
// keep calling GetNext in a loop to retrieve subsequent units matching the
// search criteria for the enumerator.
Unit building; // Unit object to hold the reference to the Structure Factory
for (i = 0; i < TethysGame::NoPlayers(); i++)
{
// Create an enumerator for this player's structure factories
PlayerBuildingEnum buildingEnum(i, mapStructureFactory);
// We only want the first one found (if any at all)
if (buildingEnum.GetNext(building))
{
// We have successfully retrieved a handle to a structure factory in "building"
// Give the first 4 structure kits unconditionally
building.SetFactoryCargo(0, mapUniversity, mapNone);
building.SetFactoryCargo(1, mapNursery, mapNone);
building.SetFactoryCargo(2, mapTokamak, mapNone);
building.SetFactoryCargo(3, mapRobotCommand, mapNone);
// Only give the next structure kit on Med or High resources
if (Player[i].Difficulty() <= 1)
building.SetFactoryCargo(4, mapCommonOreSmelter, mapNone);
// Only give the last structure kit on High resources
if (Player[i].Difficulty() == 0)
building.SetFactoryCargo(5, mapVehicleFactory, mapNone);
}
}
// Misc initialization
// Create some Tiger Speed Modifciation wreckage! =)
TethysGame::CreateWreck(95, 63, (map_id)11999, 0); // Tech #11999 - tiger speed upgrade
// Set a default starting morale level
TethysGame::ForceMoraleGood(-1);
// Enable morale to float if they've selected it from the game setup dialog box
if (TethysGame::UsesMorale())
TethysGame::FreeMoraleLevel(-1);
// Enable day and night if it's been selected from the game setup dialog box
TethysGame::SetDaylightEverywhere(TethysGame::UsesDayNight() == 0);
// Disable movement of Day and Night!
// Note: You normally don't want to do this. What this does is makes the map
// eternally dark if day and night is enabled (dependent on the SetInitialLightLevel
// as well). This of course has no effect if day and night are disabled.
TethysGame::SetDaylightMoves(0);
GameMap::SetInitialLightLevel(-32);
// Setup a victory condition
// (Just use a helper function for a common victory condition)
CreateLastOneStandingVictoryCondition();