From f436866e13ebc49d97072c80848f3e4947c64ba5 Mon Sep 17 00:00:00 2001 From: mrpvtdagger Date: Mon, 22 Feb 2021 21:31:26 -0400 Subject: [PATCH] Ace Version --- ACE_MPD_SlingLoad/init.sqf | 42 ++++++++++++++++++++++++ ACE_MPD_SlingLoad/sling.sqf | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 ACE_MPD_SlingLoad/init.sqf create mode 100644 ACE_MPD_SlingLoad/sling.sqf diff --git a/ACE_MPD_SlingLoad/init.sqf b/ACE_MPD_SlingLoad/init.sqf new file mode 100644 index 0000000..bea00b1 --- /dev/null +++ b/ACE_MPD_SlingLoad/init.sqf @@ -0,0 +1,42 @@ +/* + Simple Sling Load Script by MrPvTDagger#4176 :D +*/ + +diag_log "MPD_SlingLoad is Loading..."; + +/* +This is for Modded Objects that Might not be slingable by default. I have done this automtically but Just incase it doesn't work with all mods. + +EXAMPLE: +_ccargo = [ + RHS_Storage_Create_1, + RHS_Storage_Create_2, + RHS_Storage_Create_3 // Make sure the last one doesn't have a comment at the end +]; +*/ + + +_ccargo = [ + +]; + +// ====================== Don't Touch Anything Below this line ====================== +_acargo = entities [[], ["Air","Man","Tank","Logic"], true];; // Maybe Better way of Doing This???? +_acargo append _ccargo; +{ + _action = [ + "SlingLoad", // Action Name + "Sling Load", // Name Of action Shown In menu + "", // Icon + {[_target] execVM "MPD_SlingLoad\sling.sqf";}, // Statment + {(nearestObject [_target, "Helicopter"]) distance _target < 10}, // Condition + {}, // + [], + [0,0,0], 100] call ace_interact_menu_fnc_createAction; + + [_x, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToObject; +} forEach _acargo; + + + + diff --git a/ACE_MPD_SlingLoad/sling.sqf b/ACE_MPD_SlingLoad/sling.sqf new file mode 100644 index 0000000..6674796 --- /dev/null +++ b/ACE_MPD_SlingLoad/sling.sqf @@ -0,0 +1,65 @@ + [10, [_this select 0], { + 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 = _args select 0; + _nObject = nearestObject [_cargo, "Helicopter"]; + _pilot = currentPilot _nObject; + _cargo attachTo [_nObject, [0, 1.1, -7]]; + removeAllActions _cargo; + + /* + Credits for finding corners go to sethduda from Advanced Sling Loading + https://github.com/sethduda/ + https://github.com/sethduda/AdvancedSlingLoading + */ + _widthFactor = 0.5; + _lengthFactor = 0.5; + if(_cargo isKindOf "Air") then { + _widthFactor = 0.3; + }; + if(_cargo isKindOf "Helicopter") then { + _widthFactor = 0.2; + _lengthFactor = 0.45; + }; + + _centerOfMass = getCenterOfMass _cargo; + _bbr = boundingBoxReal _cargo; + _p1 = _bbr select 0; + _p2 = _bbr select 1; + _maxWidth = abs ((_p2 select 0) - (_p1 select 0)); + _widthOffset = ((_maxWidth / 2) - abs ( _centerOfMass select 0 )) * _widthFactor; + _maxLength = abs ((_p2 select 1) - (_p1 select 1)); + _lengthOffset = ((_maxLength / 2) - abs (_centerOfMass select 1 )) * _lengthFactor; + _maxHeight = abs ((_p2 select 2) - (_p1 select 2)); + _heightOffset = _maxHeight/6; + + _rearCorner = [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) - _lengthOffset, (_centerOfMass select 2)+_heightOffset]; + _rearCorner2 = [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) - _lengthOffset, (_centerOfMass select 2)+_heightOffset]; + _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,1.1,-2], _heightOffset + (_cargo distance _nObject)]; + _Rope2 = ropeCreate [_nObject, [0,1.1,-2], _heightOffset + (_cargo distance _nObject)]; + _Rope3 = ropeCreate [_nObject, [0,1.1,-2], _heightOffset + (_cargo distance _nObject)]; + _Rope4 = ropeCreate [_nObject, [0,1.1,-2], _heightOffset + (_cargo distance _nObject)]; + + [_cargo , _rearCorner, [0,0,-1]] ropeAttachTo (_Rope1); + [_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 { + _heli = (vehicle player); + _cargoRopes = ropes _heli; + { + ropeDestroy _x; + } forEach _cargoRopes; + { + detach _x; + [_x] execVM "MPD_SlingLoad\sling.sqf"; + } forEach attachedObjects _heli; + }; + removeAllActions player; + }]; +}, {}, "Sling Loading..."] call ace_common_fnc_progressBar; //I was lazy... \ No newline at end of file