Jump to content

Recommended Posts

I read in a dev branch update that += can be used to add an entry to a CFG field without knowing it's contents.

I have been trying to add a custom magazine to SPAR variants, and figured that it made most sense to modify the SPAR base class, rather than each SPAR variant individually.

 

Thus far I have successfully created a new ammo type, and magazine containing this ammo.

 

Currently I have the following in CfgWeapons.hpp

class CfgWeapons {
		class GrenadeLauncher;
		class Rifle_Base_F;
		class Rifle_Long_Base_F;
		class Launcher_Base_F;
		
		class arifle_SPAR_01_base_F: Rifle_Base_F 
		{
				magazines[] += {"law_30rnd_556x45_mss"};
		};
};

However, when I examine the  magazines field for arifle_SPAR_01_base_F with the mod loaded, it comes up with the default magazines but not the new magazine.

 

This might suggest that the =+ operator does not work, however, I also attempted the following:

class CfgWeapons {
		class GrenadeLauncher;
		class Rifle_Base_F;
		class Rifle_Long_Base_F;
		class Launcher_Base_F;
		
		class arifle_SPAR_01_base_F: Rifle_Base_F 
		{
				magazines[] += {"law_30rnd_556x45_mss"};
		};
		
		class arifle_SPAR_01_blk_F: arifle_SPAR_01_base_F
		{
				magazines[] += {"law_30rnd_556x45_mss"};			
		};

};

In the above example;

 

  •  arifle_SPAR_01_base_F retains it's original array of vanilla magazines, with no modded mag.
  • arifle_SPAR_01_blk_F contains no vanilla magazines, but TWO entries of law_30rnd_556x45_mss

 

 

I'm not really understanding why the change is not being applied to the base class, but is being applied to it's child, or why the magazine appears twice in the child.

Clearly I've not quite understood everything about CFG editing yet, and need some help figuring this (because my head hurts and I'm frustrated now).

 

 

Cheers,

Law

Share this post


Link to post
Share on other sites
On 4.7.2018 at 6:13 PM, lawman_actual said:

I read in a dev branch update that += can be used to add an entry to a CFG field without knowing it's contents.

Correct. But you need to make sure that your requiredAddons is correct.

 

On 4.7.2018 at 6:13 PM, lawman_actual said:

I have been trying to add a custom magazine to SPAR variants, and figured that it made most sense to modify the SPAR base class, rather than each SPAR variant individually.

It would make sense yeah. Unless each variant individually defines it's magazines. In which case your changes will just be ignored.

 

On 4.7.2018 at 6:13 PM, lawman_actual said:

However, when I examine the  magazines field for arifle_SPAR_01_base_F with the mod loaded, it comes up with the default magazines but not the new magazine.

Sounds like requiredAddons problem.

 

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Dedmen said:

Sounds like requiredAddons problem.

 

That's good to know.

I will continue experimenting with my requiredAddons and report back if I still can't figure it.

 

Much obliged, once again.

Law

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×