Jump to content
Sign in to follow this  
florianmuellerch

Get Weapons base class with no items

Recommended Posts

I got the primary weapon of my unit. Now I want to reassign it. If I do, all items (aco e.g.) gets also added at the weapon. How can i find the base class of a weapon with no addons?

Share this post


Link to post
Share on other sites

configname (inheritsFrom (configfile >> "cfgweapons" >> (primaryWeapon player)));

Will give you the parent class of your current weapon. This is generally the base model without any addons.

You can make sure a returned class has no addons by checking its "LinkedItems", if it is not a class or its count is 0 then you have the base weapon.

e.g

Function to return base weapon classname

TAG_fnc_baseWeapon = {
_weapon = primaryWeapon player;
_baseCfg = (configFile >> "cfgWeapons");
_cfg = _baseCfg >> _weapon;

while {isClass (_cfg >> "LinkedItems") } do {
	_parent = configName (inheritsFrom (_cfg));
	_cfg = _baseCfg >> _parent;
};

configName _cfg
};

//player addWeapon ([] call TAG_fnc_baseWeapon)

  • Like 1

Share this post


Link to post
Share on other sites

Depends on what you're looking for. For example, the black MX is "arifle_MX_Black_F". Most base versions of the BIS weapons end in "_F".

Also, get to know the ingame config viewer. It's invaluable, and you'll learn a lot from using it.

If you really want to dig deeper, you can open the *.pbo and look at the config.bin where the weapon has been originally created. Base weapons usually have a more extensive configuration, when the accessory variants are smaller, and you'll see where they call for those accessories.

Excuse me if I don't understand the question...

Share this post


Link to post
Share on other sites
configname (inheritsFrom (configfile >> "cfgweapons" >> (primaryWeapon player)));

Will give you the parent class of your current weapon. This is generally the base model without any addons.

You can make sure a returned class has no addons by checking its "LinkedItems", if it is not a class or its count is 0 then you have the base weapon.

e.g

Function to return base weapon classname

TAG_fnc_baseWeapon = {
_weapon = primaryWeapon player;
_baseCfg = (configFile >> "cfgWeapons");
_cfg = _baseCfg >> _weapon;

while {isClass (_cfg >> "LinkedItems") } do {
	_parent = configName (inheritsFrom (_cfg));
	_cfg = _baseCfg >> _parent;
};

configName _cfg
};

//player addWeapon ([] call TAG_fnc_baseWeapon)

Thank you! :)

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  

×