2015-11-23 19:52:04 +00:00
|
|
|
/*
|
|
|
|
* Author: Commy2
|
|
|
|
* Switch between laser modes.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Weapon <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-04-13 22:32:09 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-11-23 19:52:04 +00:00
|
|
|
params ["_unit", "_weapon"];
|
2015-04-13 22:32:09 +00:00
|
|
|
|
2015-11-23 19:52:04 +00:00
|
|
|
private _pointer = (_unit weaponAccessories _weapon) select 1;
|
2015-04-13 22:32:09 +00:00
|
|
|
|
|
|
|
if (_pointer == "") exitWith {};
|
|
|
|
|
2015-11-23 19:52:04 +00:00
|
|
|
private _config = configFile >> "CfgWeapons" >> _pointer;
|
2015-05-09 02:59:10 +00:00
|
|
|
|
2015-11-23 19:52:04 +00:00
|
|
|
private _nextPointer = getText (_config >> "ACE_nextModeClass");
|
2015-04-13 22:32:09 +00:00
|
|
|
|
|
|
|
if (_nextPointer == "") exitWith {};
|
|
|
|
|
2015-06-12 05:58:04 +00:00
|
|
|
//If system disabled, don't switch to a laser:
|
2015-11-23 19:52:04 +00:00
|
|
|
private _nextPointerIsLaser = getNumber (configFile >> "CfgWeapons" >> _nextPointer >> "ACE_laserpointer");
|
2015-06-12 05:58:04 +00:00
|
|
|
if ((!GVAR(enabled)) && {_nextPointerIsLaser == 1}) exitWith {};
|
|
|
|
|
2015-05-09 02:59:10 +00:00
|
|
|
// disable inheritance for this entry, because addons claim this as a base class for convenience
|
|
|
|
if !((_config >> "ACE_nextModeClass") in configProperties [_config, "true", false]) exitWith {};
|
|
|
|
|
2015-11-23 19:52:04 +00:00
|
|
|
_unit addWeaponItem [_weapon, _nextPointer];
|
2015-04-13 22:32:09 +00:00
|
|
|
|
2015-11-23 19:52:04 +00:00
|
|
|
private _error = false;
|
2015-04-13 22:32:09 +00:00
|
|
|
|
2015-11-23 19:52:04 +00:00
|
|
|
if ((_unit weaponAccessories _weapon) select 1 != _nextPointer) then {
|
|
|
|
ERROR("NextPointer not compatible");
|
|
|
|
_unit addWeaponItem [_weapon, _pointer];
|
|
|
|
_error = true;
|
2015-04-13 22:32:09 +00:00
|
|
|
};
|
|
|
|
|
2015-05-16 03:23:46 +00:00
|
|
|
if (!_error) then {
|
2015-11-23 19:52:04 +00:00
|
|
|
private _description = getText (configFile >> "CfgWeapons" >> _nextPointer >> "ACE_modeDescription");
|
|
|
|
private _picture = getText (configFile >> "CfgWeapons" >> _nextPointer >> "picture");
|
|
|
|
|
2015-05-16 03:23:46 +00:00
|
|
|
[_description, _picture] call EFUNC(common,displayTextPicture);
|
|
|
|
} else {
|
2015-11-23 19:52:04 +00:00
|
|
|
ACE_LOGERROR_3("Failed to add %1 to %2 - reverting to %3",_nextPointer,_weapon,_pointer);
|
2015-05-16 03:23:46 +00:00
|
|
|
};
|
2015-11-23 19:52:04 +00:00
|
|
|
|
2015-04-13 22:32:09 +00:00
|
|
|
playSound "ACE_Sound_Click";
|