Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase blood bag flow rate for basic medical #4306

Merged
merged 2 commits into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addons/medical/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ADDON = false;
#include "XEH_PREP.hpp"

GVAR(injuredUnitCollection) = [];
GVAR(IVBags) = [];

private _versionEx = "ace_medical" callExtension "version";
DFUNC(handleDamage_assignWounds) = if (_versionEx == "") then {
Expand Down
9 changes: 4 additions & 5 deletions addons/medical/functions/fnc_displayPatientInformation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ if (_show) then {
};

private _totalIvVolume = 0;
private _bloodBags = _unit getVariable [QGVAR(ivBags), []];
{
private _value = _target getVariable _x;
if !(isnil "_value") then {
_totalIvVolume = _totalIvVolume + (_target getVariable [_x, 0]);
};
} foreach GVAR(IVBags);
_x params ["_bagVolumeRemaining"];
_totalIvVolume = _totalIvVolume + _bagVolumeRemaining;
} foreach _bloodBags;

if (_totalIvVolume >= 1) then {
_genericMessages pushback [format[localize LSTRING(receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]];
Expand Down
55 changes: 27 additions & 28 deletions addons/medical/functions/fnc_getBloodVolumeChange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Global Sync Values (bloodbags) <BOOL>
*
* ReturnValue:
* Current cardiac output <NUMBER>
* Blood volume change (in % total) <NUMBER>
*
* Public: No
*/
Expand All @@ -16,40 +17,38 @@
/*
IV Change per second calculation:
250ml should take 60 seconds to fill. 250/60 = 4.166.
*/
#define IV_CHANGE_PER_SECOND -4.166

/*
Blood Change per second calculation for IVs:
250ml should take 60 seconds to fill in. Total blood volume is 7000ml = 100%.
7000/100 = 70 = 1%
250 / 70 = 3.571428571%
3.571428571 / 60 = 0.0595% per second.
*/
#define BLOOD_CHANGE_PER_SECOND 0.0595

#define EMPTY_IV_BAG_VALUE 0
#define IV_VOLUME (_unit getVariable [_x, EMPTY_IV_BAG_VALUE]) + IV_CHANGE_PER_SECOND
Basic medical is 10x (will take 6 seconds for 250ml)
*/
#define IV_CHANGE_PER_SECOND ([41.66, 4.166] select (GVAR(level) >= 2))

private ["_bloodVolume", "_bloodVolumeChange", "_ivVolume"];
params ["_unit"];
params ["_unit", "_syncValues"];

private _bloodVolume = _unit getVariable [QGVAR(bloodVolume), 100];
private _bloodVolumeChange = -([_unit] call FUNC(getBloodLoss));

if (_bloodVolume < 100) then {
{
if ((_unit getVariable [_x, EMPTY_IV_BAG_VALUE]) > EMPTY_IV_BAG_VALUE) then {
_bloodVolumeChange = _bloodVolumeChange + BLOOD_CHANGE_PER_SECOND;
_unit setVariable [_x, IV_VOLUME];
if (!isNil {_unit getVariable QGVAR(ivBags)}) then {
if (_bloodVolume < 100) then {
private _bloodBags = _unit getVariable [QGVAR(ivBags), []];
_bloodBags = _bloodBags apply {
_x params ["_bagVolumeRemaining"];
private _bagChange = IV_CHANGE_PER_SECOND min _bagVolumeRemaining; // absolute value of the change in miliLiters
_bagVolumeRemaining = _bagVolumeRemaining - _bagChange;
_bloodVolumeChange = _bloodVolumeChange + (_bagChange / 70); // ((bag change in ml) / (body total:7000ml)) out of 100 percent
if (_bagVolumeRemaining < 0.01) then {
[]
} else {
[_bagVolumeRemaining];
};
};
} forEach GVAR(IVBags);
} else {
{
if ((_unit getVariable [_x, EMPTY_IV_BAG_VALUE]) > EMPTY_IV_BAG_VALUE) then {
_unit setVariable [_x, EMPTY_IV_BAG_VALUE]; // lets get rid of exessive IV volume
_bloodBags = _bloodBags - [[]]; // remove empty bags
if (_bloodBags isEqualTo []) then {
_unit setVariable [QGVAR(ivBags), nil, true]; // no bags left - clear variable (always globaly sync this)
} else {
_unit setVariable [QGVAR(ivBags), _bloodBags, _syncValues];
};
} forEach GVAR(IVBags);
} else {
_unit setVariable [QGVAR(ivBags), nil, true]; // blood volume = 100% - clear variable (always globaly sync this)
};
};

_bloodVolumeChange;
14 changes: 1 addition & 13 deletions addons/medical/functions/fnc_handleUnitVitals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (_syncValues) then {
_unit setVariable [QGVAR(lastMomentValuesSynced), CBA_missionTime];
};

private _bloodVolume = (_unit getVariable [QGVAR(bloodVolume), 100]) + ([_unit] call FUNC(getBloodVolumeChange));
private _bloodVolume = (_unit getVariable [QGVAR(bloodVolume), 100]) + ([_unit, _syncValues] call FUNC(getBloodVolumeChange));
_bloodVolume = _bloodVolume max 0;

_unit setVariable [QGVAR(bloodVolume), _bloodVolume, _syncValues];
Expand Down Expand Up @@ -141,16 +141,4 @@ if (GVAR(level) >= 2) then {
[_unit] call FUNC(setCardiacArrest);
};
};

// syncing any remaining values
if (_syncValues) then {
TRACE_3("ACE_DEBUG_IVBAGS_SYNC",GVAR(IVBags),_syncValues,_unit);
{
private "_value";
_value = _unit getVariable _x;
if !(isNil "_value") then {
_unit setVariable [_x,(_unit getVariable [_x, 0]), true];
};
} forEach GVAR(IVBags);
};
};
4 changes: 1 addition & 3 deletions addons/medical/functions/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ _unit setVariable [QGVAR(triageLevel), 0, true];
_unit setVariable [QGVAR(triageCard), [], true];

// IVs
_unit setVariable [QGVAR(salineIVVolume), 0, true];
_unit setVariable [QGVAR(plasmaIVVolume), 0, true];
_unit setVariable [QGVAR(bloodIVVolume), 0, true];
_unit setVariable [QGVAR(ivBags), nil, true];

// damage storage
_unit setVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0], true];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ if (alive _target) exitWith {
_target setVariable [QGVAR(fractures), []];

// IVs
_target setVariable [QGVAR(salineIVVolume), 0];
_target setVariable [QGVAR(plasmaIVVolume), 0];
_target setVariable [QGVAR(bloodIVVolume), 0];
_target setVariable [QGVAR(ivBags), nil, true];

// damage storage
_target setVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0], true];
Expand Down
10 changes: 3 additions & 7 deletions addons/medical/functions/fnc_treatmentIVLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ if (isClass (_config >> _treatmentClassname)) then {
ERROR("IV Treatment Classname not found");
};

private _varName = format["ACE_Medical_IVVolume_%1",_typeOf];
_target setVariable [_varName, (_target getVariable [_varName, 0]) + _volumeAdded, true];

if !(_varName in GVAR(IVBags)) then {
GVAR(IVBags) pushBack _varName;
publicVariable QGVAR(IVBags);
};
private _bloodBags = _target getVariable [QGVAR(ivBags), []];
_bloodBags pushBack [_volumeAdded]; // Future BagType: [_volumeAdded, _typeOf]
_target setVariable [QGVAR(ivBags), _bloodBags, true];