Jump to content

Recommended Posts

Hello,

 

A little different to the usual use of primaryWeaponItems and handgunItems. I'm looking to have a "catch all" script to determine if a fired shot was suppressed. With mods introducing barrel attachments besides sound suppressors, and some weapons having integral suppressors, I've been looking at pulling a config value for weapons or suppressors on anything to do with noise or the raising of awareness, but I've made no progress on this. Basically all I've been working with is variations of:

getNumber (configFile >> "CfgWeapons" >> (primaryWeapon player) >> _x);

Where _x has been various config values that I thought might get me differing results, based on the presence of a suppressor.

 

Is there a way to do this? Or am I just going to have to load up an array of suppressors and an array of weapons with integral suppressors, then check the weapon and attachments every shot?

Share this post


Link to post
Share on other sites

Did you try checking like this?

_unit = player;
_weapon = currentweapon _unit;
_suppressors = getArray (configfile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
_isSuppressed = (count (_suppressors arrayIntersect primaryweaponitems _unit) > 0);
systemchat str _isSuppressed;

Other than checking for compatible items no idea, since there will always be some inconsistencies when pulling stuff outta configs, especially 3rd party ones.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man Would that not only return if the weapon can be suppressed since all you would get is an array of compatible muzzle attachments?

As for asserting whether the currently held player weapon has a silencer attached to it, I would simply take KK's approach, as seen here:

hasSilencer = player weaponAccessories currentMuzzle player param [0, ""] != "";

 

As for:

15 minutes ago, beno_83au said:

... at pulling a config value for weapons or suppressors on anything to do with noise or the raising of awareness

There are some interesting values in the config for the common sounds suppressor object.

htMin = 1;
htMax = 600;
afMax = 0;
mfMax = 0;
mFact = 1;
tBody = 100;
/-----
minRange = 1;
minRangeProbab = 0.3;
midRange = 150;
midRangeProbab = 0.58;
maxRange = 500;
maxRangeProbab = 0.04;

I have no idea what they are, these values might well be a cryptic cake recipe that BIS out in there, but trying things out almost never hurts.

There also seems to be a value called "detectRange" in the config for both weapons and suppressors, but the value is 0, in all cases that I have observed so far.

  • Like 1

Share this post


Link to post
Share on other sites
22 minutes ago, Grumpy Old Man said:

Did you try checking like this?


_unit = player;
_weapon = currentweapon _unit;
_suppressors = getArray (configfile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
_isSuppressed = (count (_suppressors arrayIntersect primaryweaponitems _unit) > 0);
systemchat str _isSuppressed;

Other than checking for compatible items no idea, since there will always be some inconsistencies when pulling stuff outta configs, especially 3rd party ones.

 

Cheers

 

Inconsistencies are correct. While a vanilla weapon returns an array of suppressors, a mod weapon (in this case from RHS) returns an empty array.

 

@Mokka Perhaps tomorrow I can roll through a bunch of different values and compare suppressed/non-suppressed weapons to see if there's any difference. Thanks for the link.

Share this post


Link to post
Share on other sites

You could check if the weapon has muzzle accessory with weaponAccessories, and get its audibleFire value from CfgWeapons>>class>>ammoCoef. If it's below a threshold, assume it's a suppressor. And if there's no accessory, check the same value of the used weapon.


edit. Ammo can also affect sound apparently, but I don't know what the precedence is these things, or are they just each other's multipliers.

 

And checking this with every shot doesn't sound good, but you might be able to only check it on the first shot, after player takes a something out of a container, closes inventory, respawns etc. and then store the value on the unit with setVariable. But then again, any script might change weapons without you knowing.

  • Like 1

Share this post


Link to post
Share on other sites
21 minutes ago, Mokka said:

 


hasSilencer = player weaponAccessories currentMuzzle player param [0, ""] != "";

 

 

Sorry, missed this. But while this does work for vanilla/mod sound suppressors, it throws true for other barrel attachments and false for integral suppressors.

Share this post


Link to post
Share on other sites

@Greenfist I'll definitely give it a go. I tried audibleFire but it looks like I was using the wrong config path. As for the burden of checking every shot, for now (at least) I'm going for >= 5 unsuppressed shots to initiate an event. So on shot number 5 I'll likely be removing all the related "Fired" event handlers.

 

Honestly though, I gotta stop doing stuff just before bed, I'm buggered.....:goodnight:

  • Like 1

Share this post


Link to post
Share on other sites

Don't forget, weapons also have a visibility coef for detection!

Good night! :tongue:

Share this post


Link to post
Share on other sites
1 hour ago, Mokka said:

@Grumpy Old Man Would that not only return if the weapon can be suppressed since all you would get is an array of compatible muzzle attachments?

 

It will return true if there's an item on the muzzleslot that's in the compatible muzzle items list, so about vanilla A3 weapons this covers the suppressor part.

 

Cheers

Share this post


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

Inconsistencies are correct. While a vanilla weapon returns an array of suppressors, a mod weapon (in this case from RHS) returns an empty array.

It is not necessary an array. Check the type. Works with both vanilla and RHS:
 

Spoiler

pdth_fnc_weapon_slot_comp_items = {
	/**
		Return list of compatible attachments suitable for specified weapon and for specifiied slot
		_this: Array: [ className, slotName ]:
			className: String: weapon class name
			slotName: String: slot class name, representing class entry in ()
				Commonly used slot names are:
					"CowsSlot": optics
					"PointerSlot": pointers, flashlights, etc.
					"MuzzleSlot": muzzle flash suppressors, silencers, etc.
					"UnderBarrelSlot": bipods
		@return Array: [(item1, item2, ...)]
			item1, item2, ...: Strings
		@example
			// returns ["acc_flashlight", "acc_pointer_IR"]
			_arrPointers = ["arifle_MX_F", "PointerSlot"] call pdth_fnc_weapon_slot_comp_items;
	**/
	params [["_clName", "", [""]], ["_slName", "", [""]]];
	private _ret = [];
	if ((isClass (configFile >> "CfgWeapons" >> _clName)) && (isClass (configFile >> "CfgWeapons" >> _clName >> "WeaponSlotsInfo" >> _slName))) then {
		private _compItems = (configFile >> "CfgWeapons" >> _clName >> "WeaponSlotsInfo" >> _slName >> "compatibleItems");
		if (isClass _compItems) then {
			{
				_ret pushBack (configName _x);
			} forEach (configProperties [_compItems, "(isNumber _x) && ((getNumber _x) > 0)"]);
		} else {
			if (isArray _compItems) then {
				_ret = getArray(_compItems);
			}
		}
	};
	_ret
};

 

 

Share this post


Link to post
Share on other sites
6 hours ago, Grumpy Old Man said:

 

It will return true if there's an item on the muzzleslot that's in the compatible muzzle items list, so about vanilla A3 weapons this covers the suppressor part.

 

2

My bad, missed the arrayIntersect. Reading, great skill ;_;

Share this post


Link to post
Share on other sites
23 hours ago, Greenfist said:

You could check if the weapon has muzzle accessory with weaponAccessories, and get its audibleFire value from CfgWeapons>>class>>ammoCoef. If it's below a threshold, assume it's a suppressor. And if there's no accessory, check the same value of the used weapon.


edit. Ammo can also affect sound apparently, but I don't know what the precedence is these things, or are they just each other's multipliers.

 

Well, the MX mag ammo has an audibleFire value of 40, and the KSP mag ammo has a value of 5. So I thought that maybe I could find a suppressor's value that affected the audibleFire value, but I got nowhere.

 

I had a solid look through Config Properties Megalist and tested a few things that I thought might be related, but I never got a change in their values (I tested by equipping and firing with/without suppressors). One thought I had though was to compile an array (probably manually) of the sound files used for suppressors and check through the array to see if any shots were/weren't using one of those files. But I'm not sure how to return what sound is being played when a weapon fires. Does anyone know if this is possible?

Share this post


Link to post
Share on other sites

Hi!

I was looking for a similar "catch all" script and found this thread. Sinse beno_83au didn't find what he was looking for, i thought i'd share what I've achieved.

On 5/27/2017 at 1:44 PM, beno_83au said:

 

Well, the MX mag ammo has an audibleFire value of 40, and the KSP mag ammo has a value of 5. So I thought that maybe I could find a suppressor's value that affected the audibleFire value, but I got nowhere.

The suppressor's value is located at configfile >> "CfgWeapons" >> _attachment >> "ItemInfo" >> "AmmoCoef" >> "audibleFire".

My main trouble was the russian weapons from RHS. There are muzzle attachments in RHS which are in fact not silensers(flame suppressors or smth. like that), so they have "audibleFire" set to 1.0. Normal silencers typically have "audibleFire" below 1.0,:0.04 for standard silencers and 0.4 for RHS silencers.

That's how we can filter out these 'fake silencer' attachments.

For builtin silensers, the "audibleFire" from weapon's ammo seems to be a reliable indicator if the weapon is silenced(check the table in the code below).

So, here's the function if someone needs it:

Spoiler

/*
Checks if given unit is currently using a silenced weapon.

parameters:
_unit - object

output:
silenced - [true/false] - is the current weapon of the unit silenced?
*/

params ["_unit"];

//Check if the current weapon has an attachment in silencer slot
_s = _unit weaponAccessories (currentWeapon _unit) select 0;
if(_s != "") exitWith
{
	//Check if the silencer attachment is indeed a silencer by checking the audibleFire
	_a = getNumber (configfile >> "CfgWeapons" >> _s >> "ItemInfo" >> "AmmoCoef" >> "audibleFire");
	if(_a < 1) then
	{true}
	else
	{false};
};

//If there is no silencer, check weapon's ammo audibleFire coefficient
_mag = currentMagazine (vehicle _unit);
_ammo = getText (configFile >> "cfgMagazines" >> _mag >> "ammo");
_ammoAudible = getNumber (configFile >> "cfgAmmo" >> _ammo >> "audibleFire");
//Compare with threshold value
if(_ammoAudible < 5.5) then //See table below for more values
{true}
else
{false};


/*
auidibleFire data for different ammo and silencer attachments:

configfile >> "CfgAmmo" >> _ammo >> "audibleFire"
configfile >> "CfgWeapons" >> _attachment >> "ItemInfo" >> "AmmoCoef" >> "audibleFire"

standard 5.56mm		35
standard .45		45 (handgun)
standard .50		120 LRRs
standard 9.3mm		80 (The marksmen DLC rifle)
standard 12.7mm		5 (KIR with builtin silencer)
RHS 5.45mm			7
RHS 5.56mm 			7
RHS 7.62mm 			7
RHS 9mm				5.65 (handgun)
RHS 9mm				2.5 (val/vintorez builtin silencer)

attachments:
RHS non-silencers:	1.0
RHS silencers:		0.4
standard silencers:	0.04
*/

 

 

  • Like 4
  • Thanks 2

Share this post


Link to post
Share on other sites

@Sparker

in your code:

 

_mag = currentMagazine (vehicle player);

 

should be 

 

_mag = currentMagazine (vehicle _unit);

 

  • Like 1
  • Thanks 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

×