mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
115 lines
5.0 KiB
Plaintext
115 lines
5.0 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: PabstMirror
|
|
* Shows the laser hud when vehicle is equiped with the weapon.
|
|
* Shows laser code, fire mode and seeker status.
|
|
*
|
|
* Arguments:
|
|
* 0: Player <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* Nothing
|
|
*
|
|
* Example:
|
|
* [player] call ace_laser_fnc_showVehicleHud
|
|
*
|
|
* 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
|
|
};
|
|
{
|
|
if ((getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(showHud))) == 1) then {
|
|
TRACE_1("showHud",_x);
|
|
_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));};
|
|
|
|
TRACE_2("Enabled - Adding PFEH",_enabled,GVAR(pfID));
|
|
|
|
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;
|
|
private _showLockMode = (getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(showHud))) == 1;
|
|
|
|
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:
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _vehicle currentMagazineTurret _turretPath >> "ammo");
|
|
private _laserSource = AGLtoASL (_vehicle modelToWorld (_vehicle selectionPosition _seekerSource));
|
|
private _laserCode = _vehicle getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE];
|
|
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);
|
|
private _foundTargetPos = _laserResult select 0;
|
|
private _haveLock = !isNil "_foundTargetPos";
|
|
|
|
private _defaultAttackProfile = getText (configFile >> "CfgAmmo" >> _ammo >> "ace_missileguidance" >> "defaultAttackProfile");
|
|
private _vehicleLockMode = _vehicle getVariable [QEGVAR(missileguidance,attackProfile), _defaultAttackProfile];
|
|
|
|
_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;
|
|
_ctrlCode ctrlSetText format ["CODE: %1", _laserCode];
|
|
|
|
}, 0.1, [_vehicle, _turretPath, _seekerSource, _adjustDown]] call CBA_fnc_addPerFrameHandler;
|