Skip to content

Commit

Permalink
Medical Feedback - Add parameters to fnc_playInjuredSound (#10175)
Browse files Browse the repository at this point in the history
* Additional parameters

- added parameters to allow changing distances for sounds for each severity.
- added parameter to allow unconscious units to do sounds.

* fix conditio

* Updated header formatting + minor tweaks

---------

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
  • Loading branch information
tuntematonjr and johnb432 committed Aug 9, 2024
1 parent 4db0f7d commit b2a3fac
Showing 1 changed file with 9 additions and 6 deletions.
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

0 comments on commit b2a3fac

Please sign in to comment.