Jump to content
br_ac_army1

Class inheriting problem

Recommended Posts

I have some problem creating copies of some weapons in Arma III. I created a new file and called classes to inherit from them.
However, if I just use class hgun_ACPC2_F, it says that my new weapon has undefined class "Single". If I use class hgun_ACPC2_F { class Single; class WeaponSlotsInfo; }, my weapon starts working wrong (infinite ammo, no sound, puts away when pressing F).

What should I do?

Link: https://www.dropbox.com/s/od2v2at9wvthh2j/upgradedweapons.zip?dl=0

Share this post


Link to post
Share on other sites

More detailed:

 

Quote

I have some problem creating copies of some weapons in Arma III. I created a new file and called classes to inherit from them.

I have 10 modified weapons:

- ACP .45
- 4-five .45
- Rook-40 9mm
- Mk18 EBR 7.62mm
- GM6 Lynx 12.7mm
- MXC 6.5mm
- MX 3GL 6.5mm
- Sting 9mm
- Zafir 7.62mm
- TRG-21 EGLM 5.56mm

The problem is if I just use:

class hgun_ACPC2_F;
class hgun_Pistol_heavy_01_F;
...


then Arma 3 says that my new weapon has undefined class "Single". However If I use:

class hgun_ACPC2_F { class Single; };
class hgun_Pistol_heavy_01_F { class Single; };
...


then I have the most interesting part:

- ACP .45 - the original and modified versions work normal,
- 4-five .45 - the original and modified versions work normal,
- Rook-40 9mm - the original and modified versions work normal,
- Mk18 EBR 7.62mm - the original and modified versions work wrong (infinite ammo, no sound, puts away when pressing F),
- GM6 Lynx 12.7mm - the original and modified versions work wrong (infinite ammo, no sound, puts away when pressing F),
- MXC 6.5mm - the original and modified versions work normal,
- MX 3GL 6.5mm - the original and modified versions work wrong (infinite ammo, no sound, puts away when pressing F)
- Sting 9mm - the original and modified versions disappeared at all!!!
- Zafir 7.62mm - original weapon works correct, but a modified one doesn't want to fire,
- TRG-21 EGLM 5.56mm - original weapon works correct, but a modified one just disappeared

So that some weapons works correct and other ones don't.

Please, give me some advice about what should I do?

Link to a mod: https://www.dropbox.com/s/od2v2at9wvthh2j/upgradedweapons.zip?dl=0

 

Share this post


Link to post
Share on other sites

Your best bet for correct inheritance is to check how each class inherits its config entries.

For example, you can use the following for your first two classes:

	class hgun_ACPC2_F: Pistol_Base_F
	{
		class WeaponSlotsInfo;
	};	
	class hgun_Pistol_heavy_02_F: Pistol_Base_F
	{
		class WeaponSlotsInfo;
	};

Then just refer to each of the remaining classes inheritance trees for the remainder of your config base class setup.

Share this post


Link to post
Share on other sites
On 7/12/2023 at 1:27 AM, Jackal326 said:

Your best bet for correct inheritance is to check how each class inherits its config entries.

For example, you can use the following for your first two classes:


	class hgun_ACPC2_F: Pistol_Base_F
	{
		class WeaponSlotsInfo;
	};	
	class hgun_Pistol_heavy_02_F: Pistol_Base_F
	{
		class WeaponSlotsInfo;
	};

Then just refer to each of the remaining classes inheritance trees for the remainder of your config base class setup.

Thanks for your help! Actually I've already found a solution for my problem. I decided to add class WeaponSlotsInfo to my code and inherit other classes in modified weapons. So, I have something like:
 

class WeaponSlotsInfo;
class srifle_DMR_02_cheat_F: srifle_DMR_02_F
{
		// Some code
		modes[] = {"SingleB","single_close_optics1","single_medium_optics1","single_far_optics1"}; 
  		// replacing Single to SingleB
		class Single;
		class SingleB: Single {
			// My code
		};
		class single_close_optics1: SingleB {
			// Copying from original
		};
		class single_medium_optics1: single_close_optics1 {
			// Copying from original
		};
		class single_far_optics1: single_medium_optics1 {
			// Copying from original
		};
		class WeaponSlotsInfo: WeaponSlotsInfo{
			// Copying from original with minor changes
		};
};

 

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, br_ac_army1 said:

Thanks for your help! Actually I've already found a solution for my problem. I decided to add class WeaponSlotsInfo to my code and inherit other classes in modified weapons.

[...]

Cool, glad you got it working, and good work on posting your solution, it'll help anyone who has similar issues 👍

  • Like 1

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

×