Move the hellfire hud to the laser module (#5503)

* Move the hellfire hud to the laser module

* Fix example
This commit is contained in:
PabstMirror 2017-09-16 14:24:43 -05:00 committed by GitHub
parent ca580daedd
commit 1a1fdb7c2c
14 changed files with 82 additions and 57 deletions

View File

@ -1,6 +1,5 @@
class EGVAR(missileguidance,AttackProfiles) {
class hellfire {
// LOBL and LOAL-DIR behaive the same
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
};
};

View File

@ -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"};

View File

@ -2,4 +2,3 @@ LOG("prep");
PREP(attackProfile);
PREP(getAttackProfileSettings);
PREP(setupVehicle);
PREP(showHud);

View File

@ -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;

View File

@ -20,4 +20,3 @@ class CfgPatches {
#include "CfgMagazines.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "RscTitles.hpp"

View File

@ -4,22 +4,42 @@
* Also adds a Laser Designator if vehicle is configured for one.
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Player's Turret Path <ARRAY>
* 0: Player <OBJECT>
*
* 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)
};

View File

@ -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

View File

@ -1,9 +1,3 @@
class RscControlsGroup;
class VScrollbar;
class HScrollbar;
class RscText;
class RscMapControl;
class RscInGameUI {
class RscOptics_LaserDesignator {
idd = 300;

View File

@ -1,7 +1,3 @@
class RscControlsGroupNoScrollbars;
class RscPictureKeepAspect;
class RscText;
class RscTitles {
class GVAR(modeDisplay) {
idd = -1;

View File

@ -13,3 +13,4 @@ PREP(rotateVectLineGetMap);
PREP(seekerFindLaserSpot);
PREP(shootCone);
PREP(shootRay);
PREP(showVehicleHud);

View File

@ -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"];

View File

@ -17,4 +17,15 @@ class CfgPatches {
#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"

View File

@ -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,25 +98,14 @@ 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");
};
};
};
_ctrlIcon ctrlSetTextColor ([[0,0,0,0.25],[1,0,0,0.75]] select _haveLock);
_ctrlText ctrlSetText _modeShort;

View File

@ -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