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

Medical Feedback - Add parameters to fnc_playInjuredSound #10175

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions addons/medical_feedback/functions/fnc_playInjuredSound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* 0: Unit <OBJECT>
* 1: Type (optional) ["hit" (default) or "moan"] <STRING>
* 2: Severity (optional) [0 (default), 1, 2] <NUMBER>
* 3: Hit sound distances (optional) [50, 60, 70] (default) <ARRAY>
* 4: Moan sound distances (optional) [10, 15, 20] (default) <ARRAY>
* 5: Allow unconscious units (optional) (default: false) <BOOL>
*
* Return Value:
* None
Expand All @@ -20,18 +23,18 @@
#define TIME_OUT_HIT 1
#define TIME_OUT_MOAN [12, 7.5, 5]

params [["_unit", objNull, [objNull]], ["_type", "hit", [""]], ["_severity", 0, [0]]];
params [["_unit", objNull, [objNull]], ["_type", "hit", [""]], ["_severity", 0, [0]], ["_hitDistances", [50, 60, 70], [[]],[3]], ["_moanDistances", [10, 15, 20], [[]],[3]], ["_allowUnconscious", false, [true]]];
// TRACE_3("",_unit,_type,_severity);

if (!local _unit) exitWith { ERROR_2("playInjuredSound: Unit not local or null [%1:%2]",_unit,typeOf _unit); };

if !(_unit call EFUNC(common,isAwake)) exitWith {};
if (!(_unit call EFUNC(common,isAwake)) && !_allowUnconscious) exitWith {};

// Limit network traffic by only sending the event to players who can potentially hear it
private _distance = if (_type == "hit") then {
[50, 60, 70] select _severity;
_hitDistances select _severity;
} else {
[10, 15, 20] select _severity;
_moanDistances select _severity;
};
private _targets = allPlayers inAreaArray [ASLToAGL getPosASL _unit, _distance, _distance, 0, false, _distance];
if (_targets isEqualTo []) exitWith {};
Expand Down