2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-03-15 08:02:11 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Check if the unit can interact.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-03-21 03:27:19 +00:00
|
|
|
* 0: The player. <OBJECT>
|
|
|
|
* 1: The interaction target. objNull to ignore. <OBJECT>
|
2015-09-18 11:09:40 +00:00
|
|
|
* 2: Exceptions. What general conditions are to skip? (default: []) <ARRAY>
|
2015-03-15 08:02:11 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* Unit can interact? <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [bob, target, []] call ace_common_fnc_canInteractWith
|
2015-03-15 08:02:11 +00:00
|
|
|
*
|
2015-09-18 11:09:40 +00:00
|
|
|
* Public: Yes
|
2015-03-15 08:02:11 +00:00
|
|
|
*/
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-18 11:09:40 +00:00
|
|
|
params ["_unit", "_target", ["_exceptions", []]];
|
2015-05-14 18:02:42 +00:00
|
|
|
|
2016-02-06 10:42:35 +00:00
|
|
|
_exceptions = _exceptions apply {toLower _x};
|
2015-03-15 08:26:16 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _owner = _target getVariable [QGVAR(owner), objNull];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-18 11:09:40 +00:00
|
|
|
// exit if the target is not free to interact
|
2015-03-17 11:20:46 +00:00
|
|
|
if (!isNull _owner && {_unit != _owner}) exitWith {false};
|
2015-03-15 08:02:11 +00:00
|
|
|
|
|
|
|
// check general conditions
|
2015-12-12 15:48:54 +00:00
|
|
|
private _conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
2015-09-18 11:09:40 +00:00
|
|
|
_conditions params ["_conditionNames", "_conditionFuncs"];
|
2015-03-15 08:02:11 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _canInteract = true;
|
|
|
|
|
2015-03-15 08:02:11 +00:00
|
|
|
{
|
|
|
|
if (!(_x in _exceptions) && {!([_unit, _target] call (_conditionFuncs select _forEachIndex))}) exitWith {
|
|
|
|
_canInteract = false;
|
|
|
|
};
|
|
|
|
} forEach _conditionNames;
|
|
|
|
|
|
|
|
_canInteract
|