ACE3/addons/medical/XEH_postInit.sqf

296 lines
13 KiB
Plaintext
Raw Normal View History

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"
GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"];
GVAR(heartBeatSounds_Normal) = ["ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"];
GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
2016-05-24 13:13:11 +00:00
["ace_interactMenuClosed", {[objNull, false] call FUNC(displayPatientInformation); }] call CBA_fnc_addEventHandler;
2015-02-21 22:17:20 +00:00
//Treatment EventHandlers:
2016-06-03 18:57:21 +00:00
[QGVAR(actionCheckBloodPressureLocal), DFUNC(actionCheckBloodPressureLocal)] call CBA_fnc_addEventHandler;
[QGVAR(actionCheckPulseLocal), DFUNC(actionCheckPulseLocal)] call CBA_fnc_addEventHandler;
[QGVAR(addVitalLoop), DFUNC(addVitalLoop)] call CBA_fnc_addEventHandler;
[QGVAR(addToMedicalLog), DFUNC(addToLog)] call CBA_fnc_addEventHandler;
[QGVAR(addToTriageCard), DFUNC(addToTriageCard)] call CBA_fnc_addEventHandler;
[QGVAR(setDead), DFUNC(setDead)] call CBA_fnc_addEventHandler;
[QGVAR(setHitPointDamage), DFUNC(setHitPointDamage)] call CBA_fnc_addEventHandler;
[QGVAR(setUnconscious), DFUNC(setUnconscious)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentAdvanced_bandageLocal), DFUNC(treatmentAdvanced_bandageLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentAdvanced_CPRLocal), DFUNC(treatmentAdvanced_CPRLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentAdvanced_fullHealLocal), DFUNC(treatmentAdvanced_fullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentAdvanced_medicationLocal), DFUNC(treatmentAdvanced_medicationLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentBasic_bloodbagLocal), DFUNC(treatmentBasic_bloodbagLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentBasic_morphineLocal), DFUNC(treatmentBasic_morphineLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentIVLocal), DFUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentTourniquetLocal), DFUNC(treatmentTourniquetLocal)] call CBA_fnc_addEventHandler;
[QGVAR(actionPlaceInBodyBag), FUNC(actionPlaceInBodyBag)] call CBA_fnc_addEventHandler;
//Handle Deleting Bodies and creating litter on Server:
if (isServer) then {
["ace_placedInBodyBag", FUNC(serverRemoveBody)] call CBA_fnc_addEventHandler;
[QGVAR(createLitterServer), FUNC(handleCreateLitter)] call CBA_fnc_addEventHandler;
};
2016-02-19 21:39:38 +00:00
2016-06-03 18:57:21 +00:00
["ace_unconscious", {
2015-08-22 14:26:53 +00:00
params ["_unit", "_status"];
if (local _unit) then {
if (_status) then {
_unit setVariable ["tf_voiceVolume", 0, true];
_unit setVariable ["tf_unable_to_use_radio", true, true];
_unit setVariable ["acre_sys_core_isDisabled", true, true];
} else {
_unit setVariable ["tf_voiceVolume", 1, true];
_unit setVariable ["tf_unable_to_use_radio", false, true];
_unit setVariable ["acre_sys_core_isDisabled", false, true];
};
};
}] call CBA_fnc_addEventHandler;
2015-02-10 17:17:26 +00:00
// Initialize all effects
if (hasInterface) then {
2015-02-10 17:17:26 +00:00
_fnc_createEffect = {
2015-08-22 14:26:53 +00:00
params ["_type", "_layer", "_default"];
2015-02-10 17:17:26 +00:00
private _effect = ppEffectCreate [_type, _layer];
2015-02-10 17:17:26 +00:00
_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;
2016-03-02 10:01:39 +00:00
GVAR(effectTimeBlood) = CBA_missionTime;
2015-02-10 17:17:26 +00:00
2015-02-18 18:01:25 +00:00
// MAIN EFFECTS LOOP
[{
private ["_bleeding", "_blood"];
2015-02-10 22:13:52 +00:00
// Zeus interface is open or player is dead; disable everything
2015-07-02 17:36:34 +00:00
if (!(isNull curatorCamera) 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;
["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;
["unconscious", true] call EFUNC(common,setDisableUserInputStatus);
2015-02-10 17:17:26 +00:00
} else {
GVAR(effectUnconsciousCC) ppEffectEnable false;
GVAR(effectUnconsciousRB) ppEffectEnable false;
["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 CBA_fnc_waitAndExecute;
2015-02-10 22:14:39 +00:00
[{
GVAR(effectBlindingCC) ppEffectEnable false;
}, [], (_strength * 2) + 0.5, 0] call CBA_fnc_waitAndExecute;
2015-02-10 22:14:39 +00:00
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
2016-03-02 10:01:39 +00:00
if (_bleeding > 0 and GVAR(effectTimeBlood) + 3.5 < CBA_missionTime) then {
GVAR(effectTimeBlood) = CBA_missionTime;
[600 * _bleeding] call FUNC(showBloodEffect);
2015-02-10 17:17:26 +00:00
};
// Blood Volume Effect
_blood = if (GVAR(level) < 2) then {
(ACE_player getVariable [QGVAR(bloodVolume), 100]) / 100;
} else {
(((ACE_player getVariable [QGVAR(bloodVolume), 100]) - 60) max 0) / 40;
};
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;
2016-03-02 10:01:39 +00:00
GVAR(lastHeartBeat) = CBA_missionTime;
GVAR(lastHeartBeatSound) = CBA_missionTime;
2015-02-18 18:01:25 +00:00
// HEARTRATE BASED EFFECTS
[{
private ["_heartRate", "_interval", "_minTime", "_sound", "_strength", "_pain"];
2015-02-18 18:01:25 +00:00
_heartRate = ACE_player getVariable [QGVAR(heartRate), 70];
_pain = ACE_player getVariable [QGVAR(pain), 0];
2015-03-06 21:54:44 +00:00
if (GVAR(level) == 1) then {
_heartRate = 60 + 40 * _pain;
2015-02-18 18:01:25 +00:00
};
2015-11-30 16:14:05 +00:00
if (_heartRate <= 0) exitWith {};
2015-09-14 13:18:56 +00:00
_interval = 60 / (_heartRate min 40);
if ((ACE_player getVariable ["ACE_isUnconscious", false])) then {
2015-04-14 19:49:56 +00:00
if (GVAR(painEffectType) == 1) then {
GVAR(effectPainCA) ppEffectEnable false;
} else {
GVAR(effectPainCC) ppEffectEnable false;
};
} else {
2016-03-02 10:01:39 +00:00
if ((CBA_missionTime > GVAR(lastHeartBeat) + _interval)) then {
GVAR(lastHeartBeat) = CBA_missionTime;
2015-07-02 11:56:56 +00:00
// Pain effect, no pain effect in zeus camera
2015-07-02 17:36:34 +00:00
if (isNull curatorCamera) then {
_strength = ((_pain - (ACE_player getVariable [QGVAR(painSuppress), 0])) max 0) min 1;
2015-07-02 11:56:56 +00:00
_strength = _strength * (ACE_player getVariable [QGVAR(painCoefficient), GVAR(painCoefficient)]);
if (GVAR(painEffectType) == 1) then {
GVAR(effectPainCC) ppEffectEnable false;
if (_pain > (ACE_player getVariable [QGVAR(painSuppress), 0]) && {alive ACE_player}) then {
2015-07-02 11:56:56 +00:00
_strength = _strength * 0.15;
GVAR(effectPainCA) ppEffectEnable true;
GVAR(effectPainCA) ppEffectAdjust [_strength, _strength, false];
GVAR(effectPainCA) ppEffectCommit 0.01;
2015-07-02 11:56:56 +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 CBA_fnc_waitAndExecute;
2015-07-02 11:56:56 +00:00
[{
GVAR(effectPainCA) ppEffectAdjust [(_this select 0), (_this select 0), false];
GVAR(effectPainCA) ppEffectCommit 0.01;
}, [_strength * 0.7], _interval * 0.3, 0] call CBA_fnc_waitAndExecute;
2015-07-02 11:56:56 +00:00
[{
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 CBA_fnc_waitAndExecute;
2015-07-02 11:56:56 +00:00
} else {
GVAR(effectPainCA) ppEffectEnable false;
};
} else {
GVAR(effectPainCA) ppEffectEnable false;
if (_pain > (ACE_player getVariable [QGVAR(painSuppress), 0]) && {alive ACE_player}) then {
2015-07-02 11:56:56 +00:00
_strength = _strength * 0.9;
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]];
GVAR(effectPainCC) ppEffectCommit 0.01;
2015-07-02 11:56:56 +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 CBA_fnc_waitAndExecute;
2015-07-02 11:56:56 +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 0.01;
}, [_strength * 0.7], _interval * 0.3, 0] call CBA_fnc_waitAndExecute;
2015-07-02 11:56:56 +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.55], _interval * 0.4, 0] call CBA_fnc_waitAndExecute;
2015-07-02 11:56:56 +00:00
} else {
GVAR(effectPainCC) ppEffectEnable false;
};
};
};
2015-02-18 18:01:25 +00:00
};
};
2015-03-06 21:54:44 +00:00
if (GVAR(level) >= 2 && {_heartRate > 0}) then {
_minTime = 60 / _heartRate;
2016-03-02 10:01:39 +00:00
if (CBA_missionTime - GVAR(lastHeartBeatSound) > _minTime) then {
GVAR(lastHeartBeatSound) = CBA_missionTime;
// 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;
} else {
if (_heartRate > 150) then {
playSound "ACE_heartbeat_fast_2";
};
};
};
};
2015-02-18 18:01:25 +00:00
}, 0, []] call CBA_fnc_addPerFrameHandler;
};
2016-06-03 00:59:18 +00:00
["ace_settingsInitialized", {
2015-08-29 09:58:28 +00:00
[
{(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)},
{(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.9},
{(([_this select 0] call FUNC(getBloodLoss)) > 0.25)},
{((_this select 0) getVariable [QGVAR(inReviveState), false])},
{((_this select 0) getVariable [QGVAR(inCardiacArrest), false])},
{((_this select 0) getVariable ["ACE_isDead", false])}
2015-08-29 09:58:28 +00:00
] call FUNC(addUnconsciousCondition);
}] call CBA_fnc_addEventHandler;
// 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);
// Item Event Handler
["loadout", FUNC(itemCheck)] call CBA_fnc_addPlayerEventHandler;
2015-04-28 18:33:01 +00:00
if (hasInterface) then {
["ace_playerJIP", {
ACE_LOGINFO("JIP Medical init for player.");
2015-04-28 18:33:01 +00:00
[player] call FUNC(init);
}] call CBA_fnc_addEventHandler;
2015-04-28 18:33:01 +00:00
};