Author Topic: Starting An Ai  (Read 2552 times)

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
Starting An Ai
« 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.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Starting An Ai
« Reply #1 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.
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
Starting An Ai
« Reply #2 on: January 27, 2006, 03:54:08 PM »
Thanks, I've got it working now.

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
Starting An Ai
« Reply #3 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?  

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Starting An Ai
« Reply #4 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..
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
Starting An Ai
« Reply #5 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?

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Starting An Ai
« Reply #6 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)
}
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz