mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
151d4a4bfe
New settings: * allowSelfIV * showPainInMenu Converted CBA -> ACE Settings: * advancedBandages * advancedMedication * fatalInjuryCondition * cardiacArrestTime Fixed settings: * useLocation_Epi * medicSetting_Epi * painCoefficient
117 lines
3.7 KiB
Plaintext
117 lines
3.7 KiB
Plaintext
/*
|
|
* Author: Glowbal
|
|
* Check if the treatment action can be performed.
|
|
*
|
|
* Arguments:
|
|
* 0: The caller <OBJECT>
|
|
* 1: The target <OBJECT>
|
|
* 2: Body part <STRING>
|
|
* 3: Treatment class name <STRING>
|
|
*
|
|
* ReturnValue:
|
|
* Can Treat <BOOL>
|
|
*
|
|
* Example:
|
|
* [player, cursorTarget, "Head", "SurgicalKit"] call ace_medical_treatment_fnc_canTreat
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
#include "script_component.hpp"
|
|
|
|
params ["_caller", "_target", "_bodyPart", "_className"];
|
|
|
|
if !(_target isKindOf "CAManBase") exitWith {false};
|
|
|
|
private _config = configFile >> QGVAR(Actions) >> _className;
|
|
|
|
if !(isClass _config) exitWith {false};
|
|
|
|
// allow self treatment check
|
|
private _isSelf = _caller isEqualTo _target;
|
|
private _allowSelf = 0;
|
|
|
|
if (_isSelf) then {
|
|
if (isNumber (_config >> "allowSelfTreatment")) then {
|
|
_allowSelf = getNumber (_config >> "allowSelfTreatment");
|
|
} else {
|
|
if (isText (_config >> "allowSelfTreatment")) then {
|
|
_allowSelf = missionNamespace getVariable [getText (_config >> "allowSelfTreatment"), 0];
|
|
};
|
|
};
|
|
};
|
|
|
|
if (_isSelf && {_allowSelf == 0}) exitWith {false};
|
|
|
|
private _medicRequired = 0;
|
|
|
|
if (isNumber (_config >> "requiredMedic")) then {
|
|
_medicRequired = getNumber (_config >> "requiredMedic");
|
|
} else {
|
|
if (isText (_config >> "requiredMedic")) then {
|
|
_medicRequired = missionNamespace getVariable [getText (_config >> "requiredMedic"), 0];
|
|
};
|
|
};
|
|
|
|
if !([_caller, _medicRequired] call EFUNC(medical,isMedic)) exitWith {false};
|
|
|
|
// check selection
|
|
private _allowedSelections = getArray (_config >> "allowedSelections") apply {toLower _x};
|
|
|
|
if !("all" in _allowedSelections || {(_bodyPart in _allowedSelections)}) exitWith {false};
|
|
|
|
// check item
|
|
private _items = getArray (_config >> "items");
|
|
|
|
if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exitWith {false};
|
|
|
|
private _condition = true;
|
|
|
|
if (isText (_config >> "condition")) then {
|
|
_condition = getText (_config >> "condition");
|
|
|
|
if (_condition isEqualTo "") exitWith {
|
|
_condition = true;
|
|
};
|
|
|
|
if (isNil _condition) then {
|
|
_condition = compile _condition;
|
|
} else {
|
|
_condition = missionNamespace getVariable _condition;
|
|
};
|
|
|
|
if !(_condition isEqualType false) then {
|
|
_condition = call _condition;
|
|
};
|
|
};
|
|
|
|
if !(_condition) exitWith {false};
|
|
|
|
// check allowed locations
|
|
private _locations = getArray (_config >> "treatmentLocations") apply {toLower _x};
|
|
|
|
if ("all" in _locations) then {
|
|
_locations = true;
|
|
} else {
|
|
private _medFacility = {([_caller] call EFUNC(medical,isInMedicalFacility)) || ([_target] call EFUNC(medical,isInMedicalFacility))};
|
|
private _medVeh = {([_caller] call EFUNC(medical,isInMedicalVehicle)) || ([_target] call EFUNC(medical,isInMedicalVehicle))};
|
|
|
|
{
|
|
if (_x == "field") exitWith { _locations = true; };
|
|
if (_x == "MedicalFacility" && _medFacility) exitWith { _locations = true; };
|
|
if (_x == "MedicalVehicle" && _medVeh) exitWith { _locations = true; };
|
|
if !(isNil _x) exitWith {
|
|
_locations = missionNamespace getVariable _x;
|
|
|
|
if !(_locations isEqualType false) then {
|
|
if (_locations isEqualTo 0) exitWith { _locations = true; }; //AdvancedMedicalSettings_anywhere
|
|
if (_locations isEqualTo 1) exitWith { _locations = call _medVeh; }; //AdvancedMedicalSettings_vehicle
|
|
if (_locations isEqualTo 2) exitWith { _locations = call _medFacility; }; //AdvancedMedicalSettings_facility
|
|
if (_locations isEqualTo 3) exitWith { _locations = call _medFacility || {call _medVeh}; }; //AdvancedMedicalSettings_vehicleAndFacility
|
|
_locations = false; //Disabled
|
|
};
|
|
};
|
|
} forEach _locations;
|
|
};
|
|
|
|
_locations
|