From beffc7660cb21be397b95d52689230c8dba2a2f3 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Sat, 24 Jun 2023 04:08:23 +0200 Subject: [PATCH] Fire - Loop "Pat down" action until patient is put out of fire (#9017) * Adjust burn intensity defines and move to shared * Loop "Pat down" action until patient is put out of fire --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/fire/functions/fnc_burn.sqf | 8 +++----- addons/fire/functions/fnc_medical_success.sqf | 15 ++++++++++++++- addons/fire/script_component.hpp | 4 ++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/addons/fire/functions/fnc_burn.sqf b/addons/fire/functions/fnc_burn.sqf index 15f38435ab..e4c14e3d20 100644 --- a/addons/fire/functions/fnc_burn.sqf +++ b/addons/fire/functions/fnc_burn.sqf @@ -23,8 +23,6 @@ #define BURN_PROPOGATE_UPDATE 1 #define BURN_PROPOGATE_DISTANCE 2 #define BURN_PROPOGATE_COUNTER_MAX 5 -#define MAX_INTENSITY 10 -#define MIN_INTENSITY 1 params ["_unit", "_intensity", ["_instigator", objNull]]; @@ -44,7 +42,7 @@ if (_isBurning) exitWith {}; _intensity = 0; }; - _fireParticle setDropInterval (0.01 max linearConversion [MAX_INTENSITY, MIN_INTENSITY, _intensity, 0.03, 0.1, false]); + _fireParticle setDropInterval (0.01 max linearConversion [BURN_MAX_INTENSITY, BURN_MIN_INTENSITY, _intensity, 0.03, 0.1, false]); _fireParticle setParticleParams [ ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 10, 32], // sprite sheet values "", // animation name @@ -235,7 +233,7 @@ if (_isBurning) exitWith {}; private _woundSelection = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] selectRandomWeighted [0.77, 0.5, 0.8, 0.8, 0.3, 0.3]; if (GET_PAIN_PERCEIVED(_unit) < (PAIN_UNCONSCIOUS + random 0.2)) then { // keep pain around unconciousness limit to allow for more fun interactions - [_unit, _intensity / MAX_INTENSITY, _woundSelection, "burn", _instigator] call EFUNC(medical,addDamageToUnit); + [_unit, _intensity / BURN_MAX_INTENSITY, _woundSelection, "burn", _instigator] call EFUNC(medical,addDamageToUnit); } else { [_unit, 0.15, _woundSelection, "burn", _instigator] call EFUNC(medical,addDamageToUnit); }; @@ -336,5 +334,5 @@ if (_isBurning) exitWith {}; private _unitAlive = (alive _unit) && { getNumber ((configOf _unit) >> "isPlayableLogic") != 1 }; private _unitIsUnit = { (_unit != vehicle _unit) && { isNull vehicle _unit } }; - !_unitAlive || _unitIsUnit || { _intensity <= MIN_INTENSITY } || { !([_unit] call FUNC(isBurning)) } + !_unitAlive || _unitIsUnit || { _intensity <= BURN_MIN_INTENSITY } || { !([_unit] call FUNC(isBurning)) } }, ["_intensity", "_fireParticle", "_smokeParticle", "_fireLight", "_fireSound", "_lightFlare", "_lastIntensityUpdate", "_lastPropogateUpdate", "_isThisUnitAlive"]] call CBA_fnc_createPerFrameHandlerObject; diff --git a/addons/fire/functions/fnc_medical_success.sqf b/addons/fire/functions/fnc_medical_success.sqf index a47d4eb4f0..f3a30faee9 100644 --- a/addons/fire/functions/fnc_medical_success.sqf +++ b/addons/fire/functions/fnc_medical_success.sqf @@ -16,8 +16,21 @@ * Public: No */ -params ["_medic", "_patient"]; +params ["_medic", "_patient", "_bodyPart", "_classname"]; private _intensity = _patient getVariable [QGVAR(intensity), 0]; _intensity = _intensity * INTENSITY_DECREASE_MULT_PAT_DOWN; _patient setVariable [QGVAR(intensity), _intensity, true]; + +if (_intensity > BURN_MIN_INTENSITY) then { + TRACE_1("patient still burning, looping",_this); + + if (EGVAR(medical_gui,pendingReopen)) then { + LOG("temporarily blocking medical menu reopen"); + + EGVAR(medical_gui,pendingReopen) = false; + [{EGVAR(medical_gui,pendingReopen) = true}] call CBA_fnc_execNextFrame; + }; + + [_medic, _patient, _bodyPart, _classname] call EFUNC(medical_treatment,treatment); +}; diff --git a/addons/fire/script_component.hpp b/addons/fire/script_component.hpp index 1bf14ca083..86ef159aae 100644 --- a/addons/fire/script_component.hpp +++ b/addons/fire/script_component.hpp @@ -31,5 +31,9 @@ "amovppnemstpsoptwbindnon_amovppnemevasoptwbindr"\ ] + +#define BURN_MAX_INTENSITY 10 +#define BURN_MIN_INTENSITY 1 + #define INTENSITY_DECREASE_MULT_PAT_DOWN 0.8 #define INTENSITY_DECREASE_MULT_ROLLING INTENSITY_DECREASE_MULT_PAT_DOWN