2015-04-03 15:43:41 +00:00
|
|
|
/*
|
|
|
|
* Author: esteldunedain
|
|
|
|
* Initializes the actions for turning on/off the laser for vehicles that have them
|
|
|
|
*
|
2015-08-15 21:53:04 +00:00
|
|
|
* Arguments:
|
2015-04-03 15:43:41 +00:00
|
|
|
* 0: Vehicle <OBJECT>
|
|
|
|
*
|
2015-08-15 21:53:04 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-04-03 15:43:41 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-15 21:53:04 +00:00
|
|
|
params ["_vehicle"];
|
2015-04-03 15:43:41 +00:00
|
|
|
|
2015-04-03 16:24:50 +00:00
|
|
|
// Add action to class if it is not already done
|
|
|
|
private ["_type", "_initializedClasses"];
|
|
|
|
_type = typeOf _vehicle;
|
|
|
|
_initializedClasses = GETGVAR(initializedClasses,[]);
|
|
|
|
|
|
|
|
// do nothing if the class is already initialized
|
|
|
|
if (_type in _initializedClasses) exitWith {};
|
|
|
|
_initializedClasses pushBack _type;
|
2015-04-06 12:06:56 +00:00
|
|
|
GVAR(initializedClasses) = _initializedClasses;
|
2015-04-03 16:24:50 +00:00
|
|
|
|
2015-04-03 15:43:41 +00:00
|
|
|
{
|
|
|
|
private ["_turretConfig","_onAction","_offAction"];
|
2015-04-03 16:24:50 +00:00
|
|
|
_turretConfig = [configFile >> "CfgVehicles" >> _type, _x] call EFUNC(common,getTurretConfigPath);
|
2015-04-03 15:43:41 +00:00
|
|
|
|
|
|
|
if (getNumber (_turretConfig >> QGVAR(Enabled)) == 1) exitWith {
|
|
|
|
// @todo: Add the state variables to the vehicle, instead of to the client
|
2015-04-07 19:11:28 +00:00
|
|
|
// e.g.: _vehicle setVariable [format ["%1_%2", QGVAR(active), _x], false];
|
2015-04-03 15:43:41 +00:00
|
|
|
|
|
|
|
// Add actions
|
2015-05-28 19:59:04 +00:00
|
|
|
_onAction = [QGVAR(LaserOn), localize LSTRING(DesignatorOn), "",
|
2015-04-03 15:43:41 +00:00
|
|
|
{
|
|
|
|
// Statement
|
|
|
|
_this call FUNC(laserHudDesignateOn)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Condition
|
2015-04-07 19:11:28 +00:00
|
|
|
!GVAR(active) && {[ACE_player] call FUNC(unitTurretHasDesignator)}
|
2015-04-03 15:43:41 +00:00
|
|
|
}] call EFUNC(interact_menu,createAction);
|
|
|
|
|
2015-05-28 19:59:04 +00:00
|
|
|
_offAction = [QGVAR(LaserOff), localize LSTRING(DesignatorOff), "",
|
2015-04-03 15:43:41 +00:00
|
|
|
{
|
|
|
|
// Statement
|
|
|
|
_this call FUNC(laserHudDesignateOff)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Condition
|
2015-04-07 19:11:28 +00:00
|
|
|
GVAR(active) && {[ACE_player] call FUNC(unitTurretHasDesignator)}
|
2015-04-03 15:43:41 +00:00
|
|
|
}] call EFUNC(interact_menu,createAction);
|
|
|
|
|
2015-04-03 16:24:50 +00:00
|
|
|
[_type, 1, ["ACE_SelfActions"], _onAction] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
[_type, 1, ["ACE_SelfActions"], _offAction] call EFUNC(interact_menu,addActionToClass);
|
2015-04-03 15:43:41 +00:00
|
|
|
};
|
|
|
|
} forEach allTurrets _vehicle;
|