Fixed custom conditions

This commit is contained in:
Glowbal 2015-03-09 21:42:09 +01:00
parent 5afc651519
commit f62335f71c
2 changed files with 28 additions and 25 deletions

View File

@ -24,9 +24,9 @@ _className = _this select 3;
if !(_target isKindOf "CAManBase") exitWith {false}; 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 { if (GVAR(level)>=2) then {
_config = (ConfigFile >> "ACE_Medical_Treatments" >> "Advanced" >> _className); _config = (ConfigFile >> "ACE_Medical_Actions" >> "Advanced" >> _className);
}; };
if !(isClass _config) exitwith {false}; if !(isClass _config) exitwith {false};
@ -38,17 +38,9 @@ if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exi
_locations = getArray (_config >> "treatmentLocations"); _locations = getArray (_config >> "treatmentLocations");
if ("All" in _locations) exitwith {true}; _return = true;
if (isText (_config >> "Condition")) then {
_return = false; _condition = getText(_config >> "condition");
{
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");
if (_condition != "") then { if (_condition != "") then {
if (isnil _condition) then { if (isnil _condition) then {
_condition = compile _condition; _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; _return;

View File

@ -40,19 +40,10 @@ if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exi
// Check allowed locations // Check allowed locations
_locations = getArray (_config >> "treatmentLocations"); _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 { _return = true;
_condition = getText (_config >> "condition"); if (isText (_config >> "Condition")) then {
_condition = getText(_config >> "condition");
if (_condition != "") then { if (_condition != "") then {
if (isnil _condition) then { if (isnil _condition) then {
_condition = compile _condition; _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}; if !(_return) exitwith {false};