2015-02-08 12:18:08 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Play the injured sound for a unit if the unit is damaged. The sound broadcasted across MP.
|
2015-10-21 20:52:21 +00:00
|
|
|
* Will not play if the unit has already played a sound within to close a time frame.
|
2015-02-08 12:18:08 +00:00
|
|
|
* Delay: With minimal damage (below 1), the delay is (10 + random(50)) seconds. Otherwise it is 60 seconds / damage.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit <OBJECT>
|
2015-08-22 14:25:10 +00:00
|
|
|
* 1: Amount of Pain <NUMBER>
|
2015-02-08 12:18:08 +00:00
|
|
|
*
|
|
|
|
* ReturnValue:
|
2015-08-22 14:25:10 +00:00
|
|
|
* None
|
2015-02-08 12:18:08 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-04-30 06:17:26 +00:00
|
|
|
private ["_unit","_availableSounds_A","_availableSounds_B","_availableSounds_C","_sound", "_pain"];
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_unit", "_pain"];
|
2015-11-30 16:14:05 +00:00
|
|
|
if (!local _unit || !GVAR(enableScreams)) exitWith{};
|
2015-02-08 12:18:08 +00:00
|
|
|
|
|
|
|
// Lock if the unit is already playing a sound.
|
2015-11-30 16:27:09 +00:00
|
|
|
if ((_unit getVariable [QGVAR(playingInjuredSound),false])) exitWith {};
|
|
|
|
_unit setVariable [QGVAR(playingInjuredSound),true];
|
2015-02-08 12:18:08 +00:00
|
|
|
|
|
|
|
// Play the sound if there is any damage present.
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_pain > 0 && {[_unit] call EFUNC(common,isAwake)}) exitWith {
|
2015-03-08 14:13:32 +00:00
|
|
|
// Classnames of the available sounds.
|
|
|
|
_availableSounds_A = [
|
|
|
|
"WoundedGuyA_01",
|
|
|
|
"WoundedGuyA_02",
|
|
|
|
"WoundedGuyA_03",
|
|
|
|
"WoundedGuyA_04",
|
|
|
|
"WoundedGuyA_05",
|
|
|
|
"WoundedGuyA_06",
|
|
|
|
"WoundedGuyA_07",
|
|
|
|
"WoundedGuyA_08"
|
|
|
|
];
|
|
|
|
_availableSounds_B = [
|
|
|
|
"WoundedGuyB_01",
|
|
|
|
"WoundedGuyB_02",
|
|
|
|
"WoundedGuyB_03",
|
|
|
|
"WoundedGuyB_04",
|
|
|
|
"WoundedGuyB_05",
|
|
|
|
"WoundedGuyB_06",
|
|
|
|
"WoundedGuyB_07",
|
|
|
|
"WoundedGuyB_08"
|
|
|
|
];
|
|
|
|
_availableSounds_C = [
|
|
|
|
"WoundedGuyC_01",
|
|
|
|
"WoundedGuyC_02",
|
|
|
|
"WoundedGuyC_03",
|
|
|
|
"WoundedGuyC_04",
|
|
|
|
"WoundedGuyC_05"
|
|
|
|
];
|
2015-02-08 12:18:08 +00:00
|
|
|
_sound = "";
|
|
|
|
|
|
|
|
// Select the to be played sound based upon damage amount.
|
2015-03-08 14:13:32 +00:00
|
|
|
if (_pain > 0.5) then {
|
2015-02-08 12:18:08 +00:00
|
|
|
if (random(1) > 0.5) then {
|
2015-11-29 15:33:25 +00:00
|
|
|
_sound = selectRandom _availableSounds_A;
|
2015-02-08 12:18:08 +00:00
|
|
|
} else {
|
2015-11-29 15:33:25 +00:00
|
|
|
_sound = selectRandom _availableSounds_B;
|
2015-02-08 12:18:08 +00:00
|
|
|
};
|
|
|
|
} else {
|
2015-11-29 15:48:23 +00:00
|
|
|
_sound = selectRandom _availableSounds_B;
|
2015-02-08 12:18:08 +00:00
|
|
|
};
|
|
|
|
// Play the sound
|
2015-03-08 14:13:32 +00:00
|
|
|
playSound3D [(getArray(configFile >> "CfgSounds" >> _sound >> "sound") select 0) + ".wss", objNull, false, getPos _unit, 15, 1, 25]; // +2db, 15 meters.
|
2015-02-08 12:18:08 +00:00
|
|
|
|
|
|
|
// Figure out what the delay will be before it is possible to play a sound again.
|
|
|
|
private "_delay";
|
2015-03-08 14:13:32 +00:00
|
|
|
_delay = (30 - (random(25) * _pain)) max (3.5 + random(2));
|
2015-02-08 12:18:08 +00:00
|
|
|
|
|
|
|
// Clean up the lock
|
|
|
|
[{
|
2015-11-30 16:27:09 +00:00
|
|
|
(_this select 0) setVariable [QGVAR(playingInjuredSound),nil];
|
2015-02-08 12:18:08 +00:00
|
|
|
}, [_unit], _delay, _delay] call EFUNC(common,waitAndExecute);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Clean up in case there has not been played any sounds.
|
2015-11-30 16:27:09 +00:00
|
|
|
_unit setVariable [QGVAR(playingInjuredSound),nil];
|