ACE3/addons/laser/functions/fnc_findLaserSource.sqf
Nicolás Badano ab6fc8efca Laser guidance for all designators (#3308)
* Fix laser and missileguidance over water

* Return a normalized vector in EFUNC(common,getTurretDirection)

* Make laser dispersion simulation optional, default off

* Prototype for ace_laser_designate

* Remove vanilla laser handling from ace_laser in favor of the new code on ace_laser_designate

* Simplify laser into one module

Rewrite large parts of laser
Merge laser_designate
Delete lase_selfDesignate

* Cleanup missile guidance

* Headers, fix laser over water

* Cleanup

* Test

* Change setting to scalar, more cleanup

* Add seeker debug drawing
2016-10-08 12:55:30 +02:00

42 lines
1.2 KiB
Plaintext

/*
* Author: esteldunedain
* Handler function for finding position and direction of a vanilla laser.
*
* Argument:
* 0: Vehicle (shooter of laser) <OBJECT>
* 6: Method Args <ARRAY>
* 0: Laser Source selection on Vehicle
*
* Return value:
* [position, direction]
*
* Example:
* [player, x,x,x,x,x, ["pilot"]] call ace_laser_fnc_findLaserSource;
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle", "", "", "", "", "", "_methodArgs"];
_methodArgs params ["_ownerSelection"];
// Get the laser target object stored in the unit
private _targetObject = _vehicle getVariable [QGVAR(targetObject), objNull];
private _targetPos = getPosASL _targetObject;
if (surfaceIsWater _targetPos && {(_targetPos select 2) < 0}) then {
// Vanilla lasers seem to give position at ocean floor heigh, even though the x and y are correct??
_targetPos set [2, 0.25];
};
private _povPos = AGLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _ownerSelection));
private _povDir = _povPos vectorFromTo _targetPos;
TRACE_4("",_vehicle,_targetObject,_povPos,_povDir);
if(isNil "_povPos" || isNil "_povDir") exitWith {
WARNING_2("bad data [%1][%2]",_povPos,_povDir);
[-1,-1]
};
[_povPos, _povDir]