Flight Sim X / FS2004 Forums: Making Custom AI Flight Plans in FSX - Flight Sim X / FS2004 Forums

Jump to content

  • (4 Pages) +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Making Custom AI Flight Plans in FSX Tutorial: Using FSX SDK Rate Topic: -----

#1 User is offline   Eric 

  • Only 24 Hours in a day?!
  • Icon
  • Group: Admin
  • Posts: 4,875
  • Joined: 13-April 04
  • Gender:Male
  • Location:Cincinnati, Ohio
  • Real Name:Eric
  • My FS Rig
  • CPU: Core i7 920
  • Memory: 12GB DDR3
  • Video: Nvidia 9800GTX+ 512MB

Posted 25 August 2007 - 08:42 PM

I've gotten quite a few requests for a tutorial on AI in FSX. This appears very different from FS2004, so I am learning with everyone also. :P If you see I made an error, please feel free to tell me so I can correct it. Now, before I start, let me say that the process using the SDK isn't for the faint of heart, it isn't the easiest procedure, but it will give you custom AI.

Here we go!

Step 1: You'll need to install the FSX SDK. If you have FSX Deluxe, it is on Disk 1, under a folder that says SDK. Simply install it here and you're done. Don't have FSX deluxe edition? I think you're out of luck, as it only comes with the Deluxe version. But again, someone please correct me if I am wrong.

Now download the SDK Service Pack update, this includes several new tools and bug fixes, download SP1 here, and SP2 here. You will have to install the service packs in line with the updates for FSX (here is the SP2 update for FSX.) So you'll need to download 4 files, the FSX SP1 Update, the FSX SDK SP1 update, the FSX SP2 update, and the FSX SDK SP2 update... You don't have to update if you're running the original FSX and the original SDK, but the Service Packs include many new features and fixes.

Step 2: You need to add the SDK so it is recognized by FSX.

In order to activate it, we'll need to go this directory:
Windows XP:
C:\Documents and Settings\[USERNAME]\Application Data\Microsoft\FSX
Windows Vista:
C:\Users\[USERNAME]\AppData\Roaming\Microsoft\FSX

You may need to enable viewing of hidden folders to navigate to this directory.

Now, find "dll.xml", and make a backup of this just incase we mess something up. Rename it to "dllbak.xml". Open this file in your favorite text editor such as WordPad. You'll need to find the following lines:
  <Launch.Addon>
	<Name>Traffic Toolbox</Name>
	<Disabled>True</Disabled>
	<ManualLoad>False</ManualLoad>
	<Path>..\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK\traffictoolbox.dll</Path>
  </Launch.Addon>


Change this to:
  <Launch.Addon>
	<Name>Traffic Toolbox</Name>
	<Disabled>False</Disabled>
	<ManualLoad>False</ManualLoad>
	<Path>..\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK\traffictoolbox.dll</Path>
  </Launch.Addon>


Save this file as "dll.xml" (Don't overwrite out backup file!)

Now start up FSX, and if you see Traffic Toolbox under the Tools menu in FSX, you have installed the DLL correctly. (You will need to start a flight.)

Step 3: Here is the fun part. In this portion I will be showing you how to add custom AI flight plans to FSX. This will be using default aircraft, and default airports. If you want to go more advanced and add custom airports and airplanes, see this post here.

On your desktop, make a new shortcut. Under the Target, paste:
C:\Windows\System32\cmd.exe

Name is anything you want, and complete the wizard. Now find the shortcut, Right click it and select Properties. Edit the Start In location to this:
"C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK"

Making sure to keep the quotes, and substituting any differences. (IE, the drive letter.)

Doubleclick the shortcut, you should see a command window that says something like:
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK>

Substituting your drive letter with the proper one, and you MUST copy and paste the quotation marks ("").

We're going to leave this window alone for now. You can close or minimize this.

Step 4: Making the flight plan. Now we're going to write a sample flight plan...

From the SDK documentation:

Quote

typeKey,tailNumber,trafficDensity,repeatEvery,flightRules
{
departureTime,destinationAirportId,flightLevel[,flightNumber][,circuitEndTime]
departureTime,destinationAirportId,flightLevel[,flightNumber][,circuitEndTime]
# enter as many departures as required

}

Description:
typeKey = one of the typeKeys from fs10.AircraftTypes.csv
tailNumber = unique aircraft tail number
trafficDensity = minimum traffic density required (1 to 100)
repeatEvery = ONE_HOUR, TWO_HOURS, FOUR_HOURS, SIX_HOURS, EIGHT_HOURS, TWELVE_HOURS, ONE_DAY, ONE_WEEK
flightRules = IFR or VFR
departureTime = DHHMM, where D = optional day of the week (0=Monday, 1=Tuesday, etc) and HHMM = zulu hour and minute of the day
destinationAirportId = destination airport ICAO identifier
flightLevel = the flight level, for example 20 = 20,000 feet
flightNumber = optional airline flight number
circuitEndTime = optional time to stop flying circuits at the destination


Above is the way to format the flight plan, along with detailed descriptions of what each value means. Now, I am going to make a sample flight like this:
Aircraft: C172
Tail Number: FSZONE
Traffic Density: 1% (This is the minimum traffic percentage that must be set until this flight shows up)
Repeat Flight: Every Two Hours
Type: VFR
Start Time: 0000 (Zulu Time)
Depart From: KCVG
Flight Level 4,300ft
Arrive At: KDAY
Depart At: 0100 (Depart from Arrival airport, to complete circuit)
Flight Level: 4,300

Now, the first thing I need to do is find the aircraft type, a list of default planes are found here:
C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK\fs10.AircraftTypes.cvs

Looking for the aircraft I am using, I find that the Type Key for this aircraft is C172-0. That is all I need, I can actually write my flight plan now. Following the format as the SDK documentation says, here is how I would do it:
C172-0,FSZONE,1,TWO_HOURS,VFR
{
0000,KCVG,43
0100,KDAY,43
}


All you need to so it write this in Notepad or Wordpad. Once you've written it, save it here:
C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK

You can name it whatever you want, but you MUST make it a .dat extension. I am going to save mine as custom.dat. Now, we have our sample flight plan, and we need to build a BGL file so FSX can recognize it.

Step 5: Compiling the BGL.

Open the shortcut file you made in step 3, once again you should see something like this:
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environmen
t Kit\Traffic Toolbox SDK>

Here is the command we're going to send:
TrafficDatabaseBuilder /Output=testtraffic0.bgl /AircraftTypes=fs10.AircraftTypes.csv /Countries=countries_regions.csv /Airports=fs10.Airports.dat /Schedules=custom.dat /AutoSchedule=No /log=log.txt

Lets tear that apart, so you understand it a little better...

TrafficDatabaseBuilder: This is what activates the builder.
/Output=fszonetraffic.bgl: This is our exported BGL file that FSX will use.
/AircraftTypes=fs10.AircraftTypes.csv: This is the list of aircraft types for FSX, this is the default listing.
/Countries=countries_regions.csv: This is the list of countries for FSX, again default.
/Airports=fs10.Airports.dat: Airports for FSX, once again the default listings.
/Schedules=custom.dat: This will be our flight plan file we just saved.
/AutoSchedule=No: This will add all of the default flight plans to our BGL file. I recommend choosing No for this. I will explain later.
/log=log.txt: Our log file, so we can check errors.

Now, paste the command into the Command Prompt, and hit enter. If everything is correct, you should see it compile the traffic file.

Check in the Traffic Toolbox SDK folder for a file called "fszonetraffic.bgl". If it is there, then hopefully everything went well. If not, something didn't go right.
Whether you see a file or not, always check the log.txt file. This will tell any errors you had in your flight plan. For example, I had to adjust my times and cruise altitude before.

Step 6: Installing the BGL file.
As long as your don't have any errors, you can now move your BGL file to the proper directory.

The directory FSX uses is:
C:\Program Files\Microsoft Games\Microsoft Flight Simulator X\Scenery\World\Scenery

Now, let me explain why it is a good idea not to use AutoRoute. FSX is capable of recognizing multiple traffic files in this directory. By default you will have "trafficAircraft.bgl" these are your default flight plans. If you turn AutoRoute On, then you will have duplicate flight plans, and very crowded airports. Keeping AutoRoutes Off will also save you time down the road, as you are able to organize sets of flight plans through different BGL files.

Since FSX can do multiple traffic files, just leave AutoRoute Off for now. ;)

Now, I moved "fszonetraffic.bgl" to the directory above, and thats it! Now I am going to find my AI plane in FSX!

Step 7: Finding our AI!
I set up a flight, and set the proper airport, time, and date so I can view my aircraft. If there is a lot of traffic, you can use the explorer which comes with the SDK. It is under Tools->Traffic SDK->Explorer (You will likely need to exit full screen, Alt+Enter)

Under the explorer, I find my aircraft:
Posted Image

It also shows up on the Views list:
Posted Image

My AI flight:
Posted Image

That about does it for flight plans, we can get into custom airports and aircraft later, but this tutorial was just meant to get you used to how the SDK works, please explorer it more for yourself. I learned all of this in a few days just from reading the documentation. :)

If you can't get something working, please provide many details, and what the log file from step 5 says if you have it
0

#2 User is offline   Dredd 

  • Proud to fly Horizon!
  • Icon
  • Group: + Reporters
  • Posts: 2,244
  • Joined: 14-February 07
  • Gender:Male
  • Location:UK ~ Cornwall
  • Real Name:Neil
  • My FS Rig
  • CPU: AMD AM2+ 9650
  • Memory: 4Gb @1033MHz
  • Video: GTS450 1GB

Posted 26 August 2007 - 06:14 AM

Make this a sticky Fox and we can add to it!
0

#3 User is offline   Eric 

  • Only 24 Hours in a day?!
  • Icon
  • Group: Admin
  • Posts: 4,875
  • Joined: 13-April 04
  • Gender:Male
  • Location:Cincinnati, Ohio
  • Real Name:Eric
  • My FS Rig
  • CPU: Core i7 920
  • Memory: 12GB DDR3
  • Video: Nvidia 9800GTX+ 512MB

Posted 20 February 2008 - 08:28 PM

Custom Airports

Here is a tutorial on how to get the traffic builder to recognize custom airports when you're making flight plans. Basically, the SDK comes with FSX's default airports, which are stored in the file "fs10.Airports.dat". Each time you add an airport to FSX, the .dat file used by the SDK is out of date and needs to be re-built if you want to create AI traffic at that airport.

Assuming that you have successfully added your custom airport, and it appears on the airport list in FSX, we need to export the list so the SDK can use it. I am going to be using the custom scenery I made a long time ago called KMNT, a fake airport for this example. You may use whatever airport you wish as long as it shows up in FSX after you install it.

While in a flight, click "Tools", "Traffic Toolbox", and then "Dump Airport List...". This will open a box that asks for two values, your output file and log file.
Posted Image

For the output file, I used the following text:
C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK\new_airports.dat

You can name it whatever you want, just as long as it has a ".dat" extension and you replace the file name with whatever you named it. Now, for your log file I used:
C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK\new_airports_log.txt

The utility will write any errors to this file, don't be surprised if you do get 2 or 3 errors, I did when I dumped my airport list.

Posted Image

Once you have those two values entered click "Begin" and it will start to export nearly 25,000 airports, typically it takes about a minute. As long as your custom airport shows up in the FSX airport list, it should be dumped into the file. If you want to be sure it was, once the process is finished open your dump file (new_airports.dat) in WordPad. Press "Control+F" and type in your airport's ICAO code. If everything exported successfully you should be able to find information on your airport:
KMNT,47.771050483,-122.702722102,0.0,G,0,1.00,United States
{
	RUNWAY,2500,75,HARD
}


Once you have the exported airport list, the process is similar to making a standard AI Flight Plan. All you want to do is substitute your new airport list with the one you created. So for our example, the command I would use to activate the traffic builder is:
TrafficDatabaseBuilder /Output=testtraffic0.bgl /AircraftTypes=fs10.AircraftTypes.csv /Countries=countries_regions.csv /Airports=new_airports.dat /Schedules=custom.dat /AutoSchedule=No /log=log.txt

As you can see, we substituted /Airports=new_airports.dat with our new airport list, so custom airports in our Schedule file will now be recognized.
0

#4 User is offline   dvapilot5998 

  • Ground Crew
  • Icon
  • Group: Ground Crew
  • Posts: 638
  • Joined: 31-August 07
  • Gender:Male
  • Location:United States
  • Real Name:Austin
  • My FS Rig
  • CPU: Intel Duo E7500
  • Memory: 4 GB RAM
  • Video: ATI Radeon HD 3450

Posted 21 February 2008 - 03:59 PM

Yeah, make it a sticky! I'm sure that many people will appreciate that ;)
0

#5 User is offline   ceebee123 

  • New Flyer
  • Icon
  • Group: New Flyer
  • Posts: 2
  • Joined: 13-February 08

Posted 22 February 2008 - 01:12 PM

Hi Fox

Many thanks for your second tutorial on Custom Airports in FSX SDK. :D


ceebee123
0

#6 User is offline   Daryl M 

  • New Flyer
  • Icon
  • Group: New Flyer
  • Posts: 4
  • Joined: 13-January 09

Posted 13 January 2009 - 09:47 PM

Hi, i have followed all the steps above correctly, (i think). When i type that command in to compile a .bgl it comes up with an error saying : Unable to open output file. Can anyone help me?
Thanks, Daryl
0

#7 User is offline   Eric 

  • Only 24 Hours in a day?!
  • Icon
  • Group: Admin
  • Posts: 4,875
  • Joined: 13-April 04
  • Gender:Male
  • Location:Cincinnati, Ohio
  • Real Name:Eric
  • My FS Rig
  • CPU: Core i7 920
  • Memory: 12GB DDR3
  • Video: Nvidia 9800GTX+ 512MB

Posted 14 January 2009 - 12:51 AM

Sure, Can you take a screenshot of the command prompt window with the command, and if it logs anything in the log.txt file (or whatever you named it), paste that too.
0

#8 User is offline   Daryl M 

  • New Flyer
  • Icon
  • Group: New Flyer
  • Posts: 4
  • Joined: 13-January 09

Posted 14 January 2009 - 12:56 AM

View PostFox, on Jan 14 2009, 01:51 AM, said:

Sure, Can you take a screenshot of the command prompt window with the command, and if it logs anything in the log.txt file (or whatever you named it), paste that too.

Here you go, thanks for the fast reply
Posted Image
0

#9 User is offline   Eric 

  • Only 24 Hours in a day?!
  • Icon
  • Group: Admin
  • Posts: 4,875
  • Joined: 13-April 04
  • Gender:Male
  • Location:Cincinnati, Ohio
  • Real Name:Eric
  • My FS Rig
  • CPU: Core i7 920
  • Memory: 12GB DDR3
  • Video: Nvidia 9800GTX+ 512MB

Posted 14 January 2009 - 01:01 AM

You're on vista? I found that for some reason the file permissions for the SDK folder are pretty locked down, not sure why, but I found that this causes issues in Vista because of UAC. But you can try this:

On your shortcut to cmd.exe on your desktop, right click it and choose "Run as administrator", and a UAC prompt should come up, accept it and try the command again.
0

#10 User is offline   Daryl M 

  • New Flyer
  • Icon
  • Group: New Flyer
  • Posts: 4
  • Joined: 13-January 09

Posted 14 January 2009 - 01:09 AM

View PostFox, on Jan 14 2009, 01:01 AM, said:

You're on vista? I found that for some reason the file permissions for the SDK folder are pretty locked down, not sure why, but I found that this causes issues in Vista because of UAC. But you can try this:

On your shortcut to cmd.exe on your desktop, right click it and choose "Run as administrator", and a UAC prompt should come up, accept it and try the command again.


Now i get this, same shortcut, opened under admin
Posted Image
0

#11 User is offline   Eric 

  • Only 24 Hours in a day?!
  • Icon
  • Group: Admin
  • Posts: 4,875
  • Joined: 13-April 04
  • Gender:Male
  • Location:Cincinnati, Ohio
  • Real Name:Eric
  • My FS Rig
  • CPU: Core i7 920
  • Memory: 12GB DDR3
  • Video: Nvidia 9800GTX+ 512MB

Posted 14 January 2009 - 01:13 AM

Thats weird, I guess when you run it as admin it starts in the system32 folder? Try doing that same thing (Right click, run as admin), and change to the SDK directory, type:
cd C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Traffic Toolbox SDK


And once again, try the TrafficDatabaseBuilder command again.
0

#12 User is offline   Daryl M 

  • New Flyer
  • Icon
  • Group: New Flyer
  • Posts: 4
  • Joined: 13-January 09

Posted 14 January 2009 - 01:13 AM

View PostFox, on Jan 14 2009, 01:01 AM, said:

You're on vista? I found that for some reason the file permissions for the SDK folder are pretty locked down, not sure why, but I found that this causes issues in Vista because of UAC. But you can try this:

On your shortcut to cmd.exe on your desktop, right click it and choose "Run as administrator", and a UAC prompt should come up, accept it and try the command again.


Now i get this, same shortcut, opened under admin
Posted Image

EDIT: Seeing as you said the SDK folders are pretty locked down, i went into propeties/security and edited the permissions, so then i opened up cmd, not under admin and it works perfectly..!!! thanks Fox, for your help
0

#13 User is offline   Eric 

  • Only 24 Hours in a day?!
  • Icon
  • Group: Admin
  • Posts: 4,875
  • Joined: 13-April 04
  • Gender:Male
  • Location:Cincinnati, Ohio
  • Real Name:Eric
  • My FS Rig
  • CPU: Core i7 920
  • Memory: 12GB DDR3
  • Video: Nvidia 9800GTX+ 512MB

Posted 14 January 2009 - 01:15 AM

View PostDaryl M, on Jan 14 2009, 01:13 AM, said:

View PostFox, on Jan 14 2009, 01:01 AM, said:

You're on vista? I found that for some reason the file permissions for the SDK folder are pretty locked down, not sure why, but I found that this causes issues in Vista because of UAC. But you can try this:

On your shortcut to cmd.exe on your desktop, right click it and choose "Run as administrator", and a UAC prompt should come up, accept it and try the command again.


EDIT: Seeing as you said the SDK folders are pretty locked down, i went into propeties/security and edited the permissions, so then i opened up cmd, not under admin and it works perfectly..!!! thanks Fox, for your help

No problem. I did the tutorial in Vista too and either should work (Run as admin or manually changing the permissions). Glad you got it working.
0

#14 User is offline   Thomas 

  • We Want ABBA!
  • Icon
  • Group: 747 Pilot
  • Posts: 404
  • Joined: 15-October 08
  • Gender:Male
  • Location:UK, Barnsley
  • Real Name:Thomas
  • My FS Rig
  • CPU: Athlon 2.6 Dual
  • Memory: 3GB RAM
  • Video: HD5770 1GB

Posted 15 January 2009 - 10:14 AM

will sp2 do any goos on xp or is it just for vista users?
0

#15 User is offline   Eric 

  • Only 24 Hours in a day?!
  • Icon
  • Group: Admin
  • Posts: 4,875
  • Joined: 13-April 04
  • Gender:Male
  • Location:Cincinnati, Ohio
  • Real Name:Eric
  • My FS Rig
  • CPU: Core i7 920
  • Memory: 12GB DDR3
  • Video: Nvidia 9800GTX+ 512MB

Posted 15 January 2009 - 10:34 AM

View PostCessna tomtom, on Jan 15 2009, 10:14 AM, said:

will sp2 do any goos on xp or is it just for vista users?

I'm not sure if XP has the problem since by default you have full admin access, but I haven't tested it myself.
0

  • (4 Pages) +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users