Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed/Updated isTurnedOut/isAttenuated function #1015

Closed
wants to merge 29 commits into from

Conversation

shukari
Copy link
Contributor

@shukari shukari commented Oct 21, 2018

This is a PR for radio addons like acre and tfar that there isolation is not on outside gunners and the vanilla isTurnedOut command cant handle that.

You are free to use the function or parts of it in your mod, have fun with it!

…able; rename _out to _return; added gunnerAction check for rhs m2 humvee and vanilla B_LSV_01_armed_F; added window check for rhs vehicle cargo windows;
@commy2
Copy link
Contributor

commy2 commented Oct 21, 2018

This function is legacy due to isTurnedOut command, no?

@shukari
Copy link
Contributor Author

shukari commented Oct 21, 2018

No, this functions has better results. For example the gunner of the B_LSV_01_armed_F (https://community.bistudio.com/wikidata/images/b/b5/B_LSV_01_armed_F.jpg) is with isTurnedOut FALSE... also cargo of a open cargo truck.

if (driver _vehicle == _unit) then {
_return = (_vehicle animationPhase "hatchDriver") > 0;
} else {
private _assignedRole = assignedVehicleRole _unit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command reports nil while remote controlling a unit. Try this function while remote controlling an AI with zeus, and it should fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reports []... a params should fix that...

if ((count _attenuateCargo) > 0) then {
private _index = (count _attenuateCargo)-1; // wait for command to get cargo index
private _gunnerAction = getText (_turret >> "gunnerAction");
private _hatchAnimation = getText(_turret >> "animationSourceHatch");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space

if (_index > -1) then {
if (_index > (count _attenuateCargo) - 1) then {
_index = (count _attenuateCargo) - 1;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_index = _index max (count _attenuateCargo - 1);
?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or the whole thing:

_return = _attenuateCargo param [_index, -1] == 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is old code untouched by me but will change

@shukari shukari changed the title Changed/Updated isTurnedOut function WIP: Changed/Updated isTurnedOut function Oct 21, 2018
@shukari
Copy link
Contributor Author

shukari commented Oct 21, 2018

@commy2 because FFVs are ever outside is it possible to get the functions ace_common_fnc_getTurretIndex and ace_common_fnc_getTurretsFFV to cba?

@dedmen
Copy link
Contributor

dedmen commented Oct 21, 2018

This will return true, even if not actually turned out in "open" vehicles? Like cabrio's and stuff?
That'll be awesome.

@shukari
Copy link
Contributor Author

shukari commented Oct 21, 2018

@dedmen yes... also gunners like the rhs humvee m2 gunner... also tfar can now handle open cargo seats with soundAttenuationCargo it is an array which define which cargoIndex is open to the outside... if its [1] no cargo can hear the outside... [0] means every... and [1,0] means cargo index 0 cant hear but all other.

@TheMagnetar
Copy link

Top. One of the issues with intercom was detection of turned out units

@commy2
Copy link
Contributor

commy2 commented Oct 21, 2018

Nice.

private _attenuateCargo = getArray (_cfg >> "soundAttenuationCargo");
if !(_attenuateCargo isEqualTo []) then {
private _count = count _attenuateCargo;
_return = 0 == _attenuateCargo select (if (_cargoIndex >= _count) then {_count - 1} else {_cargoIndex});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line... is art?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should i change it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been looking at it for the last 6 minutes and I still have no idea what it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1015 (comment) the last part about soundAttenuationCargo

private _window = ['ani_window_1', 'ani_window_2', 'ani_window_4', 'ani_window_3'] select (_cargoIndex + 1);
if ((_vehicle doorPhase _window) > 0) exitWith {_return = true};

if ([_unit] call ace_common_fnc_getTurretIndex in ([_vehicle] call ace_common_fnc_getTurretsFFV)) exitWith {_return = true};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unavailable when ACE is not used. Bad idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote it as attention in the first message and as @ mention comment to you #1015 (comment)

Can i add them to cba... or is there an other alternative?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will thonk about to tomorrow morning.

@shukari
Copy link
Contributor Author

shukari commented Oct 21, 2018

I think i should make a own cba function or a function for tfar itself.
Because... isTurnedOut should be if someone with a hatch goes in or out... but i want all units that are not isolated to the outside aka are on the fresh air in vehicles.
I dont know what i should do... any ideas?

@dedmen
Copy link
Contributor

dedmen commented Oct 22, 2018

Was isTurnedOut deprecated so far?
I personally don't have a problem to essentially change functionality.
If you move it to a seperate function instead. I'd prefer the return value to be the isolation (from soundAttenuation config) between 0-1 instead of just a bool.

I would vote for moving the ACE func into CBA. As it seems to be universally useful.
And the code itself (https://github.com/acemod/ACE3/blob/master/addons/common/functions/fnc_getTurretIndex.sqf) doesn't contain anything ACE specific.

@shukari
Copy link
Contributor Author

shukari commented Oct 22, 2018

@dedmen soundAttenuation is only 1 if the index cant hear or 0 if he can... i saw no value between.

@shukari
Copy link
Contributor Author

shukari commented Nov 25, 2018

Cba_fnc_isTurnOut is atm a function like the isTurnOut command for commander, turrets and gunners, not for cargos or ffs cargos.

Edit: for me this behavior is good, should it be added for ffs?

@commy2 commy2 modified the milestones: 3.9.1, 3.10 Nov 25, 2018
@jonpas
Copy link
Member

jonpas commented Nov 25, 2018

I understand this works for same cases as vanilla SQF command, but it does not work for Cargo and FFV seats, please correct me if I am wrong.

Since goal of this PR includes:

This is a change for radio addons like acre and tfar that there isolation is not on outside gunners and the vanilla isTurnedOut command cant handle that.

it makes sense in my eyes that it is done properly, including Cargo and FFV seats. If it does not work for all cases, then neither mod will use those new functions.

Additionally, gunner of the Chinook is indeed inside the vehicle, and even has a headset on as far as I know! He is not turned out.

@shukari
Copy link
Contributor Author

shukari commented Nov 25, 2018

@jonpas sry but you dont unterstand this PR... look at function isAttenuated

@jonpas
Copy link
Member

jonpas commented Nov 25, 2018

Is my understanding of the following correct?

  • isTurnedOut is true when part of unit's body is physically outside of the vehicle internals (benches of little bird, body out of the hatch etc.), false otherwise
  • isAttenuated is true when unit is attenuated by the vehicle (is inside a sound-isolated compartment such as in Humvee or BDR, has headphones on etc.), false otherwise (technical gunner, boat, open vehicle etc.)

I have worded it badly in my previous comment, but in case of Chinook gunner this would result in:

  • isTurnedOut -> false as he is not physically outside of the vehicle
  • isAttenuated -> true because he is is attenuated by the helicopter (headphones on)

@TheMagnetar is that your understanding also?
@shukari how does your understanding differ? Please, do not take this as a bad thing or any kind of flaming on you, we simply have to be very clear on what is what and make sure we understand each other. :)

@shukari
Copy link
Contributor Author

shukari commented Nov 25, 2018

My understanding:

  • isTurnedOut a function that is for me not important and does only trouble because of the the understanding. For me it is a addition to isTurnOut command that report hatches and gunner that look out.
  • isAttenuated is the function that this PR is all about. It should help or give the radio addons an idea of a solution with roles that can speak with the outside

Im a little bit frustrated and done with this PR.
If after this comment is a problem with isTurnedOut i will revert it to the old and integrate the changes to isAttenuated.

@jonpas
Copy link
Member

jonpas commented Nov 25, 2018

FYI: I have corrected my above example, got confused and inverted a thing!

@shukari
Copy link
Contributor Author

shukari commented Nov 26, 2018

CBA_fnc_isTurnedOut now is isTurnedOut + hatch Check
CBA_fnc_isAttenuated is ready, a compare to units fnc can be done in another PR

@shukari shukari changed the title WIP: Changed/Updated isTurnedOut/isAttenuated function Changed/Updated isTurnedOut/isAttenuated function Nov 26, 2018
@dedmen
Copy link
Contributor

dedmen commented Nov 26, 2018

@jonpas without the "headphones on" part.
Yes. Return true when inside a closed compartment, and can't (really) hear people outside. I wouldn't count things like headphones.. Because you can just take them off, or maybe you don't have them on right now, no way to detect that, that's something that the radio mods do on their own.

Door gunner on Chinook could return both really.. But should be false (can hear people from outside)
He should be able to hear people that are infront of his window, but not people that are outside of the vehicle behind him or infront of the chinook.. But sound also travels around corners.
You can't really check if someones sound would travel through the window or not, so a true (can't hear people outside) would also be a sensible choice.

Ref to @Magnetar

In that case, the isAttenuated function returns false, while it should return true.
I disagree, he has a open window infront of him, he can hear sounds from outside.

private _attenuationType = getText (_config >> "attenuationEffectType");
if (_attenuationType in ["OpenCarAttenuation", "OpenHeliAttenuation"]) exitWith {false};
if (_attenuationType in ["OpenCarAttenuation", "OpenHeliAttenuation", "jsrs_OpenCar_Attenuation", "jsrs_SemiOpenCar_Attenuation"]) exitWith {false};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid mod specific "compatibilities" in CBA?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you check out those classes, you can see that they don't have anything to do with whether you should or shouldn't hear anyone outside the vehicle anyway.
Tbh, it seems to me like this is something the radio mods should worry about. There is no link from the base game to this. The ingame sounds clearly follow different rules that wouldn't work for the radio mods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@commy2 This line is THE key line of this function. Because of this value i get quads, boots, littlebirds and open jeeps as open vehicles. It is not important what these classes define in cfgSoundEffects... it is important that these classes give a hint that the vehicle is open to the outside. If i delete this check... the function is useless.

@TheMagnetar yes you are right, BUT then the function is broken if someone use the clientside mod JSRS... what should i do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally have a "registerAttenuationClass" function which adds those to a global array. Similar to how "registerFeatureCamera" is but without code stuff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is THE key line of this function.

But it isn't. It is an arbitrary list that would have to be expanded every time someone makes a new class that would qualify in a random mod. I am not going to approve and merge references to i.e. JSRS in CBA.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally have a "registerAttenuationClass" function which adds those to a global array. Similar to how "registerFeatureCamera" is but without code stuff.

No, because vehicle attenuation as it appears in Arma is not linked to whether you should be able to hear someone outside the vehicle from inside or not.

Copy link
Contributor

@commy2 commy2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed after review

@shukari
Copy link
Contributor Author

shukari commented Nov 26, 2018

@dedmen headphones, distance and other blocking things are so special edge cases that they should done by the mod that needs them in my opinion.

@shukari
Copy link
Contributor Author

shukari commented Nov 26, 2018

My time with this PR is now over... i was so happy to make something for CBA but this is the end. Im done. Have fun commenting.
Anybody can use the function or parts of it in there mods.

@dedmen
Copy link
Contributor

dedmen commented Jan 6, 2019

Just integrated into TFAR. Works beautifully. both isTurnedOut and CBA_fnc_isTurnedOut return false when turned out as the gunner in vehicles, even Vanilla vehicles but this works properly.
Performance is shit. Main cause is CBA_fnc_isTurnedOut.

I tried replacing it by isTurnedOut... But apparently... There is a bug where that returns true while not turnedOut... WTF
Nah seems to be RHS bug.. Duh.
Actually it isn't... Some mod breaks it.. GG
Can't reproduce after Arma restart. GG

Replacing
private _turnedOut = [_unit] call CBA_fnc_isTurnedOut;
with
private _turnedOut = isTurnedOut _unit;
Seems to works fine and improves runtime from 0.118ms to 0.015ms.


// outside of the vehicle or turned out
if (isNull objectParent _unit) exitWith {false};
private _turnedOut = [_unit] call CBA_fnc_isTurnedOut;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this variable is nonsense. If it's true then the script exits, makes no sense checking for !_turnedOut in lines 80 or 100

};

// Specialcase
if (_return && {_role isEqualTo "gunner"} && {!_turnedOut}) exitWith {true}; // return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This _return check makes no sense, you already forced _return to true in line 84

_return = if !(_animation isEqualTo "") then {
(_vehicle animationSourcePhase _animation) > 0
} else {
true // is everytime outside
Copy link
Contributor

@dedmen dedmen Jan 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But outside would mean not attenuated, which would mean this should return false? Or is the comment wrong?

@dedmen
Copy link
Contributor

dedmen commented Jan 12, 2019

I have a workaround for the "hardocded jsrs" issue. Can just read the attenuationEffectType's entries in config
CfgSoundEffects >> AttenuationsEffects
and just collect and average out the gain entries.
That would actually be THE correct way to solve this. soundAttenuationCargo is just a bool flag for "yes attenuation effect applies" or "ignore attenuation effect and pretend he's outside"

Yeah I ended up using that for TFAR. This fixes issues where isAttenuated would return true even though the AttenuationEffect's gain is 1, meaning not attenuated.
And additionally I get correct isolation values for everything that IS attenuated.
Also checking that as i said removes your hardcoded jsrs check. And IMO removes the need for CBA_attenuatedRoles because people can just configure their vehicle correctly instead.
See https://github.com/michail-nikolaev/task-force-arma-3-radio/blob/1.0/addons/core/functions/fnc_isTurnedOut.sqf for example impl

@commy2
Copy link
Contributor

commy2 commented Jan 13, 2019

I like your function way more than this PR, although it also should be called isAttenuated and not isTurnedOut.

@dedmen
Copy link
Contributor

dedmen commented Jan 13, 2019

I like your function way more than this PR, although it also should be called isAttenuated and not isTurnedOut.

It's a copy of the PR, just turned around to return isNotAttenuated.

@commy2
Copy link
Contributor

commy2 commented Jan 13, 2019

Refering to this:

This fixes issues where isAttenuated would return true even though the AttenuationEffect's gain is 1, meaning not attenuated.
And additionally I get correct isolation values for everything that IS attenuated.
Also checking that as i said removes your hardcoded jsrs check. And IMO removes the need for CBA_attenuatedRoles because people can just configure their vehicle correctly instead.

@commy2 commy2 modified the milestones: 3.10, Backlog Feb 8, 2019
@commy2 commy2 closed this Feb 8, 2019
@shukari shukari deleted the isTurnedOut branch February 12, 2019 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants