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 all 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
15 changes: 9 additions & 6 deletions addons/medical_feedback/functions/fnc_playInjuredSound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Type (optional) ["hit" (default) or "moan"] <STRING>
* 2: Severity (optional) [0 (default), 1, 2] <NUMBER>
* 1: Type ["hit", "moan"] <STRING> (default: "hit")
* 2: Severity [0, 1, 2] <NUMBER> (default: 0)
* 3: Hit sound distances <ARRAY> (default: [50, 60, 70])
* 4: Moan sound distances <ARRAY> (default: [10, 15, 20])
* 5: Allow unconscious units <BOOL> (default: false)
*
* 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 (!_allowUnconscious && {!(_unit call EFUNC(common,isAwake))}) 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