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>
|
|
|
|
* 2: Exceptions. What general conditions are to skip? <ARRAY> (Optional)
|
2015-03-15 08:02:11 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Unit can interact?
|
|
|
|
*
|
2015-03-21 03:27:19 +00:00
|
|
|
* Public: No
|
2015-03-15 08:02:11 +00:00
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-14 18:02:42 +00:00
|
|
|
private ["_exceptions"];
|
|
|
|
|
|
|
|
PARAMS_2(_unit,_target);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-21 03:27:19 +00:00
|
|
|
_exceptions = if (count _this > 2) then {
|
|
|
|
_this select 2;
|
|
|
|
} else {
|
|
|
|
[];
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-15 08:26:16 +00:00
|
|
|
_exceptions = [_exceptions, {toLower _this}] call FUNC(map);
|
|
|
|
|
2015-03-15 08:02:11 +00:00
|
|
|
// exit if the target is not free to interact
|
|
|
|
private "_owner";
|
|
|
|
_owner = _target getVariable [QGVAR(owner), objNull];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
private ["_conditions", "_conditionNames", "_conditionFuncs"];
|
|
|
|
|
|
|
|
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
|
|
|
|
|
|
|
_conditionNames = _conditions select 0;
|
|
|
|
_conditionFuncs = _conditions select 1;
|
|
|
|
|
|
|
|
private "_canInteract";
|
|
|
|
_canInteract = true;
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!(_x in _exceptions) && {!([_unit, _target] call (_conditionFuncs select _forEachIndex))}) exitWith {
|
|
|
|
_canInteract = false;
|
|
|
|
};
|
|
|
|
} forEach _conditionNames;
|
|
|
|
|
|
|
|
_canInteract
|