Howto:Adding Bombable to FlightGear Aircraft: Difference between revisions

Jump to navigation Jump to search
→‎STEP 4. Add to an AI Scenario: more details, problems solved, troubleshooting, fixing some details, etc.
(→‎Helpful/Needed files: Added note about needed files in the AI directory of .zip)
(→‎STEP 4. Add to an AI Scenario: more details, problems solved, troubleshooting, fixing some details, etc.)
 
Line 564: Line 564:
* The statement include="F-15E_StrikeEagle-bombableinclude.xml" indicates that F-15E_StrikeEagle-bombableinclude.xml will be in the same directory as F-15E_StrikeEagle.xml.  That directory is Aircraft/F-15E/Models -- so make sure that the -bombableinclude.xml file is indeed in that directory!
* The statement include="F-15E_StrikeEagle-bombableinclude.xml" indicates that F-15E_StrikeEagle-bombableinclude.xml will be in the same directory as F-15E_StrikeEagle.xml.  That directory is Aircraft/F-15E/Models -- so make sure that the -bombableinclude.xml file is indeed in that directory!


* Model files can have only ONE Nasal <load> section and one <unload> section.
* Model files can have only ONE Nasal <load> section and one <unload> section. Ramifications:
<blockquote>''If you have more than one, the second and subsequent <load>/<unload> sections are ignored.''


If you have more than one, the second and subsequent <load>/<unload> sections are ignored.
''The problem?  Your aircraft may already have a <load> or <unload> section.  When you add the Bombable code, one of the two <load> sections (the pre-existing one or Bombable's) will be ignored.''


The problem?  Your aircraft may already have a <load> or <unload> section.  When you add the Bombable code, one of the two <load> sections (the pre-existing one or Bombable's) will be ignored.
''The solution is to combine the two <load> sections into one, and the same with the <unload> sections.  You'll need to know a little about [[Nasal]] programming to do anything complicated, but as a rule you can just copy/paste whatever is in the aircraft's <load> section to the '''end''' of Bombable's <load> section, and the same with <unload>.''
 
The solution is to combine the two <load> sections into one, and the same with the <unload> sections.  You'll need to know a little about [[Nasal]] programming to do anything complicated, but as a rule you can just copy/paste whatever is in the aircraft's <load> section to the start of Bombable's <load> section, and the same with <unload>.


* ''One trick here is to post the existing Nasal code at the END of the section, AFTER the Bombable code - both for the <load> and <unload> sections.  This is a bit of a kludge, but it allows you to use the same model file for both regular and AI aircraft.  Often the existing nasal in the model file is needed only for regular/piloted aircraft and not for the AI version.  Because of this, the code will thrown an error when run as an AI aircraft.  If you simply place the existing Nasal code AFTER the Bombable code, the Bombable code will run (it works and is needed for both regular and AI aircraft). Then if the existing Nasal code runs as a regular aircraft, it will run fine as well.  If it is an AI aircraft, it will give a runtime error and stop. But it won't hurt anything because the Bombable code has already run.''
* ''The proper way to address this issue is to make separate model files for regular and AI aircraft.  The AI aircraft can generally be stripped way down, no console and other details are needed, and much less nasal code for subsystems is needed. How to handle all of that properly is a whole topic of its own.''
</blockquote>
* You'll notice the Nasal code starts with ''<![CDATA['' and ends with '']]>''.  That is needed to make Nasal code work within XML files.  [http://www.w3schools.com/xml/xml_cdata.asp CDATA usage is explained here.]
* You'll notice the Nasal code starts with ''<![CDATA['' and ends with '']]>''.  That is needed to make Nasal code work within XML files.  [http://www.w3schools.com/xml/xml_cdata.asp CDATA usage is explained here.]


Line 611: Line 613:
       <heading type="double">192</heading>
       <heading type="double">192</heading>
     </entry>
     </entry>
   <scenario>
   </scenario>
   
   
  </PropertyList>
  </PropertyList>


Again, save as FGDATA/AI/F-15E-demo.xml.  When you start FGRun next time, F-15E-demo will be listed as one of the scenario file options.  (You may need to quit and re-start FGRun.)
Again, save as FGDATA/AI/F-15E-demo.xml.  When you start FGRun next time, F-15E-demo will be listed as one of the scenario file options.  (You may need to quit and re-start FGRun.)
If the scenario doesn't appear, check [fgfs.log] for any errors related to the scenario file. Here is a typical error message:<blockquote>''0.53 [WARN]:ai        C:\Jenkins\workspace\Windows-release\flightgear\src\AIModel\AIManager.cxx:257: Skipping malformed scenario file:Path "e:/FlightGear 2020.3/data/AI/F-15E-demo.xml"''
''   0.53 [WARN]:general   C:\Jenkins\workspace\Windows-release\simgear\simgear\debug\ErrorReportingCallback.cxx:82: Error:bad data from sceanrio load::The scenario couldn't be loaded:mismatched tag''
''at e:/FlightGear 2020.3/data/AI/F-15E-demo.xml,''
''line 31, column 2''
''   e:/FlightGear 2020.3/data/AI/F-15E-demo.xml,''
''line 31, column 2''</blockquote>
* The path given in this line can vary: ''<model type="string">Aircraft/F-15E/Models/F-15E_StrikeEagle.xml</model>''
** If you are placing the scenario file in the AI subdirectory and the aircraft is in ''AI/Aircraft/F-15E - then the above line will work as is.''
** However, a common situation is to place the aircraft file in data/Aircraft/F-15E (as we described above - that is the normal place for regular/piloted aircraft, and if we are NOT making a special AI version of the aircraft, then the aircraft will ilve in data/Aircraft/F-15E or a similar place. In that case, perhaps the AI folder is in ''data/AI'' and the F-15E folder is in ''data/Aircraft/F-15E.'' In that case, we need a correct relative directory from wherever the scenario .xml file is to wherever the F-15E model file is, for example:
*** <model type="string">../Aircraft/F-15E/Models/F-15E_StrikeEagle.xml</model>
**** Here ".." means go to the parent directory, so "../Aircraft" means go to the parent directoy of ''AI'', then go to the ''Aircraft'' subdirectory from there.
**** Regardless of the details, the point is: In order for the scenario file to work properly, you must have a proper, complete, accurate path leading from the location of the AI scenario file to the location of the ''F-15E_StrikeEagle.xml'' file.
**** More details about this below in the section ''Where your aircraft files are''.


==STEP 5. Troubleshooting==
==STEP 5. Troubleshooting==
Line 650: Line 672:
  FGDATA/Aircraft/F-15E/F-15-StrikeEagle-bombableinclude.xml
  FGDATA/Aircraft/F-15E/F-15-StrikeEagle-bombableinclude.xml


OK, that one little "E" made all the difference.  I change the filename to match what's in the -set.xml file and try again.
OK, that one little "E" after F-15 made all the difference. Plus, in one place it has "-" before StrikeEagle, and in the other one it has "_".  I change the filename to match what's in the -set.xml file and try again.


And finally:
And finally:
482

edits

Navigation menu