Jump to content
Sign in to follow this  
bigringantics

Classnames in Config.cpp Explanation

Recommended Posts

Hi there everybody,

I'm new to configs and there's a lot of stuff that isn't making a whole lot of sense to me. I found, thanks to another user, a model Config.cpp that looks something like this:

class CfgVehicles {
class [color="#0000CD"]B_Soldier_base_F[/color];
   class [color="#0000CD"]Army_Squadleader[/color] : [color="#0000CD"]B_Soldier_base_F[/color] {
	_generalMacro = "[color="#0000CD"]Army_Squadleader[/color]"; 
	scope = 2;
	displayName = "Squad Leader"; // In-game name of unit
	faction = a_units; // Puts unit under new faction
	vehicleClass = "army_units"; // Puts unit in the vehicleclass
	icon = "[color="#FF8C00"]iconManLeader[/color]";
	nakedUniform = "U_BasicBody";  
	uniformClass = "U_B_CombatUniform_mcam";  // Uniform Class
	backpack = "B_AssaultPack_khk"; // Backpack Class
	linkedItems[] = {"V_PlateCarrier3_rgr", "H_HelmetB_light", "NVGoggles", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio"}; // Item's added to the unit. 
	respawnLinkedItems[] = {"V_PlateCarrier3_rgr", "H_HelmetB_light", "NVGoggles", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio"}; // Item's added to the unit. Should be identical to the linkedItems section.
	weapons[] = {"arifle_MX_F","Binocular"}; // Weapons added to the unit.
	respawnweapons[] = {"arifle_MX_F","Binocular"}; // Weapons added to the unit. Should be identical to the linkedItems secti
	magazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","HandGrenade","HandGrenade",};
	Respawnmagazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","HandGrenade","HandGrenade",};
	};
};

I have a couple of questions about what the colored parts of this mean. First, what do the classnames in blue mean and what makes them different from each other? Why are they repeated in the places they are? I've spent a wile googling around and thinking about it and I've gotten nowhere.

Second, I understand what the part in orange about the unit's icon means, but I don't know what the other options for it are. Specifically, if somebody could float me the icons for medic, autorifleman, and AT rifleman, I would really appreciate it.

Share this post


Link to post
Share on other sites

B_Soldier_base_F is the parent class of Army_Squadleader. This is indicated by the colon symbol (this thing -> :) written between the two classnames.

Army_Squadleader will inherit all the properties of B_Soldier_base_F, apart from the ones that are altered by declaring new values for those properties, inside the Army_Squadleader class.

In order to inherit classes from external config.cpp files (i.e. not the config.cpp you are writing), you must call the class that you want to inherit from into your config first, by writing class nameOfParentClass;. Note you don't add the curly brackets { } since you're just calling the class - the line just ends with the terminal semicolon ; and calls all the properties of that class when the game reads that line of the config.

You can then write declare the inheritance for your own class in the style class myClass: nameOfParentClass and define all the new properties of your class within the { } brackets, before closing it again with the ;.

Basically that is why B_Soldier_base_F is written in the config twice - first to call it, second to make another class inherit from it.

If you want to inherit from a class that is defined in your config.cpp, you just write the inheritance as class mySecondClass: myClass, as the parent is already there in your config.cpp so doesn't need to be called again.

--

I'm not really sure what the exact purpose of the _generalMacro = ""; parameter is supposed to be, but I guess it is used by some sort of script or function within the game. I assume it's used to efficiently call the classname of the object as a simple text string rather than call the actual object class itself (and all the properties that the class contains therein), because in most cases the value has the same name as the classname, only with the quotation marks wrapped around it " " to indicate that it's a text string, not the object itself. So long as _generalMacro's value matches the classname that contains it, I think you'll be fine.

--

As you know, the icon = ""; parameter defines the little icon that appears on the map to indicate the unit's position and "iconManLeader" is a preset image from the game (it represents the image \A3\ui_f\data\map\vehicleicons\iconManLeader_ca.paa). This texture path is defined in class CfgVehicleIcons somewhere in BIS' game data to have the macro "iconManLeader" (a "macro" is a shorthand text string that equals that big long chunk of writing) so that you don't have to write the full path when declaring the icon property for every unit that uses it.

If you want the unit to have a different map icon, you change the value from "iconManLeader" to a different texture path (either by writing the full path to the texture you want or a different macro under class CfgVehicleIcons).

Existing icons for man units in the game (as defined in cfgVehicleIcons with their shorthand form and full texture path) are:

iconMan = "\A3\ui_f\data\map\vehicleicons\iconMan_ca.paa";
iconManMedic = "\A3\ui_f\data\map\vehicleicons\iconManMedic_ca.paa";
iconManEngineer = "\A3\ui_f\data\map\vehicleicons\iconManEngineer_ca.paa";
iconManExplosive = "\A3\ui_f\data\map\vehicleicons\iconManExplosive_ca.paa";
iconManRecon = "\A3\ui_f\data\map\vehicleicons\iconManRecon_ca.paa";
iconManVirtual = "\A3\ui_f\data\map\vehicleicons\iconManVirtual_ca.paa";
iconManAT = "\A3\ui_f\data\map\vehicleicons\iconManAT_ca.paa";
iconManLeader = "\A3\ui_f\data\map\vehicleicons\iconManLeader_ca.paa";
iconManMG = "\A3\ui_f\data\map\vehicleicons\iconManMG_ca.paa";
iconManOfficer = "\A3\ui_f\data\map\vehicleicons\iconManOfficer_ca.paa";

Edited by da12thMonkey
  • Like 1

Share this post


Link to post
Share on other sites

Thank you! One last question, how would I add items like a medikit or a first aid kit?

Share this post


Link to post
Share on other sites

Well, BIS do it by giving the units a backpack that contains the MediKit/FAK. The medic units have a parameter like this:

	backpack = "B_AssaultPack_rgr_Medic";

So you just add that backpack line if you want to use one of the default pack classes that contain the medical equipment.

The backpack class B_AssaultPack_rgr_Medic is set up to contain the MediKit and FAK like this:

class B_AssaultPack_rgr_Medic: B_AssaultPack_rgr
{
	scope = 1;
	class TransportItems
	{
		class _xx_Medikit
		{
			name = "Medikit";
			count = 1;
		};
		class _xx_FirstAidKit
		{
			name = "FirstAidKit";
			count = 10;
		};
	};
};

If you want a custom backpack to carry the medical equipment (or other equipment) you'd have to set one up like that, then refer to it in your custom unit's backpack line.

Other items like the body armour, NVGs, radios and helmets are done in the LinkedItems[] and respawnLinkedItems[] arrays. Weapons in the weapons[] and respawnweapons[] arrays and ammunition in the magazines[] and respawnMagazines[] arrays (AFAIK magazines just fill up any available space remaining in your uniform, vests and backpacks).

Edited by da12thMonkey

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
Sign in to follow this  

×