Skip to content

Commit

Permalink
Limping / Splint Treatment (#6947)
Browse files Browse the repository at this point in the history
* Improve adjustment calcs / wound blood loss / medications

fix func descriptions

Calc wound blood loss on events

reorder includes so scritpmacroMed has global effect

trivial optimization for getCardiacOutput

Fix var

Fix wounds not reopening (nil _category)

Fix surgical kit inherting canBandage conditional

debug hitpoints

Update ACE_Medical_Treatment_Actions.hpp

Use woundBleeding for IS_BLEEDING macro

rework medication vars

comments

Reset var in init / fullHeal

Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf

Co-Authored-By: PabstMirror <pabstmirror@gmail.com>

* Change wound data array

Drop unique id and merge classId and category

* Splinting and treatment and gui

* Add arm fractures and aim effects

* localizations and event

* fix

* cleanup

* Apply suggestions from code review

Co-Authored-By: PabstMirror <pabstmirror@gmail.com>

* formating, rename bone images

* Apply suggestions from code review

Co-Authored-By: PabstMirror <pabstmirror@gmail.com>

* disable calls to extension

* Update fnc_onMedicationUsage.sqf

* Medical - Skip unneeded setVars on initUnit (#6949)

*  Medical - Transfer state machine state on locality (#6950)

* Medical - Transfer state machine state on locality

* Fix feedback isUnconscious var

* Exclude AI

* Make UAV excludes consistant, formating

* Update fnc_treatmentFullHealLocal.sqf

* reset fractures on respawn
  • Loading branch information
PabstMirror authored May 12, 2019
1 parent 22b8e9e commit 7eb54e1
Show file tree
Hide file tree
Showing 56 changed files with 624 additions and 238 deletions.
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;
{
_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
23 changes: 16 additions & 7 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 Down Expand Up @@ -59,6 +60,10 @@
_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 @@ -82,24 +87,24 @@
_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", "_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;

// Stitched Wounds:
_return pushBack "------- Stitched Wounds: -------";
private _wounds = _unit getVariable [QEGVAR(medical,stitchedWounds), []];
{
_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;

// IVs:
Expand Down Expand Up @@ -139,6 +144,10 @@
_return pushBack "------- Medications Raw: -------";
_return append _rawMedications;

if (_unit isEqualTo ACE_player) then {
_return pushBack format ["ACE_setCustomAimCoef: %1", [missionNamespace, "ACE_setCustomAimCoef", "max"] call EFUNC(common,arithmeticGetResult)];
};

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

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",
[LSTRING(setting_limping_DisplayName), LSTRING(setting_limping_Description)],
_categoryArray,
[[0,1,2],[LELSTRING(common,disabled), LLSTRING(setting_limping_limpOnOpenWounds), LLSTRING(setting_limping_limpRequiresStitching)], 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",
[LSTRING(setting_fractures_DisplayName), LSTRING(setting_fractures_Description)],
_categoryArray,
[[0,1,2],[LELSTRING(common,disabled), LLSTRING(setting_fractures_splintHealsFully), LLSTRING(setting_fractures_splintHasEffects)], 1], // [values, titles, defaultIndex]
true, // isGlobal
{[QEGVAR(medical,fractures), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;
24 changes: 24 additions & 0 deletions addons/medical/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -481,5 +481,29 @@
<Korean>뚜껑 닫기</Korean>
<Polish>Zamknij pokrywę</Polish>
</Key>
<Key ID="STR_ACE_Medical_setting_limping_DisplayName">
<English>Limping</English>
</Key>
<Key ID="STR_ACE_Medical_setting_limping_Description">
<English>Limp when unit has leg wounds...(todo)</English>
</Key>
<Key ID="STR_ACE_Medical_setting_limping_limpOnOpenWounds">
<English>Limp on open wounds</English>
</Key>
<Key ID="STR_ACE_Medical_setting_limping_limpRequiresStitching">
<English>Limp on open or bandaged wounds</English>
</Key>
<Key ID="STR_ACE_Medical_setting_fractures_DisplayName">
<English>Fractues</English>
</Key>
<Key ID="STR_ACE_Medical_setting_fractures_Description">
<English>Limp fractures... (todo)</English>
</Key>
<Key ID="STR_ACE_Medical_setting_fractures_splintHealsFully">
<English>Splints fully heal fractures</English>
</Key>
<Key ID="STR_ACE_Medical_setting_fractures_splintHasEffects">
<English>Splints heal (but cannot sprint)</English>
</Key>
</Package>
</Project>
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
24 changes: 13 additions & 11 deletions addons/medical_damage/functions/fnc_parseConfigForInjuries.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ private _injuriesConfigRoot = configFile >> "ACE_Medical_Injuries";

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

private _woundsConfig = _injuriesConfigRoot >> "wounds";
private _classID = 0;
Expand All @@ -34,17 +35,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 = GET_NUMBER(_entry >> "causeLimping",0) == 1;
private _causeFracture = GET_NUMBER(_entry >> "causeFracture",0) == 1;

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 +61,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 Expand Up @@ -89,8 +91,8 @@ private _selectionSpecificDefault = getNumber (_damageTypesConfig >> "selectionS
];
TRACE_1("",_extensionArgs);

private _extensionRes = "ace_medical" callExtension _extensionArgs;
TRACE_1("",_extensionRes);
// private _extensionRes = "ace_medical" callExtension _extensionArgs;
// TRACE_1("",_extensionRes);
} forEach configProperties [_damageTypesConfig, "isClass _x"];

// extension loading
Expand Down Expand Up @@ -121,8 +123,8 @@ private _selectionSpecificDefault = getNumber (_damageTypesConfig >> "selectionS
];
TRACE_1("",_extensionArgs);

private _extensionRes = "ace_medical" callExtension _extensionArgs;
TRACE_1("",_extensionRes);
// private _extensionRes = "ace_medical" callExtension _extensionArgs;
// TRACE_1("",_extensionRes);
} forEach GVAR(woundsData);

"ace_medical" callExtension "ConfigComplete";
// "ace_medical" callExtension "ConfigComplete";
2 changes: 2 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_4("start",_unit,_bodyPart,_damage,_typeOfDamage);

Expand Down
Loading

0 comments on commit 7eb54e1

Please sign in to comment.