From ef01660ab3c57d07fe020d8a4f5ca23d922887e2 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Fri, 7 Aug 2015 08:07:10 +0200 Subject: [PATCH] Code cleanup in Tripod module --- addons/tripod/functions/fnc_adjust.sqf | 24 +++++++------- .../functions/fnc_handleScrollWheel.sqf | 4 +-- addons/tripod/functions/fnc_pickup.sqf | 14 ++++----- addons/tripod/functions/fnc_place.sqf | 31 ++++++++++--------- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/addons/tripod/functions/fnc_adjust.sqf b/addons/tripod/functions/fnc_adjust.sqf index ce50d38cf0..1ba99cedbe 100644 --- a/addons/tripod/functions/fnc_adjust.sqf +++ b/addons/tripod/functions/fnc_adjust.sqf @@ -1,37 +1,39 @@ /* * Author: Ruthberg - * * Adjust tripod height * * Arguments: * 0: tripod * - * Return Value: - * Nothing - * * Return value: * None + * + * Example: + * [tripod] call ace_tripod_fnc_adjust + * + * Public: No */ #include "script_component.hpp" -PARAMS_1(_tripod); +params ["_tripod"]; GVAR(adjuster) = ACE_player; GVAR(adjusting) = true; GVAR(adjustPFH) = [{ - EXPLODE_1_PVT(_this select 0,_tripod); - + params ["_args", "_pfhId"]; + _args params ["_tripod"]; + if (GVAR(adjuster) != ACE_player || !GVAR(adjusting)) exitWith { call EFUNC(interaction,hideMouseHint); [ACE_player, "DefaultAction", ACE_player getVariable [QGVAR(Adjust), -1]] call EFUNC(Common,removeActionEventHandler); - [_this select 1] call cba_fnc_removePerFrameHandler; + [_pfhId] call cba_fnc_removePerFrameHandler; }; - + { _tripod animate [_x, 1 - GVAR(height)]; - } foreach ["slide_down_tripod", "retract_leg_1", "retract_leg_2", "retract_leg_3"]; - + } count ["slide_down_tripod", "retract_leg_1", "retract_leg_2", "retract_leg_3"]; + }, 0, [_tripod]] call CBA_fnc_addPerFrameHandler; [localize "STR_ACE_Tripod_Done", "", localize "STR_ACE_Tripod_ScrollAction"] call EFUNC(interaction,showMouseHint); diff --git a/addons/tripod/functions/fnc_handleScrollWheel.sqf b/addons/tripod/functions/fnc_handleScrollWheel.sqf index 7399bf0c2c..973a57dd2f 100644 --- a/addons/tripod/functions/fnc_handleScrollWheel.sqf +++ b/addons/tripod/functions/fnc_handleScrollWheel.sqf @@ -9,13 +9,13 @@ * handled * * Example: - * 1.2 call ace_tripod_fnc_handleScrollWheel; + * [1.2] call ace_tripod_fnc_handleScrollWheel; * * Public: No */ #include "script_component.hpp" -PARAMS_1(_scroll); +params ["_scroll"]; if (GETMVAR(ACE_Modifier,0) == 0 || GVAR(adjustPFH) == -1) exitWith { false }; diff --git a/addons/tripod/functions/fnc_pickup.sqf b/addons/tripod/functions/fnc_pickup.sqf index f264eb1e2e..24fc26ea1d 100644 --- a/addons/tripod/functions/fnc_pickup.sqf +++ b/addons/tripod/functions/fnc_pickup.sqf @@ -1,30 +1,30 @@ /* * Author: Rocko, Ruthberg - * * Pick up tripod * * Arguments: * 0: tripod * 1: unit * - * Return Value: - * Nothing - * * Return value: * None + * + * Example: + * [tripod, player] call ace_tripod_fnc_pickup + * + * Public: No */ #include "script_component.hpp" -PARAMS_2(_tripod,_unit); +params ["_tripod", "_unit"]; if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then { _unit playMove "AmovPercMstpSrasWrflDnon_diary"; }; [{ - PARAMS_2(_tripod,_unit); + params ["_tripod", "_unit"]; [_unit, "ACE_Tripod"] call EFUNC(common,addToInventory); deleteVehicle _tripod; - }, [_tripod, _unit], 1, 0]call EFUNC(common,waitAndExecute); diff --git a/addons/tripod/functions/fnc_place.sqf b/addons/tripod/functions/fnc_place.sqf index 5e9c783589..ce7f445885 100644 --- a/addons/tripod/functions/fnc_place.sqf +++ b/addons/tripod/functions/fnc_place.sqf @@ -1,21 +1,22 @@ /* * Author: Rocko, Ruthberg - * * Place down tripod * * Arguments: * 0: unit * 1: tripod class * - * Return Value: - * Nothing - * * Return value: * None + * + * Example: + * [player, "ACE_Tripod"] call ace_tripod_fnc_place + * + * Public: No */ #include "script_component.hpp" -PARAMS_2(_unit,_tripodClass); +params ["_unit", "_tripodClass"]; _unit removeItem _tripodClass; @@ -24,27 +25,29 @@ if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then { }; [{ - PARAMS_1(_unit); - + params ["_unit"]; + private ["_direction", "_position", "_tripod"]; _direction = getDir _unit; _position = (getPosASL _unit) vectorAdd [0.8 * sin(_direction), 0.8 * cos(_direction), 0.02]; - + _tripod = "ACE_TripodObject" createVehicle [0, 0, 0]; { _tripod animate [_x, 1]; - } foreach ["slide_down_tripod", "retract_leg_1", "retract_leg_2", "retract_leg_3"]; - + } count ["slide_down_tripod", "retract_leg_1", "retract_leg_2", "retract_leg_3"]; + [{ - EXPLODE_3_PVT(_this select 0,_tripod,_direction,_position); + params ["_args", "_pfhId"]; + _args params ["_tripod", "_direction", "_position"]; + if (_tripod animationPhase "slide_down_tripod" == 1) then { _tripod setDir _direction; _tripod setPosASL _position; if ((getPosATL _tripod select 2) - (getPos _tripod select 2) < 1E-5) then { - _tripod setVectorUp (surfaceNormal (position _tripod)); + _tripod setVectorUp (surfaceNormal (position _tripod)); }; - [_this select 1] call CBA_fnc_removePerFrameHandler; + [_pfhId] call CBA_fnc_removePerFrameHandler; }; }, 0, [_tripod, _direction, _position]] call CBA_fnc_addPerFrameHandler; - + }, [_unit], 1, 0] call EFUNC(common,waitAndExecute);