ACE3/addons/tripod/functions/fnc_adjust.sqf

48 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-06-04 19:13:44 +00:00
/*
* Author: Ruthberg
* Adjust tripod height
*
* Arguments:
* 0: tripod <OBJECT>
*
* Return value:
* None
2015-08-07 06:07:10 +00:00
*
* Example:
* [ACE_player, tripod] call ace_tripod_fnc_adjust
2015-08-07 06:07:10 +00:00
*
* Public: No
2015-06-04 19:13:44 +00:00
*/
#include "script_component.hpp"
params ["_unit", "_tripod"];
2015-06-04 19:13:44 +00:00
_unit setVariable [QGVAR(adjusting), true, true];
2015-06-04 19:13:44 +00:00
// add PFH to adjust the tripod animation
2015-06-04 19:13:44 +00:00
GVAR(adjustPFH) = [{
(_this select 0) params ["_unit", "_tripod"];
2015-08-07 06:07:10 +00:00
if (!(_unit getVariable [QGVAR(adjusting), false]) || {isNull _tripod} || {_unit distance _tripod > 5}) exitWith {
2015-06-04 19:13:44 +00:00
call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", _unit getVariable [QGVAR(Adjust), -1]] call EFUNC(common,removeActionEventHandler);
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-06-04 19:13:44 +00:00
};
2015-08-07 06:07:10 +00:00
2015-06-04 19:13:44 +00:00
{
_tripod animate [_x, 1 - GVAR(height)];
2015-08-07 06:07:10 +00:00
} count ["slide_down_tripod", "retract_leg_1", "retract_leg_2", "retract_leg_3"];
}, 0, [_unit, _tripod]] call CBA_fnc_addPerFrameHandler;
2015-06-04 19:13:44 +00:00
// add mouse button action and hint
2015-06-04 19:13:44 +00:00
[localize "STR_ACE_Tripod_Done", "", localize "STR_ACE_Tripod_ScrollAction"] call EFUNC(interaction,showMouseHint);
_unit setVariable [QGVAR(Adjust), [
_unit, "DefaultAction",
{GVAR(adjustPFH) != -1},
{(_this select 0) setVariable [QGVAR(adjusting), false, true]}
] call EFUNC(common,addActionEventHandler)];