Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: Mcshay on January 26, 2006, 03:31:14 PM

Title: Starting An Ai
Post by: Mcshay on January 26, 2006, 03:31:14 PM
I can't seem to find the answer to this, but do you include the AI player in this line?

Code: [Select]
SDescBlock DescBlock	= { MultiSpaceRace, 3, 12, 0 };

If I don't, my AI player's buildings don't show up on the mini-map. It's units are white on the mini-map and have their lights off. When I try to make a mining group, the trucks just sit there.
Title: Starting An Ai
Post by: Eddy-B on January 27, 2006, 12:14:56 AM
the first number in that list ( 3 ) is the number of "players" -- this includes any ai player as well. If it is a colony or other single-player map, player0 will be the human player.
Title: Starting An Ai
Post by: Mcshay on January 27, 2006, 03:54:08 PM
Thanks, I've got it working now.
Title: Starting An Ai
Post by: Mcshay on January 28, 2006, 07:11:54 AM
Hmm, I have a new question now, is there a way to get a Unit handle on a building (say a VehicleFactory) that your AI builds later?  
Title: Starting An Ai
Post by: Eddy-B on January 28, 2006, 09:00:53 AM
The CreateUnit function returns the newly created unit &ReturnedUnit
You can use that to do stuff with it, like set lights, put it into a group etc..
Title: Starting An Ai
Post by: Mcshay on January 28, 2006, 09:37:30 AM
I mean, when you use RecordBuilding along with a time trigger to make your AI build a building later in the game. Is there another way to do this that does return a Unit?
Title: Starting An Ai
Post by: Eddy-B on January 29, 2006, 10:04:23 AM
Yes, but not an easy way!
You'd have to use the enumerators: i've created several functions that find buildings, using enumerators.

Open the Enumerators.h to see what enumerators you have. Select the one you want to use (eg. PlayerBuildingEnum for buildings of a certain player), then use GetNext to browse through all the buildings that player has:
Code: [Select]
Unit u;
PlayerBuildingEnum enum1(1, mapVehicleFactory);
while (enum1.GetNext(u))
{
  // this code here will get executed for each VF it finds (for this particular player)
}