2016-06-13 15:00:56 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Check if the treatment action can be performed.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The caller <OBJECT>
|
|
|
|
* 1: The target <OBJECT>
|
2016-10-13 07:47:52 +00:00
|
|
|
* 2: Body part <STRING>
|
|
|
|
* 3: Treatment class name <STRING>
|
2016-06-13 15:00:56 +00:00
|
|
|
*
|
|
|
|
* ReturnValue:
|
|
|
|
* Can Treat <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
2016-09-18 20:58:56 +00:00
|
|
|
* [player, cursorTarget, "Head", "SurgicalKit"] call ace_medical_treatment_fnc_canTreat
|
2016-06-13 15:00:56 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-10-13 07:47:52 +00:00
|
|
|
params ["_caller", "_target", "_bodyPart", "_className"];
|
2016-06-13 15:00:56 +00:00
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
if !(_target isKindOf "CAManBase") exitWith {false};
|
2016-06-13 15:00:56 +00:00
|
|
|
|
2016-10-13 07:47:52 +00:00
|
|
|
private _config = configFile >> QGVAR(Actions) >> _className;
|
2016-06-13 15:00:56 +00:00
|
|
|
|
|
|
|
if !(isClass _config) exitwith {false};
|
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
// allow self treatment check
|
|
|
|
private _isSelf = _caller isEqualTo _target;
|
|
|
|
|
|
|
|
if (_isSelf && {getNumber (_config >> "allowSelfTreatment") == 0}) exitwith {false};
|
|
|
|
|
|
|
|
private _medicRequired = 0;
|
2016-06-13 15:00:56 +00:00
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
if (isNumber (_config >> "requiredMedic")) then {
|
|
|
|
_medicRequired = getNumber (_config >> "requiredMedic");
|
2016-06-13 15:00:56 +00:00
|
|
|
} else {
|
2016-09-29 14:00:19 +00:00
|
|
|
if (isText (_config >> "requiredMedic")) then {
|
|
|
|
_medicRequired = missionNamespace getVariable [getText (_config >> "requiredMedic"), 0];
|
2016-06-13 15:00:56 +00:00
|
|
|
};
|
|
|
|
};
|
2016-09-18 20:58:56 +00:00
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
if !([_caller, _medicRequired] call EFUNC(medical,isMedic)) exitWith {false};
|
|
|
|
|
|
|
|
// check selection
|
2016-10-05 22:54:57 +00:00
|
|
|
private _allowedSelections = getArray (_config >> "allowedSelections") apply {toLower _x};
|
2016-09-29 14:00:19 +00:00
|
|
|
|
2016-10-13 07:47:52 +00:00
|
|
|
if !("all" in _allowedSelections || {(_bodyPart in _allowedSelections)}) exitWith {false};
|
2016-06-13 15:00:56 +00:00
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
// check item
|
2016-06-13 15:00:56 +00:00
|
|
|
private _items = getArray (_config >> "items");
|
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
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;
|
|
|
|
};
|
2016-06-13 15:00:56 +00:00
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
if (isNil _condition) then {
|
2016-06-13 15:00:56 +00:00
|
|
|
_condition = compile _condition;
|
|
|
|
} else {
|
|
|
|
_condition = missionNamespace getVariable _condition;
|
|
|
|
};
|
2016-09-29 14:00:19 +00:00
|
|
|
|
|
|
|
if !(_condition isEqualType false) then {
|
|
|
|
_condition = call _condition;
|
2016-06-13 15:00:56 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
if !(_condition) exitWith {false};
|
|
|
|
|
|
|
|
// check allowed locations
|
2016-10-05 22:54:57 +00:00
|
|
|
private _locations = getArray (_config >> "treatmentLocations") apply {toLower _x};
|
2016-09-29 14:00:19 +00:00
|
|
|
|
2016-10-05 22:54:57 +00:00
|
|
|
if ("all" in _locations) then {
|
2016-09-29 14:00:19 +00:00
|
|
|
_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
|
2016-06-13 15:00:56 +00:00
|
|
|
};
|
|
|
|
};
|
2016-09-29 14:00:19 +00:00
|
|
|
} forEach _locations;
|
|
|
|
};
|
2016-06-13 15:00:56 +00:00
|
|
|
|
2016-09-29 14:00:19 +00:00
|
|
|
_locations
|