Added canAccessMedicalEquipment check

This commit is contained in:
Glowbal 2015-02-22 15:01:31 +01:00
parent 7f6a647b4d
commit ab6bc998c2
4 changed files with 34 additions and 2 deletions

View File

@ -50,6 +50,7 @@ PREP(hasTourniquetAppliedTo);
PREP(isMedic); PREP(isMedic);
PREP(isInMedicalFacility); PREP(isInMedicalFacility);
PREP(isMedicalVehicle); PREP(isMedicalVehicle);
PREP(canAccessMedicalEquipment);
GVAR(injuredUnitCollection) = []; GVAR(injuredUnitCollection) = [];
call FUNC(parseConfigForInjuries); call FUNC(parseConfigForInjuries);

View File

@ -0,0 +1,31 @@
/*
* Author: Glowbal
* Check if caller can access targets medical equipment, based upon accessLevel.
*
* Arguments:
* 0: The caller <OBJECT>
* 1: The target <OBJECT>
*
* ReturnValue:
* Can Treat <BOOL>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_target", "_caller", "_accessLevel", "_return"];
_caller = _this select 0;
_target = _this select 1;
_accessLevel = _target getvariable [QGVAR(allowSharedEquipmentAccess), -1];
_return = false;
if (_accessLevel >= 0) then {
if (_accessLevel == 0) exitwith { _return = true; };
if (_accessLevel == 1) exitwith { _return = (side _target == side _caller); };
if (_accessLevel == 2) exitwith { _return = (group _target == group _caller); };
};
_return;

View File

@ -35,7 +35,7 @@ _return = false;
if ([vehicle _medic] call FUNC(isMedicalVehicle) && {(vehicle _medic != _medic)}) then { if ([vehicle _medic] call FUNC(isMedicalVehicle) && {(vehicle _medic != _medic)}) then {
_crew = crew vehicle _medic; _crew = crew vehicle _medic;
{ {
if ([_x, _medic] call FUNC(canAccessMedicalEquipment) && {([_x, _item] call EFUNC(common,hasItem))}) exitwith { if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {([_x, _item] call EFUNC(common,hasItem))}) exitwith {
_return = true; _return = true;
}; };
}foreach _crew; }foreach _crew;

View File

@ -38,7 +38,7 @@ _return = false;
if ([vehicle _medic] call FUNC(isMedicalVehicle) && {vehicle _medic != _medic}) then { if ([vehicle _medic] call FUNC(isMedicalVehicle) && {vehicle _medic != _medic}) then {
_crew = crew vehicle _medic; _crew = crew vehicle _medic;
{ {
if ([_x, _medic] call FUNC(canAccessMedicalEquipment) && {([_x, _item] call EFUNC(common,hasItem))}) exitwith { if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {([_x, _item] call EFUNC(common,hasItem))}) exitwith {
_return = true; _return = true;
[[_x, _item], QUOTE(EFUNC(common,useItem)), _x] call EFUNC(common,execRemoteFnc); [[_x, _item], QUOTE(EFUNC(common,useItem)), _x] call EFUNC(common,execRemoteFnc);
}; };