Code cleanup in Tripod module

This commit is contained in:
Michael Braun 2015-08-07 08:07:10 +02:00
parent 016f45f0e8
commit ef01660ab3
4 changed files with 39 additions and 34 deletions

View File

@ -1,36 +1,38 @@
/* /*
* Author: Ruthberg * Author: Ruthberg
*
* Adjust tripod height * Adjust tripod height
* *
* Arguments: * Arguments:
* 0: tripod <OBJECT> * 0: tripod <OBJECT>
* *
* Return Value:
* Nothing
*
* Return value: * Return value:
* None * None
*
* Example:
* [tripod] call ace_tripod_fnc_adjust
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_tripod); params ["_tripod"];
GVAR(adjuster) = ACE_player; GVAR(adjuster) = ACE_player;
GVAR(adjusting) = true; GVAR(adjusting) = true;
GVAR(adjustPFH) = [{ GVAR(adjustPFH) = [{
EXPLODE_1_PVT(_this select 0,_tripod); params ["_args", "_pfhId"];
_args params ["_tripod"];
if (GVAR(adjuster) != ACE_player || !GVAR(adjusting)) exitWith { if (GVAR(adjuster) != ACE_player || !GVAR(adjusting)) exitWith {
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
[ACE_player, "DefaultAction", ACE_player getVariable [QGVAR(Adjust), -1]] call EFUNC(Common,removeActionEventHandler); [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)]; _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; }, 0, [_tripod]] call CBA_fnc_addPerFrameHandler;

View File

@ -9,13 +9,13 @@
* handled <BOOL> * handled <BOOL>
* *
* Example: * Example:
* 1.2 call ace_tripod_fnc_handleScrollWheel; * [1.2] call ace_tripod_fnc_handleScrollWheel;
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_scroll); params ["_scroll"];
if (GETMVAR(ACE_Modifier,0) == 0 || GVAR(adjustPFH) == -1) exitWith { false }; if (GETMVAR(ACE_Modifier,0) == 0 || GVAR(adjustPFH) == -1) exitWith { false };

View File

@ -1,30 +1,30 @@
/* /*
* Author: Rocko, Ruthberg * Author: Rocko, Ruthberg
*
* Pick up tripod * Pick up tripod
* *
* Arguments: * Arguments:
* 0: tripod <OBJECT> * 0: tripod <OBJECT>
* 1: unit <OBJECT> * 1: unit <OBJECT>
* *
* Return Value:
* Nothing
*
* Return value: * Return value:
* None * None
*
* Example:
* [tripod, player] call ace_tripod_fnc_pickup
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_tripod,_unit); params ["_tripod", "_unit"];
if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then { if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then {
_unit playMove "AmovPercMstpSrasWrflDnon_diary"; _unit playMove "AmovPercMstpSrasWrflDnon_diary";
}; };
[{ [{
PARAMS_2(_tripod,_unit); params ["_tripod", "_unit"];
[_unit, "ACE_Tripod"] call EFUNC(common,addToInventory); [_unit, "ACE_Tripod"] call EFUNC(common,addToInventory);
deleteVehicle _tripod; deleteVehicle _tripod;
}, [_tripod, _unit], 1, 0]call EFUNC(common,waitAndExecute); }, [_tripod, _unit], 1, 0]call EFUNC(common,waitAndExecute);

View File

@ -1,21 +1,22 @@
/* /*
* Author: Rocko, Ruthberg * Author: Rocko, Ruthberg
*
* Place down tripod * Place down tripod
* *
* Arguments: * Arguments:
* 0: unit <OBJECT> * 0: unit <OBJECT>
* 1: tripod class <STRING> * 1: tripod class <STRING>
* *
* Return Value:
* Nothing
*
* Return value: * Return value:
* None * None
*
* Example:
* [player, "ACE_Tripod"] call ace_tripod_fnc_place
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_tripodClass); params ["_unit", "_tripodClass"];
_unit removeItem _tripodClass; _unit removeItem _tripodClass;
@ -24,7 +25,7 @@ if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then {
}; };
[{ [{
PARAMS_1(_unit); params ["_unit"];
private ["_direction", "_position", "_tripod"]; private ["_direction", "_position", "_tripod"];
_direction = getDir _unit; _direction = getDir _unit;
@ -33,17 +34,19 @@ if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then {
_tripod = "ACE_TripodObject" createVehicle [0, 0, 0]; _tripod = "ACE_TripodObject" createVehicle [0, 0, 0];
{ {
_tripod animate [_x, 1]; _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 { if (_tripod animationPhase "slide_down_tripod" == 1) then {
_tripod setDir _direction; _tripod setDir _direction;
_tripod setPosASL _position; _tripod setPosASL _position;
if ((getPosATL _tripod select 2) - (getPos _tripod select 2) < 1E-5) then { 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; }, 0, [_tripod, _direction, _position]] call CBA_fnc_addPerFrameHandler;