Merge pull request #2046 from MikeMatrix/codeCleanupTripod

Code cleanup in Tripod module
This commit is contained in:
Glowbal 2015-08-08 10:58:01 +02:00
commit 2951c9a965
4 changed files with 39 additions and 34 deletions

View File

@ -1,37 +1,39 @@
/*
* Author: Ruthberg
*
* Adjust tripod height
*
* Arguments:
* 0: tripod <OBJECT>
*
* 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);

View File

@ -9,13 +9,13 @@
* handled <BOOL>
*
* 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 };

View File

@ -1,30 +1,30 @@
/*
* Author: Rocko, Ruthberg
*
* Pick up tripod
*
* Arguments:
* 0: tripod <OBJECT>
* 1: unit <OBJECT>
*
* 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);

View File

@ -1,21 +1,22 @@
/*
* Author: Rocko, Ruthberg
*
* Place down tripod
*
* Arguments:
* 0: unit <OBJECT>
* 1: tripod class <STRING>
*
* 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);