From f62335f71c53c0e194f449e1a49e67974909b76d Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 9 Mar 2015 21:42:09 +0100 Subject: [PATCH] Fixed custom conditions --- addons/medical/functions/fnc_canTreat.sqf | 27 +++++++++++----------- addons/medical/functions/fnc_treatment.sqf | 26 +++++++++++---------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/addons/medical/functions/fnc_canTreat.sqf b/addons/medical/functions/fnc_canTreat.sqf index 65ab1e7140..bfeedcb077 100644 --- a/addons/medical/functions/fnc_canTreat.sqf +++ b/addons/medical/functions/fnc_canTreat.sqf @@ -24,9 +24,9 @@ _className = _this select 3; if !(_target isKindOf "CAManBase") exitWith {false}; -_config = (ConfigFile >> "ACE_Medical_Treatments" >> "Basic" >> _className); +_config = (ConfigFile >> "ACE_Medical_Actions" >> "Basic" >> _className); if (GVAR(level)>=2) then { - _config = (ConfigFile >> "ACE_Medical_Treatments" >> "Advanced" >> _className); + _config = (ConfigFile >> "ACE_Medical_Actions" >> "Advanced" >> _className); }; if !(isClass _config) exitwith {false}; @@ -38,17 +38,9 @@ if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exi _locations = getArray (_config >> "treatmentLocations"); -if ("All" in _locations) exitwith {true}; - -_return = false; -{ - if (_x == "field") exitwith {_return = true;}; - if (_x == "MedicalFacility" && {[_caller, _target] call FUNC(inMedicalFacility)}) exitwith {_return = true;}; - if (_x == "MedicalVehicle" && {[_caller, _target] call FUNC(inMedicalVehicle)}) exitwith {_return = true;}; -}foreach _locations; - -if (_return) then { - _condition = getText (_config >> "condition"); +_return = true; +if (isText (_config >> "Condition")) then { + _condition = getText(_config >> "condition"); if (_condition != "") then { if (isnil _condition) then { _condition = compile _condition; @@ -62,5 +54,14 @@ if (_return) then { }; }; }; +if (!_return) exitwith {false}; + +if ("All" in _locations) exitwith {true}; + +{ + if (_x == "field") exitwith {_return = true;}; + if (_x == "MedicalFacility" && {[_caller, _target] call FUNC(inMedicalFacility)}) exitwith {_return = true;}; + if (_x == "MedicalVehicle" && {[_caller, _target] call FUNC(inMedicalVehicle)}) exitwith {_return = true;}; +}foreach _locations; _return; diff --git a/addons/medical/functions/fnc_treatment.sqf b/addons/medical/functions/fnc_treatment.sqf index efcefab66f..cf5115fea5 100644 --- a/addons/medical/functions/fnc_treatment.sqf +++ b/addons/medical/functions/fnc_treatment.sqf @@ -40,19 +40,10 @@ if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exi // Check allowed locations _locations = getArray (_config >> "treatmentLocations"); -_return = false; -if ("All" in _locations) then { - _return = true; -} else { - { - if (_x == "field") exitwith {_return = true;}; - if (_x == "MedicalFacility" && {([_caller] call FUNC(isInMedicalFacility)) || ([_target] call FUNC(isInMedicalFacility))}) exitwith {_return = true;}; - if (_x == "MedicalVehicle" && {([vehicle _caller] call FUNC(isMedicalVehicle)) || ([vehicle _target] call FUNC(isMedicalVehicle))}) exitwith {_return = true;}; - }foreach _locations; -}; -if (_return) then { - _condition = getText (_config >> "condition"); +_return = true; +if (isText (_config >> "Condition")) then { + _condition = getText(_config >> "condition"); if (_condition != "") then { if (isnil _condition) then { _condition = compile _condition; @@ -66,6 +57,17 @@ if (_return) then { }; }; }; +if (!_return) exitwith {false}; + +if ("All" in _locations) then { + _return = true; +} else { + { + if (_x == "field") exitwith {_return = true;}; + if (_x == "MedicalFacility" && {([_caller] call FUNC(isInMedicalFacility)) || ([_target] call FUNC(isInMedicalFacility))}) exitwith {_return = true;}; + if (_x == "MedicalVehicle" && {([vehicle _caller] call FUNC(isMedicalVehicle)) || ([vehicle _target] call FUNC(isMedicalVehicle))}) exitwith {_return = true;}; + }foreach _locations; +}; if !(_return) exitwith {false};