2015-04-12 18:29:33 +00:00
|
|
|
/*
|
|
|
|
* Author: jaynus
|
|
|
|
* Turns on laser self designation from this vehicle based on the turret.
|
|
|
|
* There are no arguments, because it is all strictly based on the users vehicle.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* N/A
|
|
|
|
*/
|
|
|
|
//#define DEBUG_MODE_FULL
|
2015-01-20 04:13:12 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
TRACE_1("enter", _this);
|
|
|
|
|
2015-04-06 19:54:06 +00:00
|
|
|
#define FCS_UPDATE_DELAY 1
|
2015-04-03 16:49:41 +00:00
|
|
|
|
2015-01-20 04:13:12 +00:00
|
|
|
FUNC(laserHudDesignatePFH) = {
|
2015-04-12 18:01:22 +00:00
|
|
|
private["_strongestResultPos", "_args", "_localLaserTarget", "_laserResultPosition", "_laserResult", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turretInfo", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"];
|
2015-04-02 16:35:36 +00:00
|
|
|
_args = _this select 0;
|
|
|
|
|
2015-04-12 18:01:22 +00:00
|
|
|
_shooter = _args select 0;
|
|
|
|
_localLaserTarget = _args select 2;
|
|
|
|
_vehicle = vehicle _shooter;
|
|
|
|
TRACE_1("", _args);
|
|
|
|
|
2015-04-12 18:29:33 +00:00
|
|
|
if((vehicle _shooter) == _shooter || {!alive _shooter} || {isNull _vehicle} || {!GVAR(active)} ) exitWith {
|
2015-04-12 18:01:22 +00:00
|
|
|
_args call FUNC(laserHudDesignateOff);
|
2015-04-07 19:11:28 +00:00
|
|
|
};
|
2015-04-07 19:35:34 +00:00
|
|
|
if(!([_shooter] call FUNC(unitTurretHasDesignator)) ) exitWith {
|
2015-04-12 18:01:22 +00:00
|
|
|
_args call FUNC(laserHudDesignateOff);
|
2015-04-07 19:11:28 +00:00
|
|
|
};
|
|
|
|
|
2015-04-12 18:01:22 +00:00
|
|
|
if( (count _args) < 4) then {
|
|
|
|
_args set[3, diag_tickTime + FCS_UPDATE_DELAY];
|
2015-04-03 16:49:41 +00:00
|
|
|
};
|
2015-04-12 18:01:22 +00:00
|
|
|
_forceUpdateTime = _args select 3;
|
|
|
|
|
|
|
|
_gunnerInfo = [_vehicle, (currentWeapon _vehicle)] call CBA_fnc_getFirer;
|
2015-04-02 17:05:50 +00:00
|
|
|
_turretInfo = [_vehicle, _gunnerInfo select 1] call EFUNC(common,getTurretDirection);
|
|
|
|
_povPos = _turretInfo select 0;
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-04-12 18:41:50 +00:00
|
|
|
_laserCode = (vehicle ACE_player) getVariable[QGVAR(currentCode), ACE_DEFAULT_LASER_CODE];
|
|
|
|
_beamSpread = (vehicle ACE_player) getVariable[QGVAR(currentBeamSpread), ACE_DEFAULT_LASER_BEAMSPREAD];
|
|
|
|
|
|
|
|
_laserResult = [_povPos, [_beamSpread,_beamSpread], _laserCode] call EFUNC(laser,seekerFindLaserSpot);
|
2015-04-12 18:01:22 +00:00
|
|
|
_laserResultPosition = _laserResult select 0;
|
|
|
|
TRACE_1("Search", _laserResult);
|
|
|
|
|
|
|
|
if((count _laserResult) > 0) then {
|
|
|
|
if(diag_tickTime > _forceUpdateTime) then {
|
|
|
|
["ace_fcs_forceUpdate", []] call ace_common_fnc_localEvent;
|
|
|
|
_args set[3, diag_tickTime + FCS_UPDATE_DELAY];
|
|
|
|
};
|
|
|
|
|
2015-04-12 18:14:12 +00:00
|
|
|
// @TODO: Nou gets to field all tickets about missing lasers.
|
|
|
|
//_localLaserTarget setPosASL _laserResultPosition;
|
2015-04-12 18:01:22 +00:00
|
|
|
|
2015-01-20 04:13:12 +00:00
|
|
|
#ifdef DEBUG_MODE_FULL
|
2015-04-12 18:01:22 +00:00
|
|
|
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _laserResultPosition, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"];
|
|
|
|
drawLine3d [ASLToATL _povPos, ASLToATL _laserResultPosition, [0,0,1,1] ];
|
2015-01-20 04:13:12 +00:00
|
|
|
#endif
|
2015-04-02 16:35:36 +00:00
|
|
|
};
|
2015-04-03 16:49:41 +00:00
|
|
|
_this set[0, _args];
|
2015-01-20 04:13:12 +00:00
|
|
|
};
|
|
|
|
|
2015-04-12 18:38:07 +00:00
|
|
|
private ["_laserTarget", "_handle", "_vehicle", "_laserUuid", "_waveLength", "_beamSpread", "_laserCode"];
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-04-12 18:01:22 +00:00
|
|
|
if(!GVAR(active)) then {
|
2015-04-07 19:11:28 +00:00
|
|
|
GVAR(active) = true;
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-04-12 18:01:22 +00:00
|
|
|
TRACE_1("Activating laser", "");
|
2015-04-12 18:38:07 +00:00
|
|
|
|
|
|
|
// Get the self-designation variables, or use defaults
|
|
|
|
_laserCode = (vehicle ACE_player) getVariable[QGVAR(currentCode), ACE_DEFAULT_LASER_CODE];
|
|
|
|
_waveLength = (vehicle ACE_player) getVariable[QGVAR(currentWaveLength), ACE_DEFAULT_LASER_WAVELENGTH];
|
|
|
|
_beamSpread = (vehicle ACE_player) getVariable[QGVAR(currentBeamSpread), ACE_DEFAULT_LASER_BEAMSPREAD];
|
|
|
|
|
|
|
|
_laserUuid = [(vehicle ACE_player), ACE_player, QFUNC(findLaserSource), _waveLength, _laserCode, _beamSpread] call EFUNC(laser,laserOn);
|
2015-04-07 19:11:28 +00:00
|
|
|
|
2015-04-12 18:01:22 +00:00
|
|
|
// @TODO: Create the local target for the players side
|
2015-04-12 18:14:12 +00:00
|
|
|
// @TODO: Nou gets to field all tickets about missing lasers.
|
|
|
|
//_localLaserTarget = "LaserTargetW" createVehicleLocal (getpos ACE_player);
|
2015-04-12 18:01:22 +00:00
|
|
|
|
2015-04-12 18:14:12 +00:00
|
|
|
_handle = [FUNC(laserHudDesignatePFH), 0.25, [ACE_player, _laserUuid, nil]] call cba_fnc_addPerFrameHandler;
|
2015-01-20 04:13:12 +00:00
|
|
|
} else {
|
2015-04-02 16:35:36 +00:00
|
|
|
[] call FUNC(laserHudDesignateOff);
|
|
|
|
[] call FUNC(laserHudDesignateOn);
|
2015-01-20 04:13:12 +00:00
|
|
|
};
|
|
|
|
|