2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-03-03 02:29:57 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: NouberNou and esteldunedain
|
2015-03-03 02:29:57 +00:00
|
|
|
* Render the interaction menu for a base action
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-03-03 02:29:57 +00:00
|
|
|
* 0: Object <OBJECT>
|
2015-03-20 02:32:44 +00:00
|
|
|
* 1: Action node <ARRAY>
|
2015-03-23 21:08:31 +00:00
|
|
|
* 2: 3D position or 2D position <ARRAY> (Optional)
|
2015-03-03 02:29:57 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-03-03 02:29:57 +00:00
|
|
|
* Was the menu rendered <BOOL>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, [node], [0, 0, 0]] call ACE_interact_menu_fnc_renderBaseMenu
|
|
|
|
*
|
2015-03-03 02:29:57 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
BEGIN_COUNTER(fnc_renderBaseMenu)
|
|
|
|
|
2015-08-04 22:46:57 +00:00
|
|
|
params ["_object", "_baseActionNode"];
|
|
|
|
_baseActionNode params ["_actionData"];
|
2016-01-08 04:43:37 +00:00
|
|
|
_actionData params ["_actionName", "", "", "", "", "", "", "_positionCode", "_distance", "_params"];
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Obtain a 3D position for the action
|
2016-01-08 04:43:37 +00:00
|
|
|
private _pos = if((count _this) > 2) then {
|
2015-05-01 04:56:39 +00:00
|
|
|
_this select 2
|
2015-03-03 02:29:57 +00:00
|
|
|
} else {
|
2015-05-01 04:56:39 +00:00
|
|
|
// Setup scope variables for position code
|
2016-01-08 04:43:37 +00:00
|
|
|
private _target = _object;
|
2015-05-01 04:56:39 +00:00
|
|
|
|
|
|
|
// Get action position
|
2016-01-08 04:43:37 +00:00
|
|
|
_object modelToWorldVisual (call _positionCode)
|
2015-03-03 02:29:57 +00:00
|
|
|
};
|
|
|
|
|
2015-04-24 03:57:22 +00:00
|
|
|
// For non-self actions, exit if the action is too far away or ocluded
|
2016-01-08 04:43:37 +00:00
|
|
|
private _distanceToBasePoint = 0; //This will be 0 for self/zeus/in-vehicle (used later to check sub action distance)
|
2017-08-22 21:07:45 +00:00
|
|
|
if ((GVAR(openedMenuType) == 0) && {isNull (ACE_controlledUAV select 0)} && {vehicle ACE_player == ACE_player} && {isNull curatorCamera} &&
|
2015-04-24 03:57:22 +00:00
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot");
|
|
|
|
_distanceToBasePoint = _headPos distance _pos;
|
2015-04-24 03:57:22 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
if (_distanceToBasePoint > _distance) exitWith {true};
|
2015-04-24 03:57:22 +00:00
|
|
|
|
2016-02-08 22:19:10 +00:00
|
|
|
if ((_distanceToBasePoint > 1.2) && {!(_params select 4)}) exitWith {
|
|
|
|
// If distance to action is greater than 1.2 m and check isn't disabled in params, check LOS
|
2016-01-08 04:43:37 +00:00
|
|
|
lineIntersects [AGLtoASL _headPos, AGLtoASL _pos, _object, ACE_player]
|
2015-04-24 03:57:22 +00:00
|
|
|
};
|
2015-04-29 07:34:47 +00:00
|
|
|
false
|
2015-04-24 03:57:22 +00:00
|
|
|
}) exitWith {false};
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
// Exit if the action is behind you
|
2016-01-08 04:43:37 +00:00
|
|
|
private _sPos = if (count _pos != 2) then {
|
2015-03-23 21:08:31 +00:00
|
|
|
worldToScreen _pos
|
|
|
|
} else {
|
2015-03-23 21:26:20 +00:00
|
|
|
_pos
|
2015-03-23 21:08:31 +00:00
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
if (_sPos isEqualTo []) exitWith {false};
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
// Exit if the action is off screen
|
2016-01-08 04:43:37 +00:00
|
|
|
if ((_sPos select 0) < safeZoneXAbs || {(_sPos select 0) > safeZoneXAbs + safeZoneWAbs}) exitWith {false};
|
|
|
|
if ((_sPos select 1) < safeZoneY || {(_sPos select 1) > safeZoneY + safeZoneH}) exitWith {false};
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
|
2017-05-31 21:09:36 +00:00
|
|
|
BEGIN_COUNTER(fnc_collectActiveActionTree);
|
2015-03-23 21:08:31 +00:00
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
// Collect active tree
|
2016-01-08 04:43:37 +00:00
|
|
|
private _uid = format [QGVAR(ATCache_%1), _actionName];
|
|
|
|
private _activeActionTree = [
|
|
|
|
[_object, _baseActionNode, [], _distanceToBasePoint],
|
2015-03-11 02:23:13 +00:00
|
|
|
DFUNC(collectActiveActionTree),
|
2016-07-14 18:06:45 +00:00
|
|
|
_object, _uid, 1.0, "ace_interactMenuClosed"
|
2015-03-11 02:23:13 +00:00
|
|
|
] call EFUNC(common,cachedCall);
|
2015-03-21 20:50:35 +00:00
|
|
|
|
2017-05-31 21:09:36 +00:00
|
|
|
END_COUNTER(fnc_collectActiveActionTree);
|
2015-03-23 21:08:31 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
#ifdef DEBUG_MODE_EXTRA
|
2015-03-21 01:44:36 +00:00
|
|
|
diag_log "Printing: _activeActionTree";
|
2016-01-08 04:43:37 +00:00
|
|
|
[0, _activeActionTree] call {
|
|
|
|
params ["_level", "_node"];
|
|
|
|
_node params ["_actionData", "_children", "_object"];
|
2015-03-21 01:44:36 +00:00
|
|
|
diag_log text format ["Level %1 -> %2 on %3", _level, _actionData select 0, _object];
|
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
// Check if there's something left for rendering
|
2016-01-08 04:43:37 +00:00
|
|
|
if (_activeActionTree isEqualTo []) exitWith {false};
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
BEGIN_COUNTER(fnc_renderMenus);
|
|
|
|
|
2015-05-02 17:54:57 +00:00
|
|
|
if (count _pos > 2) then {
|
2016-02-18 23:20:02 +00:00
|
|
|
_sPos pushBack (((AGLtoASL _pos) vectorDiff GVAR(cameraPosASL)) vectorDotProduct GVAR(cameraDir));
|
2015-05-02 17:54:57 +00:00
|
|
|
} else {
|
|
|
|
_sPos pushBack 0;
|
|
|
|
};
|
2015-05-02 17:37:58 +00:00
|
|
|
|
|
|
|
// Add action point for oclusion and rendering
|
|
|
|
GVAR(collectedActionPoints) pushBack [_sPos select 2, _sPos, _activeActionTree];
|
2015-03-23 21:08:31 +00:00
|
|
|
|
|
|
|
END_COUNTER(fnc_renderMenus);
|
|
|
|
|
2017-05-31 21:09:36 +00:00
|
|
|
END_COUNTER(fnc_renderBaseMenu);
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
true
|