Medical - Refactor Clear Trauma Setting (#8345)

* Refactor Clear Trauma

Add in setting for clearing trauma after stitching a wound, make clearing trauma after bandage clear trauma of individual wounds as they're bandaged instead of all at once when fully bandaged.

* Make git diff slightly prettier.

* Update fnc_bandageLocal.sqf

* Style pass

* once more for the diff

* fix stupid

* Ddd trauma/visuals on bandage reopening
This commit is contained in:
GhostIsSpooky 2021-10-12 05:08:10 -03:00 committed by GitHub
parent fad7f84625
commit 374a5b632f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 46 deletions

View File

@ -55,25 +55,25 @@ if (EGVAR(medical,limping) == 1 && {_partIndex > 3} && {_amountOf <= 0} && {_pat
[_patient] call EFUNC(medical_engine,updateDamageEffects);
};
if (GVAR(clearTraumaAfterBandage)) then {
TRACE_2("clearTraumaAfterBandage - checking open wounds",_partIndex,_openWounds);
if ((_openWounds findIf {
_x params ["", "_xBodyPartN", "_xAmountOf"];
(_partIndex ==_xBodyPartN) && {_xAmountOf > 0}
}) == -1) then {
private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
if (GVAR(clearTrauma) == 2) then {
TRACE_2("clearTrauma - clearing trauma after bandage",_partIndex,_openWounds);
private _treatedDamageOf = (_wound select 4) * _impact;
private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
private _newDam = (_bodyPartDamage select _partIndex) - _treatedDamageOf;
if (_newDam < 0.05) then { // Prevent obscenely small damage from lack of floating precision
_bodyPartDamage set [_partIndex, 0];
_patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
TRACE_2("fully healed",_partIndex,_bodyPartDamage);
} else {
_bodyPartDamage set [_partIndex, _newDam];
};
_patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
TRACE_2("clearTrauma - healed damage",_partIndex,_treatedDamageOf);
switch (_partIndex) do {
case 0: { [_patient, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 1: { [_patient, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 2;
case 3: { [_patient, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); };
};
switch (_partIndex) do {
case 0: { [_patient, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 1: { [_patient, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 2;
case 3: { [_patient, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); };
};
};

View File

@ -118,6 +118,24 @@ if (random 1 <= _reopeningChance * GVAR(woundReopenChance)) then {
[_target] call EFUNC(medical_status,updateWoundBloodLoss);
// Re-add trauma and damage visuals
if (GVAR(clearTrauma) == 2) then {
private _injuryDamage = (_selectedInjury select 4) * _impact;
private _bodyPartDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
private _newDam = (_bodyPartDamage select _selBodyPart) + _injuryDamage;
_bodyPartDamage set [_selBodyPart, _newDam];
_target setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
switch (_selBodyPart) do {
case 0: { [_target, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 1: { [_target, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 2;
case 3: { [_target, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
default { [_target, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); };
};
};
// Check if we gained limping from this wound re-opening
if ((EGVAR(medical,limping) == 1) && {_bodyPartN > 3}) then {
[_target] call EFUNC(medical_engine,updateDamageEffects);

View File

@ -35,7 +35,7 @@ private _stitchedWounds = GET_STITCHED_WOUNDS(_patient);
// Remove the first stitchable wound from the bandaged wounds
private _treatedWound = _bandagedWounds deleteAt (_bandagedWounds find (_stitchableWounds select 0));
_treatedWound params ["_treatedID", "_treatedBodyPartN", "_treatedAmountOf"];
_treatedWound params ["_treatedID", "_treatedBodyPartN", "_treatedAmountOf", "", "_treatedDamageOf"];
// Check if we need to add a new stitched wound or increase the amount of an existing one
private _woundIndex = _stitchedWounds findIf {
@ -51,6 +51,22 @@ if (_woundIndex == -1) then {
_wound set [2, (_wound select 2) + _treatedAmountOf];
};
if (GVAR(clearTrauma) == 1) then {
TRACE_2("clearTrauma - clearing trauma after stitching",_partIndex,_treatedWound);
private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), []];
_bodyPartDamage set [_treatedBodyPartN, (_bodyPartDamage select _treatedBodyPartN) - _treatedDamageOf];
_patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
TRACE_2("clearTrauma - healed damage",_partIndex,_treatedDamageOf);
switch (_treatedBodyPartN) do {
case 0: { [_patient, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 1: { [_patient, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
case 2;
case 3: { [_patient, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); };
};
};
_patient setVariable [VAR_BANDAGED_WOUNDS, _bandagedWounds, true];
_patient setVariable [VAR_STITCHED_WOUNDS, _stitchedWounds, true];

View File

@ -35,11 +35,11 @@
] call CBA_fnc_addSetting;
[
QGVAR(clearTraumaAfterBandage),
"CHECKBOX",
[LSTRING(ClearTraumaAfterBandage_DisplayName), LSTRING(ClearTraumaAfterBandage_Description)],
QGVAR(clearTrauma),
"LIST",
[LSTRING(ClearTrauma_DisplayName), LSTRING(ClearTrauma_Description)],
[ELSTRING(medical,Category), LSTRING(SubCategory_Treatment)],
false,
[[0, 1, 2], [ELSTRING(common,Never), LSTRING(ClearTrauma_AfterStitch), LSTRING(ClearTrauma_AfterBandage)], 1],
true
] call CBA_fnc_addSetting;

View File

@ -150,31 +150,17 @@
<Turkish>Yaranın yeniden açılma şansını kontrol etme katsayısı. Son yeniden açılma şansı, bu değerin kullanılan yara tipi ve bandaj için spesifik yeniden açılma şansı ile çarpılmasıyla belirlenir.</Turkish>
<Spanish>Coeficiente que controla la probabilidad de reapertura de heridas. La probabilidad final de reapertura de heridas queda determinada multiplicando este valor por la probabilidad específica del tipo de herida y venda usada.</Spanish>
</Key>
<Key ID="STR_ACE_Medical_Treatment_ClearTraumaAfterBandage_DisplayName">
<English>Clear Trauma After Bandage</English>
<Japanese>治療後に外傷を削除</Japanese>
<Chinese>包紮即痊癒</Chinese>
<French>Guérir les blessures pansées</French>
<Czech>Odebrat úraz po obvázání</Czech>
<Polish>Usuń uraz po zabandażowaniu</Polish>
<Italian>Rimozione ferite bendate</Italian>
<German>Entferne Trauma nach Bandagierung.</German>
<Russian>Удалять травму после перевязки</Russian>
<Turkish>Bandaj Sonrası Travmayı Temizle</Turkish>
<Spanish>Quitar trauma despues de vendaje</Spanish>
<Key ID="STR_ACE_Medical_Treatment_ClearTrauma_DisplayName">
<English>Clear Trauma</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_ClearTraumaAfterBandage_Description">
<English>Controls whether fully bandaged body parts are healed.</English>
<Japanese>全ての傷に対して包帯を巻いた部分を治癒するかどうかを決定します。</Japanese>
<Polish>Kontroluje czy w pełni zabandażowane części ciała są uleczone.</Polish>
<French>Définit s'il faut guérir les parties du corps entièrement bandées.</French>
<Italian>Controlla se le parti del corpo completamente bendate sono guarite.</Italian>
<German>Kontrolliert, ob voll bandagierte Körperteile geheilt werden.</German>
<Chinese>控制說當傷口處理好的時候是否直接痊癒。</Chinese>
<Czech>Nastavuje zda jsou plně obvázané části těla vyléčena.</Czech>
<Russian>Контролирует то, что полностью перевязанные раны целиком исцеляют часть тела.</Russian>
<Turkish>Tamamen sargılı vücut kısımlarının iyileşip iyileşmediğini kontrol eder.</Turkish>
<Spanish>Controla si las partes del cuerpo completamente vendadas se curan.</Spanish>
<Key ID="STR_ACE_Medical_Treatment_ClearTrauma_Description">
<English>Controls when hitpoint damage from wounds is healed.</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_ClearTrauma_AfterBandage">
<English>After Bandage</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_ClearTrauma_AfterStitch">
<English>After Stitch</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_LocationsBoostTraining_DisplayName">
<English>Locations Boost Training</English>