2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-02-18 23:20:02 +00:00
|
|
|
/*
|
|
|
|
* Author: esteldunedain
|
|
|
|
* Return a suitable position for the action point for the given target vehicle
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None (uses local variable _target)
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2016-02-18 23:20:02 +00:00
|
|
|
* Children actions <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
2016-06-15 04:30:58 +00:00
|
|
|
* call ace_interaction_fnc_getVehiclePos
|
2016-02-18 23:20:02 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
// IGNORE_PRIVATE_WARNING(_target);
|
|
|
|
|
|
|
|
private _bb = boundingBoxReal _target;
|
2016-06-15 04:30:58 +00:00
|
|
|
(_bb select 0) params ["_bbX", "_bbY", "_bbZ"];
|
|
|
|
|
2017-08-22 18:30:56 +00:00
|
|
|
private _cameraPosASL = EGVAR(interact_menu,cameraPosASL);
|
|
|
|
private _relPos = _target worldToModelVisual ASLToAGL _cameraPosASL;
|
2016-02-18 23:20:02 +00:00
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
|
|
_relPos = _target worldToModelVisual ASLToAGL eyePos ACE_player;
|
|
|
|
#endif
|
|
|
|
_relPos params ["_dx", "_dy", "_dz"];
|
|
|
|
|
2018-02-10 03:45:21 +00:00
|
|
|
private _ndx = (abs _dx) / (((abs (_bbX)) - 1) max 1);
|
|
|
|
private _ndy = (abs _dy) / (((abs (_bbY)) - 1) max 1);
|
|
|
|
private _ndz = (abs _dz) / (((abs (_bbZ)) - 1) max 1);
|
|
|
|
|
2016-02-18 23:20:02 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _pos = [];
|
2016-02-18 23:20:02 +00:00
|
|
|
if (_ndx > _ndy) then {
|
|
|
|
if (_ndx > _ndz) then {
|
|
|
|
// _ndx is greater, will colide with x plane first
|
|
|
|
_pos = _relPos vectorMultiply ((1 / _ndx) min 0.8);
|
|
|
|
} else {
|
|
|
|
// _ndz is greater, will colide with z plane first
|
|
|
|
_pos = _relPos vectorMultiply ((1 / _ndz) min 0.8);
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if (_ndy > _ndz) then {
|
|
|
|
// _ndy is greater, will colide with y plane first
|
|
|
|
_pos = _relPos vectorMultiply ((1 / _ndy) min 0.8);
|
|
|
|
} else {
|
|
|
|
// _ndz is greater, will colide with z plane first
|
|
|
|
_pos = _relPos vectorMultiply ((1 / _ndz) min 0.8);
|
|
|
|
};
|
|
|
|
};
|
2017-08-22 18:30:56 +00:00
|
|
|
|
|
|
|
// Set max height at player's eye level (prevent very high interaction point on choppers)
|
|
|
|
// Only when above water level to prevent underwater actions from following player eye level
|
|
|
|
if (_cameraPosASL select 2 >= 0) then {
|
|
|
|
_pos set [2, (_pos select 2) min _dz];
|
|
|
|
};
|
|
|
|
|
2019-03-21 13:52:32 +00:00
|
|
|
TRACE_5("",_bb,_bbX,_relPos,_pos,_cameraPosASL);
|
2016-02-18 23:20:02 +00:00
|
|
|
_pos
|
|
|
|
|
|
|
|
///////////////////
|
|
|
|
// The code belows works very well for cursor mode, but not at all in normal mode
|
|
|
|
// maybe it could be enabled by default only for that mode
|
|
|
|
/*
|
|
|
|
if (cursorObject isEqualTo _target) exitWith {
|
|
|
|
private _dest = EGVAR(interact_menu,cameraPosASL) vectorAdd (EGVAR(interact_menu,cameraDir) vectorMultiply 50);
|
|
|
|
private _origin = EGVAR(interact_menu,cameraPosASL);
|
|
|
|
//private _origin = EGVAR(interact_menu,cameraPosASL) vectorAdd [0, 0, -0.35] vectorDiff (EGVAR(interact_menu,cameraDir) vectorMultiply 1.5);
|
|
|
|
//private _dest = AGLtoASL (_target modelToWorldVisual [0,0,0]);
|
|
|
|
private _results = lineIntersectsSurfaces [_origin, _dest, ACE_player, objNull, true, 5];
|
|
|
|
private _finalPos = [0,0,0];
|
|
|
|
{
|
|
|
|
_x params ["_pos", "", "_obj"];
|
|
|
|
TRACE_3("",_forEachIndex,_obj,_target);
|
|
|
|
if (_obj isEqualTo _target) exitWith {
|
|
|
|
_finalPos = _target worldToModelVisual ASLtoAGL (_pos vectorAdd (EGVAR(interact_menu,cameraDir) vectorMultiply 1.0));
|
|
|
|
};
|
|
|
|
} forEach _results;
|
|
|
|
_finalPos
|
|
|
|
};
|
|
|
|
[0,0,0]
|
|
|
|
*/
|
|
|
|
///////////////////
|
|
|
|
|