Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limping / Splint Treatment #6947

Merged
merged 20 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

//Status Effect EHs:
[QGVAR(setStatusEffect), {_this call FUNC(statusEffect_set)}] call CBA_fnc_addEventHandler;
["forceWalk", false, ["ACE_SwitchUnits", "ACE_Attach", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_Sandbag", "ACE_refuel", "ACE_rearm", "ACE_Trenches"]] call FUNC(statusEffect_addType);
["blockSprint", false, []] call FUNC(statusEffect_addType);
["forceWalk", false, ["ace_advanced_fatigue", "ACE_SwitchUnits", "ACE_Attach", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_Sandbag", "ACE_refuel", "ACE_rearm", "ACE_Trenches"]] call FUNC(statusEffect_addType);
["blockSprint", false, ["ace_advanced_fatigue", "ace_medical_fracture"]] call FUNC(statusEffect_addType);
["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered)]] call FUNC(statusEffect_addType);
["blockDamage", false, ["fixCollision", "ACE_cargo"]] call FUNC(statusEffect_addType);
["blockEngine", false, ["ACE_Refuel"]] call FUNC(statusEffect_addType);
Expand Down
20 changes: 10 additions & 10 deletions addons/common/functions/fnc_arithmeticGetResult.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Arguments:
* 0: Namespace <OBJECT><LOCATION><MISSIONNAMESPACE>
* 1: Number Set ID <STRING>
* 2: Operation (sum, product, min, max, avg) <STRING>
* 2: Operation (sum, product, min, max, avg) (Case Sensitive) <STRING>
*
* Return Value:
* Value <NUMBER>
Expand All @@ -19,11 +19,19 @@
*/

params ["_namespace", "_setID", "_op"];
TRACE_3("params",_namespace,_setID,_op);
TRACE_3("arithmeticGetResult",_namespace,_setID,_op);

private _data = (_namespace getVariable _setID) param [2, []];

switch (_op) do {
case ("max"): {
private _result = -1e99;
Copy link
Member

Choose a reason for hiding this comment

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

If data ends up empty, can this cause issues in other scripts? Would it be better to initialise to another value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is called relatively often, I think it's better to leave out the safety checks and just assume the user has added at least one entry.
The only real change I made in this func is moving "max" to the top of the switch block as that's the only one we use so far

{
_result = _result max (call _x);
nil
} count _data;
_result // return
};
case ("sum"): {
private _result = 0;
{
Expand All @@ -48,14 +56,6 @@ switch (_op) do {
} count _data;
_result // return
};
case ("max"): {
private _result = -1e99;
{
_result = _result max (call _x);
nil
} count _data;
_result // return
};
case ("avg"): {
private _result = 0;
{
Expand Down
4 changes: 1 addition & 3 deletions addons/medical/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
if (!hasInterface) exitWith {};

[missionNamespace, "ACE_setCustomAimCoef", QUOTE(ADDON), {
private _pain = GET_PAIN_PERCEIVED(ACE_player);

linearConversion [0, 1, _pain, 1, 5, true];
(linearConversion [0, 1, GET_PAIN_PERCEIVED(ACE_player), 1, 5, true]) + (ACE_player getVariable [QEGVAR(medical_engine,aimFracture), 0])
}] call EFUNC(common,arithmeticSetSource);

#ifdef DEBUG_MODE_FULL
Expand Down
2 changes: 1 addition & 1 deletion addons/medical/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
requiredAddons[] = {"ace_medical_engine"};
author = ECSTRING(common,ACETeam);
authors[] = {"Glowbal", "KoffeinFlummi","Arcanum417"};
url = ECSTRING(main,URL);
Expand Down
78 changes: 69 additions & 9 deletions addons/medical/dev/watchVariable.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
["medical", {

// Hide when patient display is up because they might overlap
if (!isNull EGVAR(medical_gui,displayPatientInformationTarget)) exitWith {""};
private _display = uiNamespace getVariable [QEGVAR(medical_gui,RscPatientInfo), displayNull];
if (!isNull _display) exitWith {"Paused"};

private _unit = cursorTarget;
if (!(_unit isKindOf "CAManBase")) then {_unit = cursorObject};
Expand All @@ -27,10 +28,13 @@

// Blood:
private _bloodVolume = GET_BLOOD_VOLUME(_unit);
private _woundBleeding = GET_WOUND_BLEEDING(_unit);
private _bloodLoss = GET_BLOOD_LOSS(_unit);
private _secondsToHeartstop = if (_bloodLoss != 0) then {format ["[<t color ='#FF9999'>Time Left:</t> %1 sec]", (((_bloodVolume - BLOOD_VOLUME_CLASS_4_HEMORRHAGE) max 0) / _bloodLoss) toFixed 1]} else {""};
_return pushBack format ["Blood: %1", _bloodVolume toFixed 3];
_return pushBack format [" - [Loss: %1] %2", _bloodLoss toFixed 5, _secondsToHeartstop];
private _hemorrhage = GET_HEMORRHAGE(_unit);
private _isBleeding = if (IS_BLEEDING(_unit)) then {"<t color ='#FF9999'>Bleeding</t>"} else {""};
private _secondsToHeartstop = if (_bloodLoss != 0) then {format ["[<t color ='#FF9999'>Time Left:</t> %1 sec]", (((_bloodVolume - BLOOD_VOLUME_CLASS_4_HEMORRHAGE) max 0) / _bloodLoss) toFixed 0]} else {""};
_return pushBack format ["Blood: %1 [Hemorrhage: %2] %3", _bloodVolume toFixed 3, _hemorrhage, _isBleeding];
_return pushBack format [" - [W: %1 T: %2] %3", _woundBleeding toFixed 4, _bloodLoss toFixed 4, _secondsToHeartstop];

// Heart:
private _cardiacOutput = [_unit] call EFUNC(medical_status,getCardiacOutput);
Expand All @@ -43,15 +47,23 @@
private _pain = GET_PAIN(_unit);
private _painSuppress = GET_PAIN_SUPPRESS(_unit);
private _painLevel = GET_PAIN_PERCEIVED(_unit);
_return pushBack format ["Effective Pain: %1", _painLevel toFixed 3];
private _isInPain = IS_IN_PAIN(_unit);
_return pushBack format ["Effective Pain: %1 [%2]", _painLevel toFixed 3, _isInPain];
_return pushBack format [" - [Pain: %1] [Suppress: %2]", _pain toFixed 3, _painSuppress toFixed 3];

// Damage:
private _damage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
private _limping = if (_unit getVariable [QEGVAR(medical,isLimping), false]) then {"[<t color ='#FFCC22'> Limping </t>]"} else {""};
_return pushBack format ["Damage: [H: %1] [B: %2] %3", (_damage select 0) toFixed 2, (_damage select 1) toFixed 2, _limping];
_return pushBack format ["Damage: [H: %1] [B: %2] %3", (_damage select 0) toFixed 2, (_damage select 1) toFixed 2];
_return pushBack format ["[LA:%1] [RA: %2] [LL:%3] [RL: %4]", (_damage select 2) toFixed 2, (_damage select 3) toFixed 2, (_damage select 4) toFixed 2, (_damage select 5) toFixed 2];

_return pushBack format ["Hitpoints: [HHed:%1] [HBod: %2]", (_unit getHitPointDamage "HitHead") toFixed 2, (_unit getHitPointDamage "HitBody") toFixed 2];
_return pushBack format ["[HHnd:%1] [HLeg: %2] %3", (_unit getHitPointDamage "HitHands") toFixed 2, (_unit getHitPointDamage "HitLegs") toFixed 2, _limping];

private _fractures = _unit getVariable [QEGVAR(medical,fractures), [0,0,0,0,0,0]];
private _canSprint = if (isSprintAllowed _unit) then {""} else {"[<t color ='#FFCC22'>Sprint Blocked</t>]"};
_return pushBack format ["Fractures: %1 %2", _fractures, _canSprint];


// Tourniquets:
_return pushBack "------- Tourniquets: -------";
Expand All @@ -75,10 +87,25 @@
_return pushBack "------- Wounds: -------";
private _wounds = _unit getVariable [QEGVAR(medical,openWounds), []];
{
_x params ["", "_xClassID", "_xBodyPartN", "_xAmountOf", "_xBleeding", "_xDamage", "_xCategory"];
_return pushBack format ["%1: [%2-%3] [x%4] [Bld: %5] [Dmg: %6]", ALL_SELECTIONS select _xBodyPartN, _xClassID, _xCategory, _xAmountOf toFixed 1, _xBleeding toFixed 4, _xDamage toFixed 2];
_x params ["_xClassID", "_xBodyPartN", "_xAmountOf", "_xBleeding", "_xDamage"];
_return pushBack format ["%1: [%2] [x%3] [Bld: %4] [Dmg: %5]", ALL_SELECTIONS select _xBodyPartN, _xClassID, _xAmountOf toFixed 1, _xBleeding toFixed 4, _xDamage toFixed 2];
} forEach _wounds;

// Bandaged Wounds:
_return pushBack "------- Bandaged Wounds: -------";
private _wounds = _unit getVariable [QEGVAR(medical,bandagedWounds), []];
{
_x params ["_xClassID", "_xBodyPartN", "_xAmountOf", "_xBleeding", "_xDamage"];
_return pushBack format ["%1: [%2] [x%3] [Bld: %4] [Dmg: %5]", ALL_SELECTIONS select _xBodyPartN, _xClassID, _xAmountOf toFixed 1, _xBleeding toFixed 4, _xDamage toFixed 2];
} forEach _wounds;

// Stitched Wounds:
_return pushBack "------- Stitched Wounds: -------";
private _wounds = _unit getVariable [QEGVAR(medical,stitchedWounds), []];
{
_x params ["_xClassID", "_xBodyPartN", "_xAmountOf", "_xBleeding", "_xDamage"];
_return pushBack format ["%1: [%2] [x%3] [Bld: %4] [Dmg: %5]", ALL_SELECTIONS select _xBodyPartN, _xClassID, _xAmountOf toFixed 1, _xBleeding toFixed 4, _xDamage toFixed 2];
} forEach _wounds;

// IVs:
_return pushBack "------- IVs: -------";
Expand All @@ -88,10 +115,43 @@
_return pushBack format ["%1: %2 [%3 ml]", ALL_SELECTIONS select _xBodyPartN, _xType, _xVolumeAdded];
} forEach _ivBags;

// Medications:
_return pushBack "------- Medications: -------";
private _hrTargetAdjustment = 0;
private _painSupressAdjustment = 0;
private _peripheralResistanceAdjustment = 0;
private _medicationCounts = [];
private _rawMedications = (_unit getVariable [VAR_MEDICATIONS, []]) apply {
_x params ["_medication", "_timeAdded", "_timeTillMaxEffect", "_maxTimeInSystem", "_hrAdjust", "_painAdjust", "_flowAdjust"];
private _timeInSystem = CBA_missionTime - _timeAdded;
private _index = _medicationCounts find _medication;
if (_index < 0) then {
_index = _medicationCounts pushBack _medication;
_medicationCounts pushBack 0
};
_medicationCounts set [(_index + 1), (_medicationCounts select (_index + 1)) + linearConversion [_timeTillMaxEffect, _maxTimeInSystem, _timeInSystem, 1, 0, true]];

private _effectRatio = (((_timeInSystem / _timeTillMaxEffect) ^ 2) min 1) * (_maxTimeInSystem - _timeInSystem) / _maxTimeInSystem;
_hrTargetAdjustment = _hrTargetAdjustment + _hrAdjust * _effectRatio;
_painSupressAdjustment = _painSupressAdjustment + _painAdjust * _effectRatio;
_peripheralResistanceAdjustment = _peripheralResistanceAdjustment + _flowAdjust * _effectRatio;
format ["%1 [%2 / %3][%4][%5,%6,%7]",_medication,_timeInSystem toFixed 0,_maxTimeInSystem toFixed 0, _effectRatio toFixed 2, _hrAdjust toFixed 1, _painAdjust toFixed 2, _flowAdjust toFixed 1];
};
_return pushBack format ["Adjusts: [HR %1][PS %2][PR %3]", _hrTargetAdjustment toFixed 2, _painSupressAdjustment toFixed 2, _peripheralResistanceAdjustment toFixed 2];
for "_i" from 0 to (count _medicationCounts) - 1 step 2 do {
_return pushBack format ["-%1: %2", _medicationCounts select _i, _medicationCounts select _i + 1];
};
_return pushBack "------- Medications Raw: -------";
_return append _rawMedications;

if (_unit isEqualTo ACE_player) then {
_return pushBack format ["ACE_setCustomAimCoef: %1", [missionNamespace, "ACE_setCustomAimCoef", "max"] call ace_common_fnc_arithmeticGetResult];
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
};

// Footer:
_return pushBack "</t>";

// Return:
_return joinString "<br/>"
}, [30]] call EFUNC(common,watchVariable);
}, [40]] call EFUNC(common,watchVariable);

2 changes: 1 addition & 1 deletion addons/medical/functions/fnc_addDamageToUnit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// #define DEBUG_TESTRESULTS

params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]]];
TRACE_5("params",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator);
TRACE_5("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator);

private _bodyPartIndex = ALL_BODY_PARTS find (toLower _bodyPart);
if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_1("addDamageToUnit - badUnit %1", _this); false};
Expand Down
20 changes: 20 additions & 0 deletions addons/medical/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,23 @@ private _categoryArray = [LELSTRING(medical,Category_DisplayName), "?"];
{[QGVAR(spontaneousWakeUpChance), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

[
QEGVAR(medical,limping), "LIST",
["limping"],//LSTRING(limping_DisplayName), LSTRING(limping_Description)],
_categoryArray,
[[0,1,2],["Disabled", "Limp on open wound", "Limp on open or bandaged wound"], 1], // [values, titles, defaultIndex]
true, // isGlobal
{[QEGVAR(medical,limping), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

[
QEGVAR(medical,fractures), "LIST",
["fractures"],//LSTRING(limping_DisplayName), LSTRING(limping_Description)],
_categoryArray,
[[0,1,2],["Disabled", "Splints fully heal", "Splints heal (but cannot sprint)"], 1], // [values, titles, defaultIndex]
true, // isGlobal
{[QEGVAR(medical,fractures), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;
2 changes: 1 addition & 1 deletion addons/medical/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_MEDICAL
#endif

#include "\z\ace\addons\main\script_macros.hpp"
#include "\z\ace\addons\medical_engine\script_macros_medical.hpp"
#include "\z\ace\addons\main\script_macros.hpp"
2 changes: 1 addition & 1 deletion addons/medical_ai/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_MEDICAL_AI
#endif

#include "\z\ace\addons\main\script_macros.hpp"
#include "\z\ace\addons\medical_engine\script_macros_medical.hpp"
#include "\z\ace\addons\main\script_macros.hpp"
2 changes: 1 addition & 1 deletion addons/medical_blood/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_MEDICAL_BLOOD
#endif

#include "\z\ace\addons\main\script_macros.hpp"
#include "\z\ace\addons\medical_engine\script_macros_medical.hpp"
#include "\z\ace\addons\main\script_macros.hpp"

#define MAX_BLOOD_OBJECTS 500
#define BLOOD_OBJECT_LIFETIME 900
2 changes: 2 additions & 0 deletions addons/medical_damage/ACE_Medical_Injuries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ACE_Medical_Injuries {
pain = 0.8;
minDamage = 0.1;
causeLimping = 1;
causeFracture = 1;
};
// Slicing wounds made with a sharp instrument, leaving even edges. They may be as minimal as a paper cut or as significant as a surgical incision.
class Cut {
Expand All @@ -59,6 +60,7 @@ class ACE_Medical_Injuries {
pain = 0.9;
minDamage = 0.35;
causeLimping = 1;
causeFracture = 1;
};
// Deep, narrow wounds produced by sharp objects such as nails, knives, and broken glass.
class PunctureWound {
Expand Down
10 changes: 6 additions & 4 deletions addons/medical_damage/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ addMissionEventHandler ["Loaded",{
}];

// decide which woundsHandler to use by whether the extension is present or not
if ("ace_medical" callExtension "version" != "") then {
DFUNC(woundsHandlerActive) = LINKFUNC(woundsHandler);
} else {
// if ("ace_medical" callExtension "version" != "") then {

// DFUNC(woundsHandlerActive) = LINKFUNC(woundsHandler);
// } else {
INFO("Using woundsHandlerSQF");
DFUNC(woundsHandlerActive) = LINKFUNC(woundsHandlerSQF);
};
// };

[QEGVAR(medical,woundReceived), {
params ["_unit", "_woundedHitPoint", "_receivedDamage", "", "_ammo"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _bodyPartDamage params ["_headDamage", "_bodyDamage", "_leftArmDamage", "_rightA

// Exclude non penetrating body damage
{
_x params ["", "", "_bodyPartN", "_amountOf", "", "_damage"];
_x params ["", "_bodyPartN", "_amountOf", "", "_damage"];
if (_bodyPartN == 1 && {_damage < PENETRATION_THRESHOLD}) then {
_bodyDamage = _bodyDamage - (_amountOf * _damage);
};
Expand Down
13 changes: 7 additions & 6 deletions addons/medical_damage/functions/fnc_parseConfigForInjuries.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
private _injuriesConfigRoot = configFile >> "ACE_Medical_Injuries";

// --- parse wounds
GVAR(woundClassNames) = [];
GVAR(woundClassNamesComplex) = []; // index = 10 * classID + category; [will contain nils] e.g. ["aMinor", "aMed", "aLarge", nil, nil..."bMinor"]
GVAR(woundsData) = []; // @todo classTypes are strings currently. Convert them to unqiue IDs instead.

private _woundsConfig = _injuriesConfigRoot >> "wounds";
Expand All @@ -34,17 +34,20 @@ private _classID = 0;
private _minDamage = GET_NUMBER(_entry >> "minDamage",0);
private _maxDamage = GET_NUMBER(_entry >> "maxDamage",-1);
private _causes = GET_ARRAY(_entry >> "causes",[]);
private _causeLimping = GET_NUMBER(_entry >> "causeLimping",0);
private _causeLimping = 1 == GET_NUMBER(_entry >> "causeLimping",0);
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
private _causeFracture = 1 == GET_NUMBER(_entry >> "causeFracture",0);
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved

if !(_causes isEqualTo []) then {
GVAR(woundClassNames) pushBack _className;
GVAR(woundsData) pushBack [_classID, _selections, _bleeding, _pain, [_minDamage, _maxDamage], _causes, _className, _causeLimping];
GVAR(woundsData) pushBack [_classID, _selections, _bleeding, _pain, [_minDamage, _maxDamage], _causes, _className, _causeLimping, _causeFracture];
{
GVAR(woundClassNamesComplex) set [10 * _classID + _forEachIndex, format ["%1%2", _className, _x]];
} forEach ["Minor", "Medium", "Large"];
_classID = _classID + 1;
};
} forEach configProperties [_woundsConfig, "isClass _x"];

// --- parse damage types
GVAR(allDamageTypes) = []; // @todo, currently unused by handle damage (was GVAR(allAvailableDamageTypes))
GVAR(allDamageTypesData) = [] call CBA_fnc_createNamespace;

// minimum lethal damage collection, mapped to damageTypes
Expand All @@ -57,8 +60,6 @@ private _selectionSpecificDefault = getNumber (_damageTypesConfig >> "selectionS
private _entry = _x;
private _className = configName _entry;

GVAR(allDamageTypes) pushBack _className;

// Check if this type is in the causes of a wound class, if so, we will store the wound types for this damage type
private _woundTypes = [];
{
Expand Down
4 changes: 4 additions & 0 deletions addons/medical_damage/functions/fnc_woundsHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Public: No
*/

WARNING("this function needs to be updated for changes to woundsHandlerSQF");

params ["_unit", "_bodyPart", "_damage", "_typeOfDamage"];
TRACE_5("start",_unit,_bodyPart,_damage,_typeOfDamage);

Expand Down Expand Up @@ -129,6 +131,8 @@ private _bodyPartVisParams = [_unit, false, false, false, false]; // params arra
_unit setVariable [QEGVAR(medical,openWounds), _openWounds, true];
_unit setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];

[_unit] call EFUNC(medical_status,updateWoundBloodLoss);

_bodyPartVisParams call EFUNC(medical_engine,updateBodyPartVisuals);

[QEGVAR(medical,injured), [_unit, _painLevel]] call CBA_fnc_localEvent;
Expand Down
Loading