Skip to content

Commit

Permalink
Quickmount - Improve interactu menu getIn for static weapon (#7090)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
PabstMirror authored Jul 5, 2019
1 parent fa910a7 commit 1534f8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addons/quickmount/XEH_postInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
14 changes: 12 additions & 2 deletions addons/quickmount/functions/fnc_getInNearest.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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} &&
Expand Down

0 comments on commit 1534f8c

Please sign in to comment.