Aircraft Weapons Lua - Editing

# Aircraft weapons Lua - Creating new weapons

## Database - Quaggles repository

You can go to this page to have a good overview over most details and available weapons: https://github.com/Quaggles/dcs-lua-datamine

## Creating a LUA - Example

This is a complete lua code from my mod for the "Name of Aircraft"\_weapons.lua inside main folder:

Most entries can be seen on the quaggles github. Im only gonna add stuff that´s unclear or not on there. This is mainly from the /rockets part:

```
--create a weapon
local PROTONM =   {
		category		= CAT\_AIR\_TO\_AIR, --Type, refer to "WStype list"
		name			= "PROTONM",
		user\_name		= \_("PROTONM"),
		wsTypeOfWeapon 	= {wsType\_Weapon,wsType\_Missile,wsType\_AA\_Missile,WSTYPE\_PLACEHOLDER}, --refer to "WStype list"
        Escort = 0,        --type of firing mode, see quaggles
        Head\_Type = 2,     -- see quaggles
		sigma = {5, 5, 5},
        M = 120.5,        -- see quaggles
        H\_max = 26000.0, -- see quaggles
        H\_min = 1.0, -- see quaggles
        Diam = 160.0, -- see quaggles
        Cx\_pil = 2.5, -- see quaggles
        D\_max = 40000.0,-- see quaggles
        D\_min = 100.0,-- see quaggles
        Head\_Form = 1,-- see quaggles
        Life\_Time = 90.0,-- see quaggles
        Nr\_max = 80,
        v\_min = 140.0, -- see quaggles
        v\_mid = 700.0, -- see quaggles
        Mach\_max = 4.0, -- see quaggles
        t\_b = 0.0, -- see quaggles
        t\_acc = 3.0, -- see quaggles
        t\_marsh = 6.0,-- see quaggles
        Range\_max = 21000.0, -- see quaggles
        H\_min\_t = 1.0, -- see quaggles
        Fi\_start = 0.5, -- see quaggles
        Fi\_rak = 3.14152, -- see quaggles
        Fi\_excort = 1.05, -- see quaggles
        Fi\_search = 1.05, -- see quaggles
        OmViz\_max = 0.52, -- see quaggles
		warhead = enhanced\_a2a\_warhead(20), -- see quaggles or use this one as simple warhead, number is for damage caused by warhead
		exhaust = { 1, 1, 1, 1 },
        X\_back = 0,
        Y\_back = 0,
        Z\_back = 0.0,
		Reflection = 2.081, -- for enemy radar to detect your missile
        KillDistance = 5.0, -- distance for exploding without direct contact
		ccm\_k0 = 0.1,
		shape\_table\_data =
		{
			{
				name	 = "PROTONM", --name as above
				file	 = "PROTONM", --edm file
				life	 = 1,
				fire	 = { 0, 1},
				username = "PROTONM",
				index = WSTYPE\_PLACEHOLDER,
			},
		},
		ModelData = {   58 ,  -- model params count
						0.5 ,   -- characteristic square (характеристическая площадь)

						 -- parameters of the Cx dependence
        [3] = 0.029, -- Cx\_k0 bar Cx0 on subsonic (M << 1)
        [4] = 0.062, -- Cx\_k1 height of the peak of the wave crisis
        [5] = 0.01, -- Cx\_k2 steepness of the front on the approach to the wave crisis
        [6] = -0.08, -- Cx\_k3 bar Cx0 at supersonic (M >> 1)
        [7] = 0.2, -- Cx\_k4 steepness of the decline after the wave crisis
        [8] = 1.2, -- coefficient of dumping of a polar

			        -- parameters of the dependence Cy
        [9] = 2.5, -- Cy\_k0 bar Сy0 at subsonic (M << 1)
        [10] = 1.2, -- Cy\_k1 bar Cy0 at supersonic (M >> 1)
        [11] = 1.2, -- Cy\_k2 steepness of the decline (front) behind the wave crisis

        [12] = 0.29, -- 7 Alfa\_max maximum balancing angle, radians
        [13] = 0, -- angular velocity created by the moment of gas rudders

	-- Engine data. Time, fuel flow, thrust.
-- t\_statr t\_b t\_accel t\_march t\_inertial t\_break t\_end -- Stage
    -1.0,		-1.0,	6,  		5.0,		0.0,			0.0,		1.0e9,         -- time of stage, sec
	 0.0,		0.0,	0.1,		0.1,		0.0,			0.0,		0.0,           -- fuel flow rate in second, kg/sec(секундный расход массы топлива кг/сек)
	 0.0,		0.0,	12000.0,	100.0,	0.0,			0.0,		0.0,           -- thrust, newtons

						  [35] = 1000000000, -- self-destruction timer, sec
        [36] = 60, -- power system operation time
        [37] = 0, -- distance to the triggering surface of the radio fuse, m
        [38] = 1, -- control switch-on delay time, sec
        [39] = 1000000000, -- range to the target at the moment of launch, above which the climb maneuver is performed
        [40] = 1000000000, -- the distance to the target on the path, less than which the completion of the climb maneuver begins (must be greater than the previous parameter)
        [41] = 0, -- sine of the elevation angle of the trajectory of the slide
        [42] = 50, -- longitudinal acceleration of fuse cocking
        [43] = 0,
		   [44] = 1.19, -- characteristic of the ACS-RAKETA system, the coefficient of the second order filter K0
        [45] = 1, -- characteristic of the SAU-RAKETA system, second-order filter coefficient K1
        [46] = 2, -- characteristic of the SAU-RAKETA system, bandwidth of the control loop
        -- DLZ. Data for calculating launch ranges (indication on the sight), also used by AI
        [52] = 60000, -- range view 0 (towards) deg, H = 10000m, V = 1100km / h, m
        [53] = 27000, -- range angle 180 (in pursuit) deg, H = 10000m, V = 1100km / h, m
        [54] = 25000, -- range view 0 (towards) deg, H = 1000m, V = 1100km / h, m
        [55] = 0.5, -- Coefficient of decreasing the range when increasing the angle between the vectors of the carrier velocity and the line of sight of the target
        [56] = 0.3, -- Vertical plane. Slope of the curve of the allowed launch range into the lower hemisphere. Reduced range when firing down.
        [57] = 2, -- Vertical plane. Slope of the curve of the allowed launch range into the upper hemisphere. Increased range when firing upwards.
        [58] = -3, -- Vertical plane. Bend angle of the permitted range curve, upper - lower hemisphere.
        [59] = 0.7, -- Changing the slope coefficients of the curve in the upper and lower hemispheres from the height of the carrier.
        } -- end of ["ModelData"]
						 --DLZnew if the above doesnt work use this one:
		-- 21.0, -- производная дальности по скорости носителя на высоте 1км, ППС
       	-- -23.0, -- производная дальности по скорости цели на высоте 1км, ЗПС
       	-- -3.0, -- производная по высоте производной дальности по скорости цели, ЗПС
        -- 13000.0, -- дальность ракурс 180 град (навстречу), Н=5000м, V=900км/ч, м
        -- 8000.0, -- дальность ракурс 0(в догон) град, Н=5000м, V=900км/ч, м
        -- 13000.0, -- дальность ракурс 180(навстречу) град, Н=10000м, V=900км/ч, м 69km
        -- 10000.0, -- дальность ракурс 0(в догон) град, Н=10000м, V=900км/ч, м
        -- 13000.0, -- дальность ракурс 180 град (навстречу), Н=1000м, V=900км/ч, м
        -- 5000.0, -- дальность ракурс 0(в догон) град, Н=1000м, V=900км/ч, м
        -- 13000.0,
       -- 0.4,
        -- -0.015,
        -- 0.5,

}

declare\_weapon(PROTONM)

--part 2: to make your weapon equippable?
declare\_loadout({
	category		=	CAT\_AIR\_TO\_AIR,
	CLSID			= 	"{PROTONM}",
	Picture	=	"PROTONM.png",
	wsTypeOfWeapon	=	PROTONM.wsTypeOfWeapon,
	displayName	=	\_("PROTONM"),
	attribute	=	{4,	4,	32,	WSTYPE\_PLACEHOLDER}, -- see wslist
	Count			=	1, --number of ammunition
	Weight			=	50,
	Elements	=
	{
		{

			ShapeName	=	"PROTONM", --edm file
			Position	=	{0,	0,	0}
		},
	},

}
)--end of declaration of one new weapon

declare\_loadout(
 	{
 		category		= CAT\_FUEL\_TANKS,
 		CLSID			= "{XFUELTANK}",
 		attribute		=  {wsType\_Air,wsType\_Free\_Fall,wsType\_FuelTank,WSTYPE\_PLACEHOLDER},
 		Picture			= "XFUEL.png",
 		displayName		= \_("ENERGY CELL"),
 		Weight\_Empty	= 1,
 		Weight			= 2005,
		Capacity		= 2000,
 		Cx\_pil			= 0.002,
 		shape\_table\_data =
 		{
 			{
 				name	= "FUEL TANK";
 				file	= "TIEFUEL";
 				life	= 1;
 				fire	= { 0, 1};
 				username	= "FUEL TANK";
 				index	= WSTYPE\_PLACEHOLDER;
 			},
 		},
 		Elements	=
 		{
 			{
 				ShapeName	= "TIEFUEL",
 			},
 		},
 	}
)

```