Medical damage fix for dead units, cleanup

This commit is contained in:
johnb432
2024-04-10 11:44:40 +02:00
parent 4f51eedaf8
commit 2bf85c0741
5 changed files with 30 additions and 23 deletions

View File

@ -60,7 +60,7 @@ if (!isServer) exitWith {};
private _hashedKey = hashValue _key;
if (isNil "_hashedKey") exitWith {
ERROR_2("Unsupported key type used: %1 - %2 - %3",_key,typeName _key);
ERROR_2("Unsupported key type used: %1 - %2",_key,typeName _key);
};
// To avoid issues, remove existing entries first before overwriting
@ -77,7 +77,7 @@ if (!isServer) exitWith {};
private _hashedKey = hashValue _key;
if (isNil "_hashedKey") exitWith {
ERROR_2("Unsupported key type used: %1 - %2 - %3",_key,typeName _key);
ERROR_2("Unsupported key type used: %1 - %2",_key,typeName _key);
};
(GVAR(fireSources) deleteAt _hashedKey) params [["_fireLogic", objNull]];

View File

@ -16,8 +16,9 @@ params ["_unit"];
if (
GVAR(dropWeapon) > 0 &&
{isNull objectParent _unit && {(currentWeapon _unit) != ""}} &&
{!isPlayer _unit || GVAR(dropWeapon) >= 2}
{isNull objectParent _unit} &&
{(currentWeapon _unit) != ""} &&
{!isPlayer _unit || GVAR(dropWeapon) == 2}
) then {
_unit call EFUNC(common,throwWeapon);
};

View File

@ -67,8 +67,8 @@ params ["_unit", "_instigator"];
_distancePercent = 1 - ((_unit distance _x) / BURN_PROPAGATE_DISTANCE);
_adjustedIntensity = _intensity * _distancePercent;
// Don't burn if intensity is too low
if (BURN_MIN_INTENSITY > _adjustedIntensity) then {
// Don't burn if intensity is too low or already burning with higher intensity
if (BURN_MIN_INTENSITY > _adjustedIntensity || {(_x getVariable [QGVAR(intensity), 0]) > _adjustedIntensity}) then {
continue;
};
@ -138,16 +138,20 @@ params ["_unit", "_instigator"];
_unit call FUNC(burnReaction);
};
// Common burn areas are the hands and face https://www.ncbi.nlm.nih.gov/pubmed/16899341/
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 / BURN_MAX_INTENSITY, _woundSelection, "burn", _instigator] call EFUNC(medical,addDamageToUnit);
} else {
[_unit, 0.15, _woundSelection, "burn", _instigator] call EFUNC(medical,addDamageToUnit);
if (!isNull _instigator) then {
_unit setVariable [QEGVAR(medical,lastDamageSource), _instigator];
_unit setVariable [QEGVAR(medical,lastInstigator), _instigator];
};
// Common burn areas are the hands and face https://www.ncbi.nlm.nih.gov/pubmed/16899341/
private _bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] selectRandomWeighted [0.77, 0.5, 0.8, 0.8, 0.3, 0.3];
// Keep pain around unconciousness limit to allow for more fun interactions
private _damageToAdd = [0.15, _intensity / BURN_MAX_INTENSITY] select (!alive _unit || {GET_PAIN_PERCEIVED(_unit) < (PAIN_UNCONSCIOUS + random 0.2)});
// Use event directly, as ace_medical_fnc_addDamageToUnit requires unit to be alive
[QEGVAR(medical,woundReceived), [_unit, [[_damageToAdd, _bodyPart, _damageToAdd]], _instigator, "burn"]] call CBA_fnc_localEvent;
_unit setVariable [QGVAR(intensity), _intensity, true]; // globally sync intensity across all clients to make sure simulation is deterministic
};
}, BURN_PROPAGATE_UPDATE, [_unit, _instigator]] call CBA_fnc_addPerFrameHandler;

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Author: tcvm, johnb43
* Handles various objects on fire and determines if units close to objects deserve to get burned.
*
* Arguments:

View File

@ -2,6 +2,7 @@
/*
* Author: tcvm
* Decreases burning intensity on successful medical action.
* The medical action is looped until the user stops the interaction or the unit is no longer burning.
*
* Arguments:
* 0: Medic <OBJECT>
@ -25,15 +26,16 @@ _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 the unit is still burning, loop the medical action
if !(_patient call FUNC(isBurning)) exitWith {};
if (EGVAR(medical_gui,pendingReopen)) then {
TRACE_1("temporarily blocking medical menu reopen",_this);
TRACE_1("patient still burning, looping",_this);
EGVAR(medical_gui,pendingReopen) = false;
[{EGVAR(medical_gui,pendingReopen) = true}] call CBA_fnc_execNextFrame;
};
if (EGVAR(medical_gui,pendingReopen)) then {
TRACE_1("temporarily blocking medical menu reopen",_this);
[_medic, _patient, _bodyPart, _classname] call EFUNC(medical_treatment,treatment);
EGVAR(medical_gui,pendingReopen) = false;
[{EGVAR(medical_gui,pendingReopen) = true}] call CBA_fnc_execNextFrame;
};
[_medic, _patient, _bodyPart, _classname] call EFUNC(medical_treatment,treatment);