Howto:Adding Bombable to FlightGear Aircraft: Difference between revisions

Jump to navigation Jump to search
Undo revision 36504 by Flug (talk)
(Undo revision 36504 by Flug (talk))
Line 177: Line 177:
* Link the -bombableinclude.xml file to the aircraft's existing model XML file
* Link the -bombableinclude.xml file to the aircraft's existing model XML file


<?xml version="1.0"?>
===Create the -bombableinclude.xml file===  
In the Bombable distribution, the include files are named [aircraftname]-bombableinclude.xml and are generally found in FGDATA/AI/Aircraft/[aircraftname]/Models.


<PropertyList>
In this case, the most similar aircraft in the Bombable distribution is the A-10. If [[Bombable]] is installed, the needed file is in:
      <!-- Nasal code -->
<nasal>
 


<load>
FGDATA\AI\Aircraft\A-10-Bombable\Models\A-10-bombableinclude.xml
<![CDATA[
print("Loading F-15E ", cmdarg().getPath());


      var nodeName = cmdarg().getPath();
Open the file with a text editor and save it with a new name in your F-15E directory. The new name & directory should be something like:


      ##checks whether it has been initialized already; if so, just return
FGDATA\Aircraft\F-15E\Models\F-15E_StrikeEagle-bombableinclude.xml
      if ( bombable.check_overall_initialized (nodeName) ) return;


Now you can open and edit this file.  Most changes are quite obvious--change the name, change the dimensions, etc.


############################################
When done, we end up with a file like this:
#FUNCTION object_init, INITIALIZER
var object_init = func() {
# Datas of this object are under: cmdarg().getPath()
var thisNodeName = cmdarg().getPath();
var thisNode = props.globals.getNode(thisNodeName);
# Add some useful nodes


 
<?xml version="1.0"?>
         ########################################################################
<PropertyList>
        ########################################################################
         <!-- Nasal code -->
<nasal>
            <load>
            <![CDATA[
              print("Loading F-15E ", cmdarg().getPath());
      var nodeName = cmdarg().getPath();
      ##checks whether it has been initialized already; if so, just return
      if ( bombable.check_overall_initialized (nodeName) ) return;
############################################
#A-10 INITIALIZER
  var object_init = func() {
  # Datas of this object are under: cmdarg().getPath()
  var thisNodeName = cmdarg().getPath();
  var thisNode = props.globals.getNode(thisNodeName);
    ########################################################################
    ########################################################################
         # INITIALIZE BOMBABLE
         # INITIALIZE BOMBABLE
         #  
         #  
Line 216: Line 225:
         # These routines are found in FG/nasal/bombable.nas
         # These routines are found in FG/nasal/bombable.nas
         #   
         #   
        ########################################################################               
          ########################################################################               
         # INITIALIZE BOMBABLE Object
         # INITIALIZE BOMBABLE Object
         # This object will be slurped in the object's node as a child
         # This object will be slurped in the object's node as a child
Line 224: Line 233:
         # location
         # location
         #  
         #  
       
         
         thisNodeName = cmdarg().getPath();  
         thisNodeName = cmdarg().getPath();  
 
         var bombableObject = {   
         var bombableObject = {   
         
         
         
         
           objectNodeName : thisNodeName,
           objectNodeName : thisNodeName,
           objectNode : props.globals.getNode(thisNodeName),
           objectNode : props.globals.getNode(thisNodeName),
Line 238: Line 247:
           #update time faster than about 1/3 seems to have a noticeable effect
           #update time faster than about 1/3 seems to have a noticeable effect
           #on frame rate                     
           #on frame rate                     
 
                       
                       
           #########################################                               
           #########################################                               
           # ALTITUDE DEFINITIONS
           # ALTITUDE DEFINITIONS
Line 245: Line 254:
           altitudes : {
           altitudes : {
             wheelsOnGroundAGL_m : 1 , #altitude correction to add to your aircraft or ship that is needed to put wheels on ground (or, for a ship, make it float in the water at the correct level).  For most objects this is 0 but some models need a small correction to place them exactly at ground level
             wheelsOnGroundAGL_m : 1 , #altitude correction to add to your aircraft or ship that is needed to put wheels on ground (or, for a ship, make it float in the water at the correct level).  For most objects this is 0 but some models need a small correction to place them exactly at ground level
           
           
             minimumAGL_m : 300, #minimum altitude above ground level this object is allowed to fly
             minimumAGL_m : 100, #minimum altitude above ground level this object is allowed to fly
             maximumAGL_m : 50000, #maximum altitude AGL this object is allowed to fly, ie, operational ceiling      
             maximumAGL_m : 3000, #maximum altitude AGL this object is allowed to fly, ie, operational ceiling      
             crashedAGL_m : 0.6, #altitude AGL when crashed.  Ships will sink to this level, aircraft or vehicles will sink into the ground as landing gear collapses or tires deflate. Should be negative, even just -0.001.
             crashedAGL_m : 0.6, #altitude AGL when crashed.  Ships will sink to this level, aircraft or vehicles will sink into the ground as landing gear collapses or tires deflate. Should be negative, even just -0.001.
           },
           },
Line 257: Line 266:
             maxSpeedReduce_percent : 0.5, #max % to reduce speed, per step, when damaged
             maxSpeedReduce_percent : 0.5, #max % to reduce speed, per step, when damaged
             minSpeed_kt : 112, #minimum speed to reduce to when damaged.  Ground vehicles and ships might stop completely when damaged but aircraft will need a minimum speed so they keep moving until they hit the ground.
             minSpeed_kt : 112, #minimum speed to reduce to when damaged.  Ground vehicles and ships might stop completely when damaged but aircraft will need a minimum speed so they keep moving until they hit the ground.
            cruiseSpeed_kt : 550, #cruising speed, typical/optimal cruising speed, V C for aircraft
   
           
            attackSpeed_kt : 900, #typical/optimal speed when aggressively attacking or evading, in
                                #level flight for aircraft
           
            maxSpeed_kt : 1400 , #Maximum possible speed under dive or downhill conditions, V NE for aircraft
   
             damagedAltitudeChangeMaxRate_meterspersecond : 30, #max rate to sink or fly downwards when damaged, in meters/second
             damagedAltitudeChangeMaxRate_meterspersecond : 30, #max rate to sink or fly downwards when damaged, in meters/second
            #The terminal velocities are calculated by opening the 'real' AC
            #in FG, level flight, full throttle, then putting
            #the AC at different angles of attack with the autopilot,
            #and noting the terminal airspeed & vertical speed velocities.
            #For best results, do it near sea level, under 5000 feet altitude.
            #One or two each of climb & dive velocities are probably sufficient.
            #However if you do more we may be able to use the more precise
            #data in the future.
            #
            #Note that these are intended to be true airspeed whereas FG's
            #/velocities/airspeed-kt reports indicated airspeed, so some
            #conversion or reference to groundspeed-kt is needed.
            #
            #In FG /velocities/groundspeed-kt is equal (or close
            #to equal, except for wind . . .) true airspeed when pitch=0
            #but as pitch increases or decreases that will change.
            #                         
            diveTerminalVelocities: {
                point1: { airspeed_kt : 1060, vertical_speed_fps : - 337},
                point2: { airspeed_kt : 1230, vertical_speed_fps : - 755},
               
            },
            climbTerminalVelocities: {
              point1: { airspeed_kt : 468, vertical_speed_fps : 236},
              point2: { airspeed_kt : 843, vertical_speed_fps : 251},
              #point3: { airspeed_kt : 1100, vertical_speed_fps : 161},
         
            },
           
           },
           },
           #   
           #   
Line 306: Line 278:
             dodgeDelayMax_sec : 15, #max time to delay/wait between dodges
             dodgeDelayMax_sec : 15, #max time to delay/wait between dodges
             dodgeDelayMin_sec : 5, #minimum time to delay/wait between dodges
             dodgeDelayMin_sec : 5, #minimum time to delay/wait between dodges
             dodgeMax_deg : 88, #Max amount to turn when dodging
             dodgeMax_deg : 75, #Max amount to turn when dodging
                               #90 degrees = instant turn, unrealistic
                               #90 degrees = instant turn, unrealistic
                               #up to 80 is usually OK, somewhere in 80-85 starts to be unrealistically fast
                               #up to 80 is usually OK, somewhere in 80-85 starts to be unrealistically fast
                               #>85 is usually very unrealistic.  You must test this in your scenario, however.
                               #>85 is usually very unrealistic.  You must test this in your scenario, however.
              
              
             dodgeMin_deg : 83, #minimum amount to turn when dodging          
             dodgeMin_deg : 57, #minimum amount to turn when dodging
            rollRateMax_degpersec : 300, #you can figure this out by rolling the corresponding FG aircraft and timing a 180 or 360 deg roll           
             dodgeROverLPreference_percent : 50, # Preference for right turns vs. left when dodging.  90% means 90% right turns, 50% means 50% right turns.
             dodgeROverLPreference_percent : 50, # Preference for right turns vs. left when dodging.  90% means 90% right turns, 50% means 50% right turns.
             dodgeAltMin_m : -8000, #Aircraft will begin to move up or down  
             dodgeAltMin_m : -6000, #Aircraft will begin to move up or down  
             dodgeAltMax_m : 8000, #Max & Min are relative to current alt  
             dodgeAltMax_m : 6000, #Max & Min are relative to current alt  
             dodgeVertSpeedClimb_mps : 1500, #Max speed to climb when evading
             dodgeVertSpeedClimb_mps : 500, #Max speed to climb when evading
             dodgeVertSpeedDive_mps : 1500, #Max speed to dive when evading  
             dodgeVertSpeedDive_mps : 1000, #Max speed to dive when evading  
           },
           },
           #   
           #   
Line 326: Line 297:
           # other aircraft  
           # other aircraft  
           attacks : {               
           attacks : {               
             maxDistance_m : 30000, #max distance to turn & attack main aircraft
             maxDistance_m : 14000, #max distance to turn & attack main aircraft
             minDistance_m : 4000, #min distance to turn & attack main aircraft, ie, fly away this far before turning to attack again
             minDistance_m : 500, #min distance to turn & attack main aircraft, ie, fly away this far before turning to attack again
             continueAttackAngle_deg : 80, #when within minDistance_m, the aircraft will continue to turn towards the main aircraft and attack *if* if the angle is less than this amount from dead ahead
             continueAttackAngle_deg : 40, #when within minDistance_m, the aircraft will continue to turn towards the main aircraft and attack *if* if the angle is less than this amount from dead ahead
             altitudeHigherCutoff_m : 30000, # will attack the main aircraft unless this amount higher than it or more
             altitudeHigherCutoff_m : 20000, # will attack the main aircraft unless this amount higher than it or more
             altitudeLowerCutoff_m : 30000, # will attack the main aircraft unless this amount lower than it or more
             altitudeLowerCutoff_m : 15000, # will attack the main aircraft unless this amount lower than it or more
             climbPower : 8000, # How powerful the aircraft is when climbing during an attack; 4000 would be typical for, say a Zero--scale accordingly for others; higher is stronger
             climbPower : 11000, # How powerful the aircraft is when climbing during an attack; 4000 would be typical for, say a Zero--scale accordingly for others; higher is stronger
             divePower : 10000, # How powerful the aircraft is when diving during and attack; 6000 typical of a Zero--could be much more than climbPower if the aircraft is a weak climber but a strong diver               
             divePower : 15000, # How powerful the aircraft is when diving during and attack; 6000 typical of a Zero--could be much more than climbPower if the aircraft is a weak climber but a strong diver               
             rollMin_deg : 82, #when turning on attack, roll to this angle min
             rollMin_deg : 58, #when turning on attack, roll to this angle min
                              #for sedate, Cessna-like manuevers make rollMin low.  If you want an aggressive,
             rollMax_deg : 74, #when turning on attack, roll to this angle max
                              #attacking, aiming fighter keep it close to rollMax, or even almost equal to rollMax
             rollMax_deg : 87, #when turning on attack, roll to this angle max
                               #90 degrees = instant turn, unrealistic
                               #90 degrees = instant turn, unrealistic
                               #up to 80 might be OK, depending on aircraft & speed; somewhere in 80-85 starts to be unrealistically fast
                               #up to 80 might be OK, depending on aircraft & speed; somewhere in 80-85 starts to be unrealistically fast
                               #>85 is usually very unrealistic.  You must test this in your scenario, however.
                               #>85 is usually very unrealistic.  You must test this in your scenario, however.
             rollRateMax_degpersec : 120, #you can figure this out by rolling the corresponding FG aircraft and timing a 180 or 360 deg roll           
              
             attackCheckTime_sec : 10, # check for need to attack/correct course this often   
             attackCheckTime_sec : 10, # check for need to attack/correct course this often   
             attackCheckTimeEngaged_sec : 0.5, # once engaged with enemy, check/update course this frequently
             attackCheckTimeEngaged_sec : 0.5, # once engaged with enemy, check/update course this frequently
                  
                  
           },
           },
         
         
           #   
           #   
           #########################################
           #########################################
Line 358: Line 327:
                 name : "Machine Gun", # name presented to users, ie in on-screen messages
                 name : "Machine Gun", # name presented to users, ie in on-screen messages
                 maxDamage_percent : 5, # maximum percentage damage one hit from the aircraft's main weapon/machine guns will do to an opponent
                 maxDamage_percent : 5, # maximum percentage damage one hit from the aircraft's main weapon/machine guns will do to an opponent
                 maxDamageDistance_m : 2000, # maximum distance at which the aircrafts main weapon/maching guns will be able to damage an opponent
                 maxDamageDistance_m : 400, # maximum distance at which the aircrafts main weapon/maching guns will be able to damage an opponent
                 weaponAngle_deg  :  { heading: 0, elevation: 0 }, # direction the aircraft's main weapon is aimed.   
                 weaponAngle_deg  :  { heading: 0, elevation: 0 }, # direction the aircraft's main weapon is aimed.   
                                                                   # 0,0 = straight ahead, 90,0=directly right, 0,90=directly up, 0,180=directly back, etc.
                                                                   # 0,0 = straight ahead, 90,0=directly right, 0,90=directly up, 0,180=directly back, etc.
                 weaponOffset_m : {x:2, y:0, z:0}, # Offset of the weapon from the main aircraft center
                 weaponOffset_m : {x:2, y:0, z:0}, # Offset of the weapon from the main aircraft center
                 weaponSize_m : {start:.1, end:.1}, # Visual size of the weapon's projectile, in meters, at start & end of its path
                 weaponSize_m : {start:.1, end:.1}, # Visual size of the weapon's projectile, in meters, at start & end of its path
 
               },     
               },     
            sidewinder_missile :  #internal name - this can be any name you want; must be a valid nasal variable name
              {             
                name : "Sidewinder guided missile", # name presented to users, ie in on-screen messages
                maxDamage_percent : 40, # maximum percentage damage one hit from the aircraft's main weapon/machine guns will do to an opponent
                maxDamageDistance_m : 6000, # maximum distance at which the aircrafts main weapon/machine guns will be able to damage an opponent
                weaponAngle_deg  :  { heading: 0, elevation: 0 }, # direction the aircraft's main weapon is aimed. 
                                                                  # 0,0 = straight ahead, 90,0=directly right, 0,90=directly up, 0,180=directly back, etc.
                weaponOffset_m : {x:2, y:0, z:0}, # Offset of the weapon from the main aircraft center
                weaponSize_m : {start:1, end:1}, # Visual size of the weapon's projectile, in meters, at start & end of its path
              },   
           },   
           },   
         
         
           #   
           #   
           #########################################
           #########################################
Line 385: Line 341:
           #
           #
           # All dimensions are in meters
           # All dimensions are in meters
           #          
           # source: http://en.wikipedia.org/wiki/Fairchild_Republic_A-10_Thunderbolt_II         
           #           
           #           
           dimensions : {                   
           dimensions : {                   
Line 391: Line 347:
             length_m : 16.26, #length of your object, ie, for aircraft, distance nose to tail
             length_m : 16.26, #length of your object, ie, for aircraft, distance nose to tail
             height_m : 4.47, #height of your object, ie, for aircraft ground to highest point when sitting on runway
             height_m : 4.47, #height of your object, ie, for aircraft ground to highest point when sitting on runway
           
           
             damageRadius_m : 8, #typically 1/2 the longest dimension of the object. Hits within this distance of the  
             damageRadius_m : 8, #typically 1/2 the longest dimension of the object. Hits within this distance of the  
                                 #center of object have some possibility of damage
                                 #center of object have some possibility of damage
Line 398: Line 354:
                                      
                                      
             crashRadius_m : 6, #It's a crash if the main aircraft hits in this area.
             crashRadius_m : 6, #It's a crash if the main aircraft hits in this area.
                               
                               
           },
           },
           #
           #
Line 406: Line 362:
           vulnerabilities : {                   
           vulnerabilities : {                   
             damageVulnerability : 9, #Vulnerability to damage from armament, 1=normal M1 tank; higher to make objects easier to kill and lower to make them more difficult.  This is a multiplier, so 5 means 5X easier to kill than an M1, 1/5 means 5X harder to kill.  
             damageVulnerability : 9, #Vulnerability to damage from armament, 1=normal M1 tank; higher to make objects easier to kill and lower to make them more difficult.  This is a multiplier, so 5 means 5X easier to kill than an M1, 1/5 means 5X harder to kill.  
           
           
             engineDamageVulnerability_percent : 6, #Chance that a small-caliber machine-gun round will damage the engine.       
             engineDamageVulnerability_percent : 6, #Chance that a small-caliber machine-gun round will damage the engine.       
              
              
             fireVulnerability_percent : 5, #Vulnerability to catching on fire. 100% means even the slightest impact will set it on fire; 20% means quite difficult to set on fire; 0% means set on fire only when completely damaged; -1% means never set on fire.                           
             fireVulnerability_percent : 5, #Vulnerability to catching on fire. 100% means even the slightest impact will set it on fire; 20% means quite difficult to set on fire; 0% means set on fire only when completely damaged; -1% means never set on fire.                           
           
           
             fireDamageRate_percentpersecond : .1, #Amount of damage to add, per second, when on fire.  100%=completely damaged. Warthog is relatively damage-resistant.
             fireDamageRate_percentpersecond : .1, #Amount of damage to add, per second, when on fire.  100%=completely damaged. Warthog is relatively damage-resistant.
           
           
             fireExtinguishMaxTime_seconds : 80, #Once a fire starts, for this many seconds there is a chance to put out the fire; fires lasting longer than this won't be put out until the object burns out.
             fireExtinguishMaxTime_seconds : 80, #Once a fire starts, for this many seconds there is a chance to put out the fire; fires lasting longer than this won't be put out until the object burns out.
           
           
             fireExtinguishSuccess_percentage : 45, #Chance of the crew putting out the fire within the MaxTime above. Warthoge is relatively damage-resistant.
             fireExtinguishSuccess_percentage : 45, #Chance of the crew putting out the fire within the MaxTime above. Warthoge is relatively damage-resistant.
           
           
             explosiveMass_kg : 27772 , #mass of the object in KG, but give at least a 2-10X bonus to anything carrying flammables or high explosives.
             explosiveMass_kg : 27772 , #mass of the object in KG, but give at least a 2-10X bonus to anything carrying flammables or high explosives.
           },
           },
Line 436: Line 392:
             damageLivery : [  ]                         
             damageLivery : [  ]                         
           },
           },
                           
                           
         };
         };
 
         #########################################
         #########################################
         # INITIALIZE ROUTINES
         # INITIALIZE ROUTINES
Line 466: Line 422:
         # damagedengine                         
         # damagedengine                         
         bombable.startSmoke("jetcontrail", thisNodeName );
         bombable.startSmoke("jetcontrail", thisNodeName );
        #F-15E already has contrails, we're leaving this out
         #
         #
         # END INITIALIZE BOMBABLE
         # END INITIALIZE BOMBABLE
         ########################################################################
         ########################################################################
         ########################################################################                 
         ########################################################################                 
     
     
 
}
      }
object_init();
      object_init();
]]>
      ]]>
</load>
      </load>
<unload>
      <unload>
<![CDATA[
      <![CDATA[
print("Unload F-15E.");
        print("Unload F-15E.");
      var nodeName= cmdarg().getPath();   
        var nodeName= cmdarg().getPath();   
      bombable.de_overall_initialize( nodeName );
        bombable.de_overall_initialize( nodeName );
      bombable.initialize_del( nodeName );
        bombable.initialize_del( nodeName );
      bombable.ground_del( nodeName );
        bombable.ground_del( nodeName );
      bombable.location_del (nodeName);
        bombable.location_del (nodeName);
      bombable.bombable_del( nodeName );
        bombable.bombable_del( nodeName );
      bombable.attack_del( nodeName );
        bombable.attack_del( nodeName );
      bombable.weapons_del (nodeName);       
        bombable.weapons_del (nodeName);       
# </unload>
   
 
    ]]>
]]>
    </unload>
</unload>
  </nasal>   
</nasal>   
</PropertyList>


</PropertyList>
Save this file with the name you have chosen ( FGDATA\Aircraft\F-15E\Models\F-15E_StrikeEagle-bombableinclude.xml).


===Link the -bombableinclude.xml file to the existing F-15 model file===
===Link the -bombableinclude.xml file to the existing F-15 model file===
482

edits

Navigation menu