From e02f5af32cb394e09de4e8706157e9fc01b4dd41 Mon Sep 17 00:00:00 2001 From: mrpvtdagger Date: Sun, 21 Feb 2021 22:28:39 -0400 Subject: [PATCH] General Bug Fix Ropes Trigger Distance --- MPD_SlingLoad/init.sqf | 8 ++++-- MPD_SlingLoad/sling.sqf | 59 ++++++++++++++++++----------------------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/MPD_SlingLoad/init.sqf b/MPD_SlingLoad/init.sqf index 34a5535..71b4541 100644 --- a/MPD_SlingLoad/init.sqf +++ b/MPD_SlingLoad/init.sqf @@ -21,9 +21,13 @@ _ccargo = [ ]; // ====================== Don't Touch Anything Below this line ====================== -_acargo = entities [[], ["Air","Man"], true];; // Maybe Better way of Doing This???? +_acargo = entities [[], ["Air","Man","Tank"], true];; // Maybe Better way of Doing This???? _acargo append _ccargo; { [_x] execVM "MPD_SlingLoad\sling.sqf"; -} forEach _acargo; \ No newline at end of file +} forEach _acargo; + + + + diff --git a/MPD_SlingLoad/sling.sqf b/MPD_SlingLoad/sling.sqf index 1f9f673..618c94c 100644 --- a/MPD_SlingLoad/sling.sqf +++ b/MPD_SlingLoad/sling.sqf @@ -1,13 +1,10 @@ -_nObject = nearestObject [_this select 0, "Helicopter"]; +heli = nearestObject [_this select 0, "Helicopter"]; [ - _this select 0, - "Sling to Nearest Helicopter", - "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", - "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", - "_this distance _target < 3", // Condition for the action to be shown - "_caller distance _target < 3", // Condition for the action to progress - {}, // Code executed when action starts - {}, // Code executed on every progress tick + _this select 0, "Sling to Nearest Helicopter","\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa","\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", + "_this distance _target < 3 && heli distance _this < 10", + "heli distance _this < 10", + {heli = nearestObject [_this select 0, "Helicopter"];}, + {}, { private ["_cargo","_nObject","_pilot","_Rope1","_Rope2","_Rope3","_Rope4","_widthFactor","_lengthFactor","_centerOfMass","_bbr","_p1","_p2","_maxWidth","_widthOffset","_maxLength","_lengthOffset","_maxHeight","_heightOffset","_rearCorner","_rearCorner2","_frontCorner","_frontCorner2"]; _cargo = _this select 0; @@ -23,16 +20,16 @@ _nObject = nearestObject [_this select 0, "Helicopter"]; */ _widthFactor = 0.5; _lengthFactor = 0.5; - if(_nObject isKindOf "Air") then { + if(_cargo isKindOf "Air") then { _widthFactor = 0.3; }; - if(_nObject isKindOf "Helicopter") then { + if(_cargo isKindOf "Helicopter") then { _widthFactor = 0.2; _lengthFactor = 0.45; }; - _centerOfMass = getCenterOfMass _nObject; - _bbr = boundingBoxReal _nObject; + _centerOfMass = getCenterOfMass _cargo; + _bbr = boundingBoxReal _cargo; _p1 = _bbr select 0; _p2 = _bbr select 1; _maxWidth = abs ((_p2 select 0) - (_p1 select 0)); @@ -47,37 +44,33 @@ _nObject = nearestObject [_this select 0, "Helicopter"]; _frontCorner = [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) + _lengthOffset, (_centerOfMass select 2)+_heightOffset]; _frontCorner2 = [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) + _lengthOffset, (_centerOfMass select 2)+_heightOffset]; - _Rope1 = ropeCreate [_nObject, [0,0,0], 14]; - _Rope2 = ropeCreate [_nObject, [0,0,0], 14]; - _Rope3 = ropeCreate [_nObject, [0,0,0], 14]; - _Rope4 = ropeCreate [_nObject, [0,0,0], 14]; + _Rope1 = ropeCreate [_nObject, [0,0,0], 5]; + _Rope2 = ropeCreate [_nObject, [0,0,0], 5]; + _Rope3 = ropeCreate [_nObject, [0,0,0], 5]; + _Rope4 = ropeCreate [_nObject, [0,0,0], 5]; [_cargo , _rearCorner, [0,0,-1]] ropeAttachTo (_Rope1); - [_cargo , __rearCorner2, [0,0,-1]] ropeAttachTo (_Rope2); + [_cargo , _rearCorner2, [0,0,-1]] ropeAttachTo (_Rope2); [_cargo , _frontCorner, [0,0,-1]] ropeAttachTo (_Rope3); [_cargo , _frontCorner2, [0,0,-1]] ropeAttachTo (_Rope4); _pilot addAction ["Release Cargo", { + private ["_heli","_cargoRopes"]; if !(isNull objectParent player) then { - _nObject = nearestObject [player, "B_MRAP_01_F"]; - _cargoRopes = ropes t1; // Needs to be changed + _heli = (vehicle player); + _cargoRopes = ropes _heli; { ropeDestroy _x; } forEach _cargoRopes; - detach _nObject; - [_nObject] execVM "MPD_SlingLoad\sling.sqf"; + { + detach _x; + [_x] execVM "MPD_SlingLoad\sling.sqf"; + } forEach attachedObjects _heli; }; removeAllActions player; }]; - - - - }, - {}, // Code executed on interrupted - [], // Arguments passed to the scripts as _this select 3 - 8, // Action duration [s] - 0, // Priority - true, // Remove on completion - false // Show in unconscious state -] remoteExec ["BIS_fnc_holdActionAdd", 0, _this select 0]; // MP compatible implementation \ No newline at end of file + },{},[],8,0,true,false +] remoteExec [ + "BIS_fnc_holdActionAdd", 0, _this select 0 +]; \ No newline at end of file