cleanup, fix headers treatment has/use item functions

This commit is contained in:
commy2 2016-09-29 19:31:48 +02:00
parent d3f6f040cd
commit e418cc05e9
4 changed files with 34 additions and 38 deletions

View File

@ -8,11 +8,10 @@
* 2: Item <STRING>
*
* ReturnValue:
* <NIL>
* Has the items <BOOL>
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_medic", "_patient", "_item"];
@ -20,6 +19,7 @@ params ["_medic", "_patient", "_item"];
if (isNil QEGVAR(medical,setting_allowSharedEquipment)) then {
EGVAR(medical,setting_allowSharedEquipment) = true;
};
if (EGVAR(medical,setting_allowSharedEquipment) && {[_patient, _item] call EFUNC(common,hasItem)}) exitWith {
true
};
@ -29,13 +29,13 @@ if ([_medic, _item] call EFUNC(common,hasItem)) exitWith {
};
private _return = false;
if ((vehicle _medic != _medic) && {[vehicle _medic] call EFUNC(medical,isMedicalVehicle)}) then {
private _crew = crew vehicle _medic;
if (vehicle _medic != _medic && {vehicle _medic call EFUNC(medical,isMedicalVehicle)}) then {
{
if ([_medic, _x] 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;
};
} forEach _crew;
} forEach crew vehicle _medic;
};
_return

View File

@ -12,20 +12,22 @@
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_medic", "_patient", "_items"];
private _return = true;
{
//
if (_x isEqualType [] && {({[_medic, _patient, _x] call FUNC(hasItem)}count _x == 0)}) exitwith {
// handle a one of type use item
if (_x isEqualType [] && {{[_medic, _patient, _x] call FUNC(hasItem)} count _x == 0}) exitWith {
_return = false;
};
if (_x isEqualType "" && {!([_medic, _patient, _x] call FUNC(hasItem))}) exitwith {
// handle required item
if (_x isEqualType "" && {!([_medic, _patient, _x] call FUNC(hasItem))}) exitWith {
_return = false;
};
}foreach _items;
} forEach _items;
_return

View File

@ -13,46 +13,33 @@
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_medic", "_patient", "_item"];
if (isNil QEGVAR(medical,setting_allowSharedEquipment)) then {
EGVAR(medical,setting_allowSharedEquipment)= true;
EGVAR(medical,setting_allowSharedEquipment) = true;
};
if (EGVAR(medical,setting_allowSharedEquipment) && {[_patient, _item] call EFUNC(common,hasItem)}) exitWith {
if (local _patient) then {
["ace_useItem", [_patient, _item]] call CBA_fnc_localEvent;
} else {
["ace_useItem", [_patient, _item], _patient] call CBA_fnc_targetEvent;
};
[true, _patient];
["ace_useItem", [_patient, _item], _patient] call CBA_fnc_targetEvent;
[true, _patient]
};
if ([_medic, _item] call EFUNC(common,hasItem)) exitWith {
if (local _medic) then {
["ace_useItem", [_medic, _item]] call CBA_fnc_localEvent;
} else {
["ace_useItem", [_medic, _item], _medic] call CBA_fnc_targetEvent;
};
[true, _medic];
["ace_useItem", [_medic, _item], _medic] call CBA_fnc_targetEvent;
[true, _medic]
};
private _return = [false, objNull];
if ([vehicle _medic] call EFUNC(medical,isMedicalVehicle) && {vehicle _medic != _medic}) then {
private _crew = crew vehicle _medic;
if (vehicle _medic != _medic && {vehicle _medic call EFUNC(medical,isMedicalVehicle)}) then {
{
if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {([_x, _item] call EFUNC(common,hasItem))}) exitWith {
if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {[_x, _item] call EFUNC(common,hasItem)}) exitWith {
["ace_useItem", [_x, _item], _x] call CBA_fnc_targetEvent;
_return = [true, _x];
if (local _x) then {
["ace_useItem", [_x, _item]] call CBA_fnc_localEvent;
} else {
["ace_useItem", [_x, _item], _x] call CBA_fnc_targetEvent;
};
};
} forEach _crew;
} forEach crew vehicle _medic;
};
_return

View File

@ -8,29 +8,36 @@
* 2: Items <ARRAY<STRING>>
*
* ReturnValue:
* None
* 0: success <BOOL>
* 1: Unit <OBJECT>
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_medic", "_patient", "_items"];
private _itemsUsedBy = [];
{
// handle a one of type use item
if (_x isEqualType []) then {
{
private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem);
if (_itemUsedInfo select 0) exitWith { _itemsUsedBy pushBack [(_itemUsedInfo select 1), _x]};
if (_itemUsedInfo select 0) exitWith {
_itemsUsedBy pushBack [_itemUsedInfo select 1, _x];
};
} forEach _x;
};
// handle required item
if (_x isEqualType "") then {
private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem);
if (_itemUsedInfo select 0) exitWith { _itemsUsedBy pushBack [(_itemUsedInfo select 1), _x]};
if (_itemUsedInfo select 0) exitWith {
_itemsUsedBy pushBack [_itemUsedInfo select 1, _x];
};
};
} forEach _items;