Jump to content

Add New Weapon to DCS


FNU LNU

Recommended Posts

Greetz,

 

Existing threads about the process to add a NEW weapon to DCS are not very clear to me, so I'm hoping someone can provide more info--or even a working example. To be clear, I want to add a single new weapon from scratch, not modify an existing one or add existing weapons to a TER/MER.

 

I have tried two methods:

 

1) Editing the core database files. This method is fairly straight forward; add the requisite data blocks to "db_weapons_data.lua", "Types.lua", "wsTypes.lua", "ContainerTable.sht", and add the CLSID to the appropriate pylons in "A-10C.lua". The problem here is that although the weapon appears correctly in the ME and in the A-10's DSMS, the 3d model does not show up on the wing using this method. The 3d model is known to be good, because I can replace any other existing A-10 weapon with my model, and it shows up fine. Conversely, using an EXISTING model with my newly defined weapon also does not work.

 

2) Creating a new "Tech Mod" which does not modify the core files at all--with the obvious exception of the pylon data contained in "A-10.lua". This method is a complete mystery. I do not understand the complete file structure, nor the syntax required. Of the scant examples I could find in this forum, none are complete and working.

 

I prefer to create a standalone mod so there is no dependence on core game files, but I've only succeeded in crashing the game. I have referenced the following threads:

 

https://forums.eagle.ru/showthread.php?t=158882&highlight=add+weapon

https://forums.eagle.ru/showthread.php?t=158714&highlight=add+weapon

https://forums.eagle.ru/showthread.php?t=89368&highlight=add+weapon

https://forums.eagle.ru/showthread.php?t=145787&highlight=add+weapon

 

Can anyone who's gotten this to work provide a complete working example? Without an SDK, this is exceedingly difficult to figure out on one's own.

Link to comment
Share on other sites

I don't know how to do it in the context of a tech mod, only in the context of an aircraft.

 

Basically, you need 4 things:

 

First, I imagine the tech mod has an entry.lua, and you could use that to call your weapon creation lua file. This file is an argument to dofile() within your entry.lua.

 

The second, is to create a table that you'll pass to declare_weapon(). This adds your weapon to the database at startup.

 

The third thing you need is to pass that weapon to declare_loadout(). This is what makes the weapon available in the mission editor.

 

The table content depends on the type of weapon you're trying to create.

 

However, you cannot add your new weapon payload to any aircraft without modifying its payload list. Adding the new CLSID from step 3 to your aircraft's valid payload list is the final step.

 

I don't know how ordering dependencies would be resolved with a tech mod.

  • Like 1
Link to comment
Share on other sites

If you do decide to attach more than one of a weapon to a pylon, it's basically done by declaring a container at the top level that uses the MER/TER model, then placing the bombs you want at the positions you want relative to the MER/TER geometry.

 

The Elements subtable has the parent container shape at offset 1, then the attached bombs at offsets 2-N.

 

On our plane there are many variations of bombs you can rack, the quantities you want, which positions get loaded or skipped based on the side, etc. so we wound up writing functional code to determine these items from a lookup table, to generate the weapon loadouts. Took a day or two to get right, but saved a TON of time in the long run.

Link to comment
Share on other sites

Thanks for the replies Gospadin. I hadn't considered downloading 3rd party modules without purchasing a key...it never occurred to me.

 

Hopefully that will provide some sort of usable example, because although I understand the procedure, it's the actual syntax that remains elusive.

 

Nonetheless, I appreciate the clues.

Link to comment
Share on other sites

What Type of Weapon?

 

As the Data is Different for each:

 

First, If it's not Part of an Aircraft Module You'll Need an Entry.LUA with the Lines for Information and Folder Mounts for Shapes and textures:

 

declare_plugin("Custom Weapons",
{
installed 	 = true, 
dirName	  	 = current_mod_path,
version		 = "0.0.01 Alpha",		 
state		 = "installed",
info		 = _("Custom Weapons"),
})
---------------------------------------------------------
-- Texture and Model Mounts --
mount_vfs_model_path	(current_mod_path.."/Shapes")
mount_vfs_texture_path  (current_mod_path.."/Textures/")

--  Do Files --
dofile(current_mod_path..'/CUSTOM_MISSILES.lua')

---------------------------------------------------------
plugin_done()

 

Then Place Entry.LUA in /USERNAME/Saved Games/DCS.Install/Mods/Aircraft/Custom Weapons/

Place the 3D Model EDMs in the /Custom Weapons/Shapes/ Folder

Place the Textures in the /Custom Weapons/Textures/ Folder

 

Now, For a New Weapon, You Need a Local File With all the Data, this will be CUSTOM_MISSILES.lua (notice it also has a Line to load that in the Entry.LUA Code, and this will also Reside in the /Custom Weapons/ Main Folder w/ the Entry.lua.

 

So:

Custom Missile Data, I'll Use my AGM-65F as an example, Most of the data is the default for the AGM-65s in DCS with some minor Changes to seeker and warhead types, which are pre-defined within dcs as well:

local AGM_65F =
	{
	category 			= CAT_MISSILES,
       Name 				= "AGM-65F",
	user_name			= _("AGM-65F"),
	wsTypeOfWeapon 		= {wsType_Weapon,wsType_Missile,wsType_AS_Missile,WSTYPE_PLACEHOLDER},
       Escort 				= 1,
       Head_Type 			= 5,
	warhead 			= predefined_warhead("AGM_65E"),
	sigma 				= {5, 5, 5},
       M 					= 286.0,
       H_max 				= 10000.0,
       H_min				= -1,
       Diam 				= 305.0,
       Cx_pil 				= 4,
       D_max 				= 11112.0,
       D_min 				= 1000.0,
       Head_Form 			= 0,
       Life_Time 			= 110,
       Nr_max 				= 16,
       v_min 				= 50.0,
       v_mid 				= 290.0,
       Mach_max 			= 1.5,
       t_b 				= 0.0,
       t_acc 				= 4.0,
       t_marsh 			= 0.0,
       Range_max 			= 11112.0,
       H_min_t 			= 0.0,
       Fi_start 			= 0.5,
       Fi_rak 				= 3.14152,
       Fi_excort 			= 1.05,
       Fi_search 			= 99.9,
       OmViz_max 			= 99.9,
       exhaust 			= {0.75, 0.75, 0.75, 0.1},
       X_back 				= -0.879,
       Y_back 				= -0.155,
       Z_back 				= 0.0,
       Reflection 			= 0.063,
       KillDistance 		= 0.0,
	shape_table_data 	=
		{
			{
			name	 = "AGM-65F",
			file	 = "AGM-65E",
			life	 = 1,
			fire	 = { 0, 1},
			username = "AGM-65F",
			index = WSTYPE_PLACEHOLDER,
			},
		},
	}
declare_weapon(AGM_65F)

 

 

Next You Need to Declare the Loadout and Category etc:

 

declare_loadout({
category		=	CAT_MISSILES,
CLSID			= 	"{LAU_117_AGM_65F}", 
Picture			=	"agm65.png",
wsTypeOfWeapon	=	AGM_65F.wsTypeOfWeapon, 
displayName		=	_("LAU-117,AGM-65F"),
attribute		=	{4,	4,	32,	WSTYPE_PLACEHOLDER},
Cx_pil			=	0.001959765625,
Count			=	1,
Weight			=	100,
Elements	=	
{
		{	ShapeName	=	"LAU-117"	  ,	IsAdapter  	=   true  }, 
		{	ShapeName	=	"AGM-65E"	  ,	Position	=	{0.075,   -0.148,   0.0}},
}, -- end of Elements
})

 

Then You Need to Add the Weapon CLSID from the Loadout Declare to the Pylon of the Aircraft You want to add the weapon to.

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

What Type of Weapon?

 

Thanks SkateZilla, I'll give your examples a try!

 

I created models for several different new stores, including JDAMs with nose plugs instead of the default M904 nose fuze, as well as a few alternate variants of the AIS pod.

 

Pods like the AIS seem to lack the type of data contained in your second code snippet. The only thing to enter there would be the basic header info (name/username/category/etc) and the shapetable data; will that suffice?

Link to comment
Share on other sites

Pods and fuel tanks are declared without the weapon parameter section, for example:

 

declare_loadout({
 category = CAT_PODS,
 CLSID = "{ANALQ101}",
 attribute = {
   4,
   15,
   45,
   WSTYPE_PLACEHOLDER
 },
 Picture = "ALQ184.png",
 displayName = _("AN/ALQ-101 ECM Pod"),
 Weight = 242.176,
 Cx_pil = 0.000244140625,
 shape_table_data = {
   {
     name = "ANALQ101",
     file = "alq_119",
     life = 1,
     fire = {0, 1},
     username = "alq_119",
     index = WSTYPE_PLACEHOLDER
   }
 },
 Elements = {
   {
     ShapeName = "alq_119"
   }
 }
})

 

The attribute parameters are obtained from the wsTypes.lua file and are categorised into three levels plus the WSTYPE_PLACEHOLDER which generates a value for the 4th level.

  • Like 1

"The only replacement for a Buccaneer is a Buccaneer".

Link to comment
Share on other sites

Pods and fuel tanks are declared without the weapon parameter section...

 

Thanks tom.

 

I tried using the format you suggested for a new pod, and although the module is visible in DCS, the pod isn't available in the ME. I've done a significant amount of tinkering with the format, order, adding elements from the declare_weapon() function from Skate's examples, amd even adding the entire declare_weapon() code block, but after 5 hours of moving stuff around I can't seem to make this work.

 

This is the entire contents of the Armament.lua file called by Entry.lua. Can anyone see an error in my syntax?

 

declare_loadout(
{
category 			= CAT_PODS,
CLSID 				= "{AAQ_33}",
attribute 			= {4, 15, 44, WSTYPE_PLACEHOLDER},
Picture 			= "AAQ-33.png",
displayName 			= _("AAQ-33 Sniper XR"),
Weight 				= 289.000,
Cx_pil 				= 0.001,
	shape_table_data 	=
	{
		{
		name		= "AAQ_33",
		file	 	= "AAQ_33",
		life	 	= 1,
		fire	 	= {0, 1},
		username 	= "AAQ_33",
		index 		= WSTYPE_PLACEHOLDER,
		},
	},
	Elements 		= 
	{
		{
		ShapeName 	= "AAQ-33",
		Position	= {0, 0, 0}	
		}
	}
}
)


Edited by FNU LNU
Link to comment
Share on other sites

Your Elements.ShapeName doesn't match your shape_table_data.name. They both need to match your .edm file name.

 

That being said, you don't actually need a working model to be visible in the mission editor.

 

Did you add it to the appropriate plane .lua file on the proper pylon?

Link to comment
Share on other sites

Okay, at one point I had EVERYTHING named "AAQ_33" just to make sure it wasn't a mismatched name or an issue with dashes, but it made no difference. I'll try again to make sure.

 

Yes, I've added the CLSID to the A-10C.lua for pylons 2 and 10.

 

Edit: Confirmed that with everything named identically to my .edm, it still does not appear in the ME.


Edited by FNU LNU
Followup troublshooting
Link to comment
Share on other sites

I'm not at my development PC until tomorrow, that being said I can see a comma after the first shape_table_data section that doesn't need to be there. It should be shape_table_data ={{}}, you have ={{},},

 

Besides that, I can't test anything until tomorrow at the earliest for you.

 

 

Sent from my iPhone using Tapatalk

"The only replacement for a Buccaneer is a Buccaneer".

Link to comment
Share on other sites

No worries, thanks for taking a look. If you have time tomorrow, I'd certainly appreciate it.

 

It's difficult to list all of the troubleshooting steps I've taken, but among them were adding and removing commas after the brackets. Some of ED's native files have them and some third parties don't, so I tried it both ways.

 

I was frustrated for a while because DCS kept crashing when loading the ME because "elements" must be written as "Elements" else it's not recognized. Without an SDK or examples like yours from which to copy and paste, there would be no way to figure that out!

 

EDIT: You've got eagle eyes; that extra comma was the problem. Thanks for saving me untold hours and days trying to figure it out on my own!


Edited by FNU LNU
Link to comment
Share on other sites

Excellent! We've all been there - I once spent an entire day (8hrs) trying to figure out why my ME kept crashing with a mod - it was because of a lower case C instead of a capital in one of the lua parameters. That's how sensitive this program is to syntax, plus errors like this aren't in the log files so it's simply trial and error at times.

 

 

Sent from my iPhone using Tapatalk

"The only replacement for a Buccaneer is a Buccaneer".

Link to comment
Share on other sites

I'm not at my development PC until tomorrow, that being said I can see a comma after the first shape_table_data section that doesn't need to be there. It should be shape_table_data ={{}}, you have ={{},},

 

Besides that, I can't test anything until tomorrow at the earliest for you.

 

 

Sent from my iPhone using Tapatalk

 

Lua allows table items to end with a comma, even the last item. It's generally preferred syntax, as I understand it.

 

Edit: that fixed it ? Wierd.

Link to comment
Share on other sites

Some ED files had the commas while others didn't; same for 3rd party files. I swear I tried it both ways, but I must have missed something. Removing the cited comma made everything work.

 

My new roadblock is getting the A-10's DSMS to recognize I've the pod without having to manually inventory it. As before, I've located the 3 relevant files and made what I think are appropriate entries, but the station is still blank in the DSMS Inventory until I manually add it via the MFCD.

 

It's hard not to get discouraged when you've made all the logical changes you can think of, and you're down to essentially pressing buttons and hoping to get lucky.

Link to comment
Share on other sites

  • 7 months later...

Hi all,

I've made a new weapon plugin mod using the template from this thread(#9) and placed it in the saved games/DCS/mods folder

the plugin appears in game and works correctly - even if the lua planes files are not updated (and passes the integrity check).

 

I created a UnitPayload files for each plane and when I use them the missile appears in game but without the pylons -- hanging mid air....

In addition, the picture of the missile in the mission building loadout page doesn't appear - only if the plane lua files are updated and then right-click and selecting the missile directly...

 

any idea's?

 

 

This is weapon loadout I used

declare_loadout(
{
category 		= CAT_AIR_TO_AIR,
CLSID 			= "{Refael_Python-3}",
Picture			=	"python3.png",
displayName		=	_("Refael Python 3"),
wsTypeOfWeapon	=	Python_3.wsTypeOfWeapon,
attribute		=	{4,	4,	32,	WSTYPE_PLACEHOLDER},
Cx_pil   		=   0.001959765625,
Count   		=   1,
Weight			=	85.5,
Elements   =   	{  
                          {	ShapeName	=	"Python3" ,	Position   =   {0.0,   0.0,   0.0}}, 
                               }, 
})

IAF.101_Phantom, 101 squadron XO, Preflight Community Manager

[sIGPIC][/sIGPIC]

watch your six, i'm behind you

-----

Mods: IAF_Weapons: Python 3 and 4

https://www.digitalcombatsimulator.com/en/files/2835842/

Link to comment
Share on other sites

  • 4 weeks later...

Hi this format that the shape_table_data section is in the declare_loadout - is strange to me - the other plugin's shown in this forum are not like it... is it needed?

 

Thanks tom.

 

declare_loadout(

{

category = CAT_PODS,

CLSID = "{AAQ_33}",

attribute = {4, 15, 44, WSTYPE_PLACEHOLDER},

Picture = "AAQ-33.png",

displayName = _("AAQ-33 Sniper XR"),

Weight = 289.000,

Cx_pil = 0.001,

shape_table_data =

{

{

name = "AAQ_33",

file = "AAQ_33",

life = 1,

fire = {0, 1},

username = "AAQ_33",

index = WSTYPE_PLACEHOLDER,

},

},

Elements =

{

{

ShapeName = "AAQ-33",

Position = {0, 0, 0}

}

}

}

)

[/code]

IAF.101_Phantom, 101 squadron XO, Preflight Community Manager

[sIGPIC][/sIGPIC]

watch your six, i'm behind you

-----

Mods: IAF_Weapons: Python 3 and 4

https://www.digitalcombatsimulator.com/en/files/2835842/

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...