From c793df48486e6f59867bfa5aadeea9f8580f77fe Mon Sep 17 00:00:00 2001 From: jaynus Date: Wed, 15 Apr 2015 09:10:00 -0700 Subject: [PATCH] Changed: Safety mode on Titan, it now doesnt show as unloaded Fixed: Some TOP shots would miss, Fixed: Lock constraints would show on fast weapon switch. --- addons/javelin/CfgEventhandlers.hpp | 6 ++ addons/javelin/RscInGameUI.hpp | 2 +- addons/javelin/XEH_pre_init.sqf | 1 + addons/javelin/functions/fnc_onFired.sqf | 18 ++++++ addons/javelin/functions/fnc_onOpticDraw.sqf | 58 +++++++++++++------ addons/javelin/functions/fnc_onOpticLoad.sqf | 3 +- .../javelin/functions/fnc_onOpticUnload.sqf | 20 +++++++ .../functions/fnc_attackProfile_JAV_TOP.sqf | 5 +- 8 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 addons/javelin/functions/fnc_onFired.sqf create mode 100644 addons/javelin/functions/fnc_onOpticUnload.sqf diff --git a/addons/javelin/CfgEventhandlers.hpp b/addons/javelin/CfgEventhandlers.hpp index 2c44a05e3a..ae7f95b232 100644 --- a/addons/javelin/CfgEventhandlers.hpp +++ b/addons/javelin/CfgEventhandlers.hpp @@ -9,4 +9,10 @@ class Extended_PostInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_post_init)); clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit)); }; +}; + +class Extended_FiredBIS_EventHandlers { + class All { + ADDON = QUOTE(_this call FUNC(onFired)); + }; }; \ No newline at end of file diff --git a/addons/javelin/RscInGameUI.hpp b/addons/javelin/RscInGameUI.hpp index 8b33c95c01..d845c1d00b 100644 --- a/addons/javelin/RscInGameUI.hpp +++ b/addons/javelin/RscInGameUI.hpp @@ -14,7 +14,7 @@ class RscInGameUI { idd = 300; controls[] = { "ACE_javelin_elements_group", "ACE_Targeting" }; //, "ACE_TargetingConstrains", "ACE_TargetingGate", "ACE_TargetingLines"}; onLoad = QUOTE(_this call FUNC(onOpticLoad)); - onUnload = "uiNameSpace setVariable ['ACE_RscOptics_javelin',nil];uiNameSpace setVariable ['ACE_RscOptics_javelin_PFH',nil];"; + onUnload = QUOTE(_this call FUNC(onOpticUnload)); class ACE_javelin_elements_group: RscControlsGroup { diff --git a/addons/javelin/XEH_pre_init.sqf b/addons/javelin/XEH_pre_init.sqf index 2b2e980191..1accd4a8f4 100644 --- a/addons/javelin/XEH_pre_init.sqf +++ b/addons/javelin/XEH_pre_init.sqf @@ -6,6 +6,7 @@ PREP(lockKeyUp); PREP(cycleFireMode); PREP(showFireMode); +PREP(onFired); PREP(onOpticLoad); PREP(onOpticDraw); diff --git a/addons/javelin/functions/fnc_onFired.sqf b/addons/javelin/functions/fnc_onFired.sqf new file mode 100644 index 0000000000..fde0f94365 --- /dev/null +++ b/addons/javelin/functions/fnc_onFired.sqf @@ -0,0 +1,18 @@ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + +// Bail on not missile +if(! (_weapon in ["launch_Titan_short_F"]) ) exitWith { false }; + +_pfh_handle = uiNamespace getVariable ["ACE_RscOptics_javelin_PFH", nil]; +if(!isNil "_pfh_handle") then { + //[_pfh_handle] call cba_fnc_removePerFrameHandler; + //uiNamespace setVariable["ACE_RscOptics_javelin_PFH", nil]; + + __JavelinIGUITargeting ctrlShow false; + __JavelinIGUITargetingGate ctrlShow false; + __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; +}; \ No newline at end of file diff --git a/addons/javelin/functions/fnc_onOpticDraw.sqf b/addons/javelin/functions/fnc_onOpticDraw.sqf index 85877f1f16..3a64a36802 100644 --- a/addons/javelin/functions/fnc_onOpticDraw.sqf +++ b/addons/javelin/functions/fnc_onOpticDraw.sqf @@ -11,18 +11,6 @@ TRACE_1("enter", _this); private["_isJavelin", "_args", "_lastTick", "_runTime", "_soundTime", "_lockTime", "_newTarget", "_currentTarget", "_range", "_pos", "_targetArray"]; -if( ! ([ (configFile >> "CfgWeapons" >> (currentWeapon (vehicle ACE_player)) ), "launch_Titan_base"] call EFUNC(common,inheritsFrom)) - || { (vehicle ACE_player) != ACE_player } - ) exitWith { - __JavelinIGUITargeting ctrlShow false; - __JavelinIGUITargetingGate ctrlShow false; - __JavelinIGUITargetingLines ctrlShow false; - __JavelinIGUITargetingConstraints ctrlShow false; - - [(_this select 1)] call cba_fnc_removePerFrameHandler; - uiNamespace setVariable["ACE_RscOptics_javelin_PFH", nil]; -}; - // Reset arguments if we havnt rendered in over a second _args = uiNamespace getVariable[QGVAR(arguments), [] ]; if( (count _args) > 0) then { @@ -40,6 +28,21 @@ _runTime = _args select 2; _lockTime = _args select 3; _soundTime = _args select 4; _randomLockInterval = _args select 5; +_fireDisabledEH = _args select 6; + +if( ! ([ (configFile >> "CfgWeapons" >> (currentWeapon (vehicle ACE_player)) ), "launch_Titan_base"] call EFUNC(common,inheritsFrom)) + || { (vehicle ACE_player) != ACE_player } + ) exitWith { + __JavelinIGUITargeting ctrlShow false; + __JavelinIGUITargetingGate ctrlShow false; + __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; + + _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); + + [(_this select 1)] call cba_fnc_removePerFrameHandler; + uiNamespace setVariable["ACE_RscOptics_javelin_PFH", nil]; +}; // Find a target within the optic range _newTarget = objNull; @@ -106,6 +109,27 @@ if((call CBA_fnc_getFoV) select 1 > 9) then { __JavelinIGUIWFOV ctrlSetTextColor __ColorGreen; }; +FUNC(disableFire) = { + _firedEH = _this select 0; + + if(_firedEH < 0) then { + _firedEH = [ACE_player, "DefaultAction", {true}, { + _canFire = ACE_player getVariable["ace_missileguidance_target", nil]; + if(!isNil "_canFire") exitWith { false }; + true + }] call EFUNC(common,addActionEventHandler); + }; + _firedEH +}; +FUNC(enableFire) = { + _firedEH = _this select 0; + + if(_firedEH > 0) then { + [ACE_player, "DefaultAction", _firedEH] call EFUNC(common,removeActionEventHandler); + }; + -1 +}; + if (isNull _newTarget) then { // No targets found _currentTarget = objNull; @@ -120,8 +144,7 @@ if (isNull _newTarget) then { ACE_player setVariable ["ace_missileguidance_target",nil, false]; // Disallow fire - if (ACE_player ammo (currentWeapon ACE_player) > 0) then { ACE_player setWeaponReloadingTime [player, (currentWeapon ACE_player), 0.2]; }; - + _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); } else { if (_newTarget distance ACE_player < 2500 && {(call CBA_fnc_getFoV) select 1 > 9} @@ -176,7 +199,7 @@ if (isNull _newTarget) then { ACE_player setVariable["ace_missileguidance_target", _currentTarget, false]; // Allow fire - ACE_player setWeaponReloadingTime [player, (currentWeapon ACE_player), 0]; + _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); if(diag_tickTime > _soundTime) then { playSound "ACE_Javelin_Locked"; @@ -217,7 +240,7 @@ if (isNull _newTarget) then { _soundTime = diag_tickTime + 0.25; }; // Disallow fire - if (ACE_player ammo (currentWeapon ACE_player) > 0) then { ACE_player setWeaponReloadingTime [player, (currentWeapon ACE_player), 0.2]; }; + _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); }; }; } else { @@ -234,7 +257,7 @@ if (isNull _newTarget) then { ACE_player setVariable ["ace_missileguidance_target",nil, false]; // Disallow fire - if (ACE_player ammo (currentWeapon ACE_player) > 0) then { ACE_player setWeaponReloadingTime [player, (currentWeapon ACE_player), 0.2]; }; + _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); }; }; @@ -246,5 +269,6 @@ _args set[1, _currentTarget]; _args set[2, _runTime]; _args set[3, _lockTime]; _args set[4, _soundTime]; +_args set[6, _fireDisabledEH]; uiNamespace setVariable[QGVAR(arguments), _args ]; \ No newline at end of file diff --git a/addons/javelin/functions/fnc_onOpticLoad.sqf b/addons/javelin/functions/fnc_onOpticLoad.sqf index d38e1c3305..a2b2692859 100644 --- a/addons/javelin/functions/fnc_onOpticLoad.sqf +++ b/addons/javelin/functions/fnc_onOpticLoad.sqf @@ -25,7 +25,8 @@ uiNameSpace setVariable [QGVAR(arguments), 0, // Run Time 0, // Lock Time 0, // Sound timer - (random __LOCKONTIMERANDOM) // random lock time addition + (random __LOCKONTIMERANDOM), // random lock time addition + -1 ] ]; diff --git a/addons/javelin/functions/fnc_onOpticUnload.sqf b/addons/javelin/functions/fnc_onOpticUnload.sqf new file mode 100644 index 0000000000..38acc1cd1c --- /dev/null +++ b/addons/javelin/functions/fnc_onOpticUnload.sqf @@ -0,0 +1,20 @@ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); + +uiNameSpace setVariable ['ACE_RscOptics_javelin',nil]; + +_pfh = uiNamespace getVariable["ACE_RscOptics_javelin_PFH", nil ]; +if(!isNil "_pfh") then { + [_pfh] call CBA_fnc_removePerFrameHandler; + uiNameSpace setVariable ['ACE_RscOptics_javelin_PFH',nil]; +}; + +_args = uiNamespace getVariable[QGVAR(arguments), nil ]; +if(!isNil "_args") then { + _disableFireEH = _args select 6; + if(_disableFireEH > 0) then { + [ACE_player, "DefaultAction", _disableFireEH] call EFUNC(common,removeActionEventHandler); + }; + uiNameSpace setVariable [QGVAR(arguments),nil]; +}; diff --git a/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf b/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf index dc8b9b8e9d..fd86c2bf03 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf @@ -58,10 +58,11 @@ switch( (_state select 0) ) do { case STAGE_COAST: { TRACE_1("STAGE_COAST",""); TRACE_1("", ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ); - if(_distanceShooterToTarget < 1250 || _distanceToTarget < ( ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ) * 1.5) then { + if(_distanceToTarget < ( ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ) * 1.5) then { _state set[0, STAGE_TERMINAL]; + } else { + _returnTargetPos = _seekerTargetPos vectorAdd [0,0,(_projectilePos select 2)]; }; - _returnTargetPos = _seekerTargetPos vectorAdd [0,0,(_projectilePos select 2)]; }; case STAGE_TERMINAL: { TRACE_1("STAGE_TERMINAL","");