diff --git a/addons/hellfire/ACE_GuidanceConfig.hpp b/addons/hellfire/ACE_GuidanceConfig.hpp index 1c5d4705f3..ad3d8c667d 100644 --- a/addons/hellfire/ACE_GuidanceConfig.hpp +++ b/addons/hellfire/ACE_GuidanceConfig.hpp @@ -1,6 +1,5 @@ class EGVAR(missileguidance,AttackProfiles) { - class hellfire { - // LOBL and LOAL-DIR behaive the same + class hellfire { name = "LOAL-DIR"; nameLocked = "LOBL"; functionName = QFUNC(attackProfile); @@ -8,10 +7,12 @@ class EGVAR(missileguidance,AttackProfiles) { }; class hellfire_hi: hellfire { name = "LOAL-HI"; + nameLocked = "LOAL-HI"; GVAR(launchHeightClear) = 304.8; // clear 1000 ft by 1500m }; class hellfire_lo: hellfire_hi { name = "LOAL-LO"; + nameLocked = "LOAL-LO"; GVAR(launchHeightClear) = 91.5; // clear 300 ft by 600m }; }; diff --git a/addons/hellfire/CfgWeapons.hpp b/addons/hellfire/CfgWeapons.hpp index 483f1dd0a7..e55492a59c 100644 --- a/addons/hellfire/CfgWeapons.hpp +++ b/addons/hellfire/CfgWeapons.hpp @@ -2,8 +2,9 @@ class CfgWeapons { class missiles_SCALPEL; class GVAR(launcher): missiles_SCALPEL { displayName = "AGM-114K Hellfire II"; - GVAR(enabled) = 1; // show attack profile / lock on hud + GVAR(enabled) = 1; // handle adding interactions and adding Laser Designator EGVAR(laser,canSelect) = 1; // can ace_laser lock (allows switching laser code) + EGVAR(laser,showHud) = 1; // show attack profile / lock on hud canLock = 0; weaponLockSystem = 0; magazines[] = {"6Rnd_ACE_Hellfire_AGM114K", "PylonMissile_1Rnd_ACE_Hellfire_AGM114K", "PylonRack_1Rnd_ACE_Hellfire_AGM114K", "PylonRack_3Rnd_ACE_Hellfire_AGM114K", "PylonRack_4Rnd_ACE_Hellfire_AGM114K"}; diff --git a/addons/hellfire/XEH_PREP.hpp b/addons/hellfire/XEH_PREP.hpp index 8b07d00b2c..f30cf0bffd 100644 --- a/addons/hellfire/XEH_PREP.hpp +++ b/addons/hellfire/XEH_PREP.hpp @@ -2,4 +2,3 @@ LOG("prep"); PREP(attackProfile); PREP(getAttackProfileSettings); PREP(setupVehicle); -PREP(showHud); diff --git a/addons/hellfire/XEH_postInit.sqf b/addons/hellfire/XEH_postInit.sqf index b5dc8bf9fe..e89bf7a3e3 100644 --- a/addons/hellfire/XEH_postInit.sqf +++ b/addons/hellfire/XEH_postInit.sqf @@ -2,18 +2,16 @@ if (!hasInterface) exitWith {}; -GVAR(pfID) = -1; - ["ace_settingsInitialized", { - ["turret", LINKFUNC(showHud), false] call CBA_fnc_addPlayerEventHandler; - ["vehicle", LINKFUNC(showHud), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag + ["turret", LINKFUNC(setupVehicle), false] call CBA_fnc_addPlayerEventHandler; + ["vehicle", LINKFUNC(setupVehicle), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag // Add UAV Control Compatibility ["ACE_controlledUAV", { params ["_UAV", "_seatAI", "_turret", "_position"]; TRACE_4("ACE_controlledUAV EH",_UAV,_seatAI,_turret,_position); if (!isNull _seatAI) then { - [_seatAI] call FUNC(showHud); + [_seatAI] call FUNC(setupVehicle); }; }] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler; diff --git a/addons/hellfire/config.cpp b/addons/hellfire/config.cpp index 14c00904f1..8df1594612 100644 --- a/addons/hellfire/config.cpp +++ b/addons/hellfire/config.cpp @@ -20,4 +20,3 @@ class CfgPatches { #include "CfgMagazines.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" -#include "RscTitles.hpp" diff --git a/addons/hellfire/functions/fnc_setupVehicle.sqf b/addons/hellfire/functions/fnc_setupVehicle.sqf index 811e6c6f3f..36b724d8a6 100644 --- a/addons/hellfire/functions/fnc_setupVehicle.sqf +++ b/addons/hellfire/functions/fnc_setupVehicle.sqf @@ -4,22 +4,42 @@ * Also adds a Laser Designator if vehicle is configured for one. * * Arguments: - * 0: Vehicle - * 1: Player's Turret Path + * 0: Player * * Return Value: * Nothing * * Example: - * [(vehicle player), [0]] call ace_hellfire_fnc_setupVehicle + * [player] call ace_hellfire_fnc_setupVehicle * * Public: No */ // #define DEBUG_MODE_FULL #include "script_component.hpp" -params ["_vehicle", "_turretPath"]; -TRACE_2("setupVehicle",_vehicle,_turretPath); + +params ["_player"]; +// Note: player may be the currently controlled UAV's AI unit (so may be different from ace_player) +TRACE_1("showHud",_player); + +private _enabled = false; +private _vehicle = vehicle _player; +private _turretPath = [-1]; + +if ((alive _player) && {_player != _vehicle}) then { + if (_player != (driver _vehicle)) then { + _turretPath = _player call CBA_fnc_turretPath + }; + { + if ((getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(enabled))) == 1) then { + TRACE_1("enabled",_x); + _enabled = true; + }; + } forEach (_vehicle weaponsTurret _turretPath); +}; + +if (!_enabled) exitWith {TRACE_3("Not enabled",_enabled,_vehicle,_turretPath);}; + // Add laser if vehicle is configured for one: if ((getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> QGVAR(addLaserDesignator))) == 1) then { @@ -40,7 +60,7 @@ if ((getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> QGVAR(addLas _vehicle addWeaponTurret ["Laserdesignator_mounted", _turretPath]; _vehicle addMagazineTurret ["Laserbatteries", _turretPath]; }; - }, _this, 1] call CBA_fnc_waitAndExecute; // Need to delay slightly for turret to become local (probably only needs a single frame) + }, [_vehicle, _turretPath], 1] call CBA_fnc_waitAndExecute; // Need to delay slightly for turret to become local (probably only needs a single frame) }; diff --git a/addons/hellfire/script_component.hpp b/addons/hellfire/script_component.hpp index 2e8cf04eff..6d16736a9c 100644 --- a/addons/hellfire/script_component.hpp +++ b/addons/hellfire/script_component.hpp @@ -20,8 +20,3 @@ #define STAGE_SEEK_CRUISE 2 #define STAGE_ATTACK_CRUISE 3 #define STAGE_ATTACK_TERMINAL 4 - -#define IDC_MODECONTROLGROUP 1000 -#define IDC_ATTACKMODE 1001 -#define IDC_LASERCODE 1002 -#define IDC_LASERICON 1003 diff --git a/addons/laser/RscInGameUI.hpp b/addons/laser/RscInGameUI.hpp index ca57f56f6f..16d3dfcd91 100644 --- a/addons/laser/RscInGameUI.hpp +++ b/addons/laser/RscInGameUI.hpp @@ -1,9 +1,3 @@ -class RscControlsGroup; -class VScrollbar; -class HScrollbar; -class RscText; -class RscMapControl; - class RscInGameUI { class RscOptics_LaserDesignator { idd = 300; diff --git a/addons/hellfire/RscTitles.hpp b/addons/laser/RscTitles.hpp similarity index 97% rename from addons/hellfire/RscTitles.hpp rename to addons/laser/RscTitles.hpp index 2bbedae1b6..7421246181 100644 --- a/addons/hellfire/RscTitles.hpp +++ b/addons/laser/RscTitles.hpp @@ -1,7 +1,3 @@ -class RscControlsGroupNoScrollbars; -class RscPictureKeepAspect; -class RscText; - class RscTitles { class GVAR(modeDisplay) { idd = -1; diff --git a/addons/laser/XEH_PREP.hpp b/addons/laser/XEH_PREP.hpp index a95eae7842..6af5643e23 100644 --- a/addons/laser/XEH_PREP.hpp +++ b/addons/laser/XEH_PREP.hpp @@ -13,3 +13,4 @@ PREP(rotateVectLineGetMap); PREP(seekerFindLaserSpot); PREP(shootCone); PREP(shootRay); +PREP(showVehicleHud); diff --git a/addons/laser/XEH_postInit.sqf b/addons/laser/XEH_postInit.sqf index b439fd1f06..5f0385cee8 100644 --- a/addons/laser/XEH_postInit.sqf +++ b/addons/laser/XEH_postInit.sqf @@ -1,7 +1,25 @@ #include "script_component.hpp" +if (hasInterface) then { #include "initKeybinds.sqf" + GVAR(pfID) = -1; + + ["ace_settingsInitialized", { + ["turret", LINKFUNC(showVehicleHud), false] call CBA_fnc_addPlayerEventHandler; + ["vehicle", LINKFUNC(showVehicleHud), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag + + // Add UAV Control Compatibility + ["ACE_controlledUAV", { + params ["_UAV", "_seatAI", "_turret", "_position"]; + TRACE_4("ACE_controlledUAV EH",_UAV,_seatAI,_turret,_position); + if (!isNull _seatAI) then { + [_seatAI] call FUNC(showVehicleHud); + }; + }] call CBA_fnc_addEventHandler; + }] call CBA_fnc_addEventHandler; +}; + // Global Laser EHs ["ace_laserOn", { params ["_uuid", "_args"]; diff --git a/addons/laser/config.cpp b/addons/laser/config.cpp index 75f70449ea..fb6ae5e638 100644 --- a/addons/laser/config.cpp +++ b/addons/laser/config.cpp @@ -13,8 +13,19 @@ class CfgPatches { }; }; -#include "ACE_Settings.hpp" +#include "ACE_Settings.hpp" #include "CfgEventhandlers.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" + + +class RscControlsGroup; +class VScrollbar; +class HScrollbar; +class RscText; +class RscMapControl; +class RscControlsGroupNoScrollbars; +class RscPictureKeepAspect; + #include "RscInGameUI.hpp" +#include "RscTitles.hpp" diff --git a/addons/hellfire/functions/fnc_showHud.sqf b/addons/laser/functions/fnc_showVehicleHud.sqf similarity index 78% rename from addons/hellfire/functions/fnc_showHud.sqf rename to addons/laser/functions/fnc_showVehicleHud.sqf index 380a31b081..b4a5bcb519 100644 --- a/addons/hellfire/functions/fnc_showHud.sqf +++ b/addons/laser/functions/fnc_showVehicleHud.sqf @@ -1,6 +1,6 @@ /* * Author: PabstMirror - * Shows the hellfire hud when vehicle is equiped with the weapon. + * Shows the laser hud when vehicle is equiped with the weapon. * Shows laser code, fire mode and seeker status. * * Arguments: @@ -10,7 +10,7 @@ * Nothing * * Example: - * [player] call ace_hellfire_fnc_showHud + * [player] call ace_laser_fnc_showVehicleHud * * Public: No */ @@ -28,8 +28,8 @@ if ((alive _player) && {_player != _vehicle}) then { _turretPath = _player call CBA_fnc_turretPath }; { - if ((getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(enabled))) == 1) then { - TRACE_1("enabled",_x); + if ((getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(showHud))) == 1) then { + TRACE_1("showHud",_x); _enabled = true; }; } forEach (_vehicle weaponsTurret _turretPath); @@ -46,9 +46,7 @@ GVAR(pfID) = -1; if (!_enabled) exitWith {TRACE_2("Disabled - Now Off",_enabled,GVAR(pfID));}; -TRACE_2("Enabled - Adding actions and PFEH",_enabled,GVAR(pfID)); - -[_vehicle, _turretPath] call FUNC(setupVehicle); +TRACE_2("Enabled - Adding PFEH",_enabled,GVAR(pfID)); private _adjustDown = false; // Flares display will block ours, if present just move ours down a bit { @@ -77,7 +75,7 @@ GVAR(pfID) = [{ }; private _currentWeapon = _vehicle currentWeaponTurret _turretPath; - private _showLockMode = (getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(enabled))) == 1; + private _showLockMode = (getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(showHud))) == 1; private _ctrlGroup = (uiNamespace getVariable [QGVAR(display), displayNull]) displayCtrl 1000; @@ -100,24 +98,13 @@ GVAR(pfID) = [{ private _foundTargetPos = _laserResult select 0; private _haveLock = !isNil "_foundTargetPos"; - private _modeShort = "ERR"; - private _vehicleLockMode = _vehicle getVariable [QEGVAR(missileguidance,attackProfile), ""]; + private _defaultAttackProfile = getText (configFile >> "CfgAmmo" >> _ammo >> "ace_missileguidance" >> "defaultAttackProfile"); + private _vehicleLockMode = _vehicle getVariable [QEGVAR(missileguidance,attackProfile), _defaultAttackProfile]; - switch (_vehicleLockMode) do { // note: missileguidance is case sensitive - case ("hellfire_hi"): { - _modeShort = getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "name"); - }; - case ("hellfire_lo"): { - _modeShort = getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "name"); - }; - default { - _vehicleLockMode = "hellfire"; - _modeShort = if (_haveLock) then { - getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "nameLocked"); - } else { - getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "name"); - }; - }; + _modeShort = if (_haveLock) then { + getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "nameLocked"); + } else { + getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "name"); }; _ctrlIcon ctrlSetTextColor ([[0,0,0,0.25],[1,0,0,0.75]] select _haveLock); diff --git a/addons/laser/script_component.hpp b/addons/laser/script_component.hpp index af562536b6..b0d9951bf3 100644 --- a/addons/laser/script_component.hpp +++ b/addons/laser/script_component.hpp @@ -23,3 +23,8 @@ #define __LaserDesignatorIGUI_ACE_Distance (__LaserDesignatorIGUI displayCtrl 123002) #define __LaserDesignatorIGUI_CA_Distance (__LaserDesignatorIGUI displayCtrl 151) #define __LaserDesignatorIGUI_LaserOn (__LaserDesignatorIGUI displayCtrl 158) + +#define IDC_MODECONTROLGROUP 1000 +#define IDC_ATTACKMODE 1001 +#define IDC_LASERCODE 1002 +#define IDC_LASERICON 1003