Code cleanup of sandbag module

This commit is contained in:
Michael Braun 2015-08-08 02:00:00 +02:00
parent a9ed1052dd
commit d1a2bec7fd
8 changed files with 37 additions and 36 deletions

View File

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

View File

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

View File

@ -9,7 +9,7 @@
* None * None
* *
* Example: * Example:
* call ace_sandbag_fnc_deploy; * [] call ace_sandbag_fnc_deploy
* *
* Public: No * Public: No
*/ */
@ -21,14 +21,14 @@ GVAR(placer) = ACE_player;
[GVAR(placer), "ACE_Sandbag", true] call EFUNC(common,setForceWalkStatus); [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(sandBag) enableSimulationGlobal false;
GVAR(deployPFH) = [{ GVAR(deployPFH) = [{
if (GVAR(placer) != ACE_player) exitWith { if (GVAR(placer) != ACE_player) exitWith {
call FUNC(deployCancel); 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); GVAR(sandBag) setDir (GVAR(deployDirection) + getDir ACE_player);
}, 0, []] call CBA_fnc_addPerFrameHandler; }, 0, []] call CBA_fnc_addPerFrameHandler;

View File

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

View File

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

View File

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

View File

@ -9,13 +9,13 @@
* handled <BOOL> * handled <BOOL>
* *
* Example: * Example:
* 1.2 call ace_sandbag_fnc_handleScrollWheel; * [1.2] call ace_sandbag_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(deployPFH) == -1) exitWith { false }; if (GETMVAR(ACE_Modifier,0) == 0 || GVAR(deployPFH) == -1) exitWith { false };

View File

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