diff --git a/addons/laser/CfgVehicles.hpp b/addons/laser/CfgVehicles.hpp index 23eb00c37c..dd3f02a0cc 100644 --- a/addons/laser/CfgVehicles.hpp +++ b/addons/laser/CfgVehicles.hpp @@ -17,4 +17,29 @@ class CfgVehicles { simulation = "LaserTarget"; model = "\A3\Weapons_f\laserTgt.p3d"; }; + + // Vehicle lockable configurations + + class AllVehicles; + class Air: AllVehicles { + class Turrets; + }; + + class Helicopter: Air { + class Turrets { + class MainTurret; + }; + }; + + class Helicopter_Base_F: Helicopter {}; + + class Heli_Attack_01_base_F: Helicopter_Base_F {}; + + class B_Heli_Attack_01_F: Heli_Attack_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(CanLockLaser) = 1; // Enable laser locking selection + }; + }; + }; }; \ No newline at end of file diff --git a/addons/laser/XEH_post_init.sqf b/addons/laser/XEH_post_init.sqf index f868ef9895..a9f0e82be3 100644 --- a/addons/laser/XEH_post_init.sqf +++ b/addons/laser/XEH_post_init.sqf @@ -1,5 +1,7 @@ #include "script_component.hpp" +#include "initKeybinds.sqf" + ["laser_laserOn", {_this call DFUNC(handleLaserOn)}] call EFUNC(common,addEventHandler); ["laser_laserOff", {_this call DFUNC(handleLaserOff)}] call EFUNC(common,addEventHandler); diff --git a/addons/laser/XEH_pre_init.sqf b/addons/laser/XEH_pre_init.sqf index 2dd6e666eb..20f31d9e5b 100644 --- a/addons/laser/XEH_pre_init.sqf +++ b/addons/laser/XEH_pre_init.sqf @@ -24,6 +24,10 @@ PREP(laserTargetPFH); GVAR(VanillaLasers) = []; +PREP(unitTurretCanLockLaser); +PREP(keyLaserCodeUp); +PREP(keyLaserCodeDown); + // Laser default variables ACE_DEFAULT_LASER_CODE = 1001; ACE_DEFAULT_LASER_WAVELENGTH = 1550; diff --git a/addons/laser/functions/fnc_keyLaserCodeDown.sqf b/addons/laser/functions/fnc_keyLaserCodeDown.sqf new file mode 100644 index 0000000000..a27b376d59 --- /dev/null +++ b/addons/laser/functions/fnc_keyLaserCodeDown.sqf @@ -0,0 +1,12 @@ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +private["_oldLaserCode", "_laserCode"]; + +_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; +if(_oldLaserCode > ACE_DEFAULT_LASER_CODE) then { + _laserCode = _oldLaserCode - 1; + ACE_player setVariable [QGVAR(code), _laserCode, false]; +}; +if(_laserCode != _oldLaserCode) then { + [format ["%1: %2", localize "STR_ACE_laser_laserCode", _laserCode]] call EFUNC(common,displayTextStructured); +}; \ No newline at end of file diff --git a/addons/laser/functions/fnc_keyLaserCodeUp.sqf b/addons/laser/functions/fnc_keyLaserCodeUp.sqf new file mode 100644 index 0000000000..4e8750164c --- /dev/null +++ b/addons/laser/functions/fnc_keyLaserCodeUp.sqf @@ -0,0 +1,10 @@ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +private["_oldLaserCode", "_laserCode"]; + +_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; +_laserCode = _oldLaserCode + 1; +ACE_player setVariable [QGVAR(code), _laserCode, false]; +if(_laserCode != _oldLaserCode) then { +[format ["%1: %2", localize "STR_ACE_laser_laserCode", _laserCode]] call EFUNC(common,displayTextStructured); +}; \ No newline at end of file diff --git a/addons/laser/functions/fnc_unitTurretCanLockLaser.sqf b/addons/laser/functions/fnc_unitTurretCanLockLaser.sqf new file mode 100644 index 0000000000..a82e42400a --- /dev/null +++ b/addons/laser/functions/fnc_unitTurretCanLockLaser.sqf @@ -0,0 +1,21 @@ +/* + * Author: jaynus + * Checks if the turret occupied by the given unit can lock a laser designator and select laser code. + * + * Argument: + * 0: Unit + * + * Return value: + * Has designator? + */ +#include "script_component.hpp" + +EXPLODE_1_PVT(_this,_unit); + +// Get the player turret path +private ["_turret","_config","_turretConfig"]; +_turret = [_unit] call EFUNC(common,getTurretIndex); +_config = configFile >> "CfgVehicles" >> typeOf vehicle _unit; +_turretConfig = [_config, _turret] call EFUNC(common,getTurretConfigPath); + +getNumber (_turretConfig >> QGVAR(CanLockLaser)) > 0 diff --git a/addons/laser/initKeybinds.sqf b/addons/laser/initKeybinds.sqf new file mode 100644 index 0000000000..d367b3553c --- /dev/null +++ b/addons/laser/initKeybinds.sqf @@ -0,0 +1,27 @@ +["ACE3 Equipment", QGVAR(LaserCodeUp), localize "STR_ACE_laser_laserCodeUp", +{ + if( EGVAR(laser_selfdesignate,active) + || + { (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope. + || + { [ACE_player] call FUNC(unitTurretCanLockLaser) } + ) then { + [] call FUNC(keyLaserCodeUp); + }; +}, +{false}, +[16, [false, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+Q) + +["ACE3 Equipment", QGVAR(LaserCodeDown), localize "STR_ACE_laser_laserCodeDown", +{ + if( EGVAR(laser_selfdesignate,active) + || + { (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope. + || + { [ACE_player] call FUNC(unitTurretCanLockLaser) } + ) then { + [] call FUNC(keyLaserCodeDown); + }; +}, +{false}, +[18, [true, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+E) diff --git a/addons/laser/stringtable.xml b/addons/laser/stringtable.xml new file mode 100644 index 0000000000..5eb1e23f1f --- /dev/null +++ b/addons/laser/stringtable.xml @@ -0,0 +1,14 @@ + + + + + Laser Code + + + Laser - Cycle Code Up + + + Laser - Cycle Code Down + + + \ No newline at end of file diff --git a/addons/laser_selfdesignate/CfgVehicles.hpp b/addons/laser_selfdesignate/CfgVehicles.hpp index 02d8b32b3d..3233a1e92c 100644 --- a/addons/laser_selfdesignate/CfgVehicles.hpp +++ b/addons/laser_selfdesignate/CfgVehicles.hpp @@ -21,4 +21,29 @@ class CfgVehicles { }; }; }; + + class Plane: Air {}; + class Plane_Base_F: Plane { + class Turrets { + class CopilotTurret; + }; + }; + + /* @TODO: LGB GBU + class Plane_CAS_01_base_F: Plane_Base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; // Enable laser self-designation + }; + }; + }; + + class Plane_CAS_02_base_F: Plane_Base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; // Enable laser self-designation + }; + }; + }; + */ }; diff --git a/addons/missileguidance/functions/fnc_onFired.sqf b/addons/missileguidance/functions/fnc_onFired.sqf index 5145258cd3..c5053c6e73 100644 --- a/addons/missileguidance/functions/fnc_onFired.sqf +++ b/addons/missileguidance/functions/fnc_onFired.sqf @@ -29,6 +29,10 @@ _seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil]; _attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil]; _lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil]; +// @TODO: make this vehicle shooter, but we need to differentiate where its set in ace_laser +_laserCode = _shooter getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE]; +_laserInfo = [_laserCode, ACE_DEFAULT_LASER_WAVELENGTH, ACE_DEFAULT_LASER_WAVELENGTH]; + _launchPos = getPosASL (vehicle _shooter); TRACE_3("Begin guidance", _target, _seekerType, _attackProfile); @@ -69,7 +73,8 @@ _args = [_this, [_target, _targetPos, _launchPos], _seekerType, _attackProfile, - _lockMode + _lockMode, + _laserInfo ], [ getNumber ( _config >> "minDeflection" ), diff --git a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf index 7aafad1114..6297d21dfa 100644 --- a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf @@ -2,17 +2,19 @@ #include "script_component.hpp" EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_angleFov", "_canSeeTarget", "_foundTargetPos", "_laserResult", "_launchParams", "_seekerParams", "_seekerTargetPos", "_sensorPos", "_target"]; +private["_angleFov", "_canSeeTarget", "_foundTargetPos", "_laserResult", "_launchParams", "_seekerParams", "_laserCode", "_laserParams", "_seekerTargetPos", "_sensorPos", "_target"]; _seekerTargetPos = _this select 0; _launchParams = _this select 1; _seekerParams = _launchParams select 3; _angleFov = _seekerParams select 0; +_laserParams = (_launchParams select 1) select 5; +TRACE_2("", _launchParams, _laserParams); if(!isNil "_target") then { // Handle AI or moving vanilla lasers _foundTargetPos = getPosASL _target; } else { - _laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot); + _laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [(_laserParams select 1),(_laserParams select 2)], (_laserParams select 0)] call EFUNC(laser,seekerFindLaserSpot); _foundTargetPos = _laserResult select 0; TRACE_1("Search", _laserResult); };