ACE3/addons/laser_selfdesignate/functions/fnc_initDesignatorActions.sqf

58 lines
1.9 KiB
Plaintext
Raw Normal View History

/*
* Author: esteldunedain
* Initializes the actions for turning on/off the laser for vehicles that have them
*
* Argument:
* 0: Vehicle <OBJECT>
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
EXPLODE_1_PVT(_this,_vehicle);
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;
GVAR(initializedClasses) = _initializedClasses;
2015-04-03 16:24:50 +00:00
{
private ["_turretConfig","_onAction","_offAction"];
2015-04-03 16:24:50 +00:00
_turretConfig = [configFile >> "CfgVehicles" >> _type, _x] call EFUNC(common,getTurretConfigPath);
if (getNumber (_turretConfig >> QGVAR(Enabled)) == 1) exitWith {
// @todo: Add the state variables to the vehicle, instead of to the client
// e.g.: _vehicle setVariable [format ["%1_%2", QGVAR(laserActive), _x], false];
// Add actions
_onAction = [QGVAR(LaserOn), localize "STR_ACE_Laser_SelfDesignate_DesignatorOn", "",
{
// Statement
_this call FUNC(laserHudDesignateOn)
},
{
// Condition
!GVAR(laserActive) && {[ACE_player] call FUNC(unitTurretHasDesignator)}
}] call EFUNC(interact_menu,createAction);
_offAction = [QGVAR(LaserOff), localize "STR_ACE_Laser_SelfDesignate_DesignatorOff", "",
{
// Statement
_this call FUNC(laserHudDesignateOff)
},
{
// Condition
GVAR(laserActive) && {[ACE_player] call FUNC(unitTurretHasDesignator)}
}] 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);
};
} forEach allTurrets _vehicle;