Merge pull request #2013 from jokoho48/codeCleanupAttach

Code cleanup of the Attach module.
This commit is contained in:
PabstMirror 2015-08-06 12:50:43 -05:00
commit b5a6e1e883
6 changed files with 17 additions and 23 deletions

View File

@ -17,10 +17,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_itemClassname", "_itemVehClass", "_onAtachText", "_selfAttachPosition", "_attachedItem", "_tempObject", "_actionID", "_model"]; private ["_itemVehClass", "_onAtachText", "_selfAttachPosition", "_attachedItem", "_tempObject", "_actionID", "_model"];
params ["_attachToVehicle","_unit","_args"];
PARAMS_3(_attachToVehicle,_unit,_args); _args params [["_itemClassname",""]];
_itemClassname = [_args, 0, ""] call CBA_fnc_defaultParam;
//Sanity Check (_unit has item in inventory, not over attach limit) //Sanity Check (_unit has item in inventory, not over attach limit)
if ((_itemClassname == "") || {!(_this call FUNC(canAttach))}) exitWith {ERROR("Tried to attach, but check failed");}; if ((_itemClassname == "") || {!(_this call FUNC(canAttach))}) exitWith {ERROR("Tried to attach, but check failed");};
@ -69,9 +68,8 @@ if (_unit == _attachToVehicle) then { //Self Attachment
[{ [{
private["_angle", "_dir", "_screenPos", "_realDistance", "_up", "_virtualPos", "_virtualPosASL", "_lineInterection"]; private["_angle", "_dir", "_screenPos", "_realDistance", "_up", "_virtualPos", "_virtualPosASL", "_lineInterection"];
params ["_args","_idPFH"];
PARAMS_2(_args,_pfID); _args params ["_unit","_attachToVehicle","_itemClassname","_itemVehClass","_onAtachText","_actionID"];
EXPLODE_6_PVT(_args,_unit,_attachToVehicle,_itemClassname,_itemVehClass,_onAtachText,_actionID);
_virtualPosASL = (eyePos _unit) vectorAdd (positionCameraToWorld [0,0,0.6]) vectorDiff (positionCameraToWorld [0,0,0]); _virtualPosASL = (eyePos _unit) vectorAdd (positionCameraToWorld [0,0,0.6]) vectorDiff (positionCameraToWorld [0,0,0]);
if (cameraView == "EXTERNAL") then { if (cameraView == "EXTERNAL") then {
@ -88,7 +86,7 @@ if (_unit == _attachToVehicle) then { //Self Attachment
{!([_unit, _attachToVehicle, []] call EFUNC(common,canInteractWith))} || {!([_unit, _attachToVehicle, []] call EFUNC(common,canInteractWith))} ||
{!([_attachToVehicle, _unit, _itemClassname] call FUNC(canAttach))}) then { {!([_attachToVehicle, _unit, _itemClassname] call FUNC(canAttach))}) then {
[_pfID] call CBA_fnc_removePerFrameHandler; [_idPFH] call CBA_fnc_removePerFrameHandler;
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
[] call EFUNC(interaction,hideMouseHint); [] call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler); [_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler);

View File

@ -17,11 +17,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_3(_attachToVehicle,_player,_args); private ["_attachLimit", "_attachedObjects","_playerPos"];
params ["_attachToVehicle","_player","_args"];
_args params [["_itemname",""]];
private ["_itemName", "_attachLimit", "_attachedObjects","_playerPos"];
_itemName = [_args, 0, ""] call CBA_fnc_defaultParam;
_attachLimit = [6, 1] select (_player == _attachToVehicle); _attachLimit = [6, 1] select (_player == _attachToVehicle);
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; _attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];

View File

@ -16,9 +16,8 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_attachToVehicle,_unit);
private ["_attachedObjects", "_inRange"]; private ["_attachedObjects", "_inRange"];
params ["_attachToVehicle", "_unit"];
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; _attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];

View File

@ -16,15 +16,14 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_attachToVehicle,_unit); private ["_attachedObjects", "_attachedItems", "_itemDisplayName",
"_attachedObject", "_attachedIndex", "_itemName", "_minDistance",
private ["_attachedObjects", "_attachedItems", "_itemDisplayName"]; "_unitPos", "_objectPos"
];
params ["_attachToVehicle","_unit"],
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; _attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
_attachedItems = _attachToVehicle getVariable [QGVAR(ItemNames), []]; _attachedItems = _attachToVehicle getVariable [QGVAR(ItemNames), []];
private ["_attachedObject", "_attachedIndex", "_itemName", "_minDistance", "_unitPos", "_objectPos"];
_attachedObject = objNull; _attachedObject = objNull;
_attachedIndex = -1; _attachedIndex = -1;
_itemName = ""; _itemName = "";

View File

@ -18,7 +18,7 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_listed", "_actions", "_item", "_displayName", "_picture", "_action"]; private ["_listed", "_actions", "_item", "_displayName", "_picture", "_action"];
PARAMS_2(_target,_player); params ["_target","_player"];
_listed = []; _listed = [];
_actions = []; _actions = [];

View File

@ -27,8 +27,7 @@
private ["_startingOffset", "_startDistanceFromCenter", "_closeInUnitVector", "_closeInMax", "_closeInMin", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_doesIntersect", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"]; private ["_startingOffset", "_startDistanceFromCenter", "_closeInUnitVector", "_closeInMax", "_closeInMin", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_doesIntersect", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"];
PARAMS_6(_unit,_attachToVehicle,_itemClassname,_itemVehClass,_onAtachText,_startingPosition); params ["_unit", "_attachToVehicle", "_itemClassname", "_itemVehClass", "_onAtachText", "_startingPosition"];
_startingOffset = _attachToVehicle worldToModel _startingPosition; _startingOffset = _attachToVehicle worldToModel _startingPosition;
_startDistanceFromCenter = vectorMagnitude _startingOffset; _startDistanceFromCenter = vectorMagnitude _startingOffset;