Jump to content
rdvtrdvt

How to replace a parameter in another mod's class?

Recommended Posts

I'm trying to replace the "incomingMissileDetectionSystem" parameter in the A-10C from the RHS mod. For this I use this code:


class CfgPatches
 {
 	class RHSplaneFIX
 	{
 		units[] = {"RHS_A10"};
 		weapons[] = {};
 		requiredVersion = 0.1;
 		requiredAddons[] = {"rhs_main_loadorder"};
 	};
};
class RHS_A10;	
class CfgVehicles {
	class RHS_A10{
		incomingMissileDetectionSystem = "16";
	};
};	

But this code removes all parameters that are passed to the class from other classes (in this case it is _generalMacro, displayName and others).

i read the article "Arma 3: Replacement Config Tutorial"(https://community.bistudio.com/wiki/Arma_3:_Replacement_Config_Tutorial). But if I use the following code, it will create a new class called newRHS_A10 rather than replace the old one. This means that the original aircraft will spawn in various scenarios.
 

class RHS_A10;	
class CfgVehicles {
	class newRHS_A10 : RHS_A10{};
};	

 

Share this post


Link to post
Share on other sites

Open Arma without your mod, but with RHS.

Go to Config Viewer cfgVehicles, find  RHS_A10 and find out what it inherits from.

Move RHS_A10 class inside cfgVehicles and define the class the plane inherits from, and inherit RHS_A10 from it.

class CfgVehicles {
  class somePlane; //edit here
  class RHS_A10;
	class RHS_A10: somePlane{ //edit here
		incomingMissileDetectionSystem = "16";
	};
};	

Share this post


Link to post
Share on other sites
19 hours ago, RCA3 said:

Open Arma without your mod, but with RHS.

Go to Config Viewer cfgVehicles, find  RHS_A10 and find out what it inherits from.

Move RHS_A10 class inside cfgVehicles and define the class the plane inherits from, and inherit RHS_A10 from it.


class CfgVehicles {
  class somePlane; //edit here
  class RHS_A10;
	class RHS_A10: somePlane{ //edit here
		incomingMissileDetectionSystem = "16";
	};
};	

I made the code according to yours, but I get the error "config.cpp, line 19... RHS-A10: Member already defined"
 

class CfgPatches {
 	class RHSplaneFIX
 	{
 		units[] = {};
 		weapons[] = {};
 		requiredVersion = 0.1;
 		requiredAddons[] = {"rhs_main", "rhs_main_loadorder"};
 	};
};

// RHS_A10: Plane_CAS_01_base_F and RHS_Su25SM_vvs: RHS_Su25_VVS_Base

class CfgVehicles {
	class Plane_CAS_01_base_F;
	class RHS_A10;
		class RHS_A10: Plane_CAS_01_base_F {
			incomingMissileDetectionSystem = "16"; // AA sensor
		};

	class RHS_Su25_VVS_Base;
	class RHS_Su25SM_vvs;
		class RHS_Su25SM_vvs: RHS_Su25_VVS_Base {
			incomingMissileDetectionSystem = 16; // AA sensor
		};

};

 

Share this post


Link to post
Share on other sites

Uuh, I might have screwed that up, try deleting those previous classes.

class CfgPatches {
 	class RHSplaneFIX
 	{
 		units[] = {};
 		weapons[] = {};
 		requiredVersion = 0.1;
 		requiredAddons[] = {"rhs_main", "rhs_main_loadorder"};
 	};
};

// RHS_A10: Plane_CAS_01_base_F and RHS_Su25SM_vvs: RHS_Su25_VVS_Base

class CfgVehicles {
	class Plane_CAS_01_base_F;
	class RHS_A10: Plane_CAS_01_base_F {
		incomingMissileDetectionSystem = "16"; // AA sensor
	};

	class RHS_Su25_VVS_Base;
	class RHS_Su25SM_vvs: RHS_Su25_VVS_Base {
		incomingMissileDetectionSystem = 16; // AA sensor
	};
};

 

Share this post


Link to post
Share on other sites
10 hours ago, RCA3 said:

Uuh, I might have screwed that up, try deleting those previous classes.


class CfgPatches {
 	class RHSplaneFIX
 	{
 		units[] = {};
 		weapons[] = {};
 		requiredVersion = 0.1;
 		requiredAddons[] = {"rhs_main", "rhs_main_loadorder"};
 	};
};

// RHS_A10: Plane_CAS_01_base_F and RHS_Su25SM_vvs: RHS_Su25_VVS_Base

class CfgVehicles {
	class Plane_CAS_01_base_F;
	class RHS_A10: Plane_CAS_01_base_F {
		incomingMissileDetectionSystem = "16"; // AA sensor
	};

	class RHS_Su25_VVS_Base;
	class RHS_Su25SM_vvs: RHS_Su25_VVS_Base {
		incomingMissileDetectionSystem = 16; // AA sensor
	};
};

 

Thank you. Now this code works. But I still don't understand how inheritance works. Could you help with one more problem?
I want to add "displayToolsForRHSfix" class to inner classes "VehicleSystemsDisplayManagerComponentLeft" and "VehicleSystemsDisplayManagerComponentRight". However, this code removes the parameters that the class already has and I have to restore them (the deleted parameters can be seen in the displayToolsForRHSfix class).
Why is class parameters overwritten? After all, I already inherited them from the base class. At the same time, the Components class does not break.

class displayToolsForRHSfix {
	class EmptyDisplay {
		componentType = "EmptyDisplayComponent";
	};
	class MinimapDisplay {
		componentType = "MinimapDisplayComponent";
		resource = "RscCustomInfoAirborneMiniMap";
	};
	class SensorDisplay {
		componentType = "SensorsDisplayComponent";
		range[] = {4000,2000,16000,8000};
		resource = "RscCustomInfoSensors";
	};
};

class CfgVehicles {
	class Plane_CAS_01_base_F;
	class RHS_A10: Plane_CAS_01_base_F {
		incomingMissileDetectionSystem = "16"; // AA sensor
		class Components {
			class VehicleSystemsDisplayManagerComponentLeft {
				class Components: displayToolsForRHSfix {};
			};
			class VehicleSystemsDisplayManagerComponentRight {
				componentType = "VehicleSystemsDisplayManager";
				defaultDisplay = "EmptyDisplay";
				right = 1;
				x = "(profilenamespace getvariable [""IGUI_GRID_CUSTOMINFORIGHT_X"",	((safezoneX + safezoneW) - (		(10 * 			(			((safezoneW / safezoneH) min 1.2) / 40)) + 0.5 * 			(			((safezoneW / safezoneH) min 1.2) / 40)))])";
				y = "(profilenamespace getvariable [""IGUI_GRID_CUSTOMINFORIGHT_Y"",	(safezoneY + safezoneH - 21 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25))])";
				class Components: displayToolsForRHSfix {};
			};
		};
	};

};

 

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

×