Merge pull request #169 from KoffeinFlummi/Medical_Medication

Medical: Advanced medication improvements
This commit is contained in:
Glowbal
2015-03-04 13:16:22 +01:00
4 changed files with 74 additions and 21 deletions

View File

@ -630,25 +630,34 @@ class ACE_Medical_Advanced {
// How much does the pain get reduced? // How much does the pain get reduced?
painReduce = 0; painReduce = 0;
// How much will the heart rate be increased when the HR is low (below 55)? {minIncrease, maxIncrease, seconds} // How much will the heart rate be increased when the HR is low (below 55)? {minIncrease, maxIncrease, seconds}
hrIncreaseLow[] = {10, 20, 35}; hrIncreaseLow[] = {0, 0, 0};
hrIncreaseNormal[] = {10, 50, 40}; hrIncreaseNormal[] = {0, 0, 0};
hrIncreaseHigh[] = {10, 40, 50}; hrIncreaseHigh[] = {0, 0, 0};
// Callback once the heart rate values have been added.
hrCallback = "";
// How long until this medication has disappeared // How long until this medication has disappeared
timeInSystem = 120; timeInSystem = 120;
// How many of this type of medication can be in the system before the patient overdoses? // How many of this type of medication can be in the system before the patient overdoses?
maxDose = 4; maxDose = 4;
// specific details for the ACE_Morphine treatment action. // Function to execute upon overdose. Arguments passed to call back are 0: unit <OBJECT>, 1: medicationClassName <STRING>
onOverDose = "";
// The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress. For liquids, it corresponds to the informal concept of "thickness". This value will increase/decrease the viscoty of the blood with the percentage given. Where 100 = max. Using the minus will decrease viscosity
viscosityChange = 0;
// specific details for the ACE_Morphine treatment action
class Morphine { class Morphine {
painReduce = 1; painReduce = 0.7;
hrIncreaseLow[] = {-10, -30, 35}; hrIncreaseLow[] = {-10, -30, 35};
hrIncreaseNormal[] = {-10, -50, 40}; hrIncreaseNormal[] = {-10, -50, 40};
hrIncreaseHigh[] = {-10, -40, 50}; hrIncreaseHigh[] = {-10, -40, 50};
timeInSystem = 120; timeInSystem = 500;
maxDose = 4; maxDose = 4;
inCompatableMedication[] = {}; inCompatableMedication[] = {};
viscosityChange = 10;
}; };
class Epinephrine { class Epinephrine {
painReduce = 1; painReduce = 0;
hrIncreaseLow[] = {10, 20, 30}; hrIncreaseLow[] = {10, 20, 30};
hrIncreaseNormal[] = {10, 50, 20}; hrIncreaseNormal[] = {10, 50, 20};
hrIncreaseHigh[] = {10, 40, 10}; hrIncreaseHigh[] = {10, 40, 10};
@ -657,14 +666,21 @@ class ACE_Medical_Advanced {
inCompatableMedication[] = {}; inCompatableMedication[] = {};
}; };
class Atropine { class Atropine {
painReduce = 1; painReduce = 0;
hrIncreaseLow[] = {-10, -20, 15}; hrIncreaseLow[] = {20, 30, 15};
hrIncreaseNormal[] = {-10, -50, 20}; hrIncreaseNormal[] = {-10, -50, 20};
hrIncreaseHigh[] = {-10, -40, 10}; hrIncreaseHigh[] = {-10, -40, 10};
timeInSystem = 120; timeInSystem = 120;
maxDose = 6; maxDose = 6;
inCompatableMedication[] = {}; inCompatableMedication[] = {};
}; };
class PainKillers {
painReduce = 0.7;
timeInSystem = 120;
maxDose = 10;
inCompatableMedication[] = {};
viscosityChange = 5;
};
}; };
class IV { class IV {
// volume is in millileters // volume is in millileters

View File

@ -34,7 +34,7 @@ if (!(_unit getvariable [QGVAR(inCardiacArrest),false])) then {
_change = (_values / _time); _change = (_values / _time);
_hrIncrease = _hrIncrease + _change; _hrIncrease = _hrIncrease + _change;
if ( (_time - 1) < 0) then { if ( (_time - 1) <= 0) then {
_time = 0; _time = 0;
_adjustment set [_foreachIndex, ObjNull]; _adjustment set [_foreachIndex, ObjNull];
[_unit] call _callBack; [_unit] call _callBack;
@ -43,7 +43,8 @@ if (!(_unit getvariable [QGVAR(inCardiacArrest),false])) then {
_adjustment set [_foreachIndex, [_values - _change, _time]]; _adjustment set [_foreachIndex, [_values - _change, _time]];
}; };
} else { } else {
_adjustment set [_foreachIndex, ObjNull]; _adjustment set [_foreachIndex, ObjNull];
[_unit] call _callBack;
}; };
}foreach _adjustment; }foreach _adjustment;

View File

@ -18,13 +18,14 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_target", "_className", "_variable", "_maxDosage", "_timeInSystem", "_incompatabileMeds", "_foundEntry", "_allUsedMedication","_allMedsFromClassname", "_usedMeds", "_hasOverDosed", "_med", "_limit", "_classNamesUsed", "_decreaseAmount"]; private ["_target", "_className", "_variable", "_maxDosage", "_timeInSystem", "_incompatabileMeds", "_foundEntry", "_allUsedMedication","_allMedsFromClassname", "_usedMeds", "_hasOverDosed", "_med", "_limit", "_classNamesUsed", "_decreaseAmount", "_viscosityChange", "_viscosityAdjustment", "_medicationConfig", "_onOverDose"];
_target = _this select 0; _target = _this select 0;
_className = _this select 1; _className = _this select 1;
_variable = _this select 2; _variable = _this select 2;
_maxDosage = _this select 3; _maxDosage = _this select 3;
_timeInSystem = _this select 4; _timeInSystem = _this select 4;
_incompatabileMeds = _this select 5; _incompatabileMeds = _this select 5;
_viscosityChange = _this select 6;
_foundEntry = false; _foundEntry = false;
_allUsedMedication = _target getvariable [QGVAR(allUsedMedication), []]; _allUsedMedication = _target getvariable [QGVAR(allUsedMedication), []];
@ -48,7 +49,7 @@ if (!_foundEntry) then {
_usedMeds = _target getvariable [_variable, 0]; _usedMeds = _target getvariable [_variable, 0];
if (_usedMeds >= floor (_maxDosage + round(random(2)))) then { if (_usedMeds >= floor (_maxDosage + round(random(2))) && _maxDosage >= 1) then {
[_target] call FUNC(setDead); [_target] call FUNC(setDead);
}; };
@ -64,15 +65,33 @@ _hasOverDosed = 0;
}foreach _allUsedMedication; }foreach _allUsedMedication;
}foreach _incompatabileMeds; }foreach _incompatabileMeds;
if (_hasOverDosed > 0) then {
_medicationConfig = (configFile >> "ACE_Medical_Advanced" >> "Treatment" >> "Medication");
_onOverDose = getText (_medicationConfig >> "onOverDose");
if (isClass (_medicationConfig >> _className)) then {
_medicationConfig = (_medicationConfig >> _className);
if (isText (_medicationConfig >> "onOverDose")) then { _onOverDose = getText (_medicationConfig >> "onOverDose"); };
};
if (isNil _onOverDose) then {
_onOverDose = compile _onOverDose;
} else {
_onOverDose = missionNamespace getvariable _onOverDose;
};
[_target, _className] call _onOverDose;
};
_decreaseAmount = 1 / _timeInSystem; _decreaseAmount = 1 / _timeInSystem;
_viscosityAdjustment = _viscosityChange / _timeInSystem;
[{ [{
private ["_args", "_target", "_timeInSystem", "_variable", "_amountDecreased","_decreaseAmount", "_usedMeds"]; private ["_args", "_target", "_timeInSystem", "_variable", "_amountDecreased","_decreaseAmount", "_usedMeds", "_viscosityAdjustment"];
_args = _this select 0; _args = _this select 0;
_target = _args select 0; _target = _args select 0;
_timeInSystem = _args select 1; _timeInSystem = _args select 1;
_variable = _args select 2; _variable = _args select 2;
_amountDecreased = _args select 3; _amountDecreased = _args select 3;
_decreaseAmount = _args select 4; _decreaseAmount = _args select 4;
_viscosityAdjustment = _args select 5;
_usedMeds = _target getvariable [_variable, 0]; _usedMeds = _target getvariable [_variable, 0];
_usedMeds = _usedMeds - _decreaseAmount; _usedMeds = _usedMeds - _decreaseAmount;
@ -80,8 +99,11 @@ _decreaseAmount = 1 / _timeInSystem;
_amountDecreased = _amountDecreased + _decreaseAmount; _amountDecreased = _amountDecreased + _decreaseAmount;
if (_amountDecreased >= 1 || (_usedMeds <= 0)) then { // Restoring the viscosity while the medication is leaving the system
_target setvariable [QGVAR(peripheralResistance), ((_target getvariable [QGVAR(peripheralResistance), 100]) - _viscosityAdjustment) max 0];
if (_amountDecreased >= 1 || (_usedMeds <= 0) || !alive _target) then {
[(_this select 1)] call cba_fnc_removePerFrameHandler; [(_this select 1)] call cba_fnc_removePerFrameHandler;
}; };
_args set [3, _amountDecreased]; _args set [3, _amountDecreased];
}, 1, [_target, _timeInSystem, _variable, 0, _decreaseAmount] ] call CBA_fnc_addPerFrameHandler; }, 1, [_target, _timeInSystem, _variable, 0, _decreaseAmount, _viscosityAdjustment] ] call CBA_fnc_addPerFrameHandler;

View File

@ -15,7 +15,7 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_target", "_className", "_currentInSystem", "_medicationConfig", "_painReduce", "_hrIncreaseLow", "_hrIncreaseNorm", "_hrIncreaseHigh", "_maxDose", "_inCompatableMedication", "_timeInSystem", "_heartRate", "_pain"]; private ["_target", "_className", "_currentInSystem", "_medicationConfig", "_painReduce", "_hrIncreaseLow", "_hrIncreaseNorm", "_hrIncreaseHigh", "_maxDose", "_inCompatableMedication", "_timeInSystem", "_heartRate", "_pain", "_resistance", "_hrCallback"];
_target = _this select 0; _target = _this select 0;
_className = _this select 1; _className = _this select 1;
@ -33,6 +33,9 @@ _hrIncreaseNorm = getArray (_medicationConfig >> "hrIncreaseNormal");
_hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh"); _hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh");
_timeInSystem = getNumber (_medicationConfig >> "timeInSystem"); _timeInSystem = getNumber (_medicationConfig >> "timeInSystem");
_maxDose = getNumber (_medicationConfig >> "maxDose"); _maxDose = getNumber (_medicationConfig >> "maxDose");
_viscosityChange = getNumber (_medicationConfig >> "viscosityChange");
_hrCallback = getText (_medicationConfig >> "hrCallback");
_inCompatableMedication = []; _inCompatableMedication = [];
if (isClass (_medicationConfig >> _className)) then { if (isClass (_medicationConfig >> _className)) then {
_medicationConfig = (_medicationConfig >> _className); _medicationConfig = (_medicationConfig >> _className);
@ -43,6 +46,13 @@ if (isClass (_medicationConfig >> _className)) then {
if (isNumber (_medicationConfig >> "timeInSystem")) then { _timeInSystem = getNumber (_medicationConfig >> "timeInSystem"); }; if (isNumber (_medicationConfig >> "timeInSystem")) then { _timeInSystem = getNumber (_medicationConfig >> "timeInSystem"); };
if (isNumber (_medicationConfig >> "maxDose")) then { _maxDose = getNumber (_medicationConfig >> "maxDose"); }; if (isNumber (_medicationConfig >> "maxDose")) then { _maxDose = getNumber (_medicationConfig >> "maxDose"); };
if (isArray (_medicationConfig >> "inCompatableMedication")) then { _inCompatableMedication = getArray (_medicationConfig >> "inCompatableMedication"); }; if (isArray (_medicationConfig >> "inCompatableMedication")) then { _inCompatableMedication = getArray (_medicationConfig >> "inCompatableMedication"); };
if (isNumber (_medicationConfig >> "viscosityChange")) then { _viscosityChange = getNumber (_medicationConfig >> "viscosityChange"); };
if (isText (_medicationConfig >> "hrCallback")) then { _hrCallback = getText (_medicationConfig >> "hrCallback"); };
};
if (isNil _hrCallback) then {
_hrCallback = compile _hrCallback;
} else {
_hrCallback = missionNamespace getvariable _hrCallback;
}; };
// Adjust the heart rate based upon config entry // Adjust the heart rate based upon config entry
@ -50,12 +60,12 @@ _heartRate = _target getvariable [QGVAR(heartRate), 70];
if (alive _target) then { if (alive _target) then {
if (_heartRate > 0) then { if (_heartRate > 0) then {
if (_heartRate <= 45) then { if (_heartRate <= 45) then {
[_target, ((_hrIncreaseLow select 0) + random((_hrIncreaseLow select 1))), (_hrIncreaseLow select 2)] call FUNC(addHeartRateAdjustment); [_target, ((_hrIncreaseLow select 0) + random((_hrIncreaseLow select 1))), (_hrIncreaseLow select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
} else { } else {
if (_heartRate > 120) then { if (_heartRate > 120) then {
[_target, ((_hrIncreaseHigh select 0) + random((_hrIncreaseHigh select 1))), (_hrIncreaseHigh select 2)] call FUNC(addHeartRateAdjustment); [_target, ((_hrIncreaseHigh select 0) + random((_hrIncreaseHigh select 1))), (_hrIncreaseHigh select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
} else { } else {
[_target, ((_hrIncreaseNorm select 0) + random((_hrIncreaseNorm select 1))), (_hrIncreaseNorm select 2)] call FUNC(addHeartRateAdjustment); [_target, ((_hrIncreaseNorm select 0) + random((_hrIncreaseNorm select 1))), (_hrIncreaseNorm select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
}; };
}; };
}; };
@ -69,7 +79,11 @@ if (_pain <= 0) then {
}; };
_target setvariable [QGVAR(pain), _pain]; _target setvariable [QGVAR(pain), _pain];
_resistance = _unit getvariable [QGVAR(peripheralResistance), 100];
_resistance = _resistance + _viscosityChange;
_unit setvariable [QGVAR(peripheralResistance), _resistance max 0];
// Call back to ensure that the medication is decreased over time // Call back to ensure that the medication is decreased over time
[_target, _classname, _varName, _maxDose, _timeInSystem, _inCompatableMedication] call FUNC(onMedicationUsage); [_target, _classname, _varName, _maxDose, _timeInSystem, _inCompatableMedication, _viscosityChange] call FUNC(onMedicationUsage);
true true