<!DOCTYPE flight_plan SYSTEM "flight_plan.dtd">

<flight_plan alt="75" ground_alt="0" lat0="43.4622" lon0="1.2729" max_dist_from_home="800" name="Versatile" qfu="270" security_height="25">
  <header>
#include "bomb.h"
</header>
  <waypoints>
    <waypoint name="HOME" x="0" y="0"/>
    <waypoint name="T1" x="-172.3" y="223.2"/>
    <waypoint name="T2" x="126.7" y="314.0"/>
    <waypoint name="T1__" x="-275.8" y="234.9"/>
    <waypoint name="T2__" x="213.1" y="307.2"/>
    <waypoint name="T3_SW" x="266.7" y="80.3"/>
    <waypoint name="T3_NE" x="439.1" y="240.0"/>
    <waypoint alt="30" name="AF" x="200" y="-10"/>
    <waypoint alt="0" name="TD" x="58.3" y="45.2"/>
    <waypoint name="BASELEG" x="309.9" y="138.1"/>
    <waypoint name="STDBY" x="-82.4" y="33.8"/>
    <waypoint name="RELEASE" x="126.9" y="181.6"/>
    <waypoint alt="30" name="START" x="168.8" y="-2.6"/>
    <waypoint name="CLIMB" x="19.2" y="212.5"/>
    <waypoint alt="0.0" name="TARGET" x="25.4" y="73.2"/>
    <waypoint name="A1" x="58.8" y="23.3"/>
    <waypoint name="A2" x="-30.7" y="66.8"/>
    <waypoint alt="9.0" name="A1__" x="150.9" y="16.5"/>
    <waypoint alt="9.0" name="A2__" x="-96.5" y="126.9"/>
    <waypoint alt="15.0" name="A0" x="214.6" y="103.7"/>
  </waypoints>
  <blocks>
    <block name="wait GPS">
      <while cond="!GpsFixValid()"/>
    </block>
    <block name="init">
      <while cond="LessThan(NavBlockTime(), 10)"/>
      <call fun="NavSetGroundReferenceHere()"/>
      <deroute block="climb"/>
    </block>
    <block name="climb">
      <attitude pitch="10" roll="0" throttle="0.9" until="estimator_z > ground_alt+30" vmode="throttle"/>
    </block>
    <block name="standby" strip_button="STDBY">
      <circle radius="nav_radius" wp="STDBY"/>
    </block>
    <block name="identify T1">
      <eight center="T1" radius="nav_radius" turn_around="T1__"/>
    </block>
    <block name="identify T2">
      <eight center="T2" radius="nav_radius" turn_around="T2__"/>
    </block>
    <block name="locate T3">
      <survey_rectangle grid="150" wp1="T3_SW" wp2="T3_NE"/>
    </block>
    <block name="bomb" strip_button="Bomb">
      <set value="BombComputeApproach(WP_TARGET, WP_START)" var="unit"/>
      <circle radius="BOMB_RADIUS" until="NavQdrCloseTo(DegOfRad(bomb_start_qdr)-10)" wp="BASELEG"/>
    </block>
    <block name="align">
      <exception cond="BombUpdateRelease(WP_TARGET)" deroute="standby"/>
      <go approaching_time="bomb_trigger_delay" from="START" hmode="route" wp="RELEASE"/>
    </block>
    <block name="shoot">
      <set value="BombShoot()" var="unit"/>
      <go approaching_time="0" from="RELEASE" hmode="route" wp="CLIMB"/>
      <set value="BombCloseHatch()" var="unit"/>
      <deroute block="standby"/>
    </block>
    <block name="close">
      <set value="BombCloseHatch()" var="unit"/>
      <deroute block="standby"/>
    </block>
    <block name="arch">
      <oval p1="A1__" p2="A2__" radius="nav_radius"/>
    </block>
    <block name="land">
      <call fun="nav_compute_baseleg(WP_AF, WP_TD, WP_BASELEG)"/>
      <circle radius="nav_radius" until="NavCircleCount() > 0.5" wp="BASELEG"/>
      <set value="V_CTL_AUTO_THROTTLE_MIN_CRUISE_THROTTLE" var="v_ctl_auto_throttle_cruise_throttle"/>
      <circle radius="nav_radius" until="NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10) && 10 > fabs(estimator_z - WaypointAlt(WP_BASELEG))" wp="BASELEG"/>
    </block>
    <block name="final">
      <exception cond="ground_alt + 10 > estimator_z" deroute="flare"/>
      <go from="AF" hmode="route" vmode="glide" wp="TD"/>
    </block>
    <block name="flare">
      <go approaching_time="0" from="AF" hmode="route" throttle="0.0" vmode="throttle" wp="TD"/>
      <attitude roll="0.0" throttle="0.0" until="FALSE" vmode="throttle"/>
    </block>
  </blocks>
</flight_plan>
