2015-01-11 19:32:51 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Check if the vehicle is in range of the player.
|
2015-01-11 23:13:47 +00:00
|
|
|
*
|
2015-05-09 02:47:15 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Vehicle <OBJECT>
|
|
|
|
* 1: Distance in meters <NUMBER>
|
2015-01-11 23:13:47 +00:00
|
|
|
*
|
2015-01-11 19:32:51 +00:00
|
|
|
* Return value:
|
2015-05-09 02:47:15 +00:00
|
|
|
* Vehicle in range of player <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* _bool = [target, 5] call ace_interaction_fnc_isInRange
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-11 19:32:51 +00:00
|
|
|
*/
|
2015-01-11 23:13:47 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-05-09 20:14:00 +00:00
|
|
|
PARAMS_2(_vehicle,_distance);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-05-09 20:14:00 +00:00
|
|
|
private ["_player", "_position0", "_position1"];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-01-12 04:20:02 +00:00
|
|
|
_player = ACE_player;
|
2015-01-11 19:32:51 +00:00
|
|
|
|
|
|
|
if (_vehicle isKindOf "Man") exitWith {_player distance _vehicle < _distance};
|
|
|
|
|
|
|
|
private ["_position0", "_position1"];//, "_direction"];
|
|
|
|
|
|
|
|
_position0 = getPosASL _player;
|
|
|
|
_position1 = getPosASL _vehicle;
|
|
|
|
|
|
|
|
/*
|
|
|
|
_direction = _position1 vectorDiff _position0;
|
|
|
|
_direction = _direction vectorMultiply (_distance / (vectorMagnitude _direction));
|
|
|
|
|
|
|
|
_position0 = eyePos _player;
|
|
|
|
_position1 = _position0 vectorAdd _direction;
|
|
|
|
|
|
|
|
_vehicle in lineIntersectsWith [_position0, _position1] || {_player distance _vehicle < _distance}
|
|
|
|
*/
|
|
|
|
|
|
|
|
_position0 = ATLToASL positionCameraToWorld [0, 0, 0];
|
|
|
|
_position0 set [2, (_position0 select 2) - (getTerrainHeightASL _position0 min 0)];
|
|
|
|
|
|
|
|
_position1 = ATLToASL positionCameraToWorld [0, 0, _distance];
|
|
|
|
_position1 set [2, (_position1 select 2) - (getTerrainHeightASL _position1 min 0)];
|
|
|
|
|
|
|
|
if (_vehicle in lineIntersectsWith [_position0, _position1] || {_player distance _vehicle < _distance}) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
true
|
2015-01-11 19:32:51 +00:00
|
|
|
} else {
|
2015-04-06 16:22:43 +00:00
|
|
|
["Not in Range"] call FUNC(addToTooltip);
|
|
|
|
false
|
2015-01-11 19:32:51 +00:00
|
|
|
}
|