2015-02-10 17:17:26 +00:00
|
|
|
// ACE Medical System Visual Loop
|
2015-02-08 09:25:03 +00:00
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-03-05 17:42:08 +00:00
|
|
|
GVAR(enabledFor) = 1; // TODO remove this once we implement settings. Just here to get the vitals working.
|
2015-02-08 10:24:36 +00:00
|
|
|
|
2015-03-01 13:06:44 +00:00
|
|
|
GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"];
|
2015-02-08 10:24:36 +00:00
|
|
|
GVAR(heartBeatSounds_Normal) = ["ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"];
|
2015-03-01 13:06:44 +00:00
|
|
|
GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
|
2015-02-08 10:24:36 +00:00
|
|
|
|
2015-02-28 19:50:08 +00:00
|
|
|
["medical_propagateWound", FUNC(onPropagateWound)] call ace_common_fnc_addEventHandler;
|
2015-03-01 11:33:05 +00:00
|
|
|
["medical_woundUpdateRequest", FUNC(onWoundUpdateRequest)] call ace_common_fnc_addEventHandler;
|
2015-03-21 13:54:37 +00:00
|
|
|
["interactMenuClosed", {[objNull, false] call FUNC(displayPatientInformation); }] call ace_common_fnc_addEventHandler;
|
2015-02-21 22:17:20 +00:00
|
|
|
|
2015-04-06 12:11:10 +00:00
|
|
|
["medical_onUnconscious", {
|
|
|
|
if (local (_this select 0)) then {
|
2015-04-30 06:17:26 +00:00
|
|
|
private ["_unit"];
|
2015-04-06 12:11:10 +00:00
|
|
|
_unit = _this select 0;
|
|
|
|
if (_this select 1) then {
|
|
|
|
_unit setVariable ["tf_globalVolume", 0.4];
|
|
|
|
_unit setVariable ["tf_voiceVolume", 0, true];
|
|
|
|
_unit setVariable ["tf_unable_to_use_radio", true, true];
|
|
|
|
|
|
|
|
_unit setVariable ["acre_sys_core_isDisabled", true, true];
|
2015-04-14 22:17:05 +00:00
|
|
|
if (!isNil "acre_api_fnc_setGlobalVolume") then { [0.4^0.33] call acre_api_fnc_setGlobalVolume; };
|
2015-04-06 12:11:10 +00:00
|
|
|
} else {
|
|
|
|
_unit setVariable ["tf_globalVolume", 1];
|
|
|
|
_unit setVariable ["tf_voiceVolume", 1, true];
|
2015-04-08 19:31:59 +00:00
|
|
|
_unit setVariable ["tf_unable_to_use_radio", false, true];
|
2015-04-06 12:11:10 +00:00
|
|
|
|
2015-04-08 19:31:59 +00:00
|
|
|
_unit setVariable ["acre_sys_core_isDisabled", false, true];
|
2015-04-14 21:45:21 +00:00
|
|
|
if (!isNil "acre_api_fnc_setGlobalVolume") then { [1] call acre_api_fnc_setGlobalVolume; };
|
2015-04-06 12:11:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}] call ace_common_fnc_addEventHandler;
|
|
|
|
|
|
|
|
|
2015-02-10 17:17:26 +00:00
|
|
|
// Initialize all effects
|
|
|
|
_fnc_createEffect = {
|
2015-04-30 06:17:26 +00:00
|
|
|
private ["_type", "_layer", "_default", "_effect"];
|
2015-02-10 17:17:26 +00:00
|
|
|
_type = _this select 0;
|
|
|
|
_layer = _this select 1;
|
|
|
|
_default = _this select 2;
|
|
|
|
|
|
|
|
_effect = ppEffectCreate [_type, _layer];
|
|
|
|
_effect ppEffectForceInNVG true;
|
|
|
|
_effect ppEffectAdjust _default;
|
|
|
|
_effect ppEffectCommit 0;
|
|
|
|
|
|
|
|
_effect
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(effectUnconsciousCC) = [
|
|
|
|
"ColorCorrections",
|
|
|
|
4201,
|
|
|
|
[1,1,0, [0,0,0,1], [0,0,0,0], [1,1,1,1], [0.4,0.4,0,0,0,0.1,0.3]]
|
|
|
|
] call _fnc_createEffect;
|
2015-02-10 22:13:52 +00:00
|
|
|
|
2015-02-10 17:17:26 +00:00
|
|
|
GVAR(effectUnconsciousRB) = [
|
|
|
|
"RadialBlur",
|
|
|
|
4202,
|
|
|
|
[0.01,0.01,0,0]
|
|
|
|
] call _fnc_createEffect;
|
|
|
|
|
|
|
|
GVAR(effectBlindingCC) = [
|
|
|
|
"ColorCorrections",
|
|
|
|
4203,
|
|
|
|
[1,1,0, [1,1,1,0], [0,0,0,1], [0,0,0,0]]
|
|
|
|
] call _fnc_createEffect;
|
|
|
|
|
|
|
|
GVAR(effectBloodVolumeCC) = [
|
|
|
|
"ColorCorrections",
|
|
|
|
4204,
|
|
|
|
[1,1,0, [0,0,0,0], [1,1,1,1], [0.2,0.2,0.2,0]]
|
|
|
|
] call _fnc_createEffect;
|
|
|
|
|
|
|
|
GVAR(effectPainCA) = [
|
|
|
|
"chromAberration",
|
|
|
|
4205,
|
|
|
|
[0, 0, false]
|
|
|
|
] call _fnc_createEffect;
|
2015-02-10 22:13:52 +00:00
|
|
|
|
2015-02-10 17:17:26 +00:00
|
|
|
GVAR(effectPainCC) = [
|
|
|
|
"ColorCorrections",
|
|
|
|
4206,
|
|
|
|
[1,1,0, [1,1,1,1], [0,0,0,0], [1,1,1,1], [1.3,1.3,0,0,0,0.2,2]]
|
|
|
|
] call _fnc_createEffect;
|
|
|
|
|
|
|
|
// Initialize Other Variables
|
|
|
|
GVAR(effectBlind) = false;
|
|
|
|
GVAR(effectTimeBlood) = time;
|
|
|
|
|
2015-02-18 18:01:25 +00:00
|
|
|
// MAIN EFFECTS LOOP
|
2015-02-08 10:24:36 +00:00
|
|
|
[{
|
2015-04-30 06:17:26 +00:00
|
|
|
private["_bleeding", "_blood"];
|
2015-02-10 22:13:52 +00:00
|
|
|
// Zeus interface is open or player is dead; disable everything
|
|
|
|
if (!(isNull (findDisplay 312)) or !(alive ACE_player)) exitWith {
|
2015-02-10 17:17:26 +00:00
|
|
|
GVAR(effectUnconsciousCC) ppEffectEnable false;
|
|
|
|
GVAR(effectUnconsciousRB) ppEffectEnable false;
|
|
|
|
GVAR(effectBlindingCC) ppEffectEnable false;
|
|
|
|
GVAR(effectBloodVolumeCC) ppEffectEnable false;
|
|
|
|
GVAR(effectPainCA) ppEffectEnable false;
|
|
|
|
GVAR(effectPainCC) ppEffectEnable false;
|
2015-03-01 13:27:44 +00:00
|
|
|
["unconscious", false] call EFUNC(common,setDisableUserInputStatus);
|
2015-02-10 17:17:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Unconsciousness effect
|
2015-03-26 07:43:30 +00:00
|
|
|
if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
|
2015-02-10 17:17:26 +00:00
|
|
|
GVAR(effectUnconsciousCC) ppEffectEnable true;
|
|
|
|
GVAR(effectUnconsciousRB) ppEffectEnable true;
|
|
|
|
GVAR(effectBlind) = true;
|
2015-03-01 13:27:44 +00:00
|
|
|
["unconscious", true] call EFUNC(common,setDisableUserInputStatus);
|
2015-02-10 17:17:26 +00:00
|
|
|
} else {
|
|
|
|
GVAR(effectUnconsciousCC) ppEffectEnable false;
|
|
|
|
GVAR(effectUnconsciousRB) ppEffectEnable false;
|
2015-03-01 13:27:44 +00:00
|
|
|
["unconscious", false] call EFUNC(common,setDisableUserInputStatus);
|
2015-02-10 17:17:26 +00:00
|
|
|
if (GVAR(effectBlind)) then {
|
2015-02-10 22:14:39 +00:00
|
|
|
_strength = 0.78 * (call EFUNC(common,ambientBrightness));
|
|
|
|
GVAR(effectBlindingCC) ppEffectEnable true;
|
|
|
|
GVAR(effectBlindingCC) ppEffectAdjust [1,1,_strength, [1,1,1,0], [0,0,0,1], [0,0,0,0]];
|
|
|
|
GVAR(effectBlindingCC) ppEffectCommit 0;
|
|
|
|
|
|
|
|
[{
|
|
|
|
GVAR(effectBlindingCC) ppEffectAdjust [1,1,0, [1,1,1,0], [0,0,0,1], [0,0,0,0]];
|
|
|
|
GVAR(effectBlindingCC) ppEffectCommit ((_this select 0) * 2);
|
|
|
|
}, [_strength], 0.01, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
|
|
|
|
[{
|
|
|
|
GVAR(effectBlindingCC) ppEffectEnable false;
|
|
|
|
}, [], (_strength * 2) + 0.5, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
|
|
|
|
GVAR(effectBlind) = false;
|
2015-02-10 17:17:26 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-04-22 20:36:41 +00:00
|
|
|
_bleeding = [ACE_player] call FUNC(getBloodLoss);
|
2015-02-10 17:17:26 +00:00
|
|
|
// Bleeding Indicator
|
2015-04-06 22:57:05 +00:00
|
|
|
if (_bleeding > 0 and GVAR(effectTimeBlood) + 3.5 < time) then {
|
2015-02-10 17:17:26 +00:00
|
|
|
GVAR(effectTimeBlood) = time;
|
2015-04-06 22:57:05 +00:00
|
|
|
[600 * _bleeding] call BIS_fnc_bloodEffect;
|
2015-02-10 17:17:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Blood Volume Effect
|
2015-02-10 22:14:11 +00:00
|
|
|
_blood = (ACE_player getVariable [QGVAR(bloodVolume), 100]) / 100;
|
2015-02-10 17:17:26 +00:00
|
|
|
if (_blood > 0.99) then {
|
|
|
|
GVAR(effectBloodVolumeCC) ppEffectEnable false;
|
|
|
|
} else {
|
|
|
|
GVAR(effectBloodVolumeCC) ppEffectEnable true;
|
|
|
|
GVAR(effectBloodVolumeCC) ppEffectAdjust [1,1,0, [0,0,0,0], [1,1,1,_blood], [0.2,0.2,0.2,0]];
|
|
|
|
GVAR(effectBloodVolumeCC) ppEffectCommit 0;
|
|
|
|
};
|
2015-02-18 18:01:25 +00:00
|
|
|
}, 0.5, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
|
|
|
|
|
|
|
|
GVAR(lastHeartBeat) = time;
|
2015-03-01 13:06:44 +00:00
|
|
|
GVAR(lastHeartBeatSound) = time;
|
2015-02-18 18:01:25 +00:00
|
|
|
|
|
|
|
// HEARTRATE BASED EFFECTS
|
|
|
|
[{
|
2015-04-30 06:17:26 +00:00
|
|
|
private["_heartRate", "_interval", "_minTime", "_sound", "_strength"];
|
2015-02-18 18:01:25 +00:00
|
|
|
_heartRate = ACE_player getVariable [QGVAR(heartRate), 70];
|
2015-03-06 21:54:44 +00:00
|
|
|
if (GVAR(level) == 1) then {
|
2015-02-18 18:01:25 +00:00
|
|
|
_heartRate = 60 + 40 * (ACE_player getVariable [QGVAR(pain), 0]);
|
|
|
|
};
|
2015-03-01 13:06:44 +00:00
|
|
|
if (_heartRate <= 0) exitwith {};
|
|
|
|
_interval = 60 / (_heartRate min 50);
|
|
|
|
if (time > GVAR(lastHeartBeat) + _interval) then {
|
|
|
|
GVAR(lastHeartBeat) = time;
|
|
|
|
|
|
|
|
// Pain effect
|
|
|
|
_strength = ACE_player getVariable [QGVAR(pain), 0];
|
2015-04-22 20:29:31 +00:00
|
|
|
_strength = _strength * (ACE_player getVariable [QGVAR(painCoefficient), GVAR(painCoefficient)]);
|
2015-04-14 19:49:56 +00:00
|
|
|
if (GVAR(painEffectType) == 1) then {
|
2015-03-01 13:06:44 +00:00
|
|
|
GVAR(effectPainCC) ppEffectEnable false;
|
|
|
|
if ((ACE_player getVariable [QGVAR(pain), 0]) > 0 && {alive ACE_player}) then {
|
|
|
|
_strength = _strength * 0.15;
|
|
|
|
GVAR(effectPainCA) ppEffectEnable true;
|
|
|
|
GVAR(effectPainCA) ppEffectAdjust [_strength, _strength, false];
|
2015-02-18 18:01:25 +00:00
|
|
|
GVAR(effectPainCA) ppEffectCommit 0.01;
|
2015-03-01 13:06:44 +00:00
|
|
|
[{
|
|
|
|
GVAR(effectPainCA) ppEffectAdjust [(_this select 0), (_this select 0), false];
|
|
|
|
GVAR(effectPainCA) ppEffectCommit (_this select 1);
|
|
|
|
}, [_strength * 0.1, _interval * 0.2], _interval * 0.05, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
[{
|
|
|
|
GVAR(effectPainCA) ppEffectAdjust [(_this select 0), (_this select 0), false];
|
|
|
|
GVAR(effectPainCA) ppEffectCommit 0.01;
|
|
|
|
}, [_strength * 0.7], _interval * 0.3, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
[{
|
|
|
|
GVAR(effectPainCA) ppEffectAdjust [(_this select 0), (_this select 0), false];
|
|
|
|
GVAR(effectPainCA) ppEffectCommit (_this select 1);
|
|
|
|
}, [_strength * 0.1, _interval * 0.55], _interval * 0.4, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
} else {
|
|
|
|
GVAR(effectPainCA) ppEffectEnable false;
|
|
|
|
};
|
2015-02-18 18:01:25 +00:00
|
|
|
} else {
|
|
|
|
GVAR(effectPainCA) ppEffectEnable false;
|
2015-03-01 13:06:44 +00:00
|
|
|
if ((ACE_player getVariable [QGVAR(pain), 0]) > 0 && {alive ACE_player}) then {
|
2015-04-14 20:49:26 +00:00
|
|
|
_strength = _strength * 0.9;
|
2015-03-01 13:06:44 +00:00
|
|
|
GVAR(effectPainCC) ppEffectEnable true;
|
|
|
|
GVAR(effectPainCC) ppEffectAdjust [1,1,0, [1,1,1,1], [0,0,0,0], [1,1,1,1], [1 - _strength,1 - _strength,0,0,0,0.2,2]];
|
2015-02-18 18:01:25 +00:00
|
|
|
GVAR(effectPainCC) ppEffectCommit 0.01;
|
2015-03-01 13:06:44 +00:00
|
|
|
[{
|
|
|
|
GVAR(effectPainCC) ppEffectAdjust [1,1,0, [1,1,1,1], [0,0,0,0], [1,1,1,1], [1 - (_this select 0),1 - (_this select 0),0,0,0,0.2,2]];
|
|
|
|
GVAR(effectPainCC) ppEffectCommit (_this select 1);
|
|
|
|
}, [_strength * 0.1, _interval * 0.2], _interval * 0.05, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
[{
|
|
|
|
GVAR(effectPainCC) ppEffectAdjust [1,1,0, [1,1,1,1], [0,0,0,0], [1,1,1,1], [1 - (_this select 0),1 - (_this select 0),0,0,0,0.2,2]];
|
|
|
|
GVAR(effectPainCC) ppEffectCommit 0.01;
|
|
|
|
}, [_strength * 0.7], _interval * 0.3, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
[{
|
|
|
|
GVAR(effectPainCC) ppEffectAdjust [1,1,0, [1,1,1,1], [0,0,0,0], [1,1,1,1], [1 - (_this select 0),1 - (_this select 0),0,0,0,0.2,2]];
|
|
|
|
GVAR(effectPainCC) ppEffectCommit (_this select 1);
|
|
|
|
}, [_strength * 0.1, _interval * 0.55], _interval * 0.4, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
} else {
|
|
|
|
GVAR(effectPainCC) ppEffectEnable false;
|
|
|
|
};
|
2015-02-18 18:01:25 +00:00
|
|
|
};
|
|
|
|
};
|
2015-02-08 10:24:36 +00:00
|
|
|
|
2015-03-06 21:54:44 +00:00
|
|
|
if (GVAR(level) >= 2 && {_heartRate > 0}) then {
|
2015-03-01 13:06:44 +00:00
|
|
|
_minTime = 60 / _heartRate;
|
|
|
|
if (time - GVAR(lastHeartBeatSound) > _minTime) then {
|
|
|
|
GVAR(lastHeartBeatSound) = time;
|
|
|
|
// Heart rate sound effect
|
|
|
|
if (_heartRate < 60) then {
|
|
|
|
_sound = GVAR(heartBeatSounds_Normal) select (random((count GVAR(heartBeatSounds_Normal)) -1));
|
2015-02-10 22:14:56 +00:00
|
|
|
playSound _sound;
|
2015-03-01 13:06:44 +00:00
|
|
|
} else {
|
|
|
|
if (_heartRate > 150) then {
|
|
|
|
playSound "ACE_heartbeat_fast_2";
|
|
|
|
};
|
2015-02-08 10:24:36 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-03-01 11:33:05 +00:00
|
|
|
|
2015-02-18 18:01:25 +00:00
|
|
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
2015-03-01 11:33:05 +00:00
|
|
|
|
2015-04-01 18:03:44 +00:00
|
|
|
if (USE_WOUND_EVENT_SYNC) then {
|
|
|
|
// broadcast injuries to JIP clients in a MP session
|
2015-04-02 22:04:41 +00:00
|
|
|
if (isMultiplayer && hasInterface) then {
|
|
|
|
["playerChanged", {
|
|
|
|
EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
|
|
|
|
if (alive _newPlayer) then {
|
|
|
|
// We are only pulling the wounds for the units in the player group. Anything else will come when the unit interacts with them.
|
|
|
|
{
|
|
|
|
[_x, _newPlayer] call FUNC(requestWoundSync);
|
2015-04-14 19:17:36 +00:00
|
|
|
}foreach units group _newPlayer;
|
2015-04-02 22:04:41 +00:00
|
|
|
};
|
|
|
|
}] call EFUNC(common,addEventhandler);
|
2015-03-22 16:04:42 +00:00
|
|
|
};
|
2015-03-01 11:33:05 +00:00
|
|
|
};
|
2015-03-08 11:27:52 +00:00
|
|
|
|
|
|
|
[
|
2015-04-17 17:13:23 +00:00
|
|
|
{(((_this select 0) getvariable [QGVAR(bloodVolume), 100]) < 65)},
|
2015-03-08 14:13:44 +00:00
|
|
|
{(((_this select 0) getvariable [QGVAR(pain), 0]) > 0.9)},
|
2015-04-22 20:36:41 +00:00
|
|
|
{(([_this select 0] call FUNC(getBloodLoss)) > 0.25)},
|
2015-03-08 12:56:24 +00:00
|
|
|
{((_this select 0) getvariable [QGVAR(inReviveState), false])},
|
2015-04-04 19:20:03 +00:00
|
|
|
{((_this select 0) getvariable [QGVAR(inCardiacArrest), false])},
|
2015-03-08 14:58:35 +00:00
|
|
|
{((_this select 0) getvariable ["ACE_isDead", false])},
|
|
|
|
{(((_this select 0) getvariable [QGVAR(airwayStatus), 100]) < 80)}
|
2015-03-08 11:28:17 +00:00
|
|
|
] call FUNC(addUnconsciousCondition);
|
2015-04-04 15:20:14 +00:00
|
|
|
|
|
|
|
// Prevent all types of interaction while unconscious
|
|
|
|
// @todo: probably remove this when CBA keybind hold key works properly
|
|
|
|
["isNotUnconscious", {!((_this select 0) getVariable ["ACE_isUnconscious", false])}] call EFUNC(common,addCanInteractWithCondition);
|
2015-04-14 19:28:18 +00:00
|
|
|
|
|
|
|
// Item Event Handler
|
|
|
|
["playerInventoryChanged", {
|
|
|
|
[ACE_player] call FUNC(itemCheck);
|
|
|
|
}] call EFUNC(common,addEventHandler);
|
2015-04-18 15:31:03 +00:00
|
|
|
|
|
|
|
// Networked litter
|
2015-04-18 18:48:44 +00:00
|
|
|
[QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler);
|
2015-04-28 18:32:29 +00:00
|
|
|
|
2015-04-28 18:33:01 +00:00
|
|
|
if (hasInterface) then {
|
|
|
|
["PlayerJip", {
|
|
|
|
diag_log format["[ACE] JIP Medical init for player"];
|
|
|
|
[player] call FUNC(init);
|
|
|
|
}] call FUNC(addEventHandler);
|
|
|
|
};
|