2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2017-02-10 18:34:51 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Gets effective interaction distance (handles very large vehicles)
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Player <OBJECT>
|
|
|
|
* 0: Target Vehicle <OBJECT>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2017-02-10 18:34:51 +00:00
|
|
|
* Distance to interaction point <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, cursorObject] call ace_interaction_fnc_getInteractionDistance
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit", "_target"];
|
|
|
|
TRACE_3("getInteractionDistance",_unit,_target,typeOf _target);
|
|
|
|
|
|
|
|
// Handle Man, Crate
|
|
|
|
if (!((_target isKindOf "Car") || {_target isKindOf "Tank"} || {_target isKindOf "Helicopter"} || {_target isKindOf "Plane"} || {_target isKindOf "Ship_F"})) exitWith {
|
|
|
|
_unit distance _target
|
|
|
|
};
|
|
|
|
|
|
|
|
private _unitEyeASL = eyePos _unit;
|
|
|
|
private _targetModelPos = [_target, _unitEyeASL] call FUNC(getVehiclePosComplex);
|
2021-10-10 13:37:05 +00:00
|
|
|
private _distance = _unitEyeASL distance (_target modelToWorldWorld _targetModelPos);
|
2017-02-10 18:34:51 +00:00
|
|
|
|
|
|
|
TRACE_2("",_targetModelPos,_distance);
|
|
|
|
|
|
|
|
_distance
|