From b312e6b9a61264fa64d78d8bd5e900e2a16c9b6a Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 01:36:27 -0800 Subject: [PATCH 01/28] Start --- addons/conversion/$PBOPREFIX$ | 1 + addons/conversion/CfgEventHandlers.hpp | 20 ++++ addons/conversion/CfgFunctions.hpp | 10 ++ addons/conversion/Statemachine.hpp | 113 ++++++++++++++++++ addons/conversion/XEH_PREP.hpp | 3 + addons/conversion/XEH_postInit.sqf | 35 ++++++ addons/conversion/XEH_preInit.sqf | 32 +++++ addons/conversion/config.cpp | 34 ++++++ .../functions/fnc_conditionSecondChance.sqf | 24 ++++ .../functions/fnc_fullHealLocal.sqf | 20 ++++ .../functions/fnc_handleRespawn.sqf | 24 ++++ addons/conversion/functions/fnc_init.sqf | 20 ++++ addons/conversion/script_component.hpp | 17 +++ addons/conversion/stringtable.xml | 8 ++ .../vitals/functions/fnc_handleUnitVitals.sqf | 5 +- .../vitals/functions/fnc_hasStableVitals.sqf | 2 + addons/vitals/script_component.hpp | 2 +- 17 files changed, 368 insertions(+), 2 deletions(-) create mode 100644 addons/conversion/$PBOPREFIX$ create mode 100644 addons/conversion/CfgEventHandlers.hpp create mode 100644 addons/conversion/CfgFunctions.hpp create mode 100644 addons/conversion/Statemachine.hpp create mode 100644 addons/conversion/XEH_PREP.hpp create mode 100644 addons/conversion/XEH_postInit.sqf create mode 100644 addons/conversion/XEH_preInit.sqf create mode 100644 addons/conversion/config.cpp create mode 100644 addons/conversion/functions/fnc_conditionSecondChance.sqf create mode 100644 addons/conversion/functions/fnc_fullHealLocal.sqf create mode 100644 addons/conversion/functions/fnc_handleRespawn.sqf create mode 100644 addons/conversion/functions/fnc_init.sqf create mode 100644 addons/conversion/script_component.hpp create mode 100644 addons/conversion/stringtable.xml diff --git a/addons/conversion/$PBOPREFIX$ b/addons/conversion/$PBOPREFIX$ new file mode 100644 index 000000000..81edac690 --- /dev/null +++ b/addons/conversion/$PBOPREFIX$ @@ -0,0 +1 @@ +x\kat\addons\conversion \ No newline at end of file diff --git a/addons/conversion/CfgEventHandlers.hpp b/addons/conversion/CfgEventHandlers.hpp new file mode 100644 index 000000000..4551ce282 --- /dev/null +++ b/addons/conversion/CfgEventHandlers.hpp @@ -0,0 +1,20 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + disableModuload = "true"; + }; +}; + +class Extended_Init_EventHandlers { + class CAManBase { + class ADDON { + init = QUOTE([ARR_2((_this select 0),false)] call FUNC(init)); + }; + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/conversion/CfgFunctions.hpp b/addons/conversion/CfgFunctions.hpp new file mode 100644 index 000000000..49ed56d33 --- /dev/null +++ b/addons/conversion/CfgFunctions.hpp @@ -0,0 +1,10 @@ +class CfgFunctions { + class overwrite_ace_medical_statemachine { + tag = "ace_medical_statemachine"; + class ace_medical_statemachine { + class conditionSecondChance { + file = QPATHTOF(functions\fnc_conditionSecondChance.sqf); + }; + }; + }; +}; diff --git a/addons/conversion/Statemachine.hpp b/addons/conversion/Statemachine.hpp new file mode 100644 index 000000000..0152f3740 --- /dev/null +++ b/addons/conversion/Statemachine.hpp @@ -0,0 +1,113 @@ +// Overwrite for ACE_Medical_StateMachine +class KAT_StateMachine { + list = QUOTE(call ACEFUNC(common,getLocalUnits)); + skipNull = 1; + class Default { + onState = QACEFUNC(medical_statemachine,handleStateDefault); + class Injury { + targetState = "Injured"; + events[] = {QACEGVAR(medical,injured), QACEGVAR(medical,LoweredVitals)}; + }; + class CriticalInjuryOrVitals { + targetState = "Unconscious"; + events[] = {QACEGVAR(medical,CriticalInjury), QACEGVAR(medical,CriticalVitals), QACEGVAR(medical,knockOut)}; + }; + class FatalVitals { + targetState = "CardiacArrest"; + events[] = {QACEGVAR(medical,FatalVitals), QACEGVAR(medical,Bleedout)}; + }; + class FatalInjury { + targetState = "FatalInjury"; + events[] = {QACEGVAR(medical,FatalInjury)}; + }; + }; + class Injured { + onState = QACEFUNC(medical_statemachine,handleStateInjured); + class FullHeal { + targetState = "Default"; + events[] = {QACEGVAR(medical,FullHeal)}; + }; + class CriticalInjuryOrVitals { + targetState = "Unconscious"; + events[] = {QACEGVAR(medical,CriticalInjury), QACEGVAR(medical,CriticalVitals), QACEGVAR(medical,knockOut)}; + }; + class FatalVitals { + targetState = "CardiacArrest"; + events[] = {QACEGVAR(medical,FatalVitals), QACEGVAR(medical,Bleedout)}; + }; + class FatalInjury { + targetState = "FatalInjury"; + events[] = {QACEGVAR(medical,FatalInjury)}; + }; + }; + class Unconscious { + onState = QACEFUNC(medical_statemachine,handleStateUnconscious); + onStateEntered = QACEFUNC(medical_statemachine,enteredStateUnconscious); + class DeathAI { + targetState = "Dead"; + condition = QUOTE(!(_this getVariable [ARR_2(QQACEGVAR(medical_statemachine,AIUnconsciousness),ACEGVAR(medical_statemachine,AIUnconsciousness))]) && !(_this getVariable [ARR_2(QQGVAR(conversion),false)]) && {!isPlayer _this}); + }; + class WakeUp { + targetState = "Injured"; + condition = QACEFUNC(medical_status,hasStableVitals); + events[] = {QACEGVAR(medical,WakeUp)}; + onTransition = QUOTE([ARR_2(_this,false)] call ACEFUNC(medical_status,setUnconsciousState)); + }; + class FatalTransitions { + targetState = "CardiacArrest"; + events[] = {QACEGVAR(medical,FatalVitals), QACEGVAR(medical,Bleedout)}; + }; + class FatalInjury { + targetState = "FatalInjury"; + events[] = {QACEGVAR(medical,FatalInjury)}; + }; + }; + class FatalInjury { + // Transition state for handling instant death from fatal injuries + // This state raises the next transition in the same frame + onStateEntered = QACEFUNC(medical_statemachine,enteredStateFatalInjury); + class SecondChance { + events[] = {QACEGVAR(medical,FatalInjuryInstantTransition)}; + targetState = "CardiacArrest"; + condition = QACEFUNC(medical_statemachine,conditionSecondChance); + onTransition = QACEFUNC(medical_statemachine,transitionSecondChance); + }; + class Death { + events[] = {QACEGVAR(medical,FatalInjuryInstantTransition)}; + targetState = "Dead"; + }; + }; + class CardiacArrest { + onState = QACEFUNC(medical_statemachine,handleStateCardiacArrest); + onStateEntered = QACEFUNC(medical_statemachine,enteredStateCardiacArrest); + onStateLeaving = QACEFUNC(medical_statemachine,leftStateCardiacArrest); + class DeathAI { + // If an AI unit reanimates, they will immediately die upon entering unconsciousness if AI Unconsciousness is disabled + // As a result, we immediately kill the AI unit since cardiac arrest is effectively useless for it + targetState = "Dead"; + condition = QUOTE(!ACEGVAR(medical_statemachine,AIUnconsciousness) && !(_this getVariable [ARR_2(QQGVAR(conversion),false)]) && {!isPlayer _this}); + }; + class Timeout { + targetState = "Dead"; + condition = QACEFUNC(medical_statemachine,conditionCardiacArrestTimer); + }; + class Reanimation { + targetState = "Unconscious"; + events[] = {QACEGVAR(medical,CPRSucceeded)}; + }; + class Execution { + targetState = "Dead"; + condition = QACEFUNC(medical_statemachine,conditionExecutionDeath); + events[] = {QACEGVAR(medical,FatalInjury)}; + }; + class Bleedout { + targetState = "Dead"; + condition = QUOTE((ACEGVAR(medical_statemachine,cardiacArrestBleedoutEnabled))); // wrap to ensure cba uses this as code and not a direct variable + events[] = {QACEGVAR(medical,Bleedout)}; + }; + }; + class Dead { + // When the unit is killed it's no longer handled by the statemachine + onStateEntered = QACEFUNC(medical_statemachine,enteredStateDeath); + }; +}; \ No newline at end of file diff --git a/addons/conversion/XEH_PREP.hpp b/addons/conversion/XEH_PREP.hpp new file mode 100644 index 000000000..a304d8237 --- /dev/null +++ b/addons/conversion/XEH_PREP.hpp @@ -0,0 +1,3 @@ +PREP(fullHealLocal); +PREP(hasStableVitals); +PREP(conditionSecondChance); \ No newline at end of file diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf new file mode 100644 index 000000000..92763cc62 --- /dev/null +++ b/addons/conversion/XEH_postInit.sqf @@ -0,0 +1,35 @@ +#include "script_component.hpp" + +[QEGVAR(misc,handleRespawn), LINKFUNC(handleRespawn)] call CBA_fnc_addEventHandler; +[QACEGVAR(medical_treatment,fullHealLocalMod), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler; + +["kat_conversion_convertCasualty", { + diag_log "WORKING"; + private _type = typeOf player; + private _group = createGroup [(side player), true]; + private _unit = _group createUnit [_type, [0,0,0], [], 0, "NONE"]; + private _previousUnit = player; + private _setName = name _previousUnit; + + _previousUnit setVariable [QACEGVAR(medical,deathBlocked), true]; + + selectPlayer _unit; + + _previousUnit setVariable [QEGVAR(vitals,simpleMedical), false, true]; + _previousUnit setVariable [QEGVAR(conversion,conversion), true, true]; + + ["kat_conversion_unitTransfer", [_previousUnit]] call CBA_fnc_serverEvent; + _previousUnit setName _setName; + + _unit setDamage 1; + deleteVehicle _unit; + + _previousUnit setVariable [QACEGVAR(medical,deathBlocked), false]; +}] call CBA_fnc_addEventHandler; + +["kat_conversion_unitTransfer", { + params ["_previousUnit"]; + private _group2 = createGroup [(side _previousUnit), true]; + [_previousUnit] join _group2; + _group2 setGroupOwner 2; +}] call CBA_fnc_addEventHandler \ No newline at end of file diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf new file mode 100644 index 000000000..e3f90b886 --- /dev/null +++ b/addons/conversion/XEH_preInit.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +#define CBA_SETTINGS_CAT "KAT - ADV Medical: Conversion" + +// Overwrite ace statemachine +ACEGVAR(medical,STATE_MACHINE) = (configFile >> "KAT_StateMachine") call CBA_statemachine_fnc_createFromConfig; + +[ + QGVAR(enableConversion), + "CHECKBOX", + [LLSTRING(CONVERSION_ENABLE), LLSTRING(CONVERSION_ENABLE_DISC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [false], + true +] call CBA_Settings_fnc_init; + +/*[ + QGVAR(enableConversionArrest), + "CHECKBOX", + [LLSTRING(CONVERSION_ARREST_ENABLE), LLSTRING(CCONVERSION_ARREST_ENABLE_DISC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [false], + true +] call CBA_Settings_fnc_init;*/ + +ADDON = true; \ No newline at end of file diff --git a/addons/conversion/config.cpp b/addons/conversion/config.cpp new file mode 100644 index 000000000..8b66b04f7 --- /dev/null +++ b/addons/conversion/config.cpp @@ -0,0 +1,34 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + requiredVersion = REQUIRED_VERSION; + units[] = {}; + weapons[] = {}; + magazines[] = {}; + requiredAddons[] = { + "ace_medical", + "ace_medical_ai", + "ace_medical_blood", + "ace_medical_damage", + "ace_medical_engine", + "ace_medical_feedback", + "ace_medical_gui", + "ace_medical_statemachine", + "ace_medical_status", + "ace_medical_treatment", + "ace_medical_vitals", + "ace_dogtags", + "cba_settings" + }; + author = "Mazinski"; + authors[] = {"Mazinski"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "Statemachine.hpp" +#include "CfgEventHandlers.hpp" +#include "CfgFunctions.hpp" diff --git a/addons/conversion/functions/fnc_conditionSecondChance.sqf b/addons/conversion/functions/fnc_conditionSecondChance.sqf new file mode 100644 index 000000000..90ff9428e --- /dev/null +++ b/addons/conversion/functions/fnc_conditionSecondChance.sqf @@ -0,0 +1,24 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_unit"]; + +if (isPlayer _unit || (_unit getVariable [QGVAR(conversion), false])) then { + ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_ALWAYS +} else { + ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_ALWAYS +} \ No newline at end of file diff --git a/addons/conversion/functions/fnc_fullHealLocal.sqf b/addons/conversion/functions/fnc_fullHealLocal.sqf new file mode 100644 index 000000000..b08798414 --- /dev/null +++ b/addons/conversion/functions/fnc_fullHealLocal.sqf @@ -0,0 +1,20 @@ +#include "..\script_component.hpp" +/* + * Author: MiszczuZPolski + * Local callback for fully healing a patient. + * + * Arguments: + * 0: Patient + * + * Return Value: + * None + * + * Example: + * [player] call kat_vitals_fnc_fullHealLocal + * + * Public: No + */ + +params ["_patient"]; + +_patient setVariable [QGVAR(conversion), false, true]; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_handleRespawn.sqf b/addons/conversion/functions/fnc_handleRespawn.sqf new file mode 100644 index 000000000..5647e0530 --- /dev/null +++ b/addons/conversion/functions/fnc_handleRespawn.sqf @@ -0,0 +1,24 @@ +#include "..\script_component.hpp" +/* + * Author: MiszczuZPolski + * Local callback for fully healing a patient. + * + * Arguments: + * 0: Patient + * + * Return Value: + * None + * + * Example: + * [player] call kat_vitals_fnc_handleRespawn + * + * Public: No + */ + +params ["_patient"]; + +_patient setVariable [QGVAR(simpleMedical), false, true]; + +if (GVAR(enableSimpleMedical)) then { + _patient setVariable [QGVAR(simpleMedical), true, true]; +}; diff --git a/addons/conversion/functions/fnc_init.sqf b/addons/conversion/functions/fnc_init.sqf new file mode 100644 index 000000000..583552f78 --- /dev/null +++ b/addons/conversion/functions/fnc_init.sqf @@ -0,0 +1,20 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Initializes unit variables. + * + * Arguments: + * 0: Patient + * + * Return Value: + * None + * + * Example: + * [player] call kat_vitals_fnc_init + * + * Public: No + */ + +params ["_patient"]; + +[_patient] call FUNC(fullHealLocal); \ No newline at end of file diff --git a/addons/conversion/script_component.hpp b/addons/conversion/script_component.hpp new file mode 100644 index 000000000..0f23222c8 --- /dev/null +++ b/addons/conversion/script_component.hpp @@ -0,0 +1,17 @@ +#define COMPONENT conversion +#define COMPONENT_BEAUTIFIED KAT - conversion +#include "\x\kat\addons\main\script_mod.hpp" + + #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_CONVERSION + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_CONVERSION + #define DEBUG_SETTINGS DEBUG_SETTINGS_CONVERSION +#endif + +#include "\x\kat\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml new file mode 100644 index 000000000..20514f3d0 --- /dev/null +++ b/addons/conversion/stringtable.xml @@ -0,0 +1,8 @@ + + + + + Activate Casualty Conversion + + + diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 133a24314..445eda3e3 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -165,8 +165,11 @@ switch (true) do { TRACE_3("Class IV Hemorrhage",_unit,_hemorrhage,_bloodVolume); [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 220}): { + case (_heartRate < 20 || {_heartRate > 110}): { TRACE_2("heartRate Fatal",_unit,_heartRate); + if !(_unit getVariable [QEGVAR(conversion,conversion), false]) then { + ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; + }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; case (_bloodPressureL < 20 || {_bloodPressureL > 180}): { diff --git a/addons/vitals/functions/fnc_hasStableVitals.sqf b/addons/vitals/functions/fnc_hasStableVitals.sqf index 58ed2f125..482ae65b3 100644 --- a/addons/vitals/functions/fnc_hasStableVitals.sqf +++ b/addons/vitals/functions/fnc_hasStableVitals.sqf @@ -24,6 +24,8 @@ if IN_CRDC_ARRST(_unit) exitWith { false }; if (_unit getVariable [QEGVAR(surgery,sedated), false]) exitWith { false }; if (_unit getVariable [QEGVAR(surgery,reboa), false]) exitWith { false }; +if (_unit getVariable [QEGVAR(conversion,conversion),false]) exitWith { false }; + private _cardiacOutput = [_unit] call ACEFUNC(medical_status,getCardiacOutput); private _bloodLoss = _unit call ACEFUNC(medical_status,getBloodLoss); if (_bloodLoss > (ACEGVAR(medical,const_bloodLossKnockOutThreshold) * _cardiacOutput / 2)) exitWith { false }; diff --git a/addons/vitals/script_component.hpp b/addons/vitals/script_component.hpp index 162080431..870277346 100644 --- a/addons/vitals/script_component.hpp +++ b/addons/vitals/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED KAT - Vitals #include "\x\kat\addons\main\script_mod.hpp" -// #define DEBUG_MODE_FULL +#define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS From 2360b7936d97efe2a3785ac50959d4e69469eaae Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 02:07:02 -0800 Subject: [PATCH 02/28] Working? --- addons/conversion/CfgFunctions.hpp | 8 +++ addons/conversion/XEH_PREP.hpp | 3 +- addons/conversion/XEH_postInit.sqf | 8 +-- addons/conversion/functions/fnc_setDead.sqf | 59 +++++++++++++++++++ .../vitals/functions/fnc_handleUnitVitals.sqf | 10 +--- 5 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 addons/conversion/functions/fnc_setDead.sqf diff --git a/addons/conversion/CfgFunctions.hpp b/addons/conversion/CfgFunctions.hpp index 49ed56d33..f2962ed94 100644 --- a/addons/conversion/CfgFunctions.hpp +++ b/addons/conversion/CfgFunctions.hpp @@ -7,4 +7,12 @@ class CfgFunctions { }; }; }; + class overwrite_ace_medical_status { + tag = "ace_medical_status"; + class ace_medical_status { + class setDead { + file = QPATHTOF(functions\fnc_setDead.sqf); + }; + }; + }; }; diff --git a/addons/conversion/XEH_PREP.hpp b/addons/conversion/XEH_PREP.hpp index a304d8237..c84b0bd1a 100644 --- a/addons/conversion/XEH_PREP.hpp +++ b/addons/conversion/XEH_PREP.hpp @@ -1,3 +1,4 @@ PREP(fullHealLocal); PREP(hasStableVitals); -PREP(conditionSecondChance); \ No newline at end of file +PREP(conditionSecondChance); +PREP(setDead); \ No newline at end of file diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index 92763cc62..fb6e543a8 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -11,20 +11,16 @@ private _previousUnit = player; private _setName = name _previousUnit; - _previousUnit setVariable [QACEGVAR(medical,deathBlocked), true]; - - selectPlayer _unit; - _previousUnit setVariable [QEGVAR(vitals,simpleMedical), false, true]; _previousUnit setVariable [QEGVAR(conversion,conversion), true, true]; + selectPlayer _unit; + ["kat_conversion_unitTransfer", [_previousUnit]] call CBA_fnc_serverEvent; _previousUnit setName _setName; _unit setDamage 1; deleteVehicle _unit; - - _previousUnit setVariable [QACEGVAR(medical,deathBlocked), false]; }] call CBA_fnc_addEventHandler; ["kat_conversion_unitTransfer", { diff --git a/addons/conversion/functions/fnc_setDead.sqf b/addons/conversion/functions/fnc_setDead.sqf new file mode 100644 index 000000000..83fdb245f --- /dev/null +++ b/addons/conversion/functions/fnc_setDead.sqf @@ -0,0 +1,59 @@ +#include "..\script_component.hpp" +/* + * Author: commy2 + * Kills a local unit. + * + * Arguments: + * 0: The unit + * 1: Reason for death + * 2: Killer + * 3: Instigator + * + * Return Value: + * None + * + * Public: No + */ + +params ["_unit", ["_reason", "#setDead"], ["_source", objNull], ["_instigator", objNull]]; +TRACE_4("setDead",_unit,_reason,_source,_instigator); + +private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; +private _unitConversion = _unit getVariable [QEGVAR(conversion,conversion), false]; +diag_log _unitConversion; + +if (_unitConversion) exitWith { + [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "Unconscious"] call CBA_statemachine_fnc_manualTransition; +}; + +// No heart rate or blood pressure to measure when dead +_unit setVariable [VAR_HEART_RATE, 0, true]; +_unit setVariable [VAR_BLOOD_PRESS, [0, 0], true]; + +// Clear uncon variable just to be safe +_unit setVariable [VAR_UNCON, nil, true]; + +_unit setVariable [QACEGVAR(medical,causeOfDeath), _reason, true]; + +// Send a local event before death +[QACEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; + +// Update the state machine if necessary (forced respawn, scripted death, etc) +private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; +if (_unitState isNotEqualTo "Dead") then { + [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "Dead"] call CBA_statemachine_fnc_manualTransition; +}; + +// (#8803) Reenable damage if disabled to prevent having live units in dead state +// Keep this after death event for compatibility with third party hooks +if (!isDamageAllowed _unit) then { + WARNING_1("setDead executed on unit with damage blocked - %1",_this); + _unit allowDamage true; +}; + +// Kill the unit without changing visual apperance +private _prevDamage = _unit getHitPointDamage "HitHead"; + +_unit setHitPointDamage ["HitHead", 1, true, _source, _instigator]; + +_unit setHitPointDamage ["HitHead", _prevDamage, true, _source, _instigator]; \ No newline at end of file diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 445eda3e3..7f3a981b6 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -165,7 +165,7 @@ switch (true) do { TRACE_3("Class IV Hemorrhage",_unit,_hemorrhage,_bloodVolume); [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 110}): { + case (_heartRate < 20 || {_heartRate > 90}): { TRACE_2("heartRate Fatal",_unit,_heartRate); if !(_unit getVariable [QEGVAR(conversion,conversion), false]) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; @@ -190,14 +190,6 @@ switch (true) do { }; }; -#ifdef DEBUG_MODE_FULL -private _cardiacOutput = [_unit] call ACEFUNC(medical_status,getCardiacOutput); -if (!isPlayer _unit) then { - private _painLevel = _unit getVariable [VAR_PAIN, 0]; - hintSilent format["blood volume: %1, blood loss: [%2, %3]\nhr: %4, bp: %5, pain: %6", round(_bloodVolume * 100) / 100, round(_woundBloodLoss * 1000) / 1000, round((_woundBloodLoss / (0.001 max _cardiacOutput)) * 100) / 100, round(_heartRate), _bloodPressure, round(_painLevel * 100) / 100]; -}; -#endif - END_COUNTER(Vitals); //placed outside the counter as 3rd-party code may be called from this event From 0bf1fefe18f000a6a00e2274a5769abdfdd12171 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 11:49:37 -0800 Subject: [PATCH 03/28] Pulling hairs --- addons/conversion/CfgFunctions.hpp | 11 +--- addons/conversion/Statemachine.hpp | 4 +- addons/conversion/XEH_PREP.hpp | 6 +- addons/conversion/XEH_postInit.sqf | 36 +++++------ addons/conversion/XEH_preInit.sqf | 2 +- .../functions/fnc_conditionExecutionDeath.sqf | 28 +++++++++ .../functions/fnc_conditionSecondChance.sqf | 5 +- .../functions/fnc_conversionCheck.sqf | 26 ++++++++ .../functions/fnc_fullHealLocal.sqf | 6 +- .../functions/fnc_handleRespawn.sqf | 6 +- addons/conversion/functions/fnc_setDead.sqf | 59 ------------------- addons/conversion/script_component.hpp | 2 +- .../vitals/functions/fnc_handleUnitVitals.sqf | 2 +- 13 files changed, 94 insertions(+), 99 deletions(-) create mode 100644 addons/conversion/functions/fnc_conditionExecutionDeath.sqf create mode 100644 addons/conversion/functions/fnc_conversionCheck.sqf delete mode 100644 addons/conversion/functions/fnc_setDead.sqf diff --git a/addons/conversion/CfgFunctions.hpp b/addons/conversion/CfgFunctions.hpp index f2962ed94..81a7de1fa 100644 --- a/addons/conversion/CfgFunctions.hpp +++ b/addons/conversion/CfgFunctions.hpp @@ -5,14 +5,9 @@ class CfgFunctions { class conditionSecondChance { file = QPATHTOF(functions\fnc_conditionSecondChance.sqf); }; - }; - }; - class overwrite_ace_medical_status { - tag = "ace_medical_status"; - class ace_medical_status { - class setDead { - file = QPATHTOF(functions\fnc_setDead.sqf); + class conditionExecutionDeath { + file = QPATHTOF(functions\fnc_conditionExecutionDeath.sqf); }; }; }; -}; +}; \ No newline at end of file diff --git a/addons/conversion/Statemachine.hpp b/addons/conversion/Statemachine.hpp index 0152f3740..a4a4aab0a 100644 --- a/addons/conversion/Statemachine.hpp +++ b/addons/conversion/Statemachine.hpp @@ -45,7 +45,7 @@ class KAT_StateMachine { onStateEntered = QACEFUNC(medical_statemachine,enteredStateUnconscious); class DeathAI { targetState = "Dead"; - condition = QUOTE(!(_this getVariable [ARR_2(QQACEGVAR(medical_statemachine,AIUnconsciousness),ACEGVAR(medical_statemachine,AIUnconsciousness))]) && !(_this getVariable [ARR_2(QQGVAR(conversion),false)]) && {!isPlayer _this}); + condition = QFUNC(conversionCheck); }; class WakeUp { targetState = "Injured"; @@ -85,7 +85,7 @@ class KAT_StateMachine { // If an AI unit reanimates, they will immediately die upon entering unconsciousness if AI Unconsciousness is disabled // As a result, we immediately kill the AI unit since cardiac arrest is effectively useless for it targetState = "Dead"; - condition = QUOTE(!ACEGVAR(medical_statemachine,AIUnconsciousness) && !(_this getVariable [ARR_2(QQGVAR(conversion),false)]) && {!isPlayer _this}); + condition = QFUNC(conversionCheck); }; class Timeout { targetState = "Dead"; diff --git a/addons/conversion/XEH_PREP.hpp b/addons/conversion/XEH_PREP.hpp index c84b0bd1a..10c398b5b 100644 --- a/addons/conversion/XEH_PREP.hpp +++ b/addons/conversion/XEH_PREP.hpp @@ -1,4 +1,6 @@ PREP(fullHealLocal); -PREP(hasStableVitals); +PREP(init); +PREP(handleRespawn); PREP(conditionSecondChance); -PREP(setDead); \ No newline at end of file +PREP(conversionCheck); +PREP(conditionExecutionDeath); \ No newline at end of file diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index fb6e543a8..958c42048 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -4,28 +4,28 @@ [QACEGVAR(medical_treatment,fullHealLocalMod), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler; ["kat_conversion_convertCasualty", { - diag_log "WORKING"; - private _type = typeOf player; - private _group = createGroup [(side player), true]; - private _unit = _group createUnit [_type, [0,0,0], [], 0, "NONE"]; - private _previousUnit = player; - private _setName = name _previousUnit; + private _type = typeOf player; + private _group = createGroup [(side player), true]; + private _unit = _group createUnit [_type, [0,0,0], [], 0, "NONE"]; + private _previousUnit = player; + private _setName = name _previousUnit; - _previousUnit setVariable [QEGVAR(vitals,simpleMedical), false, true]; - _previousUnit setVariable [QEGVAR(conversion,conversion), true, true]; + _previousUnit setVariable [QEGVAR(vitals,simpleMedical), false, true]; + _previousUnit setVariable [QGVAR(currentConverted), true, true]; - selectPlayer _unit; + selectPlayer _unit; - ["kat_conversion_unitTransfer", [_previousUnit]] call CBA_fnc_serverEvent; - _previousUnit setName _setName; + ["kat_conversion_unitTransfer", [_previousUnit]] call CBA_fnc_serverEvent; - _unit setDamage 1; - deleteVehicle _unit; + _previousUnit setName _setName; + + _unit setDamage 1; + deleteVehicle _unit; }] call CBA_fnc_addEventHandler; ["kat_conversion_unitTransfer", { - params ["_previousUnit"]; - private _group2 = createGroup [(side _previousUnit), true]; - [_previousUnit] join _group2; - _group2 setGroupOwner 2; -}] call CBA_fnc_addEventHandler \ No newline at end of file + params ["_previousUnit"]; + private _group2 = createGroup [(side _previousUnit), true]; + [_previousUnit] join _group2; + _group2 setGroupOwner 2; +}] call CBA_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf index e3f90b886..6a0095f6b 100644 --- a/addons/conversion/XEH_preInit.sqf +++ b/addons/conversion/XEH_preInit.sqf @@ -12,7 +12,7 @@ PREP_RECOMPILE_END; ACEGVAR(medical,STATE_MACHINE) = (configFile >> "KAT_StateMachine") call CBA_statemachine_fnc_createFromConfig; [ - QGVAR(enableConversion), + QGVAR(enable), "CHECKBOX", [LLSTRING(CONVERSION_ENABLE), LLSTRING(CONVERSION_ENABLE_DISC)], [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], diff --git a/addons/conversion/functions/fnc_conditionExecutionDeath.sqf b/addons/conversion/functions/fnc_conditionExecutionDeath.sqf new file mode 100644 index 000000000..81fd36895 --- /dev/null +++ b/addons/conversion/functions/fnc_conditionExecutionDeath.sqf @@ -0,0 +1,28 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_unit"]; + +diag_log "EXECUTION"; + +(if (isPlayer _unit || (_unit getVariable [QGVAR(convert), false])) then { + diag_log "EXECUTION DEATH"; + ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_NEVER +} else { + ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_NEVER +}) +&& {!(_unit getVariable [QACEGVAR(medical,deathBlocked), false])} \ No newline at end of file diff --git a/addons/conversion/functions/fnc_conditionSecondChance.sqf b/addons/conversion/functions/fnc_conditionSecondChance.sqf index 90ff9428e..0bd422aee 100644 --- a/addons/conversion/functions/fnc_conditionSecondChance.sqf +++ b/addons/conversion/functions/fnc_conditionSecondChance.sqf @@ -17,7 +17,10 @@ params ["_unit"]; -if (isPlayer _unit || (_unit getVariable [QGVAR(conversion), false])) then { +diag_log "CHANCE"; + +if (isPlayer _unit || (_unit getVariable [QGVAR(convert), false])) then { + diag_log "SECOND CHANCE"; ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_ALWAYS } else { ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_ALWAYS diff --git a/addons/conversion/functions/fnc_conversionCheck.sqf b/addons/conversion/functions/fnc_conversionCheck.sqf new file mode 100644 index 000000000..d2b4c3897 --- /dev/null +++ b/addons/conversion/functions/fnc_conversionCheck.sqf @@ -0,0 +1,26 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_this"]; + +if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!(_this getVariable [QEGVAR(conversion,convert),false])) && {!isPlayer _this}) exitWith { + diag_log "TRUE"; + true +}; + +diag_log "FALSE"; +false \ No newline at end of file diff --git a/addons/conversion/functions/fnc_fullHealLocal.sqf b/addons/conversion/functions/fnc_fullHealLocal.sqf index b08798414..6dfce3805 100644 --- a/addons/conversion/functions/fnc_fullHealLocal.sqf +++ b/addons/conversion/functions/fnc_fullHealLocal.sqf @@ -17,4 +17,8 @@ params ["_patient"]; -_patient setVariable [QGVAR(conversion), false, true]; \ No newline at end of file +if (hasInterface && GVAR(enable)) then { + _patient setVariable [QGVAR(convert), true, true]; +}; + +_patient setVariable [QGVAR(currentConverted), false, true]; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_handleRespawn.sqf b/addons/conversion/functions/fnc_handleRespawn.sqf index 5647e0530..31a3d7f40 100644 --- a/addons/conversion/functions/fnc_handleRespawn.sqf +++ b/addons/conversion/functions/fnc_handleRespawn.sqf @@ -17,8 +17,4 @@ params ["_patient"]; -_patient setVariable [QGVAR(simpleMedical), false, true]; - -if (GVAR(enableSimpleMedical)) then { - _patient setVariable [QGVAR(simpleMedical), true, true]; -}; +[_patient] call FUNC(fullHealLocal); \ No newline at end of file diff --git a/addons/conversion/functions/fnc_setDead.sqf b/addons/conversion/functions/fnc_setDead.sqf deleted file mode 100644 index 83fdb245f..000000000 --- a/addons/conversion/functions/fnc_setDead.sqf +++ /dev/null @@ -1,59 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: commy2 - * Kills a local unit. - * - * Arguments: - * 0: The unit - * 1: Reason for death - * 2: Killer - * 3: Instigator - * - * Return Value: - * None - * - * Public: No - */ - -params ["_unit", ["_reason", "#setDead"], ["_source", objNull], ["_instigator", objNull]]; -TRACE_4("setDead",_unit,_reason,_source,_instigator); - -private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; -private _unitConversion = _unit getVariable [QEGVAR(conversion,conversion), false]; -diag_log _unitConversion; - -if (_unitConversion) exitWith { - [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "Unconscious"] call CBA_statemachine_fnc_manualTransition; -}; - -// No heart rate or blood pressure to measure when dead -_unit setVariable [VAR_HEART_RATE, 0, true]; -_unit setVariable [VAR_BLOOD_PRESS, [0, 0], true]; - -// Clear uncon variable just to be safe -_unit setVariable [VAR_UNCON, nil, true]; - -_unit setVariable [QACEGVAR(medical,causeOfDeath), _reason, true]; - -// Send a local event before death -[QACEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; - -// Update the state machine if necessary (forced respawn, scripted death, etc) -private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; -if (_unitState isNotEqualTo "Dead") then { - [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "Dead"] call CBA_statemachine_fnc_manualTransition; -}; - -// (#8803) Reenable damage if disabled to prevent having live units in dead state -// Keep this after death event for compatibility with third party hooks -if (!isDamageAllowed _unit) then { - WARNING_1("setDead executed on unit with damage blocked - %1",_this); - _unit allowDamage true; -}; - -// Kill the unit without changing visual apperance -private _prevDamage = _unit getHitPointDamage "HitHead"; - -_unit setHitPointDamage ["HitHead", 1, true, _source, _instigator]; - -_unit setHitPointDamage ["HitHead", _prevDamage, true, _source, _instigator]; \ No newline at end of file diff --git a/addons/conversion/script_component.hpp b/addons/conversion/script_component.hpp index 0f23222c8..bb629e9e6 100644 --- a/addons/conversion/script_component.hpp +++ b/addons/conversion/script_component.hpp @@ -1,5 +1,5 @@ #define COMPONENT conversion -#define COMPONENT_BEAUTIFIED KAT - conversion +#define COMPONENT_BEAUTIFIED KAT - Conversion #include "\x\kat\addons\main\script_mod.hpp" #define DEBUG_MODE_FULL diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 7f3a981b6..b605dea1a 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -167,7 +167,7 @@ switch (true) do { }; case (_heartRate < 20 || {_heartRate > 90}): { TRACE_2("heartRate Fatal",_unit,_heartRate); - if !(_unit getVariable [QEGVAR(conversion,conversion), false]) then { + if (_unit getVariable [QEGVAR(conversion,convert), false]) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; From aa72614aa920a0a11d2add96568f91f4fe41c19b Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:30:21 -0800 Subject: [PATCH 04/28] Ticket/Lib Supply Conversion --- addons/conversion/CfgFunctions.hpp | 8 +++ addons/conversion/CfgVehicles.hpp | 21 +++++++ addons/conversion/XEH_PREP.hpp | 7 ++- addons/conversion/XEH_postInit.sqf | 4 +- addons/conversion/config.cpp | 1 + .../functions/fnc_conditionExecutionDeath.sqf | 3 - .../functions/fnc_conversionCheck.sqf | 2 - .../functions/fnc_conversionCondition.sqf | 38 +++++++++++++ .../functions/fnc_libConversion.sqf | 25 ++++++++ .../functions/fnc_libConversionCondition.sqf | 27 +++++++++ addons/conversion/functions/fnc_setDead.sqf | 57 +++++++++++++++++++ .../functions/fnc_ticketConversion.sqf | 22 +++++++ .../fnc_ticketConversionCondition.sqf | 24 ++++++++ addons/conversion/stringtable.xml | 8 ++- .../vitals/functions/fnc_handleUnitVitals.sqf | 9 ++- .../vitals/functions/fnc_hasStableVitals.sqf | 2 +- 16 files changed, 248 insertions(+), 10 deletions(-) create mode 100644 addons/conversion/CfgVehicles.hpp create mode 100644 addons/conversion/functions/fnc_conversionCondition.sqf create mode 100644 addons/conversion/functions/fnc_libConversion.sqf create mode 100644 addons/conversion/functions/fnc_libConversionCondition.sqf create mode 100644 addons/conversion/functions/fnc_setDead.sqf create mode 100644 addons/conversion/functions/fnc_ticketConversion.sqf create mode 100644 addons/conversion/functions/fnc_ticketConversionCondition.sqf diff --git a/addons/conversion/CfgFunctions.hpp b/addons/conversion/CfgFunctions.hpp index 81a7de1fa..f2af58a6a 100644 --- a/addons/conversion/CfgFunctions.hpp +++ b/addons/conversion/CfgFunctions.hpp @@ -10,4 +10,12 @@ class CfgFunctions { }; }; }; + class overwrite_ace_medical_status { + tag = "ace_medical_status"; + class ace_medical_status { + class setDead { + file = QPATHTOF(functions\fnc_setDead.sqf); + }; + }; + }; }; \ No newline at end of file diff --git a/addons/conversion/CfgVehicles.hpp b/addons/conversion/CfgVehicles.hpp new file mode 100644 index 000000000..87067ae96 --- /dev/null +++ b/addons/conversion/CfgVehicles.hpp @@ -0,0 +1,21 @@ +class CfgVehicles { + class Man; + class CAManBase: Man { + class ACE_Actions { + class ACE_MainActions { + class KAT_TicketConversion { + displayName = CSTRING(TicketConversion); + condition = QUOTE(_target call FUNC(ticketConversionCondition)); + statement = QUOTE(_target call FUNC(ticketConversion)); + icon = QACEPATHTOF(medical_gui,ui\cross.paa); + }; + class KAT_LibConversion { + displayName = CSTRING(LibConversion); + condition = QUOTE(_target call FUNC(libConversionCondition)); + statement = QUOTE(_target call FUNC(libConversion)); + icon = QACEPATHTOF(medical_gui,ui\cross.paa); + }; + }; + }; + }; +}; \ No newline at end of file diff --git a/addons/conversion/XEH_PREP.hpp b/addons/conversion/XEH_PREP.hpp index 10c398b5b..5a2a956ee 100644 --- a/addons/conversion/XEH_PREP.hpp +++ b/addons/conversion/XEH_PREP.hpp @@ -3,4 +3,9 @@ PREP(init); PREP(handleRespawn); PREP(conditionSecondChance); PREP(conversionCheck); -PREP(conditionExecutionDeath); \ No newline at end of file +PREP(conditionExecutionDeath); +PREP(setDead); +PREP(ticketConversion); +PREP(ticketConversionCondition); +PREP(libConversion); +PREP(libConversionCondition); \ No newline at end of file diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index 958c42048..a63d72338 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -6,9 +6,11 @@ ["kat_conversion_convertCasualty", { private _type = typeOf player; private _group = createGroup [(side player), true]; - private _unit = _group createUnit [_type, [0,0,0], [], 0, "NONE"]; private _previousUnit = player; private _setName = name _previousUnit; + private _loadout = getUnitLoadout player; + private _unit = _group createUnit [_type, [0,0,0], [], 0, "NONE"]; + _unit setUnitLoadout _loadout; _previousUnit setVariable [QEGVAR(vitals,simpleMedical), false, true]; _previousUnit setVariable [QGVAR(currentConverted), true, true]; diff --git a/addons/conversion/config.cpp b/addons/conversion/config.cpp index 8b66b04f7..884dec87e 100644 --- a/addons/conversion/config.cpp +++ b/addons/conversion/config.cpp @@ -32,3 +32,4 @@ class CfgPatches { #include "Statemachine.hpp" #include "CfgEventHandlers.hpp" #include "CfgFunctions.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/conversion/functions/fnc_conditionExecutionDeath.sqf b/addons/conversion/functions/fnc_conditionExecutionDeath.sqf index 81fd36895..d6dbdb890 100644 --- a/addons/conversion/functions/fnc_conditionExecutionDeath.sqf +++ b/addons/conversion/functions/fnc_conditionExecutionDeath.sqf @@ -17,10 +17,7 @@ params ["_unit"]; -diag_log "EXECUTION"; - (if (isPlayer _unit || (_unit getVariable [QGVAR(convert), false])) then { - diag_log "EXECUTION DEATH"; ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_NEVER } else { ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_NEVER diff --git a/addons/conversion/functions/fnc_conversionCheck.sqf b/addons/conversion/functions/fnc_conversionCheck.sqf index d2b4c3897..d51c9b144 100644 --- a/addons/conversion/functions/fnc_conversionCheck.sqf +++ b/addons/conversion/functions/fnc_conversionCheck.sqf @@ -18,9 +18,7 @@ params ["_this"]; if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!(_this getVariable [QEGVAR(conversion,convert),false])) && {!isPlayer _this}) exitWith { - diag_log "TRUE"; true }; -diag_log "FALSE"; false \ No newline at end of file diff --git a/addons/conversion/functions/fnc_conversionCondition.sqf b/addons/conversion/functions/fnc_conversionCondition.sqf new file mode 100644 index 000000000..c39e1c4d2 --- /dev/null +++ b/addons/conversion/functions/fnc_conversionCondition.sqf @@ -0,0 +1,38 @@ +#include "..\script_component.hpp" +/* + * Author: Ruthberg + * Check if a unit can be converted back into resources + * + * Arguments: + * 0: The patient + * + * Return Value: + * Has stable vitals + * + * Example: + * [player] call kat_conversion_conversionCondition + * + * Public: No + */ + +params ["_unit"]; + +private _bloodVolume = GET_BLOOD_VOLUME_LITERS(_unit); +if (_bloodVolume < ACEGVAR(medical,const_stableVitalsBloodThreshold)) exitWith { false }; + +if IN_CRDC_ARRST(_unit) exitWith { false }; + +private _bloodPressure = GET_BLOOD_PRESSURE(_unit); +_bloodPressure params ["_bloodPressureL", "_bloodPressureH"]; +if (_bloodPressureL < 50 || {_bloodPressureH < 60}) exitWith { false }; + +private _heartRate = GET_HEART_RATE(_unit); +if (_heartRate < 70 || _heartRate > 100) exitWith { false }; + +private _o2 = GET_KAT_SPO2(_unit); +if (_o2 < EGVAR(breathing,Stable_spo2)) exitWith { false }; + +private _fractures = _unit getVariable [QEGVAR(surgery,fractures), [0,0,0,0,0,0]]; +if (({_x == 0} count _fracture) != 6) exitWith { false }; + +true \ No newline at end of file diff --git a/addons/conversion/functions/fnc_libConversion.sqf b/addons/conversion/functions/fnc_libConversion.sqf new file mode 100644 index 000000000..3045283de --- /dev/null +++ b/addons/conversion/functions/fnc_libConversion.sqf @@ -0,0 +1,25 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_this"]; + +private _storageAreas = (([_this] call KPLIB_fnc_getNearestFob) nearobjects (GRLIB_fob_range)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0}; +private _crate = [KP_liberation_supplyCrate, 100, [[getPos _this] select 0, [getPos _this] select 1, 10000]]; + +{ + if ([_crate, _storage] call KPLIB_fnc_crateToStorage) then { break }; +} forEach _storageAreas; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf new file mode 100644 index 000000000..610cb2d5a --- /dev/null +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -0,0 +1,27 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_this"]; + +if !(_this getVariable [QGVAR(convert), false]) exitWith { false }; + +if (isNil GRLIB_fob_range) exitWith { false }; +if ((_this distance2d ([_this] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) exitWith { false }; + +if !([_this] call EFUNC(vitals,hasStableVitals)) exitWith { false }; + +true \ No newline at end of file diff --git a/addons/conversion/functions/fnc_setDead.sqf b/addons/conversion/functions/fnc_setDead.sqf new file mode 100644 index 000000000..4c034aa67 --- /dev/null +++ b/addons/conversion/functions/fnc_setDead.sqf @@ -0,0 +1,57 @@ +#include "..\script_component.hpp" +/* + * Author: commy2 + * Kills a local unit. + * + * Arguments: + * 0: The unit + * 1: Reason for death + * 2: Killer + * 3: Instigator + * + * Return Value: + * None + * + * Public: No + */ + +params ["_unit", ["_reason", "#setDead"], ["_source", objNull], ["_instigator", objNull]]; +TRACE_4("setDead",_unit,_reason,_source,_instigator); + +// If patient is marked for conversion, send them into arrest rather than killing them if the reason for dying is that they are AI +private _convert = _unit getVariable [QEGVAR(conversion,convert),false]; +if (_convert && (_reason isEqualTo "CardiacArrest:DeathAI" || _reason isEqualTo "Unconscious:DeathAI")) exitWith { + [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "CardiacArrest"] call CBA_statemachine_fnc_manualTransition; +}; + +// No heart rate or blood pressure to measure when dead +_unit setVariable [VAR_HEART_RATE, 0, true]; +_unit setVariable [VAR_BLOOD_PRESS, [0, 0], true]; + +// Clear uncon variable just to be safe +_unit setVariable [VAR_UNCON, nil, true]; + +_unit setVariable [QACEGVAR(medical,causeOfDeath), _reason, true]; + +// Send a local event before death +[QACEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; + +// Update the state machine if necessary (forced respawn, scripted death, etc) +private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; +if (_unitState isNotEqualTo "Dead") then { + [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "Dead"] call CBA_statemachine_fnc_manualTransition; +}; + +// (#8803) Reenable damage if disabled to prevent having live units in dead state +// Keep this after death event for compatibility with third party hooks +if (!isDamageAllowed _unit) then { + WARNING_1("setDead executed on unit with damage blocked - %1",_this); + _unit allowDamage true; +}; + +// Kill the unit without changing visual apperance +private _prevDamage = _unit getHitPointDamage "HitHead"; + +_unit setHitPointDamage ["HitHead", 1, true, _source, _instigator]; + +_unit setHitPointDamage ["HitHead", _prevDamage, true, _source, _instigator]; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_ticketConversion.sqf b/addons/conversion/functions/fnc_ticketConversion.sqf new file mode 100644 index 000000000..1797b992b --- /dev/null +++ b/addons/conversion/functions/fnc_ticketConversion.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_this"]; + +private _unitSide = side _this; + +[_unitSide, 2] call BIS_fnc_respawnTickets; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_ticketConversionCondition.sqf b/addons/conversion/functions/fnc_ticketConversionCondition.sqf new file mode 100644 index 000000000..c3b0a3f99 --- /dev/null +++ b/addons/conversion/functions/fnc_ticketConversionCondition.sqf @@ -0,0 +1,24 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_this"]; + +if !(_this getVariable [QGVAR(convert), false]) exitWith { false }; +if !(_this call ACEFUNC(medical_treatment,isInMedicalFacility)) exitWith { false }; +if !([_this] call EFUNC(vitals,hasStableVitals)) exitWith { false }; + +true \ No newline at end of file diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index 20514f3d0..909a4cd6e 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -1,8 +1,14 @@ - + Activate Casualty Conversion + + Convert Casualty to Tickets + + + Convert Casualty to Liberation Supply + diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index b605dea1a..2776b0d43 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -159,15 +159,22 @@ switch (true) do { }; case (IN_CRDC_ARRST(_unit)): {}; // if in cardiac arrest just break now to avoid throwing unneeded events case ((_spo2 < EGVAR(breathing,SpO2_cardiacValue)) && EGVAR(breathing,SpO2_cardiacActive)): { + TRACE_2("SpO2 below Cardiac Value",_unit,_spo2); + if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { + ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; + }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; case (_hemorrhage == 4): { TRACE_3("Class IV Hemorrhage",_unit,_hemorrhage,_bloodVolume); + if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { + ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; + }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; case (_heartRate < 20 || {_heartRate > 90}): { TRACE_2("heartRate Fatal",_unit,_heartRate); - if (_unit getVariable [QEGVAR(conversion,convert), false]) then { + if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; diff --git a/addons/vitals/functions/fnc_hasStableVitals.sqf b/addons/vitals/functions/fnc_hasStableVitals.sqf index 482ae65b3..ef75dd864 100644 --- a/addons/vitals/functions/fnc_hasStableVitals.sqf +++ b/addons/vitals/functions/fnc_hasStableVitals.sqf @@ -24,7 +24,7 @@ if IN_CRDC_ARRST(_unit) exitWith { false }; if (_unit getVariable [QEGVAR(surgery,sedated), false]) exitWith { false }; if (_unit getVariable [QEGVAR(surgery,reboa), false]) exitWith { false }; -if (_unit getVariable [QEGVAR(conversion,conversion),false]) exitWith { false }; +if (_unit getVariable [QEGVAR(conversion,convert),false]) exitWith { false }; private _cardiacOutput = [_unit] call ACEFUNC(medical_status,getCardiacOutput); private _bloodLoss = _unit call ACEFUNC(medical_status,getBloodLoss); From 010fd884bc95e1feadbf610c853f93e5a740eb62 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:32:14 -0800 Subject: [PATCH 05/28] Extension --- addons/conversion/functions/fnc_libConversionCondition.sqf | 4 ++-- addons/conversion/functions/fnc_ticketConversionCondition.sqf | 4 ++-- addons/vitals/functions/fnc_hasStableVitals.sqf | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf index 610cb2d5a..9f05f6c5f 100644 --- a/addons/conversion/functions/fnc_libConversionCondition.sqf +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -17,11 +17,11 @@ params ["_this"]; -if !(_this getVariable [QGVAR(convert), false]) exitWith { false }; +if !(_this getVariable [QGVAR(currentConverted), false]) exitWith { false }; if (isNil GRLIB_fob_range) exitWith { false }; if ((_this distance2d ([_this] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) exitWith { false }; -if !([_this] call EFUNC(vitals,hasStableVitals)) exitWith { false }; +if !([_this] call FUNC(conversionCondition)) exitWith { false }; true \ No newline at end of file diff --git a/addons/conversion/functions/fnc_ticketConversionCondition.sqf b/addons/conversion/functions/fnc_ticketConversionCondition.sqf index c3b0a3f99..f74804873 100644 --- a/addons/conversion/functions/fnc_ticketConversionCondition.sqf +++ b/addons/conversion/functions/fnc_ticketConversionCondition.sqf @@ -17,8 +17,8 @@ params ["_this"]; -if !(_this getVariable [QGVAR(convert), false]) exitWith { false }; +if !(_this getVariable [QGVAR(currentConverted), false]) exitWith { false }; if !(_this call ACEFUNC(medical_treatment,isInMedicalFacility)) exitWith { false }; -if !([_this] call EFUNC(vitals,hasStableVitals)) exitWith { false }; +if !([_this] call FUNC(conversionCondition)) exitWith { false }; true \ No newline at end of file diff --git a/addons/vitals/functions/fnc_hasStableVitals.sqf b/addons/vitals/functions/fnc_hasStableVitals.sqf index ef75dd864..7e096050e 100644 --- a/addons/vitals/functions/fnc_hasStableVitals.sqf +++ b/addons/vitals/functions/fnc_hasStableVitals.sqf @@ -40,4 +40,4 @@ if (_heartRate < 40) exitWith { false }; private _o2 = GET_KAT_SPO2(_unit); if (_o2 < EGVAR(breathing,Stable_spo2)) exitWith { false }; -true +true \ No newline at end of file From f89b676bc7c1b51da19f6110ff208e0dd6f59ff7 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:18:58 -0800 Subject: [PATCH 06/28] Diag_log remove --- addons/conversion/XEH_PREP.hpp | 1 + addons/conversion/functions/fnc_conditionSecondChance.sqf | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/conversion/XEH_PREP.hpp b/addons/conversion/XEH_PREP.hpp index 5a2a956ee..53127dd88 100644 --- a/addons/conversion/XEH_PREP.hpp +++ b/addons/conversion/XEH_PREP.hpp @@ -3,6 +3,7 @@ PREP(init); PREP(handleRespawn); PREP(conditionSecondChance); PREP(conversionCheck); +PREP(conversionCondition); PREP(conditionExecutionDeath); PREP(setDead); PREP(ticketConversion); diff --git a/addons/conversion/functions/fnc_conditionSecondChance.sqf b/addons/conversion/functions/fnc_conditionSecondChance.sqf index 0bd422aee..f9aa9e4eb 100644 --- a/addons/conversion/functions/fnc_conditionSecondChance.sqf +++ b/addons/conversion/functions/fnc_conditionSecondChance.sqf @@ -17,10 +17,7 @@ params ["_unit"]; -diag_log "CHANCE"; - if (isPlayer _unit || (_unit getVariable [QGVAR(convert), false])) then { - diag_log "SECOND CHANCE"; ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_ALWAYS } else { ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_ALWAYS From 234172d97599feebd277ecf85357fe209d1c6700 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:28:17 -0800 Subject: [PATCH 07/28] Mechanics --- .../ACE_Medical_Treatment_Actions.hpp | 16 ++++ addons/conversion/XEH_postInit.sqf | 1 + addons/conversion/XEH_preInit.sqf | 87 +++++++++++++++++-- addons/conversion/config.cpp | 1 + .../functions/fnc_libConversion.sqf | 7 +- .../functions/fnc_libConversionCondition.sqf | 3 + .../functions/fnc_manualConversion.sqf | 20 +++++ .../fnc_manualConversionCondition.sqf | 22 +++++ .../functions/fnc_ticketConversion.sqf | 5 +- .../fnc_ticketConversionCondition.sqf | 4 + addons/conversion/script_component.hpp | 2 +- addons/conversion/stringtable.xml | 70 ++++++++++++++- addons/gui/functions/fnc_updateInjuryList.sqf | 4 + 13 files changed, 230 insertions(+), 12 deletions(-) create mode 100644 addons/conversion/ACE_Medical_Treatment_Actions.hpp create mode 100644 addons/conversion/functions/fnc_manualConversion.sqf create mode 100644 addons/conversion/functions/fnc_manualConversionCondition.sqf diff --git a/addons/conversion/ACE_Medical_Treatment_Actions.hpp b/addons/conversion/ACE_Medical_Treatment_Actions.hpp new file mode 100644 index 000000000..afebaf992 --- /dev/null +++ b/addons/conversion/ACE_Medical_Treatment_Actions.hpp @@ -0,0 +1,16 @@ +class ACE_Medical_Treatment_Actions { + class CheckPulse; + class BasicBandage; + class ConvertPatient: CheckPulse { + displayName = CSTRING(convertPatient); + displayNameProgress = CSTRING(converting); + condition = QFUNC(manualConversionCondition); + category = "examine"; + medicRequired = QGVAR(manualConversionLevel); + treatmentLocations = QGVAR(manualConversionLocation); + treatmentTime = 10; + allowedSelections[] = {"Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"}; + items[] = {""}; + callbackSuccess = QFUNC(manualConversion); + }; +}; diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index a63d72338..2ca941eb9 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -30,4 +30,5 @@ private _group2 = createGroup [(side _previousUnit), true]; [_previousUnit] join _group2; _group2 setGroupOwner 2; + [_previousUnit, true] call ACEFUNC(medical_engine,setUnconsciousAnim); }] call CBA_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf index 6a0095f6b..a0d0d3bc8 100644 --- a/addons/conversion/XEH_preInit.sqf +++ b/addons/conversion/XEH_preInit.sqf @@ -14,19 +14,96 @@ ACEGVAR(medical,STATE_MACHINE) = (configFile >> "KAT_StateMachine") call CBA_sta [ QGVAR(enable), "CHECKBOX", - [LLSTRING(CONVERSION_ENABLE), LLSTRING(CONVERSION_ENABLE_DISC)], + [LLSTRING(CONVERSION_ENABLE), LLSTRING(CONVERSION_ENABLE_DESC)], [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], [false], true ] call CBA_Settings_fnc_init; -/*[ - QGVAR(enableConversionArrest), +[ + QGVAR(enableTicketConversion), + "CHECKBOX", + [LLSTRING(CONVERSION_TICKET_CONVERSION), LLSTRING(CONVERSION_TICKET_CONVERSION_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [false], + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(ticketConversionGain), + "SLIDER", + [LLSTRING(CONVERSION_TICKET_CONVERSION_GAIN), LLSTRING(CONVERSION_TICKET_CONVERSION_GAIN_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [0, 10, 3, 0], + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(enableLiberationConversion), + "CHECKBOX", + [LLSTRING(CONVERSION_LIBERATION_CONVERSION), LLSTRING(CONVERSION_LIBERATION_CONVERSION_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [false], + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(enableLiberationConversionGain), + "SLIDER", + [LLSTRING(CONVERSION_LIBERATION_CONVERSION_GAIN), LLSTRING(CONVERSION_LIBERATION_CONVERSION_GAIN_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [0, 100, 50, 0], + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(forceVehicleConversion), + "CHECKBOX", + [LLSTRING(CONVERSION_FORCE_VEHICLE), LLSTRING(CONVERSION_FORCE_VEHICLE_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [false], + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(convertVehicles), + "EDITBOX", + [LLSTRING(CONVERSION_FORCE_VEHICLE_LIST), LLSTRING(CONVERSION_FORCE_VEHICLE_LIST_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + "'kat_stretcher'", + 1, + { + private _array = [_this, "CfgVehicles"] call EFUNC(chemical,getList); + missionNamespace setVariable [QGVAR(convertVehicles), _array, true]; + }, + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(allowManualConversion), "CHECKBOX", - [LLSTRING(CONVERSION_ARREST_ENABLE), LLSTRING(CCONVERSION_ARREST_ENABLE_DISC)], + [LLSTRING(CONVERSION_MANUAL_CONVERSION), LLSTRING(CONVERSION_MANUAL_CONVERSION_DESC)], [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], [false], true -] call CBA_Settings_fnc_init;*/ +] call CBA_Settings_fnc_init; + +[ + QGVAR(manualConversionLevel), + "LIST", + [LLSTRING(CONVERSION_MANUAL_CONVERSION_LEVEL), LLSTRING(CONVERSION_MANUAL_CONVERSION_LEVEL_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [[0, 1, 2], ["STR_ACE_Medical_Treatment_Anyone", "STR_ACE_Medical_Treatment_Medics", "STR_ACE_Medical_Treatment_Doctors"], 0], + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(manualConversionLocation), + "LIST", + [LLSTRING(CONVERSION_MANUAL_CONVERSION_LOCATION), LLSTRING(CONVERSION_MANUAL_CONVERSION_LOCATION_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [[0,1,2,3],["STR_ACE_Common_Anywhere", "STR_ACE_Common_Vehicle", "STR_ACE_Medical_Treatment_MedicalFacilities", "STR_ACE_Medical_Treatment_VehiclesAndFacilities"],0], + true +] call CBA_Settings_fnc_init; ADDON = true; \ No newline at end of file diff --git a/addons/conversion/config.cpp b/addons/conversion/config.cpp index 884dec87e..eb41c67b0 100644 --- a/addons/conversion/config.cpp +++ b/addons/conversion/config.cpp @@ -33,3 +33,4 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgFunctions.hpp" #include "CfgVehicles.hpp" +#include "ACE_Medical_Treatment_Actions.hpp" diff --git a/addons/conversion/functions/fnc_libConversion.sqf b/addons/conversion/functions/fnc_libConversion.sqf index 3045283de..68cab4753 100644 --- a/addons/conversion/functions/fnc_libConversion.sqf +++ b/addons/conversion/functions/fnc_libConversion.sqf @@ -18,8 +18,11 @@ params ["_this"]; private _storageAreas = (([_this] call KPLIB_fnc_getNearestFob) nearobjects (GRLIB_fob_range)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0}; -private _crate = [KP_liberation_supplyCrate, 100, [[getPos _this] select 0, [getPos _this] select 1, 10000]]; +private _crate = [KP_liberation_supplyCrate, GVAR(enableLiberationConversionGain), [[getPos _this] select 0, [getPos _this] select 1, 10000]]; { if ([_crate, _storage] call KPLIB_fnc_crateToStorage) then { break }; -} forEach _storageAreas; \ No newline at end of file +} forEach _storageAreas; + +_this setDamage 1; +deleteVehicle _this; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf index 9f05f6c5f..f7280ed91 100644 --- a/addons/conversion/functions/fnc_libConversionCondition.sqf +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -17,6 +17,7 @@ params ["_this"]; +if !(GVAR(enableLiberationConversion)) exitWith { false }; if !(_this getVariable [QGVAR(currentConverted), false]) exitWith { false }; if (isNil GRLIB_fob_range) exitWith { false }; @@ -24,4 +25,6 @@ if ((_this distance2d ([_this] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) if !([_this] call FUNC(conversionCondition)) exitWith { false }; +if (GVAR(forceVehicleConversion) && ((isNull objectParent _this) || !((objectParent _this) in GVAR(convertVehicles)))) exitWith { false }; + true \ No newline at end of file diff --git a/addons/conversion/functions/fnc_manualConversion.sqf b/addons/conversion/functions/fnc_manualConversion.sqf new file mode 100644 index 000000000..944397497 --- /dev/null +++ b/addons/conversion/functions/fnc_manualConversion.sqf @@ -0,0 +1,20 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + + params ["_medic", "_patient"]; + +["kat_conversion_convertCasualty", _patient] call CBA_fnc_localEvent; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_manualConversionCondition.sqf b/addons/conversion/functions/fnc_manualConversionCondition.sqf new file mode 100644 index 000000000..6f45f9d55 --- /dev/null +++ b/addons/conversion/functions/fnc_manualConversionCondition.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: mharis001 + * Condition for going into cardiac arrest upon receiving a fatal injury. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * + * Public: No + */ + +params ["_medic", "_patient"]; + +if !(IS_UNCONSCIOUS(_patient)) exitWith { false }; + +true \ No newline at end of file diff --git a/addons/conversion/functions/fnc_ticketConversion.sqf b/addons/conversion/functions/fnc_ticketConversion.sqf index 1797b992b..8ac6b7a86 100644 --- a/addons/conversion/functions/fnc_ticketConversion.sqf +++ b/addons/conversion/functions/fnc_ticketConversion.sqf @@ -17,6 +17,7 @@ params ["_this"]; -private _unitSide = side _this; +[(side _this), GVAR(ticketConversionGain)] call BIS_fnc_respawnTickets; -[_unitSide, 2] call BIS_fnc_respawnTickets; \ No newline at end of file +_this setDamage 1; +deleteVehicle _this; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_ticketConversionCondition.sqf b/addons/conversion/functions/fnc_ticketConversionCondition.sqf index f74804873..d0681199e 100644 --- a/addons/conversion/functions/fnc_ticketConversionCondition.sqf +++ b/addons/conversion/functions/fnc_ticketConversionCondition.sqf @@ -17,8 +17,12 @@ params ["_this"]; +if !(GVAR(enableTicketConversion)) exitWith { false }; if !(_this getVariable [QGVAR(currentConverted), false]) exitWith { false }; + if !(_this call ACEFUNC(medical_treatment,isInMedicalFacility)) exitWith { false }; if !([_this] call FUNC(conversionCondition)) exitWith { false }; +if (GVAR(forceVehicleConversion) && ((isNull objectParent _this) || !((objectParent _this) in GVAR(convertVehicles)))) exitWith { false }; + true \ No newline at end of file diff --git a/addons/conversion/script_component.hpp b/addons/conversion/script_component.hpp index bb629e9e6..792efc6cd 100644 --- a/addons/conversion/script_component.hpp +++ b/addons/conversion/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED KAT - Conversion #include "\x\kat\addons\main\script_mod.hpp" - #define DEBUG_MODE_FULL +// #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index 909a4cd6e..08e8a7fde 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -1,8 +1,68 @@ - - Activate Casualty Conversion + + Enable Casualty Conversion + + + Enables Casualty Conversion for Players and Select AI + + + Ticket for Patient Conversion + + + Enables ticket gain when converting casualties + + + Tickets Gained + + + How many tickets should be regained when converting patients + + + Liberation Supply for Patient Conversion + + + Enables supply gain when converting casualties + + + Supply Gained + + + How much supply should be gien when converting patients + + + Force Vehicle Conversion + + + Should patients only be allowed to be converted when in a vehicle? + + + Conversion Vehicles + + + List of vehicles that can be used for conversion + + + Enable Manual Initial Conversion + + + Enables manual initial conversion by medical personnel + + + Medical Level for Conversion + + + What level should a player be in order to perform an initial conversion + + + Location for Conversion + + + What medical facility should a player be in order to perform an initial conversion + + + Converted Convert Casualty to Tickets @@ -10,5 +70,11 @@ Convert Casualty to Liberation Supply + + Perform Initial Conversion + + + Converting + diff --git a/addons/gui/functions/fnc_updateInjuryList.sqf b/addons/gui/functions/fnc_updateInjuryList.sqf index 55511183e..dbec751ef 100644 --- a/addons/gui/functions/fnc_updateInjuryList.sqf +++ b/addons/gui/functions/fnc_updateInjuryList.sqf @@ -132,6 +132,10 @@ if (_target call ACEFUNC(common,isAwake)) then { }; }; +if (_target getVariable [QEGVAR(conversion,currentConverted),false]) then { + _entries pushBack [LELSTRING(conversion,ConversionText), [0.35, 0.72, 0.82, 1]]; +}; + // Skip the rest as they're body part specific if (_selectionN == -1) exitWith { // Add all entries to injury list From 8dd814465e1ba4a06680b25aaa6bbea5a7d11747 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:30:37 -0800 Subject: [PATCH 08/28] Update stringtable.xml --- addons/conversion/stringtable.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index 08e8a7fde..8285f9bf0 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -55,10 +55,10 @@ What level should a player be in order to perform an initial conversion - + Location for Conversion - + What medical facility should a player be in order to perform an initial conversion From 6f2b196033fac2912ab1b7b693260b662b3aa974 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:38:46 -0800 Subject: [PATCH 09/28] Headers --- addons/conversion/functions/fnc_conditionExecutionDeath.sqf | 3 ++- addons/conversion/functions/fnc_conditionSecondChance.sqf | 3 ++- addons/conversion/functions/fnc_conversionCheck.sqf | 6 +++--- addons/conversion/functions/fnc_conversionCondition.sqf | 6 +++--- addons/conversion/functions/fnc_libConversion.sqf | 6 +++--- addons/conversion/functions/fnc_libConversionCondition.sqf | 6 +++--- addons/conversion/functions/fnc_manualConversion.sqf | 6 +++--- .../conversion/functions/fnc_manualConversionCondition.sqf | 6 +++--- addons/conversion/functions/fnc_setDead.sqf | 1 + addons/conversion/functions/fnc_ticketConversion.sqf | 6 +++--- .../conversion/functions/fnc_ticketConversionCondition.sqf | 6 +++--- 11 files changed, 29 insertions(+), 26 deletions(-) diff --git a/addons/conversion/functions/fnc_conditionExecutionDeath.sqf b/addons/conversion/functions/fnc_conditionExecutionDeath.sqf index d6dbdb890..d58def2d9 100644 --- a/addons/conversion/functions/fnc_conditionExecutionDeath.sqf +++ b/addons/conversion/functions/fnc_conditionExecutionDeath.sqf @@ -1,6 +1,7 @@ #include "..\script_component.hpp" /* * Author: mharis001 + * Edited: Mazinski.H * Condition for going into cardiac arrest upon receiving a fatal injury. * * Arguments: @@ -10,7 +11,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_conditionSecondChance * * Public: No */ diff --git a/addons/conversion/functions/fnc_conditionSecondChance.sqf b/addons/conversion/functions/fnc_conditionSecondChance.sqf index f9aa9e4eb..b2191aff8 100644 --- a/addons/conversion/functions/fnc_conditionSecondChance.sqf +++ b/addons/conversion/functions/fnc_conditionSecondChance.sqf @@ -1,6 +1,7 @@ #include "..\script_component.hpp" /* * Author: mharis001 + * Edited: Mazinski.H * Condition for going into cardiac arrest upon receiving a fatal injury. * * Arguments: @@ -10,7 +11,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_conditionSecondChance * * Public: No */ diff --git a/addons/conversion/functions/fnc_conversionCheck.sqf b/addons/conversion/functions/fnc_conversionCheck.sqf index d51c9b144..0dff7117d 100644 --- a/addons/conversion/functions/fnc_conversionCheck.sqf +++ b/addons/conversion/functions/fnc_conversionCheck.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: mharis001 - * Condition for going into cardiac arrest upon receiving a fatal injury. + * Author: Mazinski + * Condition for automatic conversion * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_conversionCheck * * Public: No */ diff --git a/addons/conversion/functions/fnc_conversionCondition.sqf b/addons/conversion/functions/fnc_conversionCondition.sqf index c39e1c4d2..bb52c3b29 100644 --- a/addons/conversion/functions/fnc_conversionCondition.sqf +++ b/addons/conversion/functions/fnc_conversionCondition.sqf @@ -1,13 +1,13 @@ #include "..\script_component.hpp" /* - * Author: Ruthberg - * Check if a unit can be converted back into resources + * Author: Mazinski + * Check if a unit is in a stable state for resource conversion * * Arguments: * 0: The patient * * Return Value: - * Has stable vitals + * Has no critical health conditions * * Example: * [player] call kat_conversion_conversionCondition diff --git a/addons/conversion/functions/fnc_libConversion.sqf b/addons/conversion/functions/fnc_libConversion.sqf index 68cab4753..c978c0c7c 100644 --- a/addons/conversion/functions/fnc_libConversion.sqf +++ b/addons/conversion/functions/fnc_libConversion.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: mharis001 - * Condition for going into cardiac arrest upon receiving a fatal injury. + * Author: Mazinski + * Converts patient to Liberation Supply * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_libConversion * * Public: No */ diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf index f7280ed91..3ad6b4329 100644 --- a/addons/conversion/functions/fnc_libConversionCondition.sqf +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: mharis001 - * Condition for going into cardiac arrest upon receiving a fatal injury. + * Author: Mazinski + * Checks if patient can be converted into Liberation Supply * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_libConversionCondition * * Public: No */ diff --git a/addons/conversion/functions/fnc_manualConversion.sqf b/addons/conversion/functions/fnc_manualConversion.sqf index 944397497..785c841f4 100644 --- a/addons/conversion/functions/fnc_manualConversion.sqf +++ b/addons/conversion/functions/fnc_manualConversion.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: mharis001 - * Condition for going into cardiac arrest upon receiving a fatal injury. + * Author: Mazinski + * Performs initial patient conversion * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_manualConversion * * Public: No */ diff --git a/addons/conversion/functions/fnc_manualConversionCondition.sqf b/addons/conversion/functions/fnc_manualConversionCondition.sqf index 6f45f9d55..a5bf2a211 100644 --- a/addons/conversion/functions/fnc_manualConversionCondition.sqf +++ b/addons/conversion/functions/fnc_manualConversionCondition.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: mharis001 - * Condition for going into cardiac arrest upon receiving a fatal injury. + * Author: Mazinski + * Checks if patient can be manually converted * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_manualConversionCondition * * Public: No */ diff --git a/addons/conversion/functions/fnc_setDead.sqf b/addons/conversion/functions/fnc_setDead.sqf index 4c034aa67..78aa8fea0 100644 --- a/addons/conversion/functions/fnc_setDead.sqf +++ b/addons/conversion/functions/fnc_setDead.sqf @@ -1,6 +1,7 @@ #include "..\script_component.hpp" /* * Author: commy2 + * Edited: Mazinski * Kills a local unit. * * Arguments: diff --git a/addons/conversion/functions/fnc_ticketConversion.sqf b/addons/conversion/functions/fnc_ticketConversion.sqf index 8ac6b7a86..ce0d9552d 100644 --- a/addons/conversion/functions/fnc_ticketConversion.sqf +++ b/addons/conversion/functions/fnc_ticketConversion.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: mharis001 - * Condition for going into cardiac arrest upon receiving a fatal injury. + * Author: Mazinski + * Converts patient to respawn tickets * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_ticketConversion * * Public: No */ diff --git a/addons/conversion/functions/fnc_ticketConversionCondition.sqf b/addons/conversion/functions/fnc_ticketConversionCondition.sqf index d0681199e..cd870de98 100644 --- a/addons/conversion/functions/fnc_ticketConversionCondition.sqf +++ b/addons/conversion/functions/fnc_ticketConversionCondition.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: mharis001 - * Condition for going into cardiac arrest upon receiving a fatal injury. + * Author: Mazinski + * Checks if patient can be converted into respawn tickets * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance + * [player] call kat_conversion_fnc_ticketConversionCondition * * Public: No */ From f4119655aad04ed22ada3881f9b5c6f6b0838a81 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:43:45 -0800 Subject: [PATCH 10/28] Update fnc_handleUnitVitals.sqf --- addons/vitals/functions/fnc_handleUnitVitals.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 2776b0d43..ba8862e20 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -172,7 +172,7 @@ switch (true) do { }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 90}): { + case (_heartRate < 20 || {_heartRate > 180}): { TRACE_2("heartRate Fatal",_unit,_heartRate); if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; From a0d0d73c375d54b8ae5a6523b8b8327d597ea9b2 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:46:55 -0800 Subject: [PATCH 11/28] Errors --- addons/conversion/XEH_postInit.sqf | 34 +++++++++---------- .../functions/fnc_conversionCheck.sqf | 4 +-- .../functions/fnc_fullHealLocal.sqf | 2 +- .../functions/fnc_libConversion.sqf | 10 +++--- .../functions/fnc_libConversionCondition.sqf | 10 +++--- .../functions/fnc_ticketConversion.sqf | 8 ++--- .../fnc_ticketConversionCondition.sqf | 10 +++--- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index 2ca941eb9..3159b54ba 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -4,31 +4,31 @@ [QACEGVAR(medical_treatment,fullHealLocalMod), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler; ["kat_conversion_convertCasualty", { - private _type = typeOf player; - private _group = createGroup [(side player), true]; - private _previousUnit = player; - private _setName = name _previousUnit; - private _loadout = getUnitLoadout player; - private _unit = _group createUnit [_type, [0,0,0], [], 0, "NONE"]; - _unit setUnitLoadout _loadout; + private _type = typeOf player; + private _group = createGroup [(side player), true]; + private _previousUnit = player; + private _setName = name _previousUnit; + private _loadout = getUnitLoadout player; + private _unit = _group createUnit [_type, [0,0,0], [], 0, "NONE"]; + _unit setUnitLoadout _loadout; - _previousUnit setVariable [QEGVAR(vitals,simpleMedical), false, true]; - _previousUnit setVariable [QGVAR(currentConverted), true, true]; + _previousUnit setVariable [QEGVAR(vitals,simpleMedical), false, true]; + _previousUnit setVariable [QGVAR(currentConverted), true, true]; - selectPlayer _unit; + selectPlayer _unit; - ["kat_conversion_unitTransfer", [_previousUnit]] call CBA_fnc_serverEvent; + ["kat_conversion_unitTransfer", [_previousUnit]] call CBA_fnc_serverEvent; - _previousUnit setName _setName; + _previousUnit setName _setName; - _unit setDamage 1; - deleteVehicle _unit; + _unit setDamage 1; + deleteVehicle _unit; }] call CBA_fnc_addEventHandler; ["kat_conversion_unitTransfer", { params ["_previousUnit"]; private _group2 = createGroup [(side _previousUnit), true]; - [_previousUnit] join _group2; - _group2 setGroupOwner 2; - [_previousUnit, true] call ACEFUNC(medical_engine,setUnconsciousAnim); + [_previousUnit] join _group2; + _group2 setGroupOwner 2; + [_previousUnit, true] call ACEFUNC(medical_engine,setUnconsciousAnim); }] call CBA_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_conversionCheck.sqf b/addons/conversion/functions/fnc_conversionCheck.sqf index 0dff7117d..9a476b11d 100644 --- a/addons/conversion/functions/fnc_conversionCheck.sqf +++ b/addons/conversion/functions/fnc_conversionCheck.sqf @@ -15,9 +15,9 @@ * Public: No */ -params ["_this"]; +params ["_patient"]; -if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!(_this getVariable [QEGVAR(conversion,convert),false])) && {!isPlayer _this}) exitWith { +if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!(_patient getVariable [QGVAR(convert),false])) && {!isPlayer _patient}) exitWith { true }; diff --git a/addons/conversion/functions/fnc_fullHealLocal.sqf b/addons/conversion/functions/fnc_fullHealLocal.sqf index 6dfce3805..3183ebdf3 100644 --- a/addons/conversion/functions/fnc_fullHealLocal.sqf +++ b/addons/conversion/functions/fnc_fullHealLocal.sqf @@ -18,7 +18,7 @@ params ["_patient"]; if (hasInterface && GVAR(enable)) then { - _patient setVariable [QGVAR(convert), true, true]; + _patient setVariable [QGVAR(convert), true, true]; }; _patient setVariable [QGVAR(currentConverted), false, true]; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_libConversion.sqf b/addons/conversion/functions/fnc_libConversion.sqf index c978c0c7c..52a5be083 100644 --- a/addons/conversion/functions/fnc_libConversion.sqf +++ b/addons/conversion/functions/fnc_libConversion.sqf @@ -15,14 +15,14 @@ * Public: No */ -params ["_this"]; +params ["_patient"]; -private _storageAreas = (([_this] call KPLIB_fnc_getNearestFob) nearobjects (GRLIB_fob_range)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0}; -private _crate = [KP_liberation_supplyCrate, GVAR(enableLiberationConversionGain), [[getPos _this] select 0, [getPos _this] select 1, 10000]]; +private _storageAreas = (([_patient] call KPLIB_fnc_getNearestFob) nearobjects (GRLIB_fob_range)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0}; +private _crate = [KP_liberation_supplyCrate, GVAR(enableLiberationConversionGain), [[getPos _patient] select 0, [getPos _patient] select 1, 10000]]; { if ([_crate, _storage] call KPLIB_fnc_crateToStorage) then { break }; } forEach _storageAreas; -_this setDamage 1; -deleteVehicle _this; \ No newline at end of file +_patient setDamage 1; +deleteVehicle _patient; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf index 3ad6b4329..01c3f1a82 100644 --- a/addons/conversion/functions/fnc_libConversionCondition.sqf +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -15,16 +15,16 @@ * Public: No */ -params ["_this"]; +params ["_patient"]; if !(GVAR(enableLiberationConversion)) exitWith { false }; -if !(_this getVariable [QGVAR(currentConverted), false]) exitWith { false }; +if !(_patient getVariable [QGVAR(currentConverted), false]) exitWith { false }; if (isNil GRLIB_fob_range) exitWith { false }; -if ((_this distance2d ([_this] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) exitWith { false }; +if ((_patient distance2d ([_patient] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) exitWith { false }; -if !([_this] call FUNC(conversionCondition)) exitWith { false }; +if !([_patient] call FUNC(conversionCondition)) exitWith { false }; -if (GVAR(forceVehicleConversion) && ((isNull objectParent _this) || !((objectParent _this) in GVAR(convertVehicles)))) exitWith { false }; +if (GVAR(forceVehicleConversion) && ((isNull objectParent _patient) || !((objectParent _patient) in GVAR(convertVehicles)))) exitWith { false }; true \ No newline at end of file diff --git a/addons/conversion/functions/fnc_ticketConversion.sqf b/addons/conversion/functions/fnc_ticketConversion.sqf index ce0d9552d..9da35e964 100644 --- a/addons/conversion/functions/fnc_ticketConversion.sqf +++ b/addons/conversion/functions/fnc_ticketConversion.sqf @@ -15,9 +15,9 @@ * Public: No */ -params ["_this"]; +params ["_patient"]; -[(side _this), GVAR(ticketConversionGain)] call BIS_fnc_respawnTickets; +[(side _patient), GVAR(ticketConversionGain)] call BIS_fnc_respawnTickets; -_this setDamage 1; -deleteVehicle _this; \ No newline at end of file +_patient setDamage 1; +deleteVehicle _patient; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_ticketConversionCondition.sqf b/addons/conversion/functions/fnc_ticketConversionCondition.sqf index cd870de98..869e3c319 100644 --- a/addons/conversion/functions/fnc_ticketConversionCondition.sqf +++ b/addons/conversion/functions/fnc_ticketConversionCondition.sqf @@ -15,14 +15,14 @@ * Public: No */ -params ["_this"]; +params ["_patient"]; if !(GVAR(enableTicketConversion)) exitWith { false }; -if !(_this getVariable [QGVAR(currentConverted), false]) exitWith { false }; +if !(_patient getVariable [QGVAR(currentConverted), false]) exitWith { false }; -if !(_this call ACEFUNC(medical_treatment,isInMedicalFacility)) exitWith { false }; -if !([_this] call FUNC(conversionCondition)) exitWith { false }; +if !(_patient call ACEFUNC(medical_treatment,isInMedicalFacility)) exitWith { false }; +if !([_patient] call FUNC(conversionCondition)) exitWith { false }; -if (GVAR(forceVehicleConversion) && ((isNull objectParent _this) || !((objectParent _this) in GVAR(convertVehicles)))) exitWith { false }; +if (GVAR(forceVehicleConversion) && ((isNull objectParent _patient) || !((objectParent _patient) in GVAR(convertVehicles)))) exitWith { false }; true \ No newline at end of file From 4fb4d005c34cac42151afd32a69d85f69996b494 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:48:11 -0800 Subject: [PATCH 12/28] Update stringtable.xml --- addons/conversion/stringtable.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index 8285f9bf0..552e2d708 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -16,7 +16,7 @@ Tickets Gained - + How many tickets should be regained when converting patients From c99d9f1e83b6e55798663b1b9b8b8b3f8e2f4f26 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 09:33:04 -0800 Subject: [PATCH 13/28] Update fnc_handleUnitVitals.sqf --- addons/vitals/functions/fnc_handleUnitVitals.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index ba8862e20..9308f5e1c 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -172,7 +172,7 @@ switch (true) do { }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 180}): { + case (_heartRate < 20 || {_heartRate > 220}): { TRACE_2("heartRate Fatal",_unit,_heartRate); if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; From 5d8768ed9241cebd4d54f8a605dc35a8ff7fc987 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 10:12:19 -0800 Subject: [PATCH 14/28] One Life Conversion --- addons/conversion/XEH_preInit.sqf | 9 ++++++++ .../functions/fnc_spectatorRespawn.sqf | 23 +++++++++++++++++++ addons/conversion/stringtable.xml | 6 +++++ 3 files changed, 38 insertions(+) create mode 100644 addons/conversion/functions/fnc_spectatorRespawn.sqf diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf index a0d0d3bc8..a26214ccc 100644 --- a/addons/conversion/XEH_preInit.sqf +++ b/addons/conversion/XEH_preInit.sqf @@ -56,6 +56,15 @@ ACEGVAR(medical,STATE_MACHINE) = (configFile >> "KAT_StateMachine") call CBA_sta true ] call CBA_Settings_fnc_init; +[ + QGVAR(enableSpectatorRespawn), + "CHECKBOX", + [LLSTRING(CONVERSION_SPECTATOR_RESPAWN), LLSTRING(CONVERSION_SPECTATOR_RESPAWN_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [false], + true +] call CBA_Settings_fnc_init; + [ QGVAR(forceVehicleConversion), "CHECKBOX", diff --git a/addons/conversion/functions/fnc_spectatorRespawn.sqf b/addons/conversion/functions/fnc_spectatorRespawn.sqf new file mode 100644 index 000000000..9da35e964 --- /dev/null +++ b/addons/conversion/functions/fnc_spectatorRespawn.sqf @@ -0,0 +1,23 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Converts patient to respawn tickets + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call kat_conversion_fnc_ticketConversion + * + * Public: No + */ + +params ["_patient"]; + +[(side _patient), GVAR(ticketConversionGain)] call BIS_fnc_respawnTickets; + +_patient setDamage 1; +deleteVehicle _patient; \ No newline at end of file diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index 552e2d708..790006536 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -31,6 +31,12 @@ How much supply should be gien when converting patients + + One Life Conversion + + + Prevents spectating players from respawning until their body has been converted + Force Vehicle Conversion From c2bdda8d06b9c63f9f83fbc9d3bdb73d0b76bc3a Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:27:09 -0800 Subject: [PATCH 15/28] Redo Config --- addons/conversion/CfgFunctions.hpp | 11 --- addons/conversion/Statemachine.hpp | 98 +------------------ addons/conversion/XEH_PREP.hpp | 16 +-- addons/conversion/XEH_preInit.sqf | 3 - ...sqf => fnc_KATConditionExecutionDeath.sqf} | 0 ...e.sqf => fnc_KATConditionSecondChance.sqf} | 0 6 files changed, 11 insertions(+), 117 deletions(-) rename addons/conversion/functions/{fnc_conditionExecutionDeath.sqf => fnc_KATConditionExecutionDeath.sqf} (100%) rename addons/conversion/functions/{fnc_conditionSecondChance.sqf => fnc_KATConditionSecondChance.sqf} (100%) diff --git a/addons/conversion/CfgFunctions.hpp b/addons/conversion/CfgFunctions.hpp index f2af58a6a..ee54ec98c 100644 --- a/addons/conversion/CfgFunctions.hpp +++ b/addons/conversion/CfgFunctions.hpp @@ -1,15 +1,4 @@ class CfgFunctions { - class overwrite_ace_medical_statemachine { - tag = "ace_medical_statemachine"; - class ace_medical_statemachine { - class conditionSecondChance { - file = QPATHTOF(functions\fnc_conditionSecondChance.sqf); - }; - class conditionExecutionDeath { - file = QPATHTOF(functions\fnc_conditionExecutionDeath.sqf); - }; - }; - }; class overwrite_ace_medical_status { tag = "ace_medical_status"; class ace_medical_status { diff --git a/addons/conversion/Statemachine.hpp b/addons/conversion/Statemachine.hpp index a4a4aab0a..c0ed36369 100644 --- a/addons/conversion/Statemachine.hpp +++ b/addons/conversion/Statemachine.hpp @@ -1,113 +1,21 @@ // Overwrite for ACE_Medical_StateMachine -class KAT_StateMachine { - list = QUOTE(call ACEFUNC(common,getLocalUnits)); - skipNull = 1; - class Default { - onState = QACEFUNC(medical_statemachine,handleStateDefault); - class Injury { - targetState = "Injured"; - events[] = {QACEGVAR(medical,injured), QACEGVAR(medical,LoweredVitals)}; - }; - class CriticalInjuryOrVitals { - targetState = "Unconscious"; - events[] = {QACEGVAR(medical,CriticalInjury), QACEGVAR(medical,CriticalVitals), QACEGVAR(medical,knockOut)}; - }; - class FatalVitals { - targetState = "CardiacArrest"; - events[] = {QACEGVAR(medical,FatalVitals), QACEGVAR(medical,Bleedout)}; - }; - class FatalInjury { - targetState = "FatalInjury"; - events[] = {QACEGVAR(medical,FatalInjury)}; - }; - }; - class Injured { - onState = QACEFUNC(medical_statemachine,handleStateInjured); - class FullHeal { - targetState = "Default"; - events[] = {QACEGVAR(medical,FullHeal)}; - }; - class CriticalInjuryOrVitals { - targetState = "Unconscious"; - events[] = {QACEGVAR(medical,CriticalInjury), QACEGVAR(medical,CriticalVitals), QACEGVAR(medical,knockOut)}; - }; - class FatalVitals { - targetState = "CardiacArrest"; - events[] = {QACEGVAR(medical,FatalVitals), QACEGVAR(medical,Bleedout)}; - }; - class FatalInjury { - targetState = "FatalInjury"; - events[] = {QACEGVAR(medical,FatalInjury)}; - }; - }; +class ACE_Medical_StateMachine { class Unconscious { - onState = QACEFUNC(medical_statemachine,handleStateUnconscious); - onStateEntered = QACEFUNC(medical_statemachine,enteredStateUnconscious); class DeathAI { - targetState = "Dead"; condition = QFUNC(conversionCheck); }; - class WakeUp { - targetState = "Injured"; - condition = QACEFUNC(medical_status,hasStableVitals); - events[] = {QACEGVAR(medical,WakeUp)}; - onTransition = QUOTE([ARR_2(_this,false)] call ACEFUNC(medical_status,setUnconsciousState)); - }; - class FatalTransitions { - targetState = "CardiacArrest"; - events[] = {QACEGVAR(medical,FatalVitals), QACEGVAR(medical,Bleedout)}; - }; - class FatalInjury { - targetState = "FatalInjury"; - events[] = {QACEGVAR(medical,FatalInjury)}; - }; }; class FatalInjury { - // Transition state for handling instant death from fatal injuries - // This state raises the next transition in the same frame - onStateEntered = QACEFUNC(medical_statemachine,enteredStateFatalInjury); class SecondChance { - events[] = {QACEGVAR(medical,FatalInjuryInstantTransition)}; - targetState = "CardiacArrest"; - condition = QACEFUNC(medical_statemachine,conditionSecondChance); - onTransition = QACEFUNC(medical_statemachine,transitionSecondChance); - }; - class Death { - events[] = {QACEGVAR(medical,FatalInjuryInstantTransition)}; - targetState = "Dead"; + condition = QFUNC(conditionSecondChance); }; }; class CardiacArrest { - onState = QACEFUNC(medical_statemachine,handleStateCardiacArrest); - onStateEntered = QACEFUNC(medical_statemachine,enteredStateCardiacArrest); - onStateLeaving = QACEFUNC(medical_statemachine,leftStateCardiacArrest); class DeathAI { - // If an AI unit reanimates, they will immediately die upon entering unconsciousness if AI Unconsciousness is disabled - // As a result, we immediately kill the AI unit since cardiac arrest is effectively useless for it - targetState = "Dead"; condition = QFUNC(conversionCheck); }; - class Timeout { - targetState = "Dead"; - condition = QACEFUNC(medical_statemachine,conditionCardiacArrestTimer); - }; - class Reanimation { - targetState = "Unconscious"; - events[] = {QACEGVAR(medical,CPRSucceeded)}; - }; class Execution { - targetState = "Dead"; - condition = QACEFUNC(medical_statemachine,conditionExecutionDeath); - events[] = {QACEGVAR(medical,FatalInjury)}; + condition = QFUNC(conditionExecutionDeath); }; - class Bleedout { - targetState = "Dead"; - condition = QUOTE((ACEGVAR(medical_statemachine,cardiacArrestBleedoutEnabled))); // wrap to ensure cba uses this as code and not a direct variable - events[] = {QACEGVAR(medical,Bleedout)}; - }; - }; - class Dead { - // When the unit is killed it's no longer handled by the statemachine - onStateEntered = QACEFUNC(medical_statemachine,enteredStateDeath); }; }; \ No newline at end of file diff --git a/addons/conversion/XEH_PREP.hpp b/addons/conversion/XEH_PREP.hpp index 53127dd88..b17cff96d 100644 --- a/addons/conversion/XEH_PREP.hpp +++ b/addons/conversion/XEH_PREP.hpp @@ -1,12 +1,12 @@ -PREP(fullHealLocal); -PREP(init); -PREP(handleRespawn); -PREP(conditionSecondChance); PREP(conversionCheck); PREP(conversionCondition); -PREP(conditionExecutionDeath); +PREP(fullHealLocal); +PREP(handleRespawn); +PREP(init); +PREP(KATConditionExecutionDeath); +PREP(KATConditionSecondChance); +PREP(libConversion); +PREP(libConversionCondition); PREP(setDead); PREP(ticketConversion); -PREP(ticketConversionCondition); -PREP(libConversion); -PREP(libConversionCondition); \ No newline at end of file +PREP(ticketConversionCondition); \ No newline at end of file diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf index a26214ccc..b27ae315e 100644 --- a/addons/conversion/XEH_preInit.sqf +++ b/addons/conversion/XEH_preInit.sqf @@ -8,9 +8,6 @@ PREP_RECOMPILE_END; #define CBA_SETTINGS_CAT "KAT - ADV Medical: Conversion" -// Overwrite ace statemachine -ACEGVAR(medical,STATE_MACHINE) = (configFile >> "KAT_StateMachine") call CBA_statemachine_fnc_createFromConfig; - [ QGVAR(enable), "CHECKBOX", diff --git a/addons/conversion/functions/fnc_conditionExecutionDeath.sqf b/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf similarity index 100% rename from addons/conversion/functions/fnc_conditionExecutionDeath.sqf rename to addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf diff --git a/addons/conversion/functions/fnc_conditionSecondChance.sqf b/addons/conversion/functions/fnc_KATConditionSecondChance.sqf similarity index 100% rename from addons/conversion/functions/fnc_conditionSecondChance.sqf rename to addons/conversion/functions/fnc_KATConditionSecondChance.sqf From 846f3fcc8ae27b16dda56c5afef88cd48e033778 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 18:04:55 -0800 Subject: [PATCH 16/28] Its broken again --- addons/conversion/Statemachine.hpp | 4 +-- .../fnc_KATConditionExecutionDeath.sqf | 4 +-- .../fnc_KATConditionSecondChance.sqf | 6 ++--- .../functions/fnc_conversionCheck.sqf | 10 +++---- addons/conversion/functions/fnc_setDead.sqf | 3 ++- addons/main/script_macros.hpp | 4 +++ addons/misc/CfgFunctions.hpp | 11 -------- addons/misc/XEH_PREP.hpp | 2 -- .../functions/fnc_conditionExecutionDeath.sqf | 26 ------------------- .../functions/fnc_conditionSecondChance.sqf | 25 ------------------ .../vitals/functions/fnc_handleUnitVitals.sqf | 2 +- addons/vitals/script_component.hpp | 2 +- 12 files changed, 19 insertions(+), 80 deletions(-) delete mode 100644 addons/misc/functions/fnc_conditionExecutionDeath.sqf delete mode 100644 addons/misc/functions/fnc_conditionSecondChance.sqf diff --git a/addons/conversion/Statemachine.hpp b/addons/conversion/Statemachine.hpp index c0ed36369..2635a2f41 100644 --- a/addons/conversion/Statemachine.hpp +++ b/addons/conversion/Statemachine.hpp @@ -7,7 +7,7 @@ class ACE_Medical_StateMachine { }; class FatalInjury { class SecondChance { - condition = QFUNC(conditionSecondChance); + condition = QFUNC(KATConditionSecondChance); }; }; class CardiacArrest { @@ -15,7 +15,7 @@ class ACE_Medical_StateMachine { condition = QFUNC(conversionCheck); }; class Execution { - condition = QFUNC(conditionExecutionDeath); + condition = QFUNC(KATConditionExecutionDeath); }; }; }; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf b/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf index d58def2d9..896e4b08d 100644 --- a/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf +++ b/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf @@ -18,9 +18,9 @@ params ["_unit"]; -(if (isPlayer _unit || (_unit getVariable [QGVAR(convert), false])) then { +(if (isPlayer _unit || GET_CONVERT_STATUS(_unit)) then { ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_NEVER } else { - ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_NEVER + (ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_NEVER) && {!(_unit getVariable [QEGVAR(misc,PreventInstantAIDeath), false])} }) && {!(_unit getVariable [QACEGVAR(medical,deathBlocked), false])} \ No newline at end of file diff --git a/addons/conversion/functions/fnc_KATConditionSecondChance.sqf b/addons/conversion/functions/fnc_KATConditionSecondChance.sqf index b2191aff8..34e675c8b 100644 --- a/addons/conversion/functions/fnc_KATConditionSecondChance.sqf +++ b/addons/conversion/functions/fnc_KATConditionSecondChance.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: mharis001 - * Edited: Mazinski.H + * Edited: Blue, Mazinski.H * Condition for going into cardiac arrest upon receiving a fatal injury. * * Arguments: @@ -18,8 +18,8 @@ params ["_unit"]; -if (isPlayer _unit || (_unit getVariable [QGVAR(convert), false])) then { +if (isPlayer _unit || GET_CONVERT_STATUS(_unit)) then { ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_ALWAYS } else { - ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_ALWAYS + ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_ALWAYS || {_unit getVariable [QEGVAR(misc,PreventInstantAIDeath), false]} } \ No newline at end of file diff --git a/addons/conversion/functions/fnc_conversionCheck.sqf b/addons/conversion/functions/fnc_conversionCheck.sqf index 9a476b11d..1ea2cb72b 100644 --- a/addons/conversion/functions/fnc_conversionCheck.sqf +++ b/addons/conversion/functions/fnc_conversionCheck.sqf @@ -15,10 +15,8 @@ * Public: No */ -params ["_patient"]; +params ["_unit"]; -if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!(_patient getVariable [QGVAR(convert),false])) && {!isPlayer _patient}) exitWith { - true -}; - -false \ No newline at end of file +if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!isPlayer _unit)) then { + GET_CONVERT_STATUS(_unit) != true +} \ No newline at end of file diff --git a/addons/conversion/functions/fnc_setDead.sqf b/addons/conversion/functions/fnc_setDead.sqf index 78aa8fea0..7a7948c7d 100644 --- a/addons/conversion/functions/fnc_setDead.sqf +++ b/addons/conversion/functions/fnc_setDead.sqf @@ -20,6 +20,8 @@ params ["_unit", ["_reason", "#setDead"], ["_source", objNull], ["_instigator", TRACE_4("setDead",_unit,_reason,_source,_instigator); // If patient is marked for conversion, send them into arrest rather than killing them if the reason for dying is that they are AI +private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; + private _convert = _unit getVariable [QEGVAR(conversion,convert),false]; if (_convert && (_reason isEqualTo "CardiacArrest:DeathAI" || _reason isEqualTo "Unconscious:DeathAI")) exitWith { [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "CardiacArrest"] call CBA_statemachine_fnc_manualTransition; @@ -38,7 +40,6 @@ _unit setVariable [QACEGVAR(medical,causeOfDeath), _reason, true]; [QACEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; // Update the state machine if necessary (forced respawn, scripted death, etc) -private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; if (_unitState isNotEqualTo "Dead") then { [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "Dead"] call CBA_statemachine_fnc_manualTransition; }; diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index a0396d871..494add5f4 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -330,6 +330,10 @@ #define VAR_BLOODPRESSURE_CHANGE QEGVAR(circulation,bloodPressureChange) #define GET_BLOODPRESSURE_CHANGE(unit) (unit getVariable [VAR_BLOODPRESSURE_CHANGE, [0,0]]) +// Conversion +#define UNIT_CONVERT QEGVAR(conversion,convert) +#define GET_CONVERT_STATUS(unit) (unit getVariable [UNIT_CONVERT, false]) + // Pharma #define VAR_VASOCONSTRICTION QEGVAR(pharma,alphaAction) #define GET_VASOCONSTRICTION(unit) (unit getVariable [VAR_VASOCONSTRICTION, 1]) diff --git a/addons/misc/CfgFunctions.hpp b/addons/misc/CfgFunctions.hpp index b1b6edfb4..b41cfab86 100644 --- a/addons/misc/CfgFunctions.hpp +++ b/addons/misc/CfgFunctions.hpp @@ -51,15 +51,4 @@ class CfgFunctions { }; }; }; - class overwrite_ace_medical_statemachine { - tag = "ace_medical_statemachine"; - class ace_medical_statemachine { - class conditionExecutionDeath { - file = QPATHTOF(functions\fnc_conditionExecutionDeath.sqf); - }; - class conditionSecondChance { - file = QPATHTOF(functions\fnc_conditionSecondChance.sqf); - }; - }; - }; }; diff --git a/addons/misc/XEH_PREP.hpp b/addons/misc/XEH_PREP.hpp index 05244afb9..ddf3d8c47 100644 --- a/addons/misc/XEH_PREP.hpp +++ b/addons/misc/XEH_PREP.hpp @@ -6,10 +6,8 @@ PREP(canCheckDogtag); PREP(canStitchFullBody); PREP(carryObject); PREP(checkArmbandCondition); -PREP(conditionExecutionDeath); PREP(conditionIV); PREP(conditionIVstand); -PREP(conditionSecondChance); PREP(FAK_ammoToArray); PREP(FAK_arrayToAmmo); PREP(FAK_checkRepack); diff --git a/addons/misc/functions/fnc_conditionExecutionDeath.sqf b/addons/misc/functions/fnc_conditionExecutionDeath.sqf deleted file mode 100644 index 9403b1776..000000000 --- a/addons/misc/functions/fnc_conditionExecutionDeath.sqf +++ /dev/null @@ -1,26 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: BaerMitUmlaut - * Modified: Blue - * Condition for an execution caused death (fatal injury received in cardiac arrest). - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [player] call ace_medical_statemachine_fnc_conditionExecutionDeath - * - * Public: No - */ - -params ["_unit"]; - -(if (isPlayer _unit) then { - ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_NEVER -} else { - (ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_NEVER) && {!(_unit getVariable [QGVAR(PreventInstantAIDeath), false])} -}) -&& {!(_unit getVariable [QACEGVAR(medical,deathBlocked), false])} diff --git a/addons/misc/functions/fnc_conditionSecondChance.sqf b/addons/misc/functions/fnc_conditionSecondChance.sqf deleted file mode 100644 index 0f3e42ef6..000000000 --- a/addons/misc/functions/fnc_conditionSecondChance.sqf +++ /dev/null @@ -1,25 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: mharis001 - * Modified: Blue - * Condition for going into cardiac arrest upon receiving a fatal injury. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [player] call ace_medical_statemachine_fnc_conditionSecondChance - * - * Public: No - */ - -params ["_unit"]; - -if (isPlayer _unit) then { - ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_ALWAYS -} else { - ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_ALWAYS || {_unit getVariable [QGVAR(PreventInstantAIDeath), false]} -}; diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 9308f5e1c..2776b0d43 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -172,7 +172,7 @@ switch (true) do { }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 220}): { + case (_heartRate < 20 || {_heartRate > 90}): { TRACE_2("heartRate Fatal",_unit,_heartRate); if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; diff --git a/addons/vitals/script_component.hpp b/addons/vitals/script_component.hpp index 870277346..162080431 100644 --- a/addons/vitals/script_component.hpp +++ b/addons/vitals/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED KAT - Vitals #include "\x\kat\addons\main\script_mod.hpp" -#define DEBUG_MODE_FULL +// #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS From ce56b12a3298fb66418455976cdc364289bc7afe Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 18:06:31 -0800 Subject: [PATCH 17/28] Update fnc_KATConditionExecutionDeath.sqf --- addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf b/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf index 896e4b08d..d607b5537 100644 --- a/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf +++ b/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: mharis001 - * Edited: Mazinski.H + * Edited: Blue, Mazinski.H * Condition for going into cardiac arrest upon receiving a fatal injury. * * Arguments: From eeccf2e73f768d464a729798e490e0177ad04f9d Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:38:25 -0800 Subject: [PATCH 18/28] Working again --- addons/conversion/Statemachine.hpp | 8 ++++---- addons/conversion/functions/fnc_setDead.sqf | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/conversion/Statemachine.hpp b/addons/conversion/Statemachine.hpp index 2635a2f41..5c349ea4a 100644 --- a/addons/conversion/Statemachine.hpp +++ b/addons/conversion/Statemachine.hpp @@ -2,20 +2,20 @@ class ACE_Medical_StateMachine { class Unconscious { class DeathAI { - condition = QFUNC(conversionCheck); + condition = QUOTE(call FUNC(conversionCheck)); }; }; class FatalInjury { class SecondChance { - condition = QFUNC(KATConditionSecondChance); + condition = QUOTE(call FUNC(KATConditionSecondChance)); }; }; class CardiacArrest { class DeathAI { - condition = QFUNC(conversionCheck); + condition = QUOTE(call FUNC(conversionCheck)); }; class Execution { - condition = QFUNC(KATConditionExecutionDeath); + condition = QUOTE(call FUNC(KATConditionExecutionDeath)); }; }; }; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_setDead.sqf b/addons/conversion/functions/fnc_setDead.sqf index 7a7948c7d..45816ba4b 100644 --- a/addons/conversion/functions/fnc_setDead.sqf +++ b/addons/conversion/functions/fnc_setDead.sqf @@ -22,8 +22,7 @@ TRACE_4("setDead",_unit,_reason,_source,_instigator); // If patient is marked for conversion, send them into arrest rather than killing them if the reason for dying is that they are AI private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; -private _convert = _unit getVariable [QEGVAR(conversion,convert),false]; -if (_convert && (_reason isEqualTo "CardiacArrest:DeathAI" || _reason isEqualTo "Unconscious:DeathAI")) exitWith { +if (GET_CONVERT_STATUS(_unit) && (_reason isEqualTo "CardiacArrest:DeathAI" || _reason isEqualTo "Unconscious:DeathAI")) exitWith { [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "CardiacArrest"] call CBA_statemachine_fnc_manualTransition; }; From 43759822d0e012b338751722dcc31a0f644ca106 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:11:12 -0800 Subject: [PATCH 19/28] Add option to disable text --- addons/conversion/XEH_postInit.sqf | 4 ++-- addons/conversion/XEH_preInit.sqf | 9 +++++++++ addons/conversion/stringtable.xml | 6 ++++++ addons/gui/functions/fnc_updateInjuryList.sqf | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index 3159b54ba..bfeb01bf7 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -21,7 +21,7 @@ _previousUnit setName _setName; - _unit setDamage 1; + forceRespawn player; deleteVehicle _unit; }] call CBA_fnc_addEventHandler; @@ -30,5 +30,5 @@ private _group2 = createGroup [(side _previousUnit), true]; [_previousUnit] join _group2; _group2 setGroupOwner 2; - [_previousUnit, true] call ACEFUNC(medical_engine,setUnconsciousAnim); + ["ace_unconscious", [_previousUnit, true]] call CBA_fnc_serverEvent; }] call CBA_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf index b27ae315e..5fda64bd7 100644 --- a/addons/conversion/XEH_preInit.sqf +++ b/addons/conversion/XEH_preInit.sqf @@ -17,6 +17,15 @@ PREP_RECOMPILE_END; true ] call CBA_Settings_fnc_init; +[ + QGVAR(enableConversionMessage), + "CHECKBOX", + [LLSTRING(CONVERSION_MESSAGE), LLSTRING(CONVERSION_MESSAGE_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [false], + true +] call CBA_Settings_fnc_init; + [ QGVAR(enableTicketConversion), "CHECKBOX", diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index 790006536..ed455c2c4 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -7,6 +7,12 @@ Enables Casualty Conversion for Players and Select AI + + Display Conversion + + + Enables text in patient menu that they are converted + Ticket for Patient Conversion diff --git a/addons/gui/functions/fnc_updateInjuryList.sqf b/addons/gui/functions/fnc_updateInjuryList.sqf index dbec751ef..2f41be081 100644 --- a/addons/gui/functions/fnc_updateInjuryList.sqf +++ b/addons/gui/functions/fnc_updateInjuryList.sqf @@ -132,7 +132,7 @@ if (_target call ACEFUNC(common,isAwake)) then { }; }; -if (_target getVariable [QEGVAR(conversion,currentConverted),false]) then { +if (_target getVariable [QEGVAR(conversion,currentConverted),false] && EGVAR(conversion,enableConversionMessage)) then { _entries pushBack [LELSTRING(conversion,ConversionText), [0.35, 0.72, 0.82, 1]]; }; From 5f143f8d25786fac4e093714a8cff63243ef8863 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 22:46:56 -0800 Subject: [PATCH 20/28] Add distance for libConversion and one life options --- addons/conversion/XEH_postInit.sqf | 16 +++++++++++++ addons/conversion/XEH_preInit.sqf | 9 ++++++++ .../fnc_KATConditionExecutionDeath.sqf | 2 +- .../fnc_KATConditionSecondChance.sqf | 2 +- .../functions/fnc_conversionCheck.sqf | 2 +- .../functions/fnc_fullHealLocal.sqf | 3 ++- .../functions/fnc_libConversion.sqf | 6 ++--- .../functions/fnc_libConversionCondition.sqf | 3 +-- .../functions/fnc_libConversionDistance.sqf | 23 +++++++++++++++++++ .../fnc_manualConversionCondition.sqf | 1 + addons/conversion/functions/fnc_setDead.sqf | 2 +- .../functions/fnc_ticketConversion.sqf | 6 +++++ addons/conversion/script_component.hpp | 2 +- addons/conversion/stringtable.xml | 6 +++++ addons/main/script_macros.hpp | 2 ++ .../vitals/functions/fnc_handleUnitVitals.sqf | 8 +++---- 16 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 addons/conversion/functions/fnc_libConversionDistance.sqf diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index bfeb01bf7..816d2e163 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -31,4 +31,20 @@ [_previousUnit] join _group2; _group2 setGroupOwner 2; ["ace_unconscious", [_previousUnit, true]] call CBA_fnc_serverEvent; +}] call CBA_fnc_addEventHandler; + +["kat_conversion_respawnTimer", { + params ["_time"]; + private _currentRespawnTime = playerRespawnTime; + setPlayerRespawnTime _time; + _currentUnit = player; + + [{ + params ["_currentUnit"]; + + (lifeState _currentUnit isEqualTo "HEALTHY") + }, { + params [_currentRespawnTime]; + setPlayerRespawnTime _currentRespawnTime; + }, [_currentUnit, _currentRespawnTime], 360, {}] call CBA_fnc_waitUntilAndExecute; }] call CBA_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf index 5fda64bd7..e4ba1738d 100644 --- a/addons/conversion/XEH_preInit.sqf +++ b/addons/conversion/XEH_preInit.sqf @@ -62,6 +62,15 @@ PREP_RECOMPILE_END; true ] call CBA_Settings_fnc_init; +[ + QGVAR(enableLiberationConversionDistance), + "SLIDER", + [LLSTRING(CONVERSION_LIBERATION_CONVERSION_DISTANCE), LLSTRING(CONVERSION_LIBERATION_CONVERSION_DISTANCE_DESC)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [0, 5000, 1000, 0], + true +] call CBA_Settings_fnc_init; + [ QGVAR(enableSpectatorRespawn), "CHECKBOX", diff --git a/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf b/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf index d607b5537..348ceff09 100644 --- a/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf +++ b/addons/conversion/functions/fnc_KATConditionExecutionDeath.sqf @@ -18,7 +18,7 @@ params ["_unit"]; -(if (isPlayer _unit || GET_CONVERT_STATUS(_unit)) then { +(if (isPlayer _unit || (GET_CONVERT_STATUS(_unit) && LIB_CONVERSION_DISTANCE(_unit))) then { ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_NEVER } else { (ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_NEVER) && {!(_unit getVariable [QEGVAR(misc,PreventInstantAIDeath), false])} diff --git a/addons/conversion/functions/fnc_KATConditionSecondChance.sqf b/addons/conversion/functions/fnc_KATConditionSecondChance.sqf index 34e675c8b..4bae57b45 100644 --- a/addons/conversion/functions/fnc_KATConditionSecondChance.sqf +++ b/addons/conversion/functions/fnc_KATConditionSecondChance.sqf @@ -18,7 +18,7 @@ params ["_unit"]; -if (isPlayer _unit || GET_CONVERT_STATUS(_unit)) then { +if (isPlayer _unit || (GET_CONVERT_STATUS(_unit) && LIB_CONVERSION_DISTANCE(_unit))) then { ACEGVAR(medical_statemachine,fatalInjuriesPlayer) != FATAL_INJURIES_ALWAYS } else { ACEGVAR(medical_statemachine,fatalInjuriesAI) != FATAL_INJURIES_ALWAYS || {_unit getVariable [QEGVAR(misc,PreventInstantAIDeath), false]} diff --git a/addons/conversion/functions/fnc_conversionCheck.sqf b/addons/conversion/functions/fnc_conversionCheck.sqf index 1ea2cb72b..1bcf2a036 100644 --- a/addons/conversion/functions/fnc_conversionCheck.sqf +++ b/addons/conversion/functions/fnc_conversionCheck.sqf @@ -17,6 +17,6 @@ params ["_unit"]; -if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!isPlayer _unit)) then { +if ((!(ACEGVAR(medical_statemachine,AIUnconsciousness))) && (!isPlayer _unit) && LIB_CONVERSION_DISTANCE(_unit)) then { GET_CONVERT_STATUS(_unit) != true } \ No newline at end of file diff --git a/addons/conversion/functions/fnc_fullHealLocal.sqf b/addons/conversion/functions/fnc_fullHealLocal.sqf index 3183ebdf3..69d473f4e 100644 --- a/addons/conversion/functions/fnc_fullHealLocal.sqf +++ b/addons/conversion/functions/fnc_fullHealLocal.sqf @@ -21,4 +21,5 @@ if (hasInterface && GVAR(enable)) then { _patient setVariable [QGVAR(convert), true, true]; }; -_patient setVariable [QGVAR(currentConverted), false, true]; \ No newline at end of file +_patient setVariable [QGVAR(currentConverted), false, true]; +_patient setVariable [QGVAR(associatedPlayer), player, true]; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_libConversion.sqf b/addons/conversion/functions/fnc_libConversion.sqf index 52a5be083..1b7f00647 100644 --- a/addons/conversion/functions/fnc_libConversion.sqf +++ b/addons/conversion/functions/fnc_libConversion.sqf @@ -17,11 +17,11 @@ params ["_patient"]; -private _storageAreas = (([_patient] call KPLIB_fnc_getNearestFob) nearobjects (GRLIB_fob_range)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0}; -private _crate = [KP_liberation_supplyCrate, GVAR(enableLiberationConversionGain), [[getPos _patient] select 0, [getPos _patient] select 1, 10000]]; +private _storageAreas = (([getPos _patient] call KPLIB_fnc_getNearestFob) nearobjects (GRLIB_fob_range)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0}; +private _crate = [KP_liberation_supplyCrate, GVAR(enableLiberationConversionGain), [(position _patient) select 0, (position _patient) select 1, 10000]] call KPLIB_fnc_createCrate; { - if ([_crate, _storage] call KPLIB_fnc_crateToStorage) then { break }; + if ([_crate, _x] call KPLIB_fnc_crateToStorage) then { break }; } forEach _storageAreas; _patient setDamage 1; diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf index 01c3f1a82..96ded8eed 100644 --- a/addons/conversion/functions/fnc_libConversionCondition.sqf +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -20,8 +20,7 @@ params ["_patient"]; if !(GVAR(enableLiberationConversion)) exitWith { false }; if !(_patient getVariable [QGVAR(currentConverted), false]) exitWith { false }; -if (isNil GRLIB_fob_range) exitWith { false }; -if ((_patient distance2d ([_patient] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) exitWith { false }; +if ((_patient distance2d ([getPos _patient] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) exitWith { false }; if !([_patient] call FUNC(conversionCondition)) exitWith { false }; diff --git a/addons/conversion/functions/fnc_libConversionDistance.sqf b/addons/conversion/functions/fnc_libConversionDistance.sqf new file mode 100644 index 000000000..856c98d70 --- /dev/null +++ b/addons/conversion/functions/fnc_libConversionDistance.sqf @@ -0,0 +1,23 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Checks if patient is far enough away from a Liberation FOB to be converted + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call kat_conversion_fnc_libConversionDistance + * + * Public: No + */ + +params ["_patient"]; + +if !(GVAR(enableConversionDistance)) exitWith { true }; +if ((_unit distance2d ([getPos _unit] call KPLIB_fnc_getNearestFob)) > enableLiberationConversionDistance) exitWith { true }; + +false \ No newline at end of file diff --git a/addons/conversion/functions/fnc_manualConversionCondition.sqf b/addons/conversion/functions/fnc_manualConversionCondition.sqf index a5bf2a211..b43916c6b 100644 --- a/addons/conversion/functions/fnc_manualConversionCondition.sqf +++ b/addons/conversion/functions/fnc_manualConversionCondition.sqf @@ -18,5 +18,6 @@ params ["_medic", "_patient"]; if !(IS_UNCONSCIOUS(_patient)) exitWith { false }; +if !(LIB_CONVERSION_DISTANCE(_patient)) exitWith { false }; true \ No newline at end of file diff --git a/addons/conversion/functions/fnc_setDead.sqf b/addons/conversion/functions/fnc_setDead.sqf index 45816ba4b..12ebc79bc 100644 --- a/addons/conversion/functions/fnc_setDead.sqf +++ b/addons/conversion/functions/fnc_setDead.sqf @@ -22,7 +22,7 @@ TRACE_4("setDead",_unit,_reason,_source,_instigator); // If patient is marked for conversion, send them into arrest rather than killing them if the reason for dying is that they are AI private _unitState = [_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; -if (GET_CONVERT_STATUS(_unit) && (_reason isEqualTo "CardiacArrest:DeathAI" || _reason isEqualTo "Unconscious:DeathAI")) exitWith { +if (GET_CONVERT_STATUS(_unit) && (_reason isEqualTo "CardiacArrest:DeathAI" || _reason isEqualTo "Unconscious:DeathAI") && LIB_CONVERSION_DISTANCE(_unit)) exitWith { [_unit, ACEGVAR(medical,STATE_MACHINE), _unitState, "CardiacArrest"] call CBA_statemachine_fnc_manualTransition; }; diff --git a/addons/conversion/functions/fnc_ticketConversion.sqf b/addons/conversion/functions/fnc_ticketConversion.sqf index 9da35e964..4d49a9bef 100644 --- a/addons/conversion/functions/fnc_ticketConversion.sqf +++ b/addons/conversion/functions/fnc_ticketConversion.sqf @@ -19,5 +19,11 @@ params ["_patient"]; [(side _patient), GVAR(ticketConversionGain)] call BIS_fnc_respawnTickets; +if (GVAR(enableSpectatorRespawn)) then { + if (lifeState (_patient getVariable [QGVAR(associatedPlayer), objNull]) isEqualTo "DEAD-RESPAWN") then { + ["kat_conversion_respawnTimer", 0] call CBA_fnc_localEvent; + }; +}; + _patient setDamage 1; deleteVehicle _patient; \ No newline at end of file diff --git a/addons/conversion/script_component.hpp b/addons/conversion/script_component.hpp index 792efc6cd..bb629e9e6 100644 --- a/addons/conversion/script_component.hpp +++ b/addons/conversion/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED KAT - Conversion #include "\x\kat\addons\main\script_mod.hpp" -// #define DEBUG_MODE_FULL + #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index ed455c2c4..ecaf78714 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -37,6 +37,12 @@ How much supply should be gien when converting patients + + Distance Required + + + How far do Liberation patients need to be from a FOB for a conversion to be valid + One Life Conversion diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index 494add5f4..4fcee97eb 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -334,6 +334,8 @@ #define UNIT_CONVERT QEGVAR(conversion,convert) #define GET_CONVERT_STATUS(unit) (unit getVariable [UNIT_CONVERT, false]) +#define LIB_CONVERSION_DISTANCE(unit) ([unit] call EFUNC(conversion,libConversionDistance)) + // Pharma #define VAR_VASOCONSTRICTION QEGVAR(pharma,alphaAction) #define GET_VASOCONSTRICTION(unit) (unit getVariable [VAR_VASOCONSTRICTION, 1]) diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 2776b0d43..60ea66af7 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -160,21 +160,21 @@ switch (true) do { case (IN_CRDC_ARRST(_unit)): {}; // if in cardiac arrest just break now to avoid throwing unneeded events case ((_spo2 < EGVAR(breathing,SpO2_cardiacValue)) && EGVAR(breathing,SpO2_cardiacActive)): { TRACE_2("SpO2 below Cardiac Value",_unit,_spo2); - if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { + if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit) && LIB_CONVERSION_DISTANCE(_unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; case (_hemorrhage == 4): { TRACE_3("Class IV Hemorrhage",_unit,_hemorrhage,_bloodVolume); - if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { + if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit) && LIB_CONVERSION_DISTANCE(_unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 90}): { + case (_heartRate < 20 || {_heartRate > 220}): { TRACE_2("heartRate Fatal",_unit,_heartRate); - if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit)) then { + if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit) && LIB_CONVERSION_DISTANCE(_unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; From e59b2d22c64093689c1506561451589c4e2e3358 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 22:50:30 -0800 Subject: [PATCH 21/28] Delete fnc_spectatorRespawn.sqf --- .../functions/fnc_spectatorRespawn.sqf | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 addons/conversion/functions/fnc_spectatorRespawn.sqf diff --git a/addons/conversion/functions/fnc_spectatorRespawn.sqf b/addons/conversion/functions/fnc_spectatorRespawn.sqf deleted file mode 100644 index 9da35e964..000000000 --- a/addons/conversion/functions/fnc_spectatorRespawn.sqf +++ /dev/null @@ -1,23 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: Mazinski - * Converts patient to respawn tickets - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [player] call kat_conversion_fnc_ticketConversion - * - * Public: No - */ - -params ["_patient"]; - -[(side _patient), GVAR(ticketConversionGain)] call BIS_fnc_respawnTickets; - -_patient setDamage 1; -deleteVehicle _patient; \ No newline at end of file From 7c7ed1d3cb4aae058bd4070210e76db11114ffc7 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Sun, 12 Jan 2025 22:51:29 -0800 Subject: [PATCH 22/28] Update XEH_PREP.hpp --- addons/conversion/XEH_PREP.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/conversion/XEH_PREP.hpp b/addons/conversion/XEH_PREP.hpp index b17cff96d..f33602952 100644 --- a/addons/conversion/XEH_PREP.hpp +++ b/addons/conversion/XEH_PREP.hpp @@ -7,6 +7,9 @@ PREP(KATConditionExecutionDeath); PREP(KATConditionSecondChance); PREP(libConversion); PREP(libConversionCondition); +PREP(libConversionDistance); +PREP(manualConversion); +PREP(manualConversionCondition); PREP(setDead); PREP(ticketConversion); PREP(ticketConversionCondition); \ No newline at end of file From 30950d3512ba6d302efc6acf20a0395b9a47fbc9 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:35:51 -0800 Subject: [PATCH 23/28] Update fnc_manualConversionCondition.sqf --- addons/conversion/functions/fnc_manualConversionCondition.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/conversion/functions/fnc_manualConversionCondition.sqf b/addons/conversion/functions/fnc_manualConversionCondition.sqf index b43916c6b..9d89dc380 100644 --- a/addons/conversion/functions/fnc_manualConversionCondition.sqf +++ b/addons/conversion/functions/fnc_manualConversionCondition.sqf @@ -18,6 +18,6 @@ params ["_medic", "_patient"]; if !(IS_UNCONSCIOUS(_patient)) exitWith { false }; -if !(LIB_CONVERSION_DISTANCE(_patient)) exitWith { false }; +if (GVAR(enableLiberationConversion) && !(LIB_CONVERSION_DISTANCE(_patient))) exitWith { false }; true \ No newline at end of file From 5ff9f096eda55a1157a648b24c492c023831a532 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Fri, 17 Jan 2025 08:44:55 -0800 Subject: [PATCH 24/28] Update addons/conversion/ACE_Medical_Treatment_Actions.hpp Co-authored-by: MiszczuZPolski <71414303+MiszczuZPolski@users.noreply.github.com> --- addons/conversion/ACE_Medical_Treatment_Actions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/conversion/ACE_Medical_Treatment_Actions.hpp b/addons/conversion/ACE_Medical_Treatment_Actions.hpp index afebaf992..8e97d7d8c 100644 --- a/addons/conversion/ACE_Medical_Treatment_Actions.hpp +++ b/addons/conversion/ACE_Medical_Treatment_Actions.hpp @@ -9,7 +9,7 @@ class ACE_Medical_Treatment_Actions { medicRequired = QGVAR(manualConversionLevel); treatmentLocations = QGVAR(manualConversionLocation); treatmentTime = 10; - allowedSelections[] = {"Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"}; + allowedSelections[] = {"All"}; items[] = {""}; callbackSuccess = QFUNC(manualConversion); }; From e0f2a1624044d18a3139e11f45046c9ae0122cf8 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Fri, 17 Jan 2025 08:45:04 -0800 Subject: [PATCH 25/28] Update addons/conversion/ACE_Medical_Treatment_Actions.hpp Co-authored-by: MiszczuZPolski <71414303+MiszczuZPolski@users.noreply.github.com> --- addons/conversion/ACE_Medical_Treatment_Actions.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/conversion/ACE_Medical_Treatment_Actions.hpp b/addons/conversion/ACE_Medical_Treatment_Actions.hpp index 8e97d7d8c..bc689e148 100644 --- a/addons/conversion/ACE_Medical_Treatment_Actions.hpp +++ b/addons/conversion/ACE_Medical_Treatment_Actions.hpp @@ -5,7 +5,6 @@ class ACE_Medical_Treatment_Actions { displayName = CSTRING(convertPatient); displayNameProgress = CSTRING(converting); condition = QFUNC(manualConversionCondition); - category = "examine"; medicRequired = QGVAR(manualConversionLevel); treatmentLocations = QGVAR(manualConversionLocation); treatmentTime = 10; From 3fa54b95ef291d75d6041252aac3c3b5c0fa7e24 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Fri, 17 Jan 2025 08:51:16 -0800 Subject: [PATCH 26/28] Review --- addons/conversion/ACE_Medical_Treatment_Actions.hpp | 2 +- addons/conversion/XEH_preInit.sqf | 9 +++++++++ .../conversion/functions/fnc_libConversionCondition.sqf | 1 + addons/conversion/script_component.hpp | 2 +- addons/conversion/stringtable.xml | 3 +++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/addons/conversion/ACE_Medical_Treatment_Actions.hpp b/addons/conversion/ACE_Medical_Treatment_Actions.hpp index afebaf992..6872220ec 100644 --- a/addons/conversion/ACE_Medical_Treatment_Actions.hpp +++ b/addons/conversion/ACE_Medical_Treatment_Actions.hpp @@ -8,7 +8,7 @@ class ACE_Medical_Treatment_Actions { category = "examine"; medicRequired = QGVAR(manualConversionLevel); treatmentLocations = QGVAR(manualConversionLocation); - treatmentTime = 10; + treatmentTime = QGVAR(manualConversionTime); allowedSelections[] = {"Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"}; items[] = {""}; callbackSuccess = QFUNC(manualConversion); diff --git a/addons/conversion/XEH_preInit.sqf b/addons/conversion/XEH_preInit.sqf index e4ba1738d..92e69c3d6 100644 --- a/addons/conversion/XEH_preInit.sqf +++ b/addons/conversion/XEH_preInit.sqf @@ -130,4 +130,13 @@ PREP_RECOMPILE_END; true ] call CBA_Settings_fnc_init; +[ + QGVAR(manualConversionTime), + "SLIDER", + [LLSTRING(CONVERSION_LIBERATION_CONVERSION_TIME)], + [CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)], + [0, 60, 15, 0], + true +] call CBA_Settings_fnc_init; + ADDON = true; \ No newline at end of file diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf index 96ded8eed..6578c7df2 100644 --- a/addons/conversion/functions/fnc_libConversionCondition.sqf +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -17,6 +17,7 @@ params ["_patient"]; +if ((missionNamespace getVariable ["GRLIB_fob_range", -1]) == -1) exitWith { false }; if !(GVAR(enableLiberationConversion)) exitWith { false }; if !(_patient getVariable [QGVAR(currentConverted), false]) exitWith { false }; diff --git a/addons/conversion/script_component.hpp b/addons/conversion/script_component.hpp index bb629e9e6..792efc6cd 100644 --- a/addons/conversion/script_component.hpp +++ b/addons/conversion/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED KAT - Conversion #include "\x\kat\addons\main\script_mod.hpp" - #define DEBUG_MODE_FULL +// #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/conversion/stringtable.xml b/addons/conversion/stringtable.xml index ecaf78714..8e9fed82c 100644 --- a/addons/conversion/stringtable.xml +++ b/addons/conversion/stringtable.xml @@ -79,6 +79,9 @@ What medical facility should a player be in order to perform an initial conversion + + Manual Conversion Time + Converted From 3493372637c4b94bac6835eaa04bf16d8e47541b Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:32:44 -0800 Subject: [PATCH 27/28] Shift statemachine to seperate addon --- addons/conversion/XEH_postInit.sqf | 2 +- addons/conversion/config.cpp | 1 - .../functions/fnc_libConversionCondition.sqf | 2 +- .../functions/fnc_libConversionDistance.sqf | 4 +++- addons/statemachine/$PBOPREFIX$ | 1 + .../Statemachine.hpp | 8 +++---- addons/statemachine/config.cpp | 21 +++++++++++++++++++ addons/statemachine/script_component.hpp | 17 +++++++++++++++ .../vitals/functions/fnc_handleUnitVitals.sqf | 2 +- 9 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 addons/statemachine/$PBOPREFIX$ rename addons/{conversion => statemachine}/Statemachine.hpp (50%) create mode 100644 addons/statemachine/config.cpp create mode 100644 addons/statemachine/script_component.hpp diff --git a/addons/conversion/XEH_postInit.sqf b/addons/conversion/XEH_postInit.sqf index 816d2e163..7b802e18e 100644 --- a/addons/conversion/XEH_postInit.sqf +++ b/addons/conversion/XEH_postInit.sqf @@ -30,7 +30,7 @@ private _group2 = createGroup [(side _previousUnit), true]; [_previousUnit] join _group2; _group2 setGroupOwner 2; - ["ace_unconscious", [_previousUnit, true]] call CBA_fnc_serverEvent; + [_previousUnit, true] call ACEFUNC(medical,setUnconscious); }] call CBA_fnc_addEventHandler; ["kat_conversion_respawnTimer", { diff --git a/addons/conversion/config.cpp b/addons/conversion/config.cpp index eb41c67b0..ebb8c0e54 100644 --- a/addons/conversion/config.cpp +++ b/addons/conversion/config.cpp @@ -29,7 +29,6 @@ class CfgPatches { }; }; -#include "Statemachine.hpp" #include "CfgEventHandlers.hpp" #include "CfgFunctions.hpp" #include "CfgVehicles.hpp" diff --git a/addons/conversion/functions/fnc_libConversionCondition.sqf b/addons/conversion/functions/fnc_libConversionCondition.sqf index 6578c7df2..66a8413bf 100644 --- a/addons/conversion/functions/fnc_libConversionCondition.sqf +++ b/addons/conversion/functions/fnc_libConversionCondition.sqf @@ -17,8 +17,8 @@ params ["_patient"]; -if ((missionNamespace getVariable ["GRLIB_fob_range", -1]) == -1) exitWith { false }; if !(GVAR(enableLiberationConversion)) exitWith { false }; +if ((missionNamespace getVariable ["GRLIB_fob_range", -1]) == -1) exitWith { false }; if !(_patient getVariable [QGVAR(currentConverted), false]) exitWith { false }; if ((_patient distance2d ([getPos _patient] call KPLIB_fnc_getNearestFob)) > GRLIB_fob_range) exitWith { false }; diff --git a/addons/conversion/functions/fnc_libConversionDistance.sqf b/addons/conversion/functions/fnc_libConversionDistance.sqf index 856c98d70..88785188c 100644 --- a/addons/conversion/functions/fnc_libConversionDistance.sqf +++ b/addons/conversion/functions/fnc_libConversionDistance.sqf @@ -17,7 +17,9 @@ params ["_patient"]; +if ((missionNamespace getVariable ["GRLIB_fob_range", -1]) == -1) exitWith { true }; +if !(GVAR(enableLiberationConversion)) exitWith { true }; if !(GVAR(enableConversionDistance)) exitWith { true }; -if ((_unit distance2d ([getPos _unit] call KPLIB_fnc_getNearestFob)) > enableLiberationConversionDistance) exitWith { true }; +if ((_patient distance2d ([getPos _patient] call KPLIB_fnc_getNearestFob)) < enableLiberationConversionDistance) exitWith { true }; false \ No newline at end of file diff --git a/addons/statemachine/$PBOPREFIX$ b/addons/statemachine/$PBOPREFIX$ new file mode 100644 index 000000000..c89e17185 --- /dev/null +++ b/addons/statemachine/$PBOPREFIX$ @@ -0,0 +1 @@ +x\kat\addons\statemachine \ No newline at end of file diff --git a/addons/conversion/Statemachine.hpp b/addons/statemachine/Statemachine.hpp similarity index 50% rename from addons/conversion/Statemachine.hpp rename to addons/statemachine/Statemachine.hpp index 5c349ea4a..89f8929a5 100644 --- a/addons/conversion/Statemachine.hpp +++ b/addons/statemachine/Statemachine.hpp @@ -2,20 +2,20 @@ class ACE_Medical_StateMachine { class Unconscious { class DeathAI { - condition = QUOTE(call FUNC(conversionCheck)); + condition = QUOTE(call EFUNC(conversion,conversionCheck)); }; }; class FatalInjury { class SecondChance { - condition = QUOTE(call FUNC(KATConditionSecondChance)); + condition = QUOTE(call EFUNC(conversion,conversionKATConditionSecondChance)); }; }; class CardiacArrest { class DeathAI { - condition = QUOTE(call FUNC(conversionCheck)); + condition = QUOTE(call EFUNC(conversion,conversionCheck)); }; class Execution { - condition = QUOTE(call FUNC(KATConditionExecutionDeath)); + condition = QUOTE(call EFUNC(conversion,KATConditionExecutionDeath)); }; }; }; \ No newline at end of file diff --git a/addons/statemachine/config.cpp b/addons/statemachine/config.cpp new file mode 100644 index 000000000..b3f22ff34 --- /dev/null +++ b/addons/statemachine/config.cpp @@ -0,0 +1,21 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + requiredVersion = REQUIRED_VERSION; + units[] = {}; + weapons[] = {}; + magazines[] = {}; + requiredAddons[] = { + "ace_medical", + "ace_medical_statemachine" + }; + author = "Mazinski"; + authors[] = {"Mazinski"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "Statemachine.hpp" diff --git a/addons/statemachine/script_component.hpp b/addons/statemachine/script_component.hpp new file mode 100644 index 000000000..2dc8e10ce --- /dev/null +++ b/addons/statemachine/script_component.hpp @@ -0,0 +1,17 @@ +#define COMPONENT statemachine +#define COMPONENT_BEAUTIFIED KAT - StateMachine +#include "\x\kat\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_STATEMACHINE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_STATEMACHINE + #define DEBUG_SETTINGS DEBUG_SETTINGS_STATEMACHINE +#endif + +#include "\x\kat\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 60ea66af7..5e6f60984 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -172,7 +172,7 @@ switch (true) do { }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 220}): { + case (_heartRate < 20 || {_heartRate > 90}): { TRACE_2("heartRate Fatal",_unit,_heartRate); if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit) && LIB_CONVERSION_DISTANCE(_unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent; From bd83366d12babf542854bbc18cef512e6d9e0cbe Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Wed, 22 Jan 2025 10:06:11 -0800 Subject: [PATCH 28/28] Update fnc_handleUnitVitals.sqf --- addons/vitals/functions/fnc_handleUnitVitals.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index 5e6f60984..60ea66af7 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -172,7 +172,7 @@ switch (true) do { }; [QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; }; - case (_heartRate < 20 || {_heartRate > 90}): { + case (_heartRate < 20 || {_heartRate > 220}): { TRACE_2("heartRate Fatal",_unit,_heartRate); if ((_unit getVariable [QEGVAR(conversion,convert), false]) && (isPlayer _unit) && LIB_CONVERSION_DISTANCE(_unit)) then { ["kat_conversion_convertCasualty", _unit] call CBA_fnc_localEvent;