Quickmount - Improve interactu menu getIn for static weapon (#7090)

For small static weapons getInNearest would sometimes not detect the vehicle as the `getCameraViewDirection` may be pointing at the interaction node and not the vehicle
This commit is contained in:
PabstMirror 2019-07-05 15:22:07 -05:00 committed by GitHub
parent fa910a7fd8
commit 1534f8cd8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -4,7 +4,7 @@ if (!hasInterface) exitWith {};
["ACE3 Movement", QGVAR(mount), [localize LSTRING(KeybindName), localize LSTRING(KeybindDescription)], "", {
if (!dialog) then {
call FUNC(getInNearest);
[] call FUNC(getInNearest);
};
false
}] call CBA_fnc_addKeybind;

View File

@ -4,7 +4,7 @@
* Mount the player in the vehicle they are directly looking at based on their distance.
*
* Arguments:
* None
* 0: Target <OBJECT>(Optional)
*
* Return Value:
* None
@ -22,17 +22,27 @@ if (!GVAR(enabled) ||
{ACE_player getVariable ["ace_unconscious", false]}
) exitWith {};
params [["_interactionTarget", objNull, [objNull]]];
TRACE_1("getInNearest",_interactionTarget);
private _start = AGLtoASL (ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot"));
private _end = (_start vectorAdd (getCameraViewDirection ACE_player vectorMultiply GVAR(distance)));
private _objects = lineIntersectsSurfaces [_start, _end, ACE_player];
private _target = (_objects param [0, []]) param [2, objNull];
if ((isNull _target) && {alive _interactionTarget}) then {
_end = _start vectorAdd ((_start vectorFromTo (aimPos _interactionTarget)) vectorMultiply GVAR(distance));
_objects = lineIntersectsSurfaces [_start, _end, ACE_player];
TRACE_1("2nd ray attempt at interaction target aim pos",_objects);
_target = (_objects param [0, []]) param [2, objNull];
};
if (locked _target in [2,3]) exitWith {
[localize LSTRING(VehicleLocked)] call EFUNC(common,displayTextStructured);
true
};
TRACE_1("",_target);
TRACE_2("",_target,typeOf _target);
if (!isNull _target &&
{alive _target} &&