ACE3/addons/medical/functions/fnc_useItem.sqf

60 lines
1.6 KiB
Plaintext
Raw Normal View History

/*
* Author: Glowbal
* Use Equipment if any is available. Priority: 1) Medic, 2) Patient. If in vehicle: 3) Crew
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
* 2: Item <STRING>
*
* ReturnValue:
2015-08-22 17:47:23 +00:00
* 0: success <BOOL>
* 1: Unit <OBJECT>
*
* Public: Yes
*/
#include "script_component.hpp"
2015-08-22 17:47:23 +00:00
private ["_return","_crew"];
params ["_medic", "_patient", "_item"];
2015-11-30 16:22:16 +00:00
if (isNil QGVAR(setting_allowSharedEquipment)) then {
GVAR(setting_allowSharedEquipment) = true;
};
2015-11-30 16:14:05 +00:00
if (GVAR(setting_allowSharedEquipment) && {[_patient, _item] call EFUNC(common,hasItem)}) exitWith {
2016-02-18 01:54:43 +00:00
if (local _patient) then {
2016-05-24 13:13:11 +00:00
["ace_useItem", [_patient, _item]] call CBA_fnc_localEvent;
2016-02-18 01:54:43 +00:00
} else {
2016-05-24 13:13:11 +00:00
["ace_useItem", [_patient, _item], _patient] call CBA_fnc_targetEvent;
2016-02-18 01:54:43 +00:00
};
[true, _patient];
};
2015-11-30 16:14:05 +00:00
if ([_medic, _item] call EFUNC(common,hasItem)) exitWith {
2016-02-18 01:54:43 +00:00
if (local _medic) then {
2016-05-24 13:13:11 +00:00
["ace_useItem", [_medic, _item]] call CBA_fnc_localEvent;
2016-02-18 01:54:43 +00:00
} else {
2016-05-24 13:13:11 +00:00
["ace_useItem", [_medic, _item], _medic] call CBA_fnc_targetEvent;
2016-02-18 01:54:43 +00:00
};
[true, _medic];
};
_return = [false, objNull];
if ([vehicle _medic] call FUNC(isMedicalVehicle) && {vehicle _medic != _medic}) then {
_crew = crew vehicle _medic;
{
2015-11-30 16:14:05 +00:00
if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {([_x, _item] call EFUNC(common,hasItem))}) exitWith {
_return = [true, _x];
2016-02-18 01:54:43 +00:00
if (local _x) then {
2016-05-24 13:13:11 +00:00
["ace_useItem", [_x, _item]] call CBA_fnc_localEvent;
2016-02-18 01:54:43 +00:00
} else {
2016-05-24 13:13:11 +00:00
["ace_useItem", [_x, _item], _x] call CBA_fnc_targetEvent;
2016-02-18 01:54:43 +00:00
};
};
2015-11-30 16:23:48 +00:00
} forEach _crew;
};
2015-08-22 17:47:23 +00:00
_return