Added: ace_fcs_forceUpdate event for forcing the FCS to update from self-designate

Merged: in-vehicle interact for laser designator
Changed: Perf. tweaks on laser update times.
This commit is contained in:
jaynus 2015-04-03 09:49:41 -07:00
parent 63c42e26c8
commit 84d801a45a
5 changed files with 48 additions and 6 deletions

View File

@ -5,3 +5,6 @@ GVAR(time) = 0;
GVAR(position) = [0,0,0]; GVAR(position) = [0,0,0];
#include "initKeybinds.sqf" #include "initKeybinds.sqf"
// Register event for global updates
[QGVAR(forceUpdate), FUNC(onForceUpdate)] call ace_common_fnc_addEventHandler

View File

@ -10,6 +10,7 @@ PREP(firedEH);
PREP(getAngle); PREP(getAngle);
PREP(getRange); PREP(getRange);
PREP(handleAirBurstAmmunitionPFH); PREP(handleAirBurstAmmunitionPFH);
PREP(onForceUpdate);
PREP(keyDown); PREP(keyDown);
PREP(keyUp); PREP(keyUp);
PREP(reset); PREP(reset);

View File

@ -12,7 +12,7 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_vehicle", "_turret", "_turretConfig", "_distance", "_magazines"]; private ["_vehicle", "_turret", "_turretConfig", "_distance", "_magazines", "_userChange"];
_vehicle = _this select 0; _vehicle = _this select 0;
_turret = _this select 1; _turret = _this select 1;
@ -46,7 +46,9 @@ if (_weaponDirection isEqualTo [0,0,0]) then { // dummy value for non main turr
_angleTarget = asin (_weaponDirection select 2); _angleTarget = asin (_weaponDirection select 2);
if (count _this > 2) then { if (count _this > 2) then {
if((_this select 2) > -1) then {
_distance = _this select 2; _distance = _this select 2;
};
}; };
if (!(isNil QGVAR(backgroundCalculation)) and {!(scriptDone GVAR(backgroundCalculation))}) then { if (!(isNil QGVAR(backgroundCalculation)) and {!(scriptDone GVAR(backgroundCalculation))}) then {
@ -160,4 +162,11 @@ _FCSElevation = [];
[_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation] call EFUNC(common,setVariablePublic); [_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation] call EFUNC(common,setVariablePublic);
[_vehicle, format ["%1_%2", QGVAR(Azimuth), _turret], _FCSAzimuth] call EFUNC(common,setVariablePublic); [_vehicle, format ["%1_%2", QGVAR(Azimuth), _turret], _FCSAzimuth] call EFUNC(common,setVariablePublic);
[format ["%1: %2", localize "STR_ACE_FCS_ZeroedTo", _distance]] call EFUNC(common,displayTextStructured); _userChange = true;
if( (count _this) > 3) then {
_userChange = _this select 3;
};
if(_userChange) then {
[format ["%1: %2", localize "STR_ACE_FCS_ZeroedTo", _distance]] call EFUNC(common,displayTextStructured);
};

View File

@ -0,0 +1,7 @@
#include "script_component.hpp"
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false};
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -1, false] call FUNC(keyDown);
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -1, false] call FUNC(keyUp);

View File

@ -3,6 +3,8 @@
TRACE_1("enter", _this); TRACE_1("enter", _this);
#define FCS_UPDATE_DELAY 2.0
FUNC(magnitude) = { FUNC(magnitude) = {
_this distance [0, 0, 0] _this distance [0, 0, 0]
}; };
@ -17,11 +19,16 @@ FUNC(mat_normalize3d) = {
}; };
FUNC(laserHudDesignatePFH) = { FUNC(laserHudDesignatePFH) = {
private["_args", "_laserTarget", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult"]; private["_args", "_laserTarget", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"];
_args = _this select 0; _args = _this select 0;
_laserTarget = _args select 0; _laserTarget = _args select 0;
_shooter = _args select 1; _shooter = _args select 1;
if( (count _args) < 3) then {
_args set[2, diag_tickTime + FCS_UPDATE_DELAY];
};
_forceUpdateTime = _args select 2;
_vehicle = vehicle _shooter; _vehicle = vehicle _shooter;
_weapon = currentWeapon _vehicle; _weapon = currentWeapon _vehicle;
@ -50,14 +57,29 @@ FUNC(laserHudDesignatePFH) = {
// Just regular use of lasers will commonly make them move this much, // Just regular use of lasers will commonly make them move this much,
// but not across multiple close frames. // but not across multiple close frames.
// This loses accuracy a little, but saves position updates per frame. // This loses accuracy a little, but saves position updates per frame.
//if( ((getPosASL _laserTarget) distance _pos) > 0.5) then { 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;
};
if( diag_tickTime > _forceUpdateTime || ((getPosASL _laserTarget) distance _pos) > 0.5) then {
TRACE_1("LaserPos Update", "");
_laserTarget setPosATL (ASLToATL _pos); _laserTarget setPosATL (ASLToATL _pos);
//};
};
if(diag_tickTime > _forceUpdateTime) then {
_args set[3, diag_tickTime + FCS_UPDATE_DELAY];
};
#ifdef DEBUG_MODE_FULL #ifdef DEBUG_MODE_FULL
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLToATL _pos, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLToATL _pos, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"];
#endif #endif
}; };
}; };
_this set[0, _args];
}; };
private "_laserTarget"; private "_laserTarget";