2015-04-06 14:40:20 +00:00
|
|
|
//#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-03 16:49:41 +00:00
|
|
|
private["_args", "_laserTarget", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"];
|
2015-04-02 16:35:36 +00:00
|
|
|
_args = _this select 0;
|
|
|
|
_laserTarget = _args select 0;
|
|
|
|
_shooter = _args select 1;
|
2015-04-07 19:11:28 +00:00
|
|
|
|
|
|
|
TRACE_1("", _args);
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-04-07 19:35:34 +00:00
|
|
|
if(vehicle ACE_player) != _shooter || !alive _shooter || isNull _vehicle || isNull _laserTarget || !GVAR(active) ) exitWith {
|
2015-04-07 19:11:28 +00:00
|
|
|
[_vehicle, _shooter, _laserTarget] call FUNC(laserHudDesignateOff);
|
|
|
|
};
|
2015-04-07 19:35:34 +00:00
|
|
|
if(!([_shooter] call FUNC(unitTurretHasDesignator)) ) exitWith {
|
2015-04-07 19:11:28 +00:00
|
|
|
[_vehicle, _shooter, _laserTarget] call FUNC(laserHudDesignateOff);
|
|
|
|
};
|
|
|
|
|
2015-04-03 16:49:41 +00:00
|
|
|
if( (count _args) < 3) then {
|
|
|
|
_args set[2, diag_tickTime + FCS_UPDATE_DELAY];
|
|
|
|
};
|
|
|
|
_forceUpdateTime = _args select 2;
|
|
|
|
|
2015-04-02 16:35:36 +00:00
|
|
|
_vehicle = vehicle _shooter;
|
|
|
|
_weapon = currentWeapon _vehicle;
|
|
|
|
|
|
|
|
// Retrieve the gunner and turret memory point information
|
|
|
|
_gunnerInfo = [_vehicle, _weapon] 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;
|
|
|
|
_povDir = _turretInfo select 1;
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-04-07 16:05:19 +00:00
|
|
|
_targetInfo = _vehicle getVariable[QGVAR(currentTarget), [] ];
|
|
|
|
if( (count _targetInfo) > 0) then {
|
|
|
|
if(_laserTarget != (_targetInfo select 0) ) then {
|
|
|
|
_targetInfo = []
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if( (count _targetInfo) < 1) then {
|
|
|
|
_targetInfo = [_laserTarget, 1001]; // TODO: set laser code
|
|
|
|
_vehicle setVariable[QGVAR(currentTarget), _targetInfo, true];
|
|
|
|
_laserTarget setVariable[QGVAR(owner), _vehicle, true];
|
|
|
|
};
|
2015-04-03 22:26:27 +00:00
|
|
|
|
|
|
|
|
2015-04-02 16:35:36 +00:00
|
|
|
_result = [_povPos, _povDir] call EFUNC(laser,shootCone);
|
|
|
|
if((count _result) > 0) then {
|
|
|
|
_resultPositions = _result select 2;
|
2015-01-20 04:13:12 +00:00
|
|
|
|
2015-04-02 16:35:36 +00:00
|
|
|
if((count _resultPositions) > 0) then {
|
|
|
|
_firstResult = _resultPositions select 0;
|
|
|
|
_pos = _firstResult select 0;
|
|
|
|
|
|
|
|
// If the laser has moved less than a half meter, then dont move it.
|
|
|
|
// Just regular use of lasers will commonly make them move this much,
|
|
|
|
// but not across multiple close frames.
|
|
|
|
// This loses accuracy a little, but saves position updates per frame.
|
2015-04-03 16:49:41 +00:00
|
|
|
TRACE_5("", diag_tickTime, _forceUpdateTime, getPosASL _laserTarget, _pos, ((getPosASL _laserTarget) distance _pos));
|
|
|
|
|
|
|
|
if(diag_tickTime > _forceUpdateTime) then {
|
|
|
|
TRACE_1("FCS Update", "");
|
|
|
|
["ace_fcs_forceUpdate", []] call ace_common_fnc_localEvent;
|
|
|
|
};
|
|
|
|
|
2015-04-07 19:35:34 +00:00
|
|
|
//if( (_laserTarget distance _pos) > 0.1) then {
|
2015-04-03 16:49:41 +00:00
|
|
|
TRACE_1("LaserPos Update", "");
|
2015-04-02 16:35:36 +00:00
|
|
|
_laserTarget setPosATL (ASLToATL _pos);
|
2015-04-07 19:35:34 +00:00
|
|
|
//};
|
2015-04-03 16:49:41 +00:00
|
|
|
|
|
|
|
if(diag_tickTime > _forceUpdateTime) then {
|
2015-04-06 18:44:17 +00:00
|
|
|
_args set[2, diag_tickTime + FCS_UPDATE_DELAY];
|
2015-04-03 16:49:41 +00:00
|
|
|
};
|
2015-01-20 04:13:12 +00:00
|
|
|
#ifdef DEBUG_MODE_FULL
|
2015-04-03 21:28:12 +00:00
|
|
|
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], (getPosATL _laserTarget), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"];
|
2015-04-03 22:26:27 +00:00
|
|
|
|
2015-04-03 21:28:12 +00:00
|
|
|
{
|
|
|
|
private["_position"];
|
|
|
|
_position = _x select 0;
|
2015-04-03 22:26:27 +00:00
|
|
|
drawLine3d [ASLToATL _povPos, ASLToATL _position, [0,0,1,1] ];
|
2015-04-03 21:28:12 +00:00
|
|
|
} forEach _resultPositions;
|
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-07 19:35:34 +00:00
|
|
|
private ["_laserTarget", "_handle", "_vehicle"];
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-01-20 04:13:12 +00:00
|
|
|
if(isNil QGVAR(laser)) then {
|
2015-04-07 16:05:19 +00:00
|
|
|
_laserTarget = "LaserTargetW" createVehicle (getpos ACE_player);
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-04-07 19:11:28 +00:00
|
|
|
GVAR(active) = true;
|
2015-04-02 16:35:36 +00:00
|
|
|
|
2015-04-07 16:05:19 +00:00
|
|
|
_handle = [FUNC(laserHudDesignatePFH), 0.1, [_laserTarget, ACE_player]] call cba_fnc_addPerFrameHandler;
|
2015-04-02 16:35:36 +00:00
|
|
|
_laserTarget setVariable ["ACE_PFH_HANDLE", _handle, false];
|
|
|
|
|
2015-04-07 19:11:28 +00:00
|
|
|
// Clear the vehicle parameters
|
|
|
|
_vehicle setVariable[QGVAR(currentTarget), [], true];
|
|
|
|
|
2015-04-02 16:35:36 +00:00
|
|
|
GVAR(laser) = _laserTarget;
|
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
|
|
|
};
|
|
|
|
|