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
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
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);
|
2017-06-02 21:51:38 +00:00
|
|
|
if (((getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> "laser")) == 0) &&
|
|
|
|
{(getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(canSelect))) == 0}) exitWith {false};
|
2016-10-08 10:55:30 +00:00
|
|
|
|
|
|
|
private _oldLaserCode = _currentShooter getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE];
|
|
|
|
private _newLaserCode = _oldLaserCode;
|
|
|
|
|
|
|
|
// "Four-digit code equipment settings range from 1111 to 1788"
|
|
|
|
// While there is a 0 or 9 in code, keep adding change
|
|
|
|
|
|
|
|
if (((_codeChange < 0) && {_oldLaserCode > ACE_DEFAULT_LASER_CODE}) || {(_codeChange > 0) && {_oldLaserCode < 1788}}) then {
|
|
|
|
_newLaserCode = _oldLaserCode + _codeChange;
|
|
|
|
while {(((str _newLaserCode) find "0") >= 0) || {((str _newLaserCode) find "9") >= 0}} do {
|
|
|
|
_newLaserCode = _newLaserCode + _codeChange;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|