2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2017-06-02 21:51:38 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
2017-09-16 19:24:43 +00:00
|
|
|
* Shows the laser hud when vehicle is equiped with the weapon.
|
2017-06-02 21:51:38 +00:00
|
|
|
* Shows laser code, fire mode and seeker status.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Player <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Example:
|
2017-09-16 19:24:43 +00:00
|
|
|
* [player] call ace_laser_fnc_showVehicleHud
|
2017-06-02 21:51:38 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_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
|
|
|
|
};
|
|
|
|
{
|
2017-09-16 19:24:43 +00:00
|
|
|
if ((getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(showHud))) == 1) then {
|
|
|
|
TRACE_1("showHud",_x);
|
2017-06-02 21:51:38 +00:00
|
|
|
_enabled = true;
|
|
|
|
};
|
|
|
|
} forEach (_vehicle weaponsTurret _turretPath);
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((!_enabled) && (GVAR(pfID) < 0)) exitWith {TRACE_2("Disabled - No Change",_enabled,GVAR(pfID));};
|
|
|
|
|
|
|
|
TRACE_2("Cleaning up old pfeh and display",_enabled,GVAR(pfID));
|
|
|
|
[GVAR(pfID)] call CBA_fnc_removePerFrameHandler;
|
|
|
|
if (!isNull (uiNamespace getVariable [QGVAR(display), displayNull])) then {
|
|
|
|
([QGVAR(modeDisplay)] call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
|
|
|
|
};
|
|
|
|
GVAR(pfID) = -1;
|
|
|
|
|
|
|
|
if (!_enabled) exitWith {TRACE_2("Disabled - Now Off",_enabled,GVAR(pfID));};
|
|
|
|
|
2017-09-16 19:24:43 +00:00
|
|
|
TRACE_2("Enabled - Adding PFEH",_enabled,GVAR(pfID));
|
2017-06-02 21:51:38 +00:00
|
|
|
|
|
|
|
private _adjustDown = false; // Flares display will block ours, if present just move ours down a bit
|
|
|
|
{
|
|
|
|
if ((getText (configFile >> "CfgWeapons" >> _x >> "simulation")) == "cmlauncher") exitWith {_adjustDown = true};
|
|
|
|
} forEach (_vehicle weaponsTurret _turretPath);
|
|
|
|
|
|
|
|
private _turretConfig = [_vehicle, _turretPath] call CBA_fnc_getTurret;
|
|
|
|
private _seekerSource = getText (_turretConfig >> "memoryPointGunnerOptics");
|
|
|
|
TRACE_3("",_adjustDown,_seekerSource,_vehicle selectionPosition _seekerSource);
|
|
|
|
|
|
|
|
GVAR(pfID) = [{
|
|
|
|
params ["_args", "_pfID"];
|
|
|
|
_args params ["_vehicle", "_turretPath", "_seekerSource", "_adjustDown"];
|
|
|
|
|
|
|
|
// Restart display if null (not just at start, this will happen periodicly)
|
|
|
|
if (isNull (uiNamespace getVariable [QGVAR(display), displayNull])) then {
|
|
|
|
TRACE_1("creating display",_this);
|
|
|
|
([QGVAR(modeDisplay)] call BIS_fnc_rscLayer) cutRsc [QGVAR(modeDisplay), "PLAIN", 1, false];
|
|
|
|
if (_adjustDown) then {
|
|
|
|
private _ctrl = (uiNamespace getVariable [QGVAR(display), displayNull]) displayCtrl IDC_MODECONTROLGROUP;
|
|
|
|
private _pos = ctrlPosition _ctrl;
|
|
|
|
_pos set [1, (_pos select 1) + ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)];
|
|
|
|
_ctrl ctrlSetPosition _pos;
|
|
|
|
_ctrl ctrlCommit 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
private _currentWeapon = _vehicle currentWeaponTurret _turretPath;
|
2017-09-16 19:24:43 +00:00
|
|
|
private _showLockMode = (getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(showHud))) == 1;
|
2017-06-02 21:51:38 +00:00
|
|
|
|
|
|
|
private _ctrlGroup = (uiNamespace getVariable [QGVAR(display), displayNull]) displayCtrl 1000;
|
|
|
|
|
|
|
|
if (!_showLockMode) exitWith {
|
|
|
|
_ctrlGroup ctrlShow false;
|
|
|
|
};
|
|
|
|
_ctrlGroup ctrlShow true;
|
|
|
|
|
|
|
|
private _ctrlText = (uiNamespace getVariable [QGVAR(display), displayNull]) displayCtrl IDC_ATTACKMODE;
|
|
|
|
private _ctrlCode = (uiNamespace getVariable [QGVAR(display), displayNull]) displayCtrl IDC_LASERCODE;
|
|
|
|
private _ctrlIcon = (uiNamespace getVariable [QGVAR(display), displayNull]) displayCtrl IDC_LASERICON;
|
|
|
|
|
|
|
|
// Do Laser Scan:
|
2017-08-03 17:50:29 +00:00
|
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _vehicle currentMagazineTurret _turretPath >> "ammo");
|
2017-06-02 21:51:38 +00:00
|
|
|
private _laserSource = AGLtoASL (_vehicle modelToWorld (_vehicle selectionPosition _seekerSource));
|
|
|
|
private _laserCode = _vehicle getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE];
|
2017-08-03 17:50:29 +00:00
|
|
|
private _seekerAngle = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_missileguidance" >> "seekerAngle");
|
|
|
|
private _seekerMaxRange = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_missileguidance" >> "seekerMaxRange");
|
|
|
|
private _laserResult = [_laserSource, vectorDir _vehicle, _seekerAngle, _seekerMaxRange, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], _laserCode, _vehicle] call EFUNC(laser,seekerFindLaserSpot);
|
2017-06-02 21:51:38 +00:00
|
|
|
private _foundTargetPos = _laserResult select 0;
|
|
|
|
private _haveLock = !isNil "_foundTargetPos";
|
|
|
|
|
2017-09-16 19:24:43 +00:00
|
|
|
private _defaultAttackProfile = getText (configFile >> "CfgAmmo" >> _ammo >> "ace_missileguidance" >> "defaultAttackProfile");
|
|
|
|
private _vehicleLockMode = _vehicle getVariable [QEGVAR(missileguidance,attackProfile), _defaultAttackProfile];
|
2017-06-02 21:51:38 +00:00
|
|
|
|
2017-09-16 19:24:43 +00:00
|
|
|
_modeShort = if (_haveLock) then {
|
|
|
|
getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "nameLocked");
|
|
|
|
} else {
|
|
|
|
getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _vehicleLockMode >> "name");
|
2017-06-02 21:51:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_ctrlIcon ctrlSetTextColor ([[0,0,0,0.25],[1,0,0,0.75]] select _haveLock);
|
|
|
|
_ctrlText ctrlSetText _modeShort;
|
|
|
|
_ctrlCode ctrlSetText format ["CODE: %1", _laserCode];
|
|
|
|
|
|
|
|
}, 0.1, [_vehicle, _turretPath, _seekerSource, _adjustDown]] call CBA_fnc_addPerFrameHandler;
|