MISSION_TEMPLATE

name:       "Fleet Defense"
type:       DEFEND
degrees:    true

alias:      { name: A1, code: player_carrier    }
alias:      { name: A2, code: player_squadron   }

callsign:   { name: Player,  iff: 1 }
callsign:   { name: Helper,  iff: 1 }
callsign:   { name: Cobra1,  iff: 2 }
callsign:   { name: Cobra2,  iff: 2 }

element: {
   name:    Player,
   design:  Falcon,
   squadron: A2,
   commander: A1,
   rloc:    { ref: A1, dex: 20e3, dex_var: 1e3 },
   mission: patrol,

   player:  1,
   alert:   true,
   count:   2,
   iff:     1,

   navpt:   { cmd: patrol, rloc: { ref: A1,       dex: 150e3, dex_var: 25e3, az:   0, az_var: 10 }, speed: 750 },
   navpt:   { cmd: patrol, rloc: { ref: "this:1", dex: 150e3, dex_var: 25e3, az:  90, az_var: 10 }, speed: 750 },
   navpt:   { cmd: patrol, rloc: { ref: "this:2", dex: 150e3, dex_var: 15e3, az: 170, az_var: 10 }, speed: 750 },
   navpt:   { cmd: vector, rloc: { ref: A1,       dex: 40e3,                 az: 140, az_var: 10 }, speed: 500 },
   navpt:   { cmd: rtb,    rloc: { ref: A1,       dex: 20e3,                 az: 180, az_var:  0 }, speed: 250 },
 
   objective: { cmd: patrol,            tgt_desc: "inbound enemy units" },
   objective: { cmd: rtb },

   loadout: { ship: -1, name: "ACM Medium Range" },
}

element: {
   name:    Helper,
   design:  Stormhawk,
   squadron: A2,
   commander: A1,
   rloc:    { ref: A1, dex: 55e3, dex_var: 25e3, az: -20, az_var: 10 },
   mission: patrol,
   count:   2,
   iff:     1,
}

element: {
   name:    Cobra1,
   design:  Cobra,
   rloc:    { ref: "Player:1", dex: 55e3, dex_var: 25e3, az: -20, az_var: 10 },
   mission: assault,
   count:   4,
   iff:     2,
   loadout: { ship: -1, name: "Hvy Ship Strike" },

   objective: { cmd: assault, tgt: A1 },
   navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 40e3, dex_var: 10e3, az: 0, az_var: 70 }, speed: 750 },
}

element: {
   name:    Cobra2,
   design:  Cobra,
   rloc:    { ref: "Player:3", dex: 55e3, dex_var: 25e3, az: -20, az_var: 10 },
   mission: assault,
   count:   4,
   iff:     2,
   loadout: { ship: -1, name: "Hvy Ship Strike" },

   objective: { cmd: assault, tgt: A1 },
   navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 40e3, dex_var: 10e3, az: 0, az_var: 70 }, speed: 750 },
}


optional: {
    min: 4,
    max: 8,

    element: {
       name:    DB1,
       design:  Broadsword,
       rloc:    { ref: "Player:1", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: assault, tgt: A1 },
       navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 60e3, dex_var: 20e3, az: 0, az_var: 70 }, speed: 750 },
    },

    element: {
       name:    DB2,
       design:  Broadsword,
       rloc:    { ref: "Player:1", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: assault, tgt: A1 },
       navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 60e3, dex_var: 20e3, az: 0, az_var: 70 }, speed: 750 },
    },

    optional: { min: 2, max: 2,
    element: {
       name:    DV1,
       design:  Volnaris,
       rloc:    { ref: "Player:2", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: assault, tgt: A1 },
       navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 60e3, dex_var: 20e3, az: 0, az_var: 70 }, speed: 750 },
    },

    element: {
       name:    T1,
       design:  Tiger,
       rloc:    { ref: "Player:2", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: escort, tgt: DV1 },
    },
    },

    optional: { min: 2, max: 2,
    element: {
       name:    DV2,
       design:  Volnaris,
       rloc:    { ref: "Player:2", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: assault, tgt: A1 },
       navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 60e3, dex_var: 20e3, az: 0, az_var: 70 }, speed: 750 },
    },

    element: {
       name:    T2,
       design:  Tiger,
       rloc:    { ref: "Player:2", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: escort, tgt: DV2 },
    },
    },

    element: {
       name:    DB3,
       design:  Broadsword,
       rloc:    { ref: "Player:3", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: assault, tgt: A1 },
       navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 70e3, dex_var: 20e3, az: 0, az_var: 30 }, speed: 750 },
    },

    element: {
       name:    DB4,
       design:  Broadsword,
       rloc:    { ref: "Player:3", dex: 40e3, dex_var: 7e3 },
       count:   1,
       iff:     2,
       intel:   secret,

       objective: { cmd: assault, tgt: A1 },
       navpt:     { cmd: assault, tgt: A1, rloc: { ref: A1, dex: 70e3, dex_var: 20e3, az: 0, az_var: 30 }, speed: 750 },
    },
}


event: {
   id:              1,
   event:           Message,
   event_ship:      Player,
   event_source:    A1,
   sound:           "Vox/Misc/A02-01.ogg",
   event_message:   "Mayday! Mayday! We are under attack!",

   trigger:         Time,
   time:            38,
}

event: {
   id:              3,
   event:           Damage,
   event_ship:      A1,
   event_param:     30e3,

   trigger:         Event,
   trigger_param:   1,
   delay:           82,
}

event: {
   id:              4,
   event:           Damage,
   event_ship:      A1,
   event_param:     30e3,

   trigger:         Event,
   trigger_param:   1,
   delay:           148,
}

event: {
   id:              5,
   event:           Damage,
   event_ship:      A1,
   event_param:     30e3,

   trigger:         Event,
   trigger_param:   1,
   delay:           186,
}
