2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-04-05 06:57:24 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
2024-07-20 06:13:42 +00:00
|
|
|
* Handles player getting into new vehicle. Loads PFEG for mortar display if it is a mortar.
|
2015-04-05 06:57:24 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2016-02-14 12:51:44 +00:00
|
|
|
* 0: Player <OBJECT>
|
2015-04-05 22:50:07 +00:00
|
|
|
* 1: New Vehicle <OBJECT>
|
2015-04-05 06:57:24 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-04-05 06:57:24 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-07-20 06:13:42 +00:00
|
|
|
* [player, cursorObject] call ace_mk6mortar_fnc_handlePlayerVehicleChanged
|
2015-04-05 06:57:24 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2016-03-14 13:21:02 +00:00
|
|
|
params ["_player", "_newVehicle"];
|
2015-07-08 06:00:43 +00:00
|
|
|
|
2015-04-05 06:57:24 +00:00
|
|
|
if (isNull _newVehicle) exitWith {};
|
2024-06-18 14:08:03 +00:00
|
|
|
if !(_newVehicle isKindOf "Mortar_01_base_F") exitWith {};
|
2015-04-05 06:57:24 +00:00
|
|
|
|
2016-03-14 13:21:02 +00:00
|
|
|
private _tubeWeaponName = (weapons _newVehicle) select 0;
|
|
|
|
private _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes");
|
2015-04-05 19:34:39 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Restore last firemode
|
|
|
|
private _lastSavedWeaponsInfo = _newVehicle getVariable QGVAR(lastFireMode);
|
|
|
|
|
|
|
|
if (!isNil "_lastSavedWeaponsInfo") then {
|
|
|
|
_newVehicle selectWeaponTurret [_lastSavedWeaponsInfo select 0, [0], _lastSavedWeaponsInfo select 1, _lastSavedWeaponsInfo select 2];
|
2015-07-14 00:09:55 +00:00
|
|
|
};
|
|
|
|
|
2015-04-05 06:57:24 +00:00
|
|
|
[{
|
2024-07-20 06:13:42 +00:00
|
|
|
params ["_mortarVeh", "_pfhID"];
|
2015-04-05 06:57:24 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
if ((vehicle ACE_player) != _mortarVeh) exitWith {
|
|
|
|
_pfhID call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|
2015-04-05 19:34:39 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Save firemode ('charge' from weaponstate) on vehicle
|
|
|
|
_mortarVeh setVariable [QGVAR(lastFireMode), (weaponState [_mortarVeh, [0]]) select [0, 3]];
|
2015-04-05 22:50:07 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
if (shownArtilleryComputer && {!GVAR(allowComputerRangefinder)}) then {
|
|
|
|
// Don't like this solution, but it works
|
|
|
|
closeDialog 0;
|
|
|
|
[parseText "Computer Disabled"] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|
2015-04-05 19:34:39 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
private _display = uiNamespace getVariable ["ACE_Mk6_RscWeaponRangeArtillery", displayNull];
|
2016-02-14 12:51:44 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
if (isNull _display) exitWith {}; // It may be null for the first frame
|
2015-04-05 19:34:39 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Hud should hidden in 3rd person
|
|
|
|
private _notGunnerView = cameraView != "GUNNER";
|
|
|
|
private _useMils = _mortarVeh getVariable [QGVAR(useMils), true];
|
2015-04-06 06:05:28 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Get aiming values from ace_artillerytables
|
|
|
|
// Note: it also handles displaying the "charge" level
|
|
|
|
private _realAzimuth = missionNamespace getVariable [QEGVAR(artillerytables,predictedAzimuth), -1];
|
|
|
|
private _realElevation = missionNamespace getVariable [QEGVAR(artillerytables,predictedElevation), -1];
|
2015-04-05 06:57:24 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Update Heading Display
|
|
|
|
if (_notGunnerView || !GVAR(allowCompass)) then {
|
|
|
|
(_display displayCtrl 80156) ctrlSetText "";
|
|
|
|
} else {
|
|
|
|
if (_useMils) then {
|
|
|
|
(_display displayCtrl 80156) ctrlSetText str (((round (_realAzimuth * 6400 / 360)) + 6400) % 6400);
|
2015-06-14 05:52:30 +00:00
|
|
|
} else {
|
2024-07-20 06:13:42 +00:00
|
|
|
(_display displayCtrl 80156) ctrlSetText str ((round (_realAzimuth + 360)) % 360);
|
2015-06-14 05:52:30 +00:00
|
|
|
};
|
2024-07-20 06:13:42 +00:00
|
|
|
};
|
2015-06-14 05:52:30 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Update CurrentElevation Display
|
|
|
|
if (_notGunnerView) then {
|
|
|
|
(_display displayCtrl 80175) ctrlSetText "";
|
|
|
|
} else {
|
|
|
|
if (_useMils) then {
|
|
|
|
(_display displayCtrl 80175) ctrlSetText str ((round (_realElevation * 6400 / 360)) % 6400);
|
2015-04-05 06:57:24 +00:00
|
|
|
} else {
|
2024-07-20 06:13:42 +00:00
|
|
|
(_display displayCtrl 80175) ctrlSetText str (((round (_realElevation * 100)) / 100) % 360);
|
2015-04-05 06:57:24 +00:00
|
|
|
};
|
2024-07-20 06:13:42 +00:00
|
|
|
};
|
2015-04-05 06:57:24 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Update ElevationNeeded Display
|
|
|
|
if (_notGunnerView || !GVAR(allowComputerRangefinder)) then {
|
|
|
|
(_display displayCtrl 80176) ctrlSetText "";
|
|
|
|
} else {
|
|
|
|
private _elevDeg = parseNumber ctrlText (_display displayCtrl 176);
|
|
|
|
if (_elevDeg <= 0) then { // Bad data means "----" out of range
|
|
|
|
(_display displayCtrl 80176) ctrlSetText (ctrlText (_display displayCtrl 176));
|
2015-04-05 06:57:24 +00:00
|
|
|
} else {
|
2024-07-20 06:13:42 +00:00
|
|
|
_elevDeg = _elevDeg + (_realElevation - (parseNumber ctrlText (_display displayCtrl 175)));
|
|
|
|
if (_useMils) then {
|
|
|
|
(_display displayCtrl 80176) ctrlSetText str round ((round (_elevDeg * 6400 / 360)) % 6400);
|
2015-04-05 06:57:24 +00:00
|
|
|
} else {
|
2024-07-20 06:13:42 +00:00
|
|
|
(_display displayCtrl 80176) ctrlSetText str (((round (_elevDeg * 100)) / 100) % 360);
|
2015-04-05 06:57:24 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-07-20 06:13:42 +00:00
|
|
|
}, 0, _newVehicle] call CBA_fnc_addPerFrameHandler;
|