Merge pull request #2056 from MikeMatrix/codeCleanupSandbag

Code cleanup of Sandbag module
This commit is contained in:
Glowbal 2015-08-09 23:56:25 +02:00
commit 0c2c71e70e
8 changed files with 37 additions and 36 deletions

View File

@ -6,10 +6,10 @@
* None
*
* Return Value:
* can deploy? <BOOLEAN>
* Can deploy <BOOL>
*
* Example:
* call ace_sandbag_fnc_canDeploy;
* [] call ace_sandbag_fnc_canDeploy
*
* Public: No
*/
@ -22,6 +22,7 @@ if (ACE_player getVariable [QGVAR(usingSandbag), false]) exitWith { false };
if ((getPosATL ACE_player select 2) - (getPos ACE_player select 2) > 1E-5) exitWith { false };
private ["_surfaceClass", "_surfaceType"];
_surfaceClass = ([surfaceType (position ACE_player), "#"] call CBA_fnc_split) select 1;
_surfaceType = getText (configfile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron");

View File

@ -10,39 +10,39 @@
* None
*
* Example:
* [_sandbag, _unit] call ace_sandbag_fnc_carry;
* [_sandbag, _unit] call ace_sandbag_fnc_carry
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_sandbag,_unit);
params ["_sandbag", "_unit"];
_unit playActionNow "PutDown";
_unit setVariable [QGVAR(usingSandbag), true];
[{
PARAMS_2(_sandbag,_unit);
params ["_sandbag", "_unit"];
GVAR(carrier) = ACE_player;
[GVAR(carrier), "ACE_Sandbag", true] call EFUNC(common,setForceWalkStatus);
deleteVehicle _sandbag;
GVAR(sandBag) = createVehicle ["ACE_SandbagObject_NoGeo", [0,0,0], [], 0, "NONE"];
GVAR(sandBag) = createVehicle ["ACE_SandbagObject_NoGeo", [0, 0, 0], [], 0, "NONE"];
GVAR(sandBag) enableSimulationGlobal false;
// Force physx update
{
_x setPosASL (getPosASL _x);
} forEach (GVAR(carrier) nearObjects ["ACE_SandbagObject", 5]);
} count (GVAR(carrier) nearObjects ["ACE_SandbagObject", 5]);
GVAR(carryPFH) = [{
if (GVAR(carrier) != ACE_player) exitWith {
call FUNC(drop);
};
GVAR(sandBag) setPosASL ((eyePos ACE_player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]));
GVAR(sandBag) setPosASL ((eyePos ACE_player) vectorAdd (positionCameraToWorld [0, 0, 1] vectorDiff positionCameraToWorld [0, 0, 0]));
GVAR(sandBag) setDir (GVAR(deployDirection) + getDir ACE_player);
}, 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* call ace_sandbag_fnc_deploy;
* [] call ace_sandbag_fnc_deploy
*
* Public: No
*/
@ -21,14 +21,14 @@ GVAR(placer) = ACE_player;
[GVAR(placer), "ACE_Sandbag", true] call EFUNC(common,setForceWalkStatus);
GVAR(sandBag) = createVehicle ["ACE_SandbagObject_NoGeo", [0,0,0], [], 0, "NONE"];
GVAR(sandBag) = createVehicle ["ACE_SandbagObject_NoGeo", [0, 0, 0], [], 0, "NONE"];
GVAR(sandBag) enableSimulationGlobal false;
GVAR(deployPFH) = [{
if (GVAR(placer) != ACE_player) exitWith {
call FUNC(deployCancel);
};
GVAR(sandBag) setPosASL ((eyePos ACE_player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]));
GVAR(sandBag) setPosASL ((eyePos ACE_player) vectorAdd (positionCameraToWorld [0, 0, 1] vectorDiff positionCameraToWorld [0, 0, 0]));
GVAR(sandBag) setDir (GVAR(deployDirection) + getDir ACE_player);
}, 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* call ace_sandbag_fnc_deployCancel;
* [] call ace_sandbag_fnc_deployCancel
*
* Public: No
*/

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* call ace_sandbag_fnc_deployConfirm;
* [] call ace_sandbag_fnc_deployConfirm
*
* Public: No
*/
@ -36,16 +36,16 @@ GVAR(placer) setVariable [QGVAR(usingSandbag), true];
private ["_sandBag", "_position", "_direction"];
_position = getPosASL GVAR(sandBag);
_direction = getDir GVAR(sandBag);
deleteVehicle GVAR(sandBag);
_sandBag = createVehicle ["ACE_SandbagObject", [0,0,0], [], 0, "NONE"];
_sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"];
_sandBag enableSimulationGlobal true;
_sandBag setPosASL _position;
_sandBag setDir _direction;
GVAR(placer) removeItem "ACE_Sandbag_empty";
GVAR(sandBag) = objNull;
GVAR(placer) = objNull;
}, [], 1.0, 0.5] call EFUNC(common,waitAndExecute);

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* call ace_sandbag_fnc_deployCancel;
* [] call ace_sandbag_fnc_deployCancel
*
* Public: No
*/
@ -34,14 +34,14 @@ GVAR(carrier) playActionNow "PutDown";
private ["_sandBag", "_position", "_direction"];
_position = getPosASL GVAR(sandBag);
_direction = getDir GVAR(sandBag);
deleteVehicle GVAR(sandBag);
_sandBag = createVehicle ["ACE_SandbagObject", [0,0,0], [], 0, "NONE"];
_sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"];
_sandBag enableSimulationGlobal true;
_sandBag setPosASL _position;
_sandBag setDir _direction;
GVAR(sandBag) = objNull;
GVAR(carrier) = objNull;
}, [], 1.0, 0.5] call EFUNC(common,waitAndExecute);

View File

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

View File

@ -10,26 +10,26 @@
* None
*
* Example:
* [_sandbag, _unit] call ace_sandbag_fnc_pickup;
* [_sandbag, _unit] call ace_sandbag_fnc_pickup
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_sandbag,_unit);
params ["_sandbag", "_unit"];
_unit playActionNow "PutDown";
_unit setVariable [QGVAR(usingSandbag), true];
[{
PARAMS_2(_sandbag,_unit);
params ["_sandbag", "_unit"];
_unit setVariable [QGVAR(usingSandbag), false];
deletevehicle _sandbag;
// Force physx update
{
_x setPosASL (getPosASL _x);
} forEach (_unit nearObjects ["ACE_SandbagObject", 5]);
} count (_unit nearObjects ["ACE_SandbagObject", 5]);
[_unit, "ACE_Sandbag_empty"] call EFUNC(common,addToInventory);
}, [_sandbag, _unit], 1.5, 0.5] call EFUNC(common,waitAndExecute);