2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-10-08 10:55:30 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Change the laser key code (both seeker and transmitter)
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Change in code <NUMBER>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2016-10-08 10:55:30 +00:00
|
|
|
* Key Handled <BOOL>
|
|
|
|
|
|
|
|
* Example:
|
|
|
|
* [1] call ace_laser_fnc_keyLaserCodeChange;
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params [["_codeChange", 0, [0]]];
|
|
|
|
|
|
|
|
TRACE_1("params",_codeChange);
|
|
|
|
|
|
|
|
if ((!alive ACE_player) || {!([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith))}) exitWith {false};
|
|
|
|
|
|
|
|
private _currentShooter = objNull;
|
|
|
|
private _currentWeapon = "";
|
|
|
|
|
2017-08-22 21:07:45 +00:00
|
|
|
if (isNull (ACE_controlledUAV param [0, objNull])) then {
|
|
|
|
if (ACE_player call CBA_fnc_canUseWeapon) then {
|
|
|
|
_currentShooter = ACE_player;
|
|
|
|
_currentWeapon = currentWeapon ACE_player;
|
|
|
|
} else {
|
|
|
|
_currentShooter = vehicle ACE_player;
|
|
|
|
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
|
|
|
|
_currentWeapon = _currentShooter currentWeaponTurret _turretPath;
|
|
|
|
};
|
2016-10-08 10:55:30 +00:00
|
|
|
} else {
|
2017-08-22 21:07:45 +00:00
|
|
|
_currentShooter = ACE_controlledUAV select 0;
|
|
|
|
private _turretPath = ACE_controlledUAV select 2;
|
2017-06-02 21:51:38 +00:00
|
|
|
_currentWeapon = _currentShooter currentWeaponTurret _turretPath;
|
2016-10-08 10:55:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TRACE_2("",_currentShooter,_currentWeapon);
|
2023-07-28 04:03:02 +00:00
|
|
|
private _currentWeaponCfg = configFile >> "CfgWeapons" >> _currentWeapon;
|
|
|
|
if (
|
|
|
|
(getNumber (_currentWeaponCfg >> "laser") == 0) &&
|
|
|
|
{
|
|
|
|
!(_currentShooter getVariable [QGVAR(hasLaserSpotTracker), false]) &&
|
|
|
|
{(getNumber (_currentWeaponCfg >> QGVAR(canSelect))) == 0}
|
|
|
|
}
|
|
|
|
) exitWith {false};
|
2016-10-08 10:55:30 +00:00
|
|
|
|
|
|
|
private _oldLaserCode = _currentShooter getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE];
|
2023-10-02 17:29:38 +00:00
|
|
|
private _newLaserCode = 0;
|
2016-10-08 10:55:30 +00:00
|
|
|
|
|
|
|
// "Four-digit code equipment settings range from 1111 to 1788"
|
|
|
|
// While there is a 0 or 9 in code, keep adding change
|
|
|
|
|
2023-10-02 17:29:38 +00:00
|
|
|
_codeChange = floor((_codeChange max 0) min 2);
|
|
|
|
private _placeValue = 10 ^ _codeChange;
|
|
|
|
|
|
|
|
private _oldDigit = (floor(_oldLaserCode / _placeValue)) % 10;
|
|
|
|
private _newDigit = _oldDigit + 1;
|
|
|
|
private _limit = 8;
|
|
|
|
if (_codeChange == 2) then {_limit = 7};
|
|
|
|
|
|
|
|
if (_newDigit > _limit) then {_newDigit = 1};
|
|
|
|
|
|
|
|
for "_i" from 0 to 3 step 1 do {
|
|
|
|
private _digit = floor(_oldLaserCode / (10 ^ _i)) mod 10;
|
|
|
|
if (_i == _codeChange) then {
|
|
|
|
_digit = _newDigit;
|
2016-10-08 10:55:30 +00:00
|
|
|
};
|
2023-10-02 17:29:38 +00:00
|
|
|
_newLaserCode = _newLaserCode + (_digit * 10 ^ _i);
|
2016-10-08 10:55:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TRACE_2("",_oldLaserCode,_newLaserCode);
|
|
|
|
|
|
|
|
if (_oldLaserCode != _newLaserCode) then {
|
2017-06-02 21:51:38 +00:00
|
|
|
_currentShooter setVariable [QGVAR(code), _newLaserCode, true];
|
2016-10-08 10:55:30 +00:00
|
|
|
};
|
|
|
|
[format ["%1: %2", localize LSTRING(laserCode), _newLaserCode]] call EFUNC(common,displayTextStructured);
|
|
|
|
|
|
|
|
true
|