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
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* Was the menu rendered <BOOL>
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
BEGIN_COUNTER(fnc_renderBaseMenu)
|
|
|
|
|
2015-04-29 06:26:13 +00:00
|
|
|
private ["_distance","_pos","_weaponDir","_ref","_sPos","_activeActionTree", "_line"];
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-03-20 02:32:44 +00:00
|
|
|
EXPLODE_2_PVT(_this,_object,_baseActionNode);
|
|
|
|
EXPLODE_1_PVT(_baseActionNode,_actionData);
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-03-20 02:32:44 +00:00
|
|
|
_distance = _actionData select 8;
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
// Obtain a 3D position for the action
|
2015-05-01 04:56:39 +00:00
|
|
|
_pos = if((count _this) > 2) then {
|
|
|
|
_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
|
|
|
|
private ["_target"];
|
|
|
|
_target = _object;
|
|
|
|
|
|
|
|
// Get action position
|
|
|
|
_object modelToWorldVisual (call (_actionData select 7))
|
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
|
2015-03-24 15:27:27 +00:00
|
|
|
if (GVAR(openedMenuType) == 0 && vehicle ACE_player == ACE_player &&
|
2015-04-24 03:57:22 +00:00
|
|
|
{
|
|
|
|
private ["_headPos","_actualDistance"];
|
|
|
|
_headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot");
|
|
|
|
_actualDistance = _headPos distance _pos;
|
|
|
|
|
|
|
|
if (_actualDistance > _distance) exitWith {true};
|
|
|
|
|
2015-04-29 07:34:47 +00:00
|
|
|
if (_actualDistance > 1.0) exitWith {
|
2015-04-24 03:57:22 +00:00
|
|
|
// If distance to action is greater than 1.0 m, check LOS
|
|
|
|
_line = [_headPos call EFUNC(common,positionToASL), _pos call EFUNC(common,positionToASL), _object, ACE_player];
|
|
|
|
lineIntersects _line
|
|
|
|
};
|
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
|
2015-03-23 21:08:31 +00:00
|
|
|
_sPos = if (count _pos != 2) then {
|
|
|
|
worldToScreen _pos
|
|
|
|
} else {
|
2015-03-23 21:26:20 +00:00
|
|
|
_pos
|
2015-03-23 21:08:31 +00:00
|
|
|
};
|
2015-03-03 02:29:57 +00:00
|
|
|
if(count _sPos == 0) exitWith {false};
|
|
|
|
|
|
|
|
// Exit if the action is off screen
|
|
|
|
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-23 21:08:31 +00:00
|
|
|
BEGIN_COUNTER(fnc_collectActiveActionTree)
|
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
// Collect active tree
|
2015-03-11 02:23:13 +00:00
|
|
|
private "_uid";
|
2015-03-20 02:32:44 +00:00
|
|
|
_uid = format [QGVAR(ATCache_%1), _actionData select 0];
|
2015-03-11 02:23:13 +00:00
|
|
|
_activeActionTree = [
|
2015-03-20 02:32:44 +00:00
|
|
|
[_object, _baseActionNode, []],
|
2015-03-11 02:23:13 +00:00
|
|
|
DFUNC(collectActiveActionTree),
|
2015-03-21 20:50:35 +00:00
|
|
|
_object, _uid, 1.0, "interactMenuClosed"
|
2015-03-11 02:23:13 +00:00
|
|
|
] call EFUNC(common,cachedCall);
|
2015-03-21 20:50:35 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
END_COUNTER(fnc_collectActiveActionTree)
|
|
|
|
|
2015-03-21 01:44:36 +00:00
|
|
|
/*
|
|
|
|
diag_log "Printing: _activeActionTree";
|
|
|
|
_fnc_print = {
|
|
|
|
EXPLODE_2_PVT(_this,_level,_node);
|
|
|
|
EXPLODE_3_PVT(_node,_actionData,_children,_object);
|
|
|
|
diag_log text format ["Level %1 -> %2 on %3", _level, _actionData select 0, _object];
|
|
|
|
{
|
|
|
|
[_level + 1, _x] call _fnc_print;
|
|
|
|
} forEach _children;
|
|
|
|
};
|
|
|
|
[0, _activeActionTree] call _fnc_print;
|
|
|
|
*/
|
2015-03-03 02:29:57 +00:00
|
|
|
// Check if there's something left for rendering
|
|
|
|
if (count _activeActionTree == 0) exitWith {false};
|
|
|
|
|
|
|
|
//EXPLODE_2_PVT(_activeActionTree,_actionData,_actionChildren);
|
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
BEGIN_COUNTER(fnc_renderMenus);
|
|
|
|
|
|
|
|
[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu);
|
|
|
|
|
|
|
|
END_COUNTER(fnc_renderMenus);
|
|
|
|
|
|
|
|
END_COUNTER(fnc_renderBaseMenu)
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
true
|