Mando Bombs (mando_airsupportdlg.sqf)

By Mandoble

mando_airsupportdlg.sqf

Creates and handles the air support console. From this console you may order bomb runs against selected position in the map, or close air support missions where the planes will engange any not friendly vehicle, ship or static weapon within a range of 500m around the marked center. This console also allows the operator to call for gunships support, airborne assaults and cruise missile attacks.

This script doesnt require parameters, you may execute it as action menu, from a trigger, etc.
This script requires mando_bombs.sqf, mando_bombs_sadarm.sqf and mando_bombs_effects.sqf.
This script requires mando_airsupportdlg.h, include it in your description.ext file (#include "mando_bombs\mando_airsupportdlg.h").

This script uses the following set of global variables:
   mando_support_left_WEST: Maximum number of west planes available for bomb run or cas missions (default value is 8).
   mando_support_left_EAST: Maximum number of east planes available for bomb run or cas missions (default value is 8).
   mando_support_left_GUER: Maximum number of res planes available for bomb run or cas missions (default value is 8).
   mando_support_left_CIV: Maximum number of civ planes available for bomb run or cas missions (default value is 8).
   mando_support_left_ca_WEST: Maximum number of west chopper attacks (default value is 8).
   mando_support_left_ca_EAST: Maximum number of east chopper attacks (default value is 8).
   mando_support_left_ca_GUER: Maximum number of res chopper attacks (default value is 8).
   mando_support_left_ca_CIV: Maximum number of civ chopper attacks (default value is 8).
   mando_support_left_pa_WEST: Maximum number of west airborne chopper assaults (default value is 8).
   mando_support_left_pa_EAST: Maximum number of east airborne chopper assaults  (default value is 8).
   mando_support_left_pa_GUER: Maximum number of res airborne chopper assaults  (default value is 8).
   mando_support_left_pa_CIV: Maximum number of civ airborne chopper assaults  (default value is 8).
   mando_support_left_cm_WEST: Maximum number of west cruise missile attacks (default value is 8).
   mando_support_left_cm_EAST: Maximum number of east cruise missile attacks (default value is 8).
   mando_support_left_cm_GUER: Maximum number of res cruise missile attacks (default value is 8).
   mando_support_left_cm_CIV: Maximum number of civ cruise missile attacks (default value is 8).
   mando_support_left_rc_WEST: Maximum number of west reconnaissance missions (default value is 8).
   mando_support_left_rc_EAST: Maximum number of east reconnaissance missions (default value is 8).
   mando_support_left_rc_GUER: Maximum number of res reconnaissance missions (default value is 8).
   mando_support_left_rc_CIV: Maximum number of civ reconnaissance missions (default value is 8).
   mando_support_left_am_WEST: Maximum number of west ammo supply missions (default value is 8).
   mando_support_left_am_EAST: Maximum number of east ammo supply missions (default value is 8).
   mando_support_left_am_GUER: Maximum number of res ammo supply missions (default value is 8).
   mando_support_left_am_CIV: Maximum number of civ ammo supply missions (default value is 8).
   mando_support_left_ve_WEST: Maximum number of west vehicle supply missions (default value is 8).
   mando_support_left_ve_EAST: Maximum number of east vehicle supply missions (default value is 8).
   mando_support_left_ve_GUER: Maximum number of res vehicle supply missions (default value is 8).
   mando_support_left_ve_CIV: Maximum number of civ vehicle supply missions (default value is 8).
   mando_support_left_re_WEST: Maximum number of west reinforcement missions (default value is 8).
   mando_support_left_re_EAST: Maximum number of east reinforcement missions (default value is 8).
   mando_support_left_re_GUER: Maximum number of res reinforcement missions (default value is 8).
   mando_support_left_re_CIV: Maximum number of civ reinforcement missions (default value is 8).
   mando_support_left_cp_WEST: Maximum number of west CAP missions (default value is 8).
   mando_support_left_cp_EAST: Maximum number of east CAP missions (default value is 8).
   mando_support_left_cp_GUER: Maximum number of res CAP missions (default value is 8).
   mando_support_left_cp_CIV: Maximum number of civ CAP missions (default value is 8).
   mando_support_left_sa_WEST: Maximum number of west cruise missile saturation attacks (default value is 8).
   mando_support_left_sa_EAST: Maximum number of east cruise missile saturation attacks (default value is 8).
   mando_support_left_sa_GUER: Maximum number of res cruise missile saturation attacks (default value is 8).
   mando_support_left_sa_CIV: Maximum number of civ cruise missile saturation attacks (default value is 8).
   mando_support_left_ev_WEST: Maximum number of west evacuation missions (default value is 8).
   mando_support_left_ev_EAST: Maximum number of east evacuation missions (default value is 8).
   mando_support_left_ev_GUER: Maximum number of res evacuation missions (default value is 8).
   mando_support_left_ev_CIV: Maximum number of civ evacuation missions (default value is 8).
   mando_support_left_la_WEST: Maximum number of west laser bombs missions (default value is 8).
   mando_support_left_la_EAST: Maximum number of east laser bombs missions (default value is 8).
   mando_support_left_la_GUER: Maximum number of res laser bombs missions (default value is 8).
   mando_support_left_la_CIV: Maximum number of civ laser bombs missions (default value is 8).
   mando_support_left_cb_WEST: Maximum number of west carpet bombing missions (default value is 8).
   mando_support_left_cb_EAST: Maximum number of east carpet bombing missions (default value is 8).
   mando_support_left_cb_GUER: Maximum number of res carpet bombing missions (default value is 8).
   mando_support_left_cb_CIV: Maximum number of civ carpet bombing missions (default value is 8).

   mando_airsupport_carpetcode: Code global var with code for carpet bombing, receives plane and target position as arguments.

Code variable example for carpet bombing using AV8B with 6 bombs, this might be setup directly into your init.sqf

 // Carpet bombing custom code global variable for AV8B
mando_airsupport_carpetcode =
{
private["_plane", "_targetpos"];
_plane = _this select 0;
_targetpos = _this select 1;

// Wait until horizontal distance between plane and target position is < 2000m or until plane is destroyed
while {(([getPos _plane select 0, getPos _plane select 1, 0] distance _targetpos) > 2000) && (alive _plane)} do
{
Sleep 1;
};

// If the plane is alive, it drops 6 bombs in sequence.
if (alive _plane) then
{
for [{_i=0}, {_i<6}, {_i=_i+1}] do
{
// A bomb is dropped, index 0 is for LGBs in the AV8B, if you change the plane type, set here the correct weapon index for bombs
_plane action ["useWeapon",_plane,driver _plane,0];
Sleep 0.4;
};
};
};

 

   mando_airsupport_type: type of plane for the missions (default value is "AV8B2" for west and "Su34B" for east).
   mando_airsupport_type_ca: type of chopper for chopper attack missions (default value is "AH1W" for west and "KA50" for east).
   mando_airsupport_type_pa: type of chopper for airborne assault and reinforcements missions (default value is "AH1W" for west and "KA50" for east).
   mando_airsupport_type_pal: type of chopper for airborne assault landing missions (default value is "UH60MG" for west and "Mi17_MG" for east)
   mando_support_infantrytype: Array defining soldier classes for airborne assaults infantry groups.
   mando_support_infantrytype_re: Array defining soldier classes for reinforcements missions.
   mando_airsupport_type_rc: type of plane or chopper for reconnaissance missions (default is "AV8B" for west and "Su34" for east).
   mando_airsupport_type_ev: type of chopper for evacuation missions (default is "UH60MG" for west and "Mi17_MG" for east).
   mando_airsupport_type_am: type of chopper for ammo supply missions (default value is "UH60MG" for west and "Mi17_MG" for east).
   mando_airsupport_type_ambox: ammo box type to be used in ammo supply missions, default is "WeaponBoxWest" for west, etc.

   mando_airsupport_type_ve: type of chopper for vehicle supply missions (default value is "UH60MG" for west and "Mi17_MG" for east).
   mando_airsupport_type_vehicle: vehicle type to be used in vehicle supply missions, default is "Truck5t" for west, etc.
   mando_airsupport_type_cp: type of plane or chopper for CAP missions (default is "AV8B" for west and "Su34" for east).
   mando_airsupport_type_la: type of plane for laser bombs missions (default is "AV8B" for west and "Su34B" for east).
   mando_airsupport_type_cb: type of plane for carpet bombing missions (default is "AV8B" for west and "Su34B" for east).

   mando_airsupport_range: Range from target where the planes will be spawned (default and minimum value is 4500).
   mando_airsupport_range_he: Range from target where the helicopters will be spawned (default and minimum value is 4500).

   mando_airsupport_max_cas: In close air support, maximum number of attacks per plane (default value is 2).
   mando_airsupport_bomb_type: The class of a bomb type ammo or the special type "SADARM". "Bo_GBU12_LGB" is used by default.
   mando_airsupport_bomb_alt: The base flying altitude for the bomb runs in m, default value is 150.
   mando_airsupport_bomb_altmax : The maximum base flying altitude for the bomb runs or reco in m, default value is 400, max is 1000.
   mando_airsupport_bomb_pos: Model coords position of a bomb spawned relative to the plane (the second bomb will be spawned at the opposite side). [2, 0, -2] by default.
   mando_airsupport_cmissile: Cruise missile launcher (requires mando missile initialized), default value is objNull;
   mando_airsupport_cmissile_pos: Model coordinates of the cruise missile launch position.
   mando_airsupport_cmissile_alt :cruise altitude for cruise missiles flying in inertial mode, default is 800m.

   mando_support_ingress_limits: Array with angles limiting the ingress arc [min, max], by default [-180,180] (any direction).
   mando_ingress_dir : Initial ingrees dir, between defined ingress limits, by default the half of the limits defined range.
   mando_reco_cam_filter: array [R,G,B,A] for reconnaissance and missile camera color filter, by default [0,0,0,0]
   mando_reco_cam_pos: model coordinates of reconnaissance camera relative to reconnaissance plane, by default [0,3,-2]
   mando_last_plane_cam_pos:  model coordinates of last mission plane camera (except reco), by default [0,1,-2.5]

   mando_airsupport_planes_delay: number of seconds after any mission activation (except missiles) to wait until the option is enabled again (default is 4).
   mando_airsupport_missile_delay: number of seconds after cruise missile attack to wait until the option is enabled again (default is 15).
   mando_support_enemy_sides: array of enemy sides for laser and gun ships support armed with mando missiles. (default = [east] for west, resistance and civilian players, [west] for east players.

   mando_no_default_map: if true, default map click behaviour will be disabled (overrides any onMapSingleClick active code, default is false).

   mando_airsupport_magz: array of pairs of [mag class, quantity] in case you want to change the default content of ammo boxes ([] by default, which means default ammo box maganize content). Ex.: mando_airsupport_magz = [["30Rnd_556x45_G36", 7], ["10Rnd_127x99_m107", 5]];
   mando_airsupport_weap: array of pairs of [weapon class, quantity] in case you want to change the default content of ammo boxes ([] by default, which means default ammo box maganize content). Ex.: mando_airsupport_weap = [["G36K", 2], ["m107", 2]];

   mando_airsupport_re_switchable: true if reinforcement units will be switchable/playable (default value is false).
   mando_airsupport_ab_switchable: true if airborne assault units will be switchable/playable (default value is false).
   mando_airsupport_jump: true for JUMP, false for LAND (applies to reinforcements and airborne assault missions).
   mando_airsupport_ab_action: code var receiving airborne assault group as argument, executed when infantry group is created.
   mando_airsupport_re_action: code var receiving reinforcements group as argument, executed when infantry group is created.

Code variable example for weaponless reinforcements directly into your init.sqf

mando_airsupport_re_action =
{
private["_grp"];
_grp = _this select 0;
{
removeAllWeapons _x;
} forEach units _grp;
};

   mando_airsupport_armedrec: true if player can use reconnaissance planes to attack targets (requires mando missile), default value is false.
   mando_airsupport_armedrec_max: number of attacks allowed per reco plane (requires mando missile), default value is 4.
   mando_airsupport_rec_captive: true will set reconnaissance pilot captive (default is false).
   mando_airsupport_maxrecoscan: max distance to scan with camera (default value is 1500m + mando_airsupport_bomb_altmax).
   mando_airsupport_armedrec_man: true if missiles fired from armed reco plane will have manual (TV) guidance, default is false.

   mando_airsupport_nocomms:  if set to 1, comms will not work and the console will become useless, default value is 0.
   mando_support_side: side for the console, if not defined it will be equal to side player
   mando_airsupport_cams: read only array with the planes of the mission leaders currently flying commanded from this console (you may copy its content to a global per side and then publish it periodically so that other players might have remote cams for these planes).

   mando_airsupport_info: Structured text with info that is displayed in the info/setup dialog.
Example of structured text:
mando_airsupport_info = "Mission info:
Try altitudes between 190 and 250m for carpet bombing using AV8B.

Objetive:
Destroy vehicles near Cayo and enemy ships aproaching your missile launcher at the NW.
Try also the support options available for this mission (all the setup is into init.sqf script).
If you destroy the radar tower near your initial position, comms will be lost.

Note that the options you see below are fully customizable using globals (same as this text block), check online help for more info.";

 

   mando_airsupport_opt1_text: Simple text for info/setup listbox1 title
   mando_airsupport_opt1_array: Array of texts for info/setup listbox1 contents
   mando_airsupport_opt1_action: Code variable with opt1 action when selected item changes (receives item text as argument)
   mando_airsupport_opt2_text: Simple text for info/setup listbox2 title
   mando_airsupport_opt2_array: Array of texts for info/setup listbox2 contents
   mando_airsupport_opt2_action: Code variable with opt2 action when selected item changes (receives item text as argument)
   mando_airsupport_opt3_text: Simple text for info/setup listbox3 title
   mando_airsupport_opt3_array: Array of texts for info/setup listbox3 contents
   mando_airsupport_opt3_action: Code variable with opt3 action when selected item changes (receives item text as argument)
   mando_airsupport_opt4_text: Simple text for info/setup listbox4 title
   mando_airsupport_opt4_array: Array of texts for info/setup listbox4 contents
   mando_airsupport_opt4_action: Code variable with opt4 action when selected item changes (receives item text as argument)
   mando_airsupport_opt5_text: Simple text for info/setup listbox5 title
   mando_airsupport_opt5_array: Array of texts for info/setup listbox5 contents
   mando_airsupport_opt5_action: Code variable with opt5 action when selected item changes (receives item text as argument)

Example to setup one of the options lisboxes with several options for reinforcements:
   // This code might be into an activation script or directly into your init.sqf
   // Title of the second listbox inside setup/info dialog
   mando_airsupport_opt2_text = "Reinforcements type";

   // Items inside second listbox
   mando_airsupport_opt2_array = ["Normal", "Heavy AA","Heavy MG","Engineers"];

   // Code executed when selection chages in second listbox, it changes mando_support_infantrytype_re content based on selected item
   mando_airsupport_opt2_action =
   {
      private["_item"];
      _item = _this select 0;
      switch (_item) do
      {
         case "Normal":
         {
            mando_support_infantrytype_re = ["TeamLeaderW","SoldierWMedic","SoldierWAT","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB"];
         };

         case "Heavy AA":
         {
            mando_support_infantrytype_re = ["TeamLeaderW", "SoldierWMedic", "SoldierWAA","SoldierWAA","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB"];
         };

         case "Heavy MG":
         {
            mando_support_infantrytype_re = ["TeamLeaderW", "SoldierWMedic", "SoldierWMG","SoldierWMG","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB"];
         };

         case "Engineers":
         {
            mando_support_infantrytype_re = ["TeamLeaderW", "SoldierWMedic", "SoldierWMiner","SoldierWMiner","SoldierWMiner","SoldierWB","SoldierWB","SoldierWB","SoldierWB","SoldierWB"];
         };
      };
   };
 

   The following variables set to true disable corresponding buttons:
   mando_support_no_cas: Disables Close Air Support button (default value is false).
   mando_support_no_br: Disables Bomb run button (default value is false).
   mando_support_no_ff: Disables Free fall bombs button (default value is false).
   mando_support_no_sa: Disables SADARM button (default value is false).
   mando_support_no_gs: Disables Gunships Support button (default value is false).
   mando_support_no_ab: Disables Airborne assault button (default value is false).
   mando_support_no_cm: Disables Cruise missile attack button (default value is false)
   mando_support_no_sat: Disables Cruise missile saturation attack button.
   mando_support_no_rc: Disables reconnaissance button.
   mando_support_no_ev: Disables evacuation button.
   mando_support_no_am: Disables ammo supply button.
   mando_support_no_ve: Disables vehicle supply button.
   mando_support_no_re: Disables Airborne reinforcements button.
   mando_support_no_cp: Disables Combat Air Patrol button.
   mando_support_no_la: Disables laser bombs button.
   mando_support_no_cb: Disables carpet bombing button.

   The following variables may be set to radio resources to have radio chat messages (default value for radio resources is "").
   mando_console_radio_delay: Delay in seconds between request and reply, by default 4.
   mando_radio_req_cas: Request for CAS
   mando_radio_rep_cas: Reply from CAS
   mando_radio_req_br: Request for bomb run
   mando_radio_rep_br: Reply from bomb run
   mando_radio_req_gs: Request for gunships
   mando_radio_rep_gs: Reply from gunships
   mando_radio_req_ab: Request for airborne assault
   mando_radio_rep_ab: Reply from airborne assault
   mando_radio_repr_ab: Reply from airborne assault ready
   mando_radio_req_cm: Request for cruise missile
   mando_radio_rep_cm: Reply from cruise missile
   mando_radio_req_sa: Request for saturation
   mando_radio_rep_sa: Reply from saturation
   mando_radio_req_am: Request for ammo supply
   mando_radio_rep_am: Reply from ammo supply otw
   mando_radio_repr_am: Reply from ammo supply ready
   mando_radio_req_ve: Request for vehicle supply
   mando_radio_rep_ve: Reply from vehicle supply otw
   mando_radio_repr_ve: Reply from vehicle supply ready
   mando_radio_req_re: Request for reinforcements
   mando_radio_rep_re: Reply from reinforcements otw
   mando_radio_repr_re: Reply from reinforcements ready
   mando_radio_req_cp: Request for CAP
   mando_radio_rep_cp: Reply from CAP otw
   mando_radio_req_rc: Request for reconnaissance
   mando_radio_rep_rc: Reply from reconnaissance otw
   mando_radio_req_ev: Request for evacuation
   mando_radio_rep_ev: Reply from evacuation otw
   mando_radio_repr_ev: Reply from evacuation ready
   mando_radio_req_la: Request for laser bombs
   mando_radio_rep_la: Reply from laser bombs otw
   mando_radio_req_cb: Request for carpet bombing
   mando_radio_rep_cb: Reply from carpet bombing otw

To set any of the avobe radio vars, you need to define the corresponding radio resources first in your description.ext, for example, for a evacuation request:
// description.ext file
class CfgRadio
{
   sounds[] = {};
   class my_evac_sound
   {
      name = "";
      sound[] = {"evac_request.ogg", db-0, 1.0};
      title = "Requesting evacuation chopper.";
   };
};
Then, in your init.sqf, you may set the corresponding global var:
// init.sqf
...
...
mando_radio_req_rc = my_evac_sound;
Remember to place the .ogg sound files for the radio transmissions into your mission Sound folder.
 
 

Before executing this script you may set the desired values for the previous variables, if you dont, default values will be used.
Examples:
player addAction ["Air Support console", "mando_bombs\mando_airsupportdlg.sqf"];
or
[]execVM"mando_bombs\mando_airsupportdlg.sqf";

Simple example of action reasignment after player's death:
// init.sqf
[]spawn
{
   while {true} do
   {
      player addAction ["Air Support console", "mando_airsupportdlg.sqf"];
      waitUntil {!alive player};
      waitUntil {alive player};
   };
};

Simple example of action reasignment after player's death, but only if player is corporal:
// init.sqf
[]spawn
{
   while {true} do
   {
      sleep 4;
      if (alive player) then
      {
         if (rank player == "CORPORAL") then
         {
            vehicle player addAction ["Air Support console", "mando_bombs\mando_airsupportdlg.sqf"];
         };
         waitUntil {!alive player};
      };
   };
};

Example assigning the action only if the player has a laser designator.
// Add somewhere to your init.sqf
[] spawn
{
  private["_acidx1", "_acidx2", "_unit", "_veh"];
  _acidx1 = -1;
  _acidx2 = -1;
  while {true} do
  {
     waitUntil {("Laserdesignator" in weapons player) && (alive player)};
     _acidx1 = player addAction ["Console: Air support", "mando_bombs\mando_airsupportdlg.sqf"];
     while {("Laserdesignator" in weapons player) && (alive player)} do
     {
        _unit = player;
        if (vehicle _unit != _unit) then
        {
           _veh = vehicle _unit;
           _acidx2 = vehicle _unit addAction ["Console: Air support", "mando_bombs\mando_airsupportdlg.sqf"];
           waitUntil {(vehicle _unit == _unit) || (!alive _unit)};
           _veh removeAction _acidx2;
        };
        Sleep 1;
     };
     _unit removeAction _acidx1;
  };
};

Example using the universal console allowance script:
res =  ["Air Support Console", {"Laserdesignator" in weapons player}]execVM"mando_bombs\mando_giveme_console.sqf";
 

This script requires mando_airsupportdlg.h included into your description.ext file.
// description.ext file
// Include required for air support console dialog
#include "mando_bombs\mando_airsupportdlg.h"