mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
40 lines
1.0 KiB
Plaintext
40 lines
1.0 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: VKing
|
|
* Get the distance to the next object the player is looking at. Used for laser distance measurements.
|
|
*
|
|
* Arguments:
|
|
* 0: Measurement Accuracy (default: 1) <NUMBER>
|
|
* 1: Maximum measure distance (default: 5000) <NUMBER>
|
|
* 2: Minimum measure distance (default: 0) <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* Distance in meters <NUMBER>
|
|
*
|
|
* Example:
|
|
* [5,20000,56] call ace_common_fnc_getTargetDistance
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
params [["_accuracy",1], ["_maxDistance",5000], ["_minDistance",0]];
|
|
|
|
private _camPosition = AGLToASL positionCameraToWorld [0, 0, 0];
|
|
private _aimLinePos = AGLToASL positionCameraToWorld [0, 0, _maxDistance];
|
|
|
|
private _LIS = lineIntersectsSurfaces [_camPosition, _aimLinePos];
|
|
|
|
private _distance = 0;
|
|
if (count _LIS > 0) then {
|
|
_distance = _camPosition vectorDistance ((_LIS select 0) select 0);
|
|
} else {
|
|
_distance = _maxDistance;
|
|
};
|
|
|
|
_distance = _distance max _minDistance;
|
|
|
|
_accuracy = _accuracy max 1;
|
|
_distance = (round (_distance/_accuracy)) * _accuracy;
|
|
|
|
_distance
|