2015-04-05 18:54:00 +00:00
|
|
|
//#define DEBUG_MODE_FULL
|
2015-04-04 23:55:53 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-05 18:51:39 +00:00
|
|
|
//TRACE_1("enter", _this);
|
2015-04-04 23:55:53 +00:00
|
|
|
|
2015-04-06 16:22:43 +00:00
|
|
|
#define __TRACKINTERVAL 0.1 // how frequent the check should be.
|
|
|
|
#define __LOCKONTIME 1.85 // Lock on won't occur sooner
|
|
|
|
#define __LOCKONTIMERANDOM 0.3 // Deviation in lock on time
|
|
|
|
#define __SENSORSQUARE 1 // Locking on sensor square side in angles
|
2015-04-04 23:55:53 +00:00
|
|
|
|
|
|
|
#define __ConstraintTop (((ctrlPosition __JavelinIGUITargetingConstrainTop) select 1) + ((ctrlPosition (__JavelinIGUITargetingConstrainTop)) select 3))
|
|
|
|
#define __ConstraintBottom ((ctrlPosition __JavelinIGUITargetingConstrainBottom) select 1)
|
|
|
|
#define __ConstraintLeft (((ctrlPosition __JavelinIGUITargetingConstrainLeft) select 0) + ((ctrlPosition (__JavelinIGUITargetingConstrainLeft)) select 2))
|
|
|
|
#define __ConstraintRight ((ctrlPosition __JavelinIGUITargetingConstrainRight) select 0)
|
|
|
|
|
|
|
|
#define __OffsetX ((ctrlPosition __JavelinIGUITargetingLineV) select 0) - 0.5
|
|
|
|
#define __OffsetY ((ctrlPosition __JavelinIGUITargetingLineH) select 1) - 0.5
|
|
|
|
|
|
|
|
|
2015-04-05 18:51:39 +00:00
|
|
|
private["_args", "_lastTick", "_runTime", "_soundTime", "_lockTime", "_newTarget", "_currentTarget", "_range", "_pos", "_targetArray"];
|
2015-04-04 23:55:53 +00:00
|
|
|
|
|
|
|
// Reset arguments if we havnt rendered in over a second
|
|
|
|
_args = uiNamespace getVariable[QGVAR(arguments), [] ];
|
|
|
|
if( (count _args) > 0) then {
|
|
|
|
_lastTick = _args select 0;
|
|
|
|
if(diag_tickTime - _lastTick > 1) then {
|
|
|
|
[] call FUNC(onOpticLoad);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Pull the arguments
|
|
|
|
_currentTarget = _args select 1;
|
2015-04-05 18:51:39 +00:00
|
|
|
_runTime = _args select 2;
|
|
|
|
_lockTime = _args select 3;
|
|
|
|
_soundTime = _args select 4;
|
2015-04-04 23:55:53 +00:00
|
|
|
|
|
|
|
// Find a target within the optic range
|
|
|
|
_newTarget = objNull;
|
2015-04-06 16:22:43 +00:00
|
|
|
|
2015-04-05 18:51:39 +00:00
|
|
|
// Bail on fast movement
|
2015-04-06 16:22:43 +00:00
|
|
|
if ((velocity ACE_player) distance [0,0,0] > 0.5 && {cameraView == "GUNNER"} && {cameraOn == ACE_player}) exitWith { // keep it steady.
|
2015-04-05 18:51:39 +00:00
|
|
|
ACE_player switchCamera "INTERNAL";
|
|
|
|
};
|
|
|
|
|
|
|
|
// Only start locking on holding tab
|
|
|
|
if(!GVAR(isLockKeyDown)) exitWith { false };
|
|
|
|
|
2015-04-04 23:55:53 +00:00
|
|
|
_range = parseNumber (ctrlText __JavelinIGUIRangefinder);
|
|
|
|
if (_range > 50 && {_range < 2500}) then {
|
|
|
|
_pos = positionCameraToWorld [0,0,_range];
|
|
|
|
_targetArray = _pos nearEntities ["AllVehicles", _range/25];
|
|
|
|
if (count (_targetArray) > 0) then {
|
|
|
|
_newTarget = _targetArray select 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (isNull _newTarget) then {
|
|
|
|
_newTarget = cursorTarget;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (isNull _newTarget) then {
|
|
|
|
// No targets found
|
|
|
|
_currentTarget = objNull;
|
2015-04-05 18:51:39 +00:00
|
|
|
_lockTime = 0;
|
|
|
|
|
2015-04-04 23:55:53 +00:00
|
|
|
__JavelinIGUISeek ctrlSetTextColor __ColorGray;
|
|
|
|
__JavelinIGUINFOV ctrlSetTextColor __ColorGreen;
|
|
|
|
__JavelinIGUITargetingConstrains ctrlShow false;
|
|
|
|
__JavelinIGUITargetingGate ctrlShow false;
|
|
|
|
__JavelinIGUITargetingLines ctrlShow false;
|
|
|
|
|
|
|
|
ACE_player setVariable [QGVAR(currentTarget),nil, false];
|
|
|
|
|
|
|
|
// Disallow fire
|
2015-04-06 16:22:43 +00:00
|
|
|
//if (ACE_player ammo "Javelin" > 0 || {ACE_player ammo "ACE_Javelin_Direct" > 0}) then {ACE_player setWeaponReloadingTime //[player, "Javelin", 0.2];};
|
2015-04-04 23:55:53 +00:00
|
|
|
} else {
|
2015-04-05 18:51:39 +00:00
|
|
|
if (_newTarget distance ACE_player < 2500
|
|
|
|
// && {(call CBA_fnc_getFoV) select 1 > 7}
|
|
|
|
// && { (currentVisionMode ACE_player == 2)}
|
2015-04-04 23:55:53 +00:00
|
|
|
) then {
|
2015-04-05 18:51:39 +00:00
|
|
|
// Lock on after 3 seconds
|
|
|
|
if(_currentTarget != _newTarget) then {
|
|
|
|
TRACE_1("New Target, reseting locking", _newTarget);
|
|
|
|
_lockTime = diag_tickTime;
|
|
|
|
_currentTarget = _newTarget;
|
|
|
|
|
|
|
|
playSound "ACE_Javelin_Locking";
|
|
|
|
} else {
|
|
|
|
if(diag_tickTime - _lockTime > 3) then {
|
|
|
|
TRACE_2("LOCKED!", _currentTarget, _lockTime);
|
|
|
|
__JavelinIGUISeek ctrlSetTextColor __ColorGreen;
|
|
|
|
__JavelinIGUINFOV ctrlSetTextColor __ColorNull;
|
|
|
|
__JavelinIGUITargetingConstrains ctrlShow true;
|
|
|
|
|
|
|
|
ACE_player setVariable[QGVAR(currentTarget), _currentTarget, false];
|
|
|
|
ACE_player setVariable[QGVAR(currentTargetPos), getPosASL _currentTarget, false];
|
|
|
|
|
|
|
|
if(diag_tickTime > _soundTime) then {
|
|
|
|
playSound "ACE_Javelin_Locked";
|
|
|
|
_soundTime = diag_tickTime + 0.25;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if(diag_tickTime > _soundTime) then {
|
|
|
|
playSound "ACE_Javelin_Locking";
|
|
|
|
_soundTime = diag_tickTime + 0.25;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-04-04 23:55:53 +00:00
|
|
|
} else {
|
|
|
|
// Something is wrong with our seek
|
|
|
|
_currentTarget = objNull;
|
|
|
|
|
|
|
|
__JavelinIGUISeek ctrlSetTextColor __ColorGray;
|
|
|
|
__JavelinIGUINFOV ctrlSetTextColor __ColorGray;
|
|
|
|
__JavelinIGUITargetingConstrains ctrlShow false;
|
|
|
|
__JavelinIGUITargetingGate ctrlShow false;
|
|
|
|
__JavelinIGUITargetingLines ctrlShow false;
|
|
|
|
|
|
|
|
ACE_player setVariable [QGVAR(currentTarget),nil, false];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-04-05 18:51:39 +00:00
|
|
|
//TRACE_2("", _newTarget, _currentTarget);
|
2015-04-04 23:55:53 +00:00
|
|
|
|
2015-04-05 00:15:59 +00:00
|
|
|
// Save arguments for next run
|
2015-04-04 23:55:53 +00:00
|
|
|
_args set[0, diag_tickTime];
|
|
|
|
_args set[1, _currentTarget];
|
2015-04-05 18:51:39 +00:00
|
|
|
_args set[2, _runTime];
|
|
|
|
_args set[3, _lockTime];
|
|
|
|
_args set[4, _soundTime];
|
2015-04-04 23:55:53 +00:00
|
|
|
|
|
|
|
uiNamespace setVariable[QGVAR(arguments), _args ];
|