-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
780fd5e
commit 6ca29ab
Showing
3 changed files
with
102 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: Glowbal, Cplhardcore | ||
* Handles the medication given to a patient. | ||
* | ||
* Arguments: | ||
* 0: Patient <OBJECT> | ||
* 1: Medication Treatment classname <STRING> | ||
* 2: Incompatible medication <ARRAY of <STRING, NUMBER>> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [player, "morphine", [["x", 1]]] call ace_medical_treatment_fnc_onMedicationUsage | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_target", "_className", "_incompatibleMedication"]; | ||
TRACE_3("onMedicationUsage",_target,_className,_incompatibleMedication); | ||
|
||
if (QGVAR(AMS_Enabled)) then { | ||
private _medicationParts = (_className splitString "_"); | ||
|
||
if (count _medicationParts > 3) then { | ||
_medicationName = _medicationParts select 1; { | ||
private _defaultConfig = configFile >> QUOTE(ADDON) >> "Medication"; | ||
private _medicationConfig = _defaultConfig >> _medicationName; | ||
private _maxDose = GET_NUMBER(_medicationConfig >> "maxDose",getNumber (_defaultConfig >> "maxDose")); | ||
|
||
if (_maxDose > 0) then { | ||
private _maxDoseDeviation = GET_NUMBER(_medicationConfig >> "maxDoseDeviation",getNumber (_defaultConfig >> "maxDoseDeviation")); | ||
private _currentDose = [_target, _medicationName] call EFUNC(medical_status,getMedicationCount) select 0; | ||
// Because both {floor random 0} and {floor random 1} return 0 | ||
if (_maxDoseDeviation > 0) then { | ||
_maxDoseDeviation = _maxDoseDeviation + 1; | ||
}; | ||
|
||
private _limit = _maxDose + (floor random _maxDoseDeviation); | ||
if (_currentDose > _limit) then { | ||
TRACE_1("exceeded max dose",_currentDose); | ||
[_target, _medicationName, _currentDose, _limit, _incompatibleMed] call FUNC(overDose); | ||
}; | ||
{ | ||
_x params ["_xMed", "_xLimit"]; | ||
private _inSystem = ([_target, _xMed] call EFUNC(medical_status,getMedicationCount)) select 0; | ||
if (_inSystem > _xLimit) then { | ||
[_target, _medicationName, _inSystem, _xLimit, _xMed] call FUNC(overDose); | ||
}; | ||
} forEach _incompatibleMedication; | ||
}; | ||
}; | ||
}; | ||
} else { | ||
private _defaultConfig = configFile >> QUOTE(ADDON) >> "Medication"; | ||
private _medicationConfig = _defaultConfig >> _classname; | ||
private _maxDose = GET_NUMBER(_medicationConfig >> "maxDose",getNumber (_defaultConfig >> "maxDose")); | ||
|
||
if (_maxDose > 0) then { | ||
private _maxDoseDeviation = GET_NUMBER(_medicationConfig >> "maxDoseDeviation",getNumber (_defaultConfig >> "maxDoseDeviation")); | ||
private _currentDose = [_target, _className] call EFUNC(medical_status,getMedicationCount) select 0; | ||
// Because both {floor random 0} and {floor random 1} return 0 | ||
if (_maxDoseDeviation > 0) then { | ||
_maxDoseDeviation = _maxDoseDeviation + 1; | ||
}; | ||
|
||
private _limit = _maxDose + (floor random _maxDoseDeviation); | ||
if (_currentDose > _limit) then { | ||
TRACE_1("exceeded max dose",_currentDose); | ||
[_target, _classname, _currentDose, _limit, _classname] call FUNC(overDose); | ||
}; | ||
}; | ||
|
||
// Check incompatible medication (format [med,limit]) | ||
{ | ||
_x params ["_xMed", "_xLimit"]; | ||
private _inSystem = ([_target, _xMed] call EFUNC(medical_status,getMedicationCount)) select 0; | ||
if (_inSystem > _xLimit) then { | ||
[_target, _classname, _inSystem, _xLimit, _xMed] call FUNC(overDose); | ||
}; | ||
} forEach _incompatibleMedication;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters