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 Enable Setting #9593

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
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
34 changes: 19 additions & 15 deletions addons/medical/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
// #define DEBUG_MODE_FULL
#include "script_component.hpp"

[QEGVAR(medical,setUnconscious), LINKFUNC(setUnconscious)] call CBA_fnc_addEventHandler;
["CBA_settingsInitialized", {
if !(GETEGVAR(medical,enabled,false)) exitWith {};

if (!hasInterface) exitWith {};
[QEGVAR(medical,setUnconscious), LINKFUNC(setUnconscious)] call CBA_fnc_addEventHandler;

// Fractures affect base sway, pain makes it worse
["baseline", {
ACE_player getVariable [QEGVAR(medical_engine,aimFracture), 0]
}, QUOTE(ADDON)] call EFUNC(common,addSwayFactor);
if (!hasInterface) exitWith {};

// Max pain = 5x sway
["multiplier", {
1 + (GET_PAIN_PERCEIVED(ACE_player) * 4)
}, QUOTE(ADDON)] call EFUNC(common,addSwayFactor);
// Fractures affect base sway, pain makes it worse
["baseline", {
ACE_player getVariable [QEGVAR(medical_engine,aimFracture), 0]
}, QUOTE(ADDON)] call EFUNC(common,addSwayFactor);

#ifdef DEBUG_MODE_FULL
call compile preprocessFileLineNumbers QPATHTOF(dev\reportSettings.sqf);
call compile preprocessFileLineNumbers QPATHTOF(dev\watchVariable.sqf);
call compile preprocessFileLineNumbers QPATHTOF(dev\debugDisplay.sqf);
#endif
// Max pain = 5x sway
["multiplier", {
1 + (GET_PAIN_PERCEIVED(ACE_player) * 4)
}, QUOTE(ADDON)] call EFUNC(common,addSwayFactor);

#ifdef DEBUG_MODE_FULL
call compile preprocessFileLineNumbers QPATHTOF(dev\reportSettings.sqf);
call compile preprocessFileLineNumbers QPATHTOF(dev\watchVariable.sqf);
call compile preprocessFileLineNumbers QPATHTOF(dev\debugDisplay.sqf);
#endif
}] call CBA_fnc_addEventHandler;
6 changes: 6 additions & 0 deletions addons/medical/functions/fnc_addDamageToUnit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
*/
// #define DEBUG_TESTRESULTS

if (!EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(addDamageToUnit), _this];
};

if !(GETEGVAR(medical,enabled,false)) exitWith {false};

params [
["_unit", objNull, [objNull]],
["_damageToAdd", -1, [0]],
Expand Down
10 changes: 8 additions & 2 deletions addons/medical/functions/fnc_adjustPainLevel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@
* The new pain level <NUMBER>
*
* Example:
* [guy, 0.5] call ace_medical_fnc_adjustPainLevel
* [player, 0.5] call ace_medical_fnc_adjustPainLevel
*
* Public: Yes
*/

params ["_unit", "_addedPain"];
if (!EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(adjustPainLevel), _this];
};

if !(GETEGVAR(medical,enabled,false)) exitWith {};

params [["_unit", objNull, [objNull]], ["_addedPain", 0, [0]]];

if (!local _unit) exitWith { ERROR_1("unit [%1] is not local",_unit); };

Expand Down
7 changes: 7 additions & 0 deletions addons/medical/functions/fnc_deserializeState.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
*
* Public: Yes
*/

if (!EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(deserializeState), _this];
};

if !(GETEGVAR(medical,enabled,false)) exitWith {};

params [["_unit", objNull, [objNull]], ["_json", "{}", [""]]];

// Don't run in scheduled environment
Expand Down
9 changes: 8 additions & 1 deletion addons/medical/functions/fnc_serializeState.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
* Serialized state as JSON string <STRING>
*
* Example:
* [player] call ace_medical_fnc_serializeState
* player call ace_medical_fnc_serializeState
*
* Public: Yes
*/

if (!EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(serializeState), _this];
};

if !(GETEGVAR(medical,enabled,false)) exitWith {""};

params [["_unit", objNull, [objNull]]];

private _state = [] call CBA_fnc_createNamespace;
Expand Down
11 changes: 6 additions & 5 deletions addons/medical/functions/fnc_setUnconscious.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Arguments:
* 0: The unit that will be put in an unconscious state <OBJECT>
* 1: Set unconsciouns <BOOL> (default: true)
* 2: Minimum unconscious time (set to 0 to ignore) <NUMBER><OPTIONAL> (default: 0)
* 3: Force wakeup at given time if vitals are stable <BOOL><OPTIONAL> (default: false)
* 2: Minimum unconscious time (set to 0 to ignore) <NUMBER> (default: 0)
* 3: Force wakeup at given time if vitals are stable <BOOL> (default: false)
*
* Return Value:
* Success? <BOOLEAN>
Expand All @@ -19,11 +19,12 @@
* Public: Yes
*/

// only run this after the settings are initialized
if !(EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(setUnconscious), _this];
if (!EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(setUnconscious), _this];
};

if !(GETEGVAR(medical,enabled,false)) exitWith {};

params [["_unit", objNull, [objNull]], ["_knockOut", true, [false]], ["_minWaitingTime", 0, [0]], ["_forcedWakup", false, [false]]];
TRACE_4("setUnconscious",_unit,_knockOut,_minWaitingTime,_forcedWakup);

Expand Down
11 changes: 9 additions & 2 deletions addons/medical_ai/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#include "script_component.hpp"

["CBA_settingsInitialized", {
TRACE_1("settingsInitialized",GVAR(enabledFor));
TRACE_2("settingsInitialized",GVAR(enabledFor),GETEGVAR(medical,enabled,false));

if (GVAR(enabledFor) == 0) exitWith {}; // 0: disabled
if (GVAR(enabledFor) == 0 || {!(GETEGVAR(medical,enabled,false))}) exitWith {}; // 0: disabled
if ((GVAR(enabledFor) == 1) && {!isServer} && {hasInterface}) exitWith {}; // 1: Don't Run on non-hc Clients

// default time values for AI being ready to heal, used in fnc_isSafe
if (isNil QGVAR(timeSafe_shoot)) then { GVAR(timeSafe_shoot) = 30; };
if (isNil QGVAR(timeSafe_hit)) then { GVAR(timeSafe_hit) = 30; };
if (isNil QGVAR(timeSafe_suppressed)) then { GVAR(timeSafe_suppressed) = 30; };

GVAR(itemHash) = uiNamespace getVariable QGVAR(itemHash);

["ace_firedNonPlayer", {
_unit setVariable [QGVAR(lastFired), CBA_missionTime];
}] call CBA_fnc_addEventHandler;
Expand Down
7 changes: 0 additions & 7 deletions addons/medical_ai/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@ PREP_RECOMPILE_END;

#include "initSettings.inc.sqf"

// default time values for AI being ready to heal, used in fnc_isSafe
if (isNil QGVAR(timeSafe_shoot)) then { GVAR(timeSafe_shoot) = 30; };
if (isNil QGVAR(timeSafe_hit)) then { GVAR(timeSafe_hit) = 30; };
if (isNil QGVAR(timeSafe_suppressed)) then { GVAR(timeSafe_suppressed) = 30; };

GVAR(itemHash) = uiNamespace getVariable QGVAR(itemHash);

ADDON = true;
40 changes: 22 additions & 18 deletions addons/medical_blood/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
#include "script_component.hpp"

// To support public API regardless of component settings
[QGVAR(spurt), LINKFUNC(spurt)] call CBA_fnc_addEventHandler;
["CBA_settingsInitialized", {
if !(GETEGVAR(medical,enabled,false)) exitWith {};

if (isServer) then {
GVAR(bloodDrops) = [];
// To support public API regardless of component settings
[QGVAR(spurt), LINKFUNC(spurt)] call CBA_fnc_addEventHandler;

[QGVAR(bloodDropCreated), {
params ["_bloodDrop", "_source"];
if (isServer) then {
GVAR(bloodDrops) = [];

// Add to created queue with format: [expire time, blood object, source unit]
private _index = GVAR(bloodDrops) pushBack [CBA_missionTime + GVAR(bloodLifetime), _bloodDrop, _source];
[QGVAR(bloodDropCreated), {
params ["_bloodDrop", "_source"];

if (count GVAR(bloodDrops) >= GVAR(maxBloodObjects)) then {
(GVAR(bloodDrops) deleteAt 0) params ["", "_deletedBloodDrop"];
deleteVehicle _deletedBloodDrop;
};
// Add to created queue with format: [expire time, blood object, source unit]
private _index = GVAR(bloodDrops) pushBack [CBA_missionTime + GVAR(bloodLifetime), _bloodDrop, _source];

// Start the cleanup loop
if (_index == 0) then {
[LINKFUNC(cleanupLoop), [], GVAR(bloodLifetime)] call CBA_fnc_waitAndExecute;
};
}] call CBA_fnc_addEventHandler;
};
if (count GVAR(bloodDrops) >= GVAR(maxBloodObjects)) then {
(GVAR(bloodDrops) deleteAt 0) params ["", "_deletedBloodDrop"];
deleteVehicle _deletedBloodDrop;
};

// Start the cleanup loop
if (_index == 0) then {
[LINKFUNC(cleanupLoop), [], GVAR(bloodLifetime)] call CBA_fnc_waitAndExecute;
};
}] call CBA_fnc_addEventHandler;
};
}] call CBA_fnc_addEventHandler;
12 changes: 0 additions & 12 deletions addons/medical_engine/CfgActions.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

class CfgActions {
class None;
class Heal: None {
show = 0;
};
class HealSoldier: None {
show = 0;
};
class HealSoldierSelf: None {
show = 0;
};
class FirstAid: None {
show = 0;
};
class UnloadUnconsciousUnits: None {
show = 0;
};
Expand Down
11 changes: 0 additions & 11 deletions addons/medical_engine/CfgWeapons.hpp

This file was deleted.

Loading