Fix various bugs (#6523)

* Fix medical menu not reopening regardless of setting
* Ensure no heartrate or bloodpressure on death
* Fix status variables not being reset on respawn
* Fix JIP resetting status variables for all units
* Fix heart rate adjustment overflow and
This commit is contained in:
Rutger "RedBery" Meijering 2018-08-14 22:34:35 +02:00 committed by SilentSpike
parent 0e8ed5315e
commit 5fbaf426a8
6 changed files with 16 additions and 6 deletions

View File

@ -97,7 +97,7 @@ private _entries = [ACE_player, GVAR(INTERACTION_TARGET), _name] call FUNC(getTr
private _ctrl = (_display displayCtrl (START_IDC + _forEachIndex)); private _ctrl = (_display displayCtrl (START_IDC + _forEachIndex));
if (!(_forEachIndex > AMOUNT_OF_ENTRIES)) then { if (!(_forEachIndex > AMOUNT_OF_ENTRIES)) then {
_ctrl ctrlSetText (_x select 0); _ctrl ctrlSetText (_x select 0);
private _code = format ["ace_medical_menu_pendingReopen = true; call %1;", (_x select 3)]; private _code = format ["ace_medical_gui_pendingReopen = true; call %1;", (_x select 3)];
_ctrl ctrlSetEventHandler ["ButtonClick", _code]; _ctrl ctrlSetEventHandler ["ButtonClick", _code];
_ctrl ctrlSetTooltip (_x select 0); // TODO implement _ctrl ctrlSetTooltip (_x select 0); // TODO implement
_ctrl ctrlShow true; _ctrl ctrlShow true;

View File

@ -14,4 +14,4 @@
params ["_unit"]; params ["_unit"];
(GVAR(fatalInjuryCondition) < 2) && {!(_unit getVariable [QGVAR(deathBlocked), false])} (GVAR(fatalInjuryCondition) < 2) && {!(_unit getVariable [QEGVAR(medical,deathBlocked), false])}

View File

@ -19,4 +19,7 @@ params ["_unit"];
// Send a local event before death // Send a local event before death
[QEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; [QEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent;
_unit setVariable [VAR_HEART_RATE, 0, true];
_unit setVariable [VAR_BLOOD_PRESS, [0, 0], true];
_unit setDamage 1; _unit setDamage 1;

View File

@ -19,6 +19,7 @@ class Extended_PostInit_EventHandlers {
class Extended_Init_EventHandlers { class Extended_Init_EventHandlers {
class CAManBase { class CAManBase {
class ADDON { class ADDON {
onRespawn = 1;
init = QUOTE(call FUNC(initUnit)); init = QUOTE(call FUNC(initUnit));
}; };
}; };

View File

@ -17,6 +17,8 @@
params ["_unit"]; params ["_unit"];
if (!local _unit) exitWith {};
if (damage _unit > 0) then { if (damage _unit > 0) then {
_unit setDamage 0; _unit setDamage 0;
}; };

View File

@ -46,6 +46,7 @@ private _heartRate = GET_HEART_RATE(_unit);
if !IN_CRDC_ARRST(_unit) then { if !IN_CRDC_ARRST(_unit) then {
private _hrChange = 0; private _hrChange = 0;
private _targetHR = 0;
private _bloodVolume = GET_BLOOD_VOLUME(_unit); private _bloodVolume = GET_BLOOD_VOLUME(_unit);
if (_bloodVolume > BLOOD_VOLUME_CLASS_4_HEMORRHAGE) then { if (_bloodVolume > BLOOD_VOLUME_CLASS_4_HEMORRHAGE) then {
GET_BLOOD_PRESSURE(_unit) params ["_bloodPressureL", "_bloodPressureH"]; GET_BLOOD_PRESSURE(_unit) params ["_bloodPressureL", "_bloodPressureH"];
@ -57,23 +58,26 @@ if !IN_CRDC_ARRST(_unit) then {
_targetBP = _targetBP * (_bloodVolume / DEFAULT_BLOOD_VOLUME); _targetBP = _targetBP * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
}; };
private _targetHR = DEFAULT_HEART_RATE; _targetHR = DEFAULT_HEART_RATE;
if (_bloodVolume < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) then { if (_bloodVolume < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) then {
_targetHR = _heartRate * (_targetBP / (45 max _meanBP)); _targetHR = _heartRate * (_targetBP / (45 max _meanBP));
}; };
if (_painLevel > 0.2) then { if (_painLevel > 0.2) then {
_targetHR = _targetHR max (80 + 50 * _painLevel); _targetHR = _targetHR max (80 + 50 * _painLevel);
}; };
_targetHR = _targetHR + _hrTargetAdjustment; _targetHR = (_targetHR + _hrTargetAdjustment) max 0;
_hrChange = round(_targetHR - _heartRate) / 2; _hrChange = round(_targetHR - _heartRate) / 2;
} else { } else {
_hrChange = -round(_heartRate / 10); _hrChange = -round(_heartRate / 10);
}; };
_heartRate = (_heartRate + _deltaT * _hrChange) max 0; if (_hrChange < 0) then {
_heartRate = (_heartRate + _deltaT * _hrChange) max _targetHR;
} else {
_heartRate = (_heartRate + _deltaT * _hrChange) min _targetHR;
};
}; };
_unit setVariable [VAR_HEART_RATE, _heartRate, _syncValue]; _unit setVariable [VAR_HEART_RATE, _heartRate, _syncValue];
_heartRate _heartRate