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 - Add Unconscious Effects #716

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions addons/medical/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PREP(unconsciousFX);
20 changes: 20 additions & 0 deletions addons/medical/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@
};
}, _unit, 1] call CBA_fnc_waitAndExecute;
}] call CBA_fnc_addEventHandler;

// Unconscious Moaning
if (isServer) then {
["ace_unconscious", {
params ["_unit", "_state"];

if !(GVAR(unconsciousFXEnabled)) exitWith {};

if (isPlayer _unit && _state) then {
// Knock out sound
private _knockOutNoise = selectRandom KO_NOISES;
[QEGVAR(mission,say3D), [_unit, _knockOutNoise]] call CBA_fnc_globalEvent;

// Local PFH for periodic groaning
[QGVAR(unconsciousFX), [], _unit] call CBA_fnc_targetEvent;
};
}] call CBA_fnc_addEventHandler;
};

[QGVAR(unconsciousFx), LINKFUNC(unconsciousFX)] call CBA_fnc_addEventHandler;
4 changes: 4 additions & 0 deletions addons/medical/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#include "initSettings.inc.sqf"

ADDON = true;
10 changes: 8 additions & 2 deletions addons/medical/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"tac_main", "ace_medical_engine"};
requiredAddons[] = {
"tac_main",
"tac_mission",
"ace_fire",
"ace_medical_engine",
"ace_medical_feedback"
};
author = ECSTRING(main,Author);
authors[] = {"Jonpas"};
authors[] = {"Jonpas", "Mike"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
Expand Down
38 changes: 38 additions & 0 deletions addons/medical/functions/fnc_unconsciousFX.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "..\script_component.hpp"
/*
* Author: Mike
* Handles noises while unconscious
*
* Called locally per player via target event
Comment on lines +4 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Handles noises while unconscious
*
* Called locally per player via target event
* Handles noises while unconscious.
*
* Called locally per player via target event.

*
* Arguments
* None
*
* Return Value:
* None
*
* Example:
* [] call tac_medical_fnc_unconsciousFX
*/

[{
params ["_args", "_handle"];
_args params [["_firstIteration", true]];

// If woken up or died end PFH.
if !(ace_player getVariable ["ACE_isUnconscious", false]) exitWith {
_handle call CBA_fnc_removePerFrameHandler;
};

// Don't want the groaning to happen instantly.
if (_firstIteration) exitWith {
_args set [0, false];
};

// 50% chance of making noises, requires a heart rate above CPR/Cardiac Arrest
private _heartRate = ace_player getVariable ["ace_medical_heartRate", 80];
if (random 1 > GVAR(unconsciousFXChance) && _heartRate > 40) then {
private _moan = selectRandom UNCONSCIOUS_NOISES;
[QEGVAR(mission,say3D), [ace_player, _moan]] call CBA_fnc_globalEvent;
};
}, GVAR(unconsciousFXTimer)] call CBA_fnc_addPerFrameHandler;
31 changes: 30 additions & 1 deletion addons/medical/initSettings.inc.sqf
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
private _category = format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)];

[
QGVAR(fatalInjuriesCardiacArrestTimeCoefficient),
"SLIDER",
[LSTRING(FatalInjuriesCardiacArrestTimeCoefficient_DisplayName), LSTRING(FatalInjuriesCardiacArrestTimeCoefficient_Description)],
format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)],
_category,
[0.01, 1, 0.2, 2],
true // isGlobal
] call CBA_fnc_addSetting;

[
QGVAR(unconsciousFXEnabled),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setting is unnecessary when chance can be set to 0%.

"CHECKBOX",
[LSTRING(UnconsciousFX_DisplayName), LSTRING(UnconsciousFX_Description)],
_category,
true,
1
] call CBA_fnc_addSetting;

[
QGVAR(unconsciousFXChance),
"SLIDER",
[LSTRING(UnconsciousFXChance_DisplayName), LSTRING(UnconsciousFXChance_Description)],
_category,
[0, 1, 0.5, 1, true],
1
] call CBA_fnc_addSetting;

[
QGVAR(unconsciousFXTimer),
"SLIDER",
[LSTRING(UnconsciousFXTimer_DisplayName), LSTRING(UnconsciousFXTimer_Description)],
_category,
[5, 60, 30, 1, false],
1
] call CBA_fnc_addSetting;
3 changes: 3 additions & 0 deletions addons/medical/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
#endif

#include "\x\tac\addons\main\script_macros.hpp"

#define KO_NOISES ["ace_fire_scream_12", "ACE_hit_Male05ENG_high_3", "ACE_hit_Male05ENG_high_4", "ACE_hit_Male05ENG_mid_4", "ACE_moan_Male06ENG_high_8"]
#define UNCONSCIOUS_NOISES ["ace_fire_scream_8", "ACE_moan_Male07ENG_high_2", "ACE_moan_Male07ENG_high_4", "ACE_moan_Male09ENG_high_1", "ACE_moan_Male09ENG_high_2", "ACE_moan_Male09ENG_high_3", "ACE_moan_Male09ENG_high_4"]
22 changes: 20 additions & 2 deletions addons/medical/stringtable.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="TAC">
<Package name="Medical">
<Key ID="STR_TAC_Medical_FatalInjuriesCardiacArrestTimeCoefficient_Description">
<English>Coefficient for controlling the Cardiac Arrest Time on fatal injuries when 'Fatal Injuries' is NOT 'Always'.</English>
</Key>
<Key ID="STR_TAC_Medical_FatalInjuriesCardiacArrestTimeCoefficient_DisplayName">
<English>Fatal Injuries Cardiac Arrest Time Coefficient</English>
</Key>
<Key ID="STR_TAC_Medical_FatalInjuriesCardiacArrestTimeCoefficient_Description">
<English>Coefficient for controlling the Cardiac Arrest Time on fatal injuries when 'Fatal Injuries' is NOT 'Always'.</English>
<Key ID="STR_TAC_Medical_UnconsciousFXChance_Description">
<English>The chance of unconscious sounds playing each check.</English>
</Key>
<Key ID="STR_TAC_Medical_UnconsciousFXChance_DisplayName">
<English>Unconscious Effect Sound Chance</English>
</Key>
<Key ID="STR_TAC_Medical_UnconsciousFXTimer_Description">
<English>Time interval for checking if the sound effect should play</English>
</Key>
<Key ID="STR_TAC_Medical_UnconsciousFXTimer_DisplayName">
<English>Unconscious Effect Timer</English>
</Key>
<Key ID="STR_TAC_Medical_UnconsciousFX_Description">
<English>Enabled groaning sounds for unconscious players with a heart rate.</English>
</Key>
<Key ID="STR_TAC_Medical_UnconsciousFX_DisplayName">
<English>Unconscious Effect Sounds</English>
</Key>
</Package>
</Project>