From 29e505c2d6d9e03698ec6f23d15975ad6b4f2ef8 Mon Sep 17 00:00:00 2001 From: sethduda Date: Tue, 12 Apr 2016 22:54:56 -0400 Subject: [PATCH] Updating sling loading code to follow towing code patterns, adding exile support --- addons/SA_AdvancedSlingLoading.pbo | Bin 19245 -> 0 bytes ...ingLoading.pbo.AdvancedSlingLoading.bisign | Bin 573 -> 0 bytes addons/SA_AdvancedSlingLoading/config.cpp | 51 +- .../functions/fn_advancedSlingLoadingInit.sqf | 1074 +++++++++++------ 4 files changed, 746 insertions(+), 379 deletions(-) delete mode 100644 addons/SA_AdvancedSlingLoading.pbo delete mode 100644 addons/SA_AdvancedSlingLoading.pbo.AdvancedSlingLoading.bisign diff --git a/addons/SA_AdvancedSlingLoading.pbo b/addons/SA_AdvancedSlingLoading.pbo deleted file mode 100644 index aee3ffb22a8e6ca1c4a823395182c32052c0d84c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19245 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 diff --git a/addons/SA_AdvancedSlingLoading.pbo.AdvancedSlingLoading.bisign b/addons/SA_AdvancedSlingLoading.pbo.AdvancedSlingLoading.bisign deleted file mode 100644 index 45e8b091255776a0842194cf7ee013d46bc9afc7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 573 zcmV-D0>b@4WOiY0V`XGhY-w(1OmAUiX>Ml#lmGw#1_A&803-kaQd2=O00aO40RRC2 z{pPNXp<0#kV5;$I2TB3>y^Ym7f+M~rv<;xb^r^3N9sMR z&s-|qhtJ3aMPE_0?5~xr?Yn;O+f+<+Eq9y>u`e;csho&Uu#zyEii3=KVWNE_?)bnRBQZoDc?YX!&b8XPtWb;+*W&L!22B?LUG{{F(D>1gpbzZGvu3!@dncxSg zM#2U|NwSVEHnAEN0@|XhPrgN?O^3*a^v9R}0_rj#fB*mh(~X3!EoYBXsFw(Nlg2<# zF0SKo-dD7gDn)fdXU>r}dz(%C41yWpoY@qiJS$`vW-R=uBu;KXRz)WZ@v6 zd=hsSnB=s_EtG?8p=%p5Cx8A!eq=;mw0?puuSG!JGH-F7r#g#}1=wxakILAs>g`V5 LQh%P0Fk{7vPzV2- diff --git a/addons/SA_AdvancedSlingLoading/config.cpp b/addons/SA_AdvancedSlingLoading/config.cpp index 209b4aa..2e9d051 100644 --- a/addons/SA_AdvancedSlingLoading/config.cpp +++ b/addons/SA_AdvancedSlingLoading/config.cpp @@ -8,53 +8,22 @@ class CfgPatches }; }; -/* -class CfgVehicles +class CfgNetworkMessages { - class Logic; - class Module_F: Logic + + class AdvancedSlingLoadingRemoteExecClient { - class ArgumentsBaseUnits - { - class Anything; - }; - class ModuleDescription - { - class Anything; - }; + module = "AdvancedSlingLoading"; + parameters[] = {"ARRAY","STRING","OBJECT","BOOL"}; }; - class SA_AdvancedSlingLoadingModule: Module_F + + class AdvancedSlingLoadingRemoteExecServer { - // Standard object definitions - scope = 2; // Editor visibility; 2 will show it in the menu, 1 will hide it. - displayName = "Advanced Sling Loading"; // Name displayed in the menu - category = "NO_CATEGORY"; - - // Name of function triggered once conditions are met - function = "SA_fnc_advancedSlingLoadingInit"; - // Execution priority, modules with lower number are executed first. 0 is used when the attribute is undefined - functionPriority = 1; - // 0 for server only execution, 1 for global execution, 2 for persistent global execution - isGlobal = 0; - // 1 for module waiting until all synced triggers are activated - isTriggerActivated = 0; - // 1 if modules is to be disabled once it's activated (i.e., repeated trigger activation won't work) - isDisposable = 0; - // // 1 to run init function in Eden Editor as well - is3DEN = 0; - - // Menu displayed when the module is placed or double-clicked on by Zeus - //curatorInfoType = "RscDisplayAttributeModuleNuke"; - - // Module description. Must inherit from base class, otherwise pre-defined entities won't be available - class ModuleDescription: ModuleDescription - { - description = "Enables advanced sling loading"; // Short description, will be formatted as structured text - sync[] = {}; // Array of synced entities (can contain base classes) - }; + module = "AdvancedSlingLoading"; + parameters[] = {"ARRAY","STRING","BOOL"}; }; + }; -*/ class CfgFunctions { diff --git a/addons/SA_AdvancedSlingLoading/functions/fn_advancedSlingLoadingInit.sqf b/addons/SA_AdvancedSlingLoading/functions/fn_advancedSlingLoadingInit.sqf index bd4c8e6..3b4fb5f 100644 --- a/addons/SA_AdvancedSlingLoading/functions/fn_advancedSlingLoadingInit.sqf +++ b/addons/SA_AdvancedSlingLoading/functions/fn_advancedSlingLoadingInit.sqf @@ -9,13 +9,16 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -{ -if(!isNil "SA_ROPE_INIT" || !hasInterface) exitWith {}; +ASL_Advanced_Sling_Loading_Install = { -SA_ROPE_INIT = true; +// Prevent advanced sling loading from installing twice +if(!isNil "ASL_ROPE_INIT") exitWith {}; +ASL_ROPE_INIT = true; -SA_Rope_Get_Lift_Capability = { +diag_log "Advanced Sling Loading Loading..."; + +ASL_Rope_Get_Lift_Capability = { private ["_heli","_heliType"]; _heli = [_this,0] call BIS_fnc_param; _heliType = toLower(typeOf _heli); @@ -42,20 +45,20 @@ SA_Rope_Get_Lift_Capability = { _returnVal; }; -SA_Rope_Set_Mass = { +ASL_Rope_Set_Mass = { private ["_obj","_mass"]; _obj = [_this,0] call BIS_fnc_param; _mass = [_this,1] call BIS_fnc_param; _obj setMass _mass; }; -SA_Rope_Adjust_Mass = { +ASL_Rope_Adjust_Mass = { private ["_obj","_mass","_lift","_heli","_originalMass","_ropes"]; _obj = [_this,0] call BIS_fnc_param; _heli = [_this,1] call BIS_fnc_param; _ropes = [_this,2,[]] call BIS_fnc_param; - _lift = [_heli] call SA_Rope_Get_Lift_Capability; - _originalMass = _obj getVariable ["sa_rope_original_mass", getMass _obj]; + _lift = [_heli] call ASL_Rope_Get_Lift_Capability; + _originalMass = _obj getVariable ["asl_rope_original_mass", getMass _obj]; // Is mass adjustment needed? if( _originalMass >= ((_lift select 0)*0.8) && _originalMass <= _lift select 1 ) then { private ["_originalMassSet","_ends","_endDistance","_ropeLength"]; @@ -66,7 +69,7 @@ SA_Rope_Adjust_Mass = { _endDistance = (_ends select 0) distance (_ends select 1); _ropeLength = ropeLength _x; if((_ropeLength - 2) <= _endDistance && ((position _heli) select 2) > 0 ) then { - [[_obj, ((_lift select 0)*0.8)],"SA_Rope_Set_Mass",_obj,false,true] spawn BIS_fnc_MP; + [[_obj, ((_lift select 0)*0.8)],"ASL_Rope_Set_Mass",_obj,false,true] spawn BIS_fnc_MP; _originalMassSet = false; }; } forEach _ropes; @@ -75,387 +78,782 @@ SA_Rope_Adjust_Mass = { while { _obj in (ropeAttachedObjects _heli) } do { sleep 0.5; }; - [[_obj, _originalMass],"SA_Rope_Set_Mass",_obj,false,true] spawn BIS_fnc_MP; + [[_obj, _originalMass],"ASL_Rope_Set_Mass",_obj,false,true] spawn BIS_fnc_MP; }; }; - -SA_Rope_Build_Action_Menu = { - private ["_heli","_actionMenu","_length"]; - - _heli = vehicle player; - - _actionMenu = [ - ["Ropes",false] - ]; - - if( _heli isKindOf "Helicopter" ) then { - - _cargoRopesDeployed = _heli getVariable ["sa_rope_cargo_ropes_deployed",false]; - if(!_cargoRopesDeployed) then { - _actionMenu = _actionMenu + [["Deploy Cargo Ropes (5m)", [0], "", -5, [["expression", "[[vehicle player, 5],""SA_Rope_Deploy_Cargo_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - _actionMenu = _actionMenu + [["Deploy Cargo Ropes (10m)", [0], "", -5, [["expression", "[[vehicle player, 10],""SA_Rope_Deploy_Cargo_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - _actionMenu = _actionMenu + [["Deploy Cargo Ropes (15m)", [0], "", -5, [["expression", "[[vehicle player, 15],""SA_Rope_Deploy_Cargo_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - } else { - if( count ropeAttachedObjects _heli == 0 ) then { - _actionMenu = _actionMenu + [["Retract Cargo Ropes", [0], "", -5, [["expression", "[[vehicle player],""SA_Rope_Retract_Cargo_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - } else { - _actionMenu = _actionMenu + [["Release Cargo", [0], "", -5, [["expression", "[[vehicle player],""SA_Rope_Release_Cargo"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; +ASL_Extend_Ropes = { + params ["_vehicle","_player"]; + if(local _vehicle) then { + private ["_existingRopes"]; + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + if(count _existingRopes > 0) then { + _ropeLength = ropeLength (_existingRopes select 0); + if(_ropeLength <= 100 ) then { + { + ropeUnwind [_x, 3, 5, true]; + } forEach _existingRopes; }; - _length = ropeLength (ropes _heli select 0); - _actionMenu = _actionMenu + [["Extend Cargo Ropes (+5m)", [0], "", -5, [["expression", "[[vehicle player, 5],""SA_Rope_Extend_Cargo_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - if(_length >= 10) then { - _actionMenu = _actionMenu + [["Shorten Cargo Ropes (-5m)", [0], "", -5, [["expression", "[[vehicle player, -5],""SA_Rope_Shorten_Cargo_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; + }; + } else { + [_this,"ASL_Extend_Ropes",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Extend_Ropes_Action = { + private ["_vehicle"]; + _vehicle = vehicle player; + if([_vehicle] call ASL_Can_Extend_Ropes) then { + [_vehicle,player] call ASL_Extend_Ropes; + }; +}; + +ASL_Extend_Ropes_Action_Check = { + [vehicle player] call ASL_Can_Extend_Ropes; +}; + +ASL_Can_Extend_Ropes = { + params ["_vehicle"]; + private ["_existingRopes"]; + if([_vehicle] call ASL_Is_Supported_Vehicle) then { + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + player distance _vehicle < 10 && (count _existingRopes) > 0; + } else { + false; + }; +}; + +ASL_Shorten_Ropes = { + params ["_vehicle","_player"]; + if(local _vehicle) then { + private ["_existingRopes"]; + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + if(count _existingRopes > 0) then { + _ropeLength = ropeLength (_existingRopes select 0); + if(_ropeLength <= 2 ) then { + _this call ASL_Release_Cargo; } else { - if(_length > 2) then { - _actionMenu = _actionMenu + [["Shorten Cargo Ropes (-1m)", [0], "", -5, [["expression", "[[vehicle player, -1],""SA_Rope_Shorten_Cargo_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; + { + if(_ropeLength >= 10) then { + ropeUnwind [_x, 3, -5, true]; + } else { + ropeUnwind [_x, 3, -1, true]; + }; + } forEach _existingRopes; + }; + }; + } else { + [_this,"ASL_Shorten_Ropes",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Shorten_Ropes_Action = { + private ["_vehicle"]; + _vehicle = vehicle player; + if([_vehicle] call ASL_Can_Shorten_Ropes) then { + [_vehicle,player] call ASL_Shorten_Ropes; + }; +}; + +ASL_Shorten_Ropes_Action_Check = { + [vehicle player] call ASL_Can_Shorten_Ropes; +}; + +ASL_Can_Shorten_Ropes = { + params ["_vehicle"]; + private ["_existingRopes"]; + if([_vehicle] call ASL_Is_Supported_Vehicle) then { + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + player distance _vehicle < 10 && (count _existingRopes) > 0; + } else { + false; + }; +}; + +ASL_Release_Cargo = { + params ["_vehicle","_player"]; + if(local _vehicle) then { + private ["_existingRopes","_attachedCargo","_attachedObj"]; + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + _attachedCargo = ropeAttachedObjects _vehicle; + if(count _existingRopes > 0 && count _attachedCargo > 0) then { + { + _attachedObj = _x; + { + _attachedObj ropeDetach _x; + } forEach _existingRopes; + } forEach ropeAttachedObjects _vehicle; + _this call ASL_Retract_Ropes; + }; + } else { + [_this,"ASL_Release_Cargo",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Release_Cargo_Action = { + private ["_vehicle"]; + _vehicle = vehicle player; + if([_vehicle] call ASL_Can_Release_Cargo) then { + [_vehicle,player] call ASL_Release_Cargo; + }; +}; + +ASL_Release_Cargo_Action_Check = { + [vehicle player] call ASL_Can_Release_Cargo; +}; + +ASL_Can_Release_Cargo = { + params ["_vehicle"]; + private ["_existingRopes"]; + if([_vehicle] call ASL_Is_Supported_Vehicle) then { + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + player distance _vehicle < 10 && (count _existingRopes) > 0 && count (ropeAttachedObjects _vehicle) > 0; + } else { + false; + }; +}; + +ASL_Retract_Ropes = { + params ["_vehicle","_player"]; + if(local _vehicle) then { + private ["_existingRopes","_attachedCargo"]; + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + _attachedCargo = ropeAttachedObjects _vehicle; + if(count _existingRopes > 0 && count _attachedCargo == 0) then { + _this call ASL_Drop_Ropes; + { + [_x,_vehicle] spawn { + params ["_rope","_vehicle"]; + private ["_count"]; + _count = 0; + ropeUnwind [_rope, 3, 0]; + while {(!ropeUnwound _rope) && _count < 20} do { + sleep 1; + _count = _count + 1; + }; + ropeDestroy _rope; + }; + } forEach _existingRopes; + _vehicle setVariable ["ASL_Ropes",nil,true]; + }; + } else { + [_this,"ASL_Retract_Ropes",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Retract_Ropes_Action = { + private ["_vehicle","_canRetractRopes"]; + if(vehicle player == player) then { + _vehicle = cursorTarget; + } else { + _vehicle = vehicle player; + }; + if([_vehicle] call ASL_Can_Retract_Ropes) then { + + _canRetractRopes = true; + + if!(missionNamespace getVariable ["ASL_LOCKED_VEHICLES_ENABLED",false]) then { + if( locked _vehicle > 1 ) then { + ["Cannot retract cargo ropes to locked vehicle",false] call ASL_Hint; + _canRetractRopes = false; + }; + }; + + if!(missionNamespace getVariable ["ASL_EXILE_SAFEZONE_ENABLED",false]) then { + if(!isNil "ExilePlayerInSafezone") then { + if( ExilePlayerInSafezone ) then { + ["Cannot retract cargo ropes in safe zone",false] call ASL_Hint; + _canRetractRopes = false; }; }; - }; + + if(_canRetractRopes) then { + [_vehicle,player] call ASL_Retract_Ropes; + }; + + }; +}; - /* - _fastRopesDeployed = _heli getVariable ["sa_rope_fast_ropes_deployed",false]; - if(!_fastRopesDeployed) then { - _actionMenu = _actionMenu + [["Deploy Fast Rope", [0], "", -5, [["expression", "[[vehicle player],""SA_Rope_Deploy_Fast_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - } else { - _actionMenu = _actionMenu + [["Retract Fast Rope", [0], "", -5, [["expression", "[[vehicle player],""SA_Rope_Retract_Fast_Ropes"",vehicle player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - if(vehicle player != player) then { - _actionMenu = _actionMenu + [["Rappel to Ground", [0], "", -5, [["expression", "[[vehicle player, player],""SA_Rope_Rappel_To_Groud"", player,false,true] spawn BIS_fnc_MP"]], "1", "1"]]; - } +ASL_Retract_Ropes_Action_Check = { + [vehicle player] call ASL_Can_Retract_Ropes; +}; + +ASL_Can_Retract_Ropes = { + params ["_vehicle"]; + private ["_existingRopes"]; + if([_vehicle] call ASL_Is_Supported_Vehicle) then { + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + player distance _vehicle < 10 && (count _existingRopes) > 0 && count (ropeAttachedObjects _vehicle) == 0; + } else { + false; + }; +}; + +ASL_Deploy_Ropes = { + params ["_vehicle","_player",["_ropeLength",15]]; + if(local _vehicle) then { + private ["_existingRopes","_cargoRopes"]; + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + if(count _existingRopes == 0) then { + _cargoRopes = []; + _cargoRopes = _cargoRopes + [ropeCreate [_vehicle, "slingload0", 5]]; + _cargoRopes = _cargoRopes + [ropeCreate [_vehicle, "slingload0", 5]]; + _cargoRopes = _cargoRopes + [ropeCreate [_vehicle, "slingload0", 5]]; + _cargoRopes = _cargoRopes + [ropeCreate [_vehicle, "slingload0", 5]]; + _vehicle setVariable ["ASL_Ropes",_cargoRopes,true]; + { + ropeUnwind [_x, 5, _ropeLength]; + } forEach _cargoRopes; + if(vehicle _player == _player) then { + // Pick up the ropes if player outside of vehicle + _this call ASL_Pickup_Ropes; + }; + }; + } else { + [_this,"ASL_Deploy_Ropes",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Deploy_Ropes_Action = { + private ["_vehicle","_canDeployRopes"]; + if(vehicle player == player) then { + _vehicle = cursorTarget; + } else { + _vehicle = vehicle player; + }; + if([_vehicle] call ASL_Can_Deploy_Ropes) then { + + _canDeployRopes = true; + + if!(missionNamespace getVariable ["ASL_LOCKED_VEHICLES_ENABLED",false]) then { + if( locked _vehicle > 1 ) then { + ["Cannot deploy cargo ropes from locked vehicle",false] call ASL_Hint; + _canDeployRopes = false; + }; + }; + + if!(missionNamespace getVariable ["ASL_EXILE_SAFEZONE_ENABLED",false]) then { + if(!isNil "ExilePlayerInSafezone") then { + if( ExilePlayerInSafezone ) then { + ["Cannot deploy cargo ropes in safe zone",false] call ASL_Hint; + _canDeployRopes = false; + }; + }; + }; + + if(_canDeployRopes) then { + [_vehicle,player] call ASL_Deploy_Ropes; + }; + + }; +}; + +ASL_Deploy_Ropes_Action_Check = { + if(vehicle player == player) then { + [cursorTarget] call ASL_Can_Deploy_Ropes; + } else { + [vehicle player] call ASL_Can_Deploy_Ropes; + }; +}; + +ASL_Can_Deploy_Ropes = { + params ["_vehicle"]; + if([_vehicle] call ASL_Is_Supported_Vehicle) then { + private ["_existingVehicle","_existingRopes"]; + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + _existingVehicle = player getVariable ["ASL_Ropes_Vehicle", objNull]; + player distance _vehicle < 10 && (count _existingRopes) == 0 && isNull _existingVehicle; + } else { + false; + }; +}; + +ASL_Put_Away_Ropes = { + params ["_vehicle","_player"]; + if(local _vehicle) then { + private ["_existingRopes"]; + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + if(count _existingRopes > 0) then { + _this call ASL_Pickup_Ropes; + _this call ASL_Drop_Ropes; + { + ropeDestroy _x; + } forEach _existingRopes; + _vehicle setVariable ["ASL_Ropes",nil,true]; + }; + } else { + [_this,"ASL_Put_Away_Ropes",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Put_Away_Ropes_Action = { + private ["_vehicle","_canPutAwayRopes"]; + _vehicle = cursorTarget; + if([_vehicle] call ASL_Can_Put_Away_Ropes) then { + + _canPutAwayRopes = true; + + if!(missionNamespace getVariable ["ASL_LOCKED_VEHICLES_ENABLED",false]) then { + if( locked _vehicle > 1 ) then { + ["Cannot put away cargo ropes in locked vehicle",false] call ASL_Hint; + _canPutAwayRopes = false; + }; + }; + + if!(missionNamespace getVariable ["ASL_EXILE_SAFEZONE_ENABLED",false]) then { + if(!isNil "ExilePlayerInSafezone") then { + if( ExilePlayerInSafezone ) then { + ["Cannot put away cargo ropes in safe zone",false] call ASL_Hint; + _canPutAwayRopes = false; + }; + }; + }; + + if(_canPutAwayRopes) then { + [_vehicle,player] call ASL_Put_Away_Ropes; }; - */ }; +}; + +ASL_Put_Away_Ropes_Action_Check = { + [cursorTarget] call ASL_Can_Put_Away_Ropes; +}; + +ASL_Can_Put_Away_Ropes = { + params ["_vehicle"]; + private ["_existingRopes"]; + if([_vehicle] call ASL_Is_Supported_Vehicle) then { + _existingRopes = _vehicle getVariable ["ASL_Ropes",[]]; + vehicle player == player && player distance _vehicle < 10 && (count _existingRopes) > 0; + } else { + false; + }; +}; + +ASL_Get_Corner_Points = { + params ["_vehicle"]; + private ["_centerOfMass","_bbr","_p1","_p2","_rearCorner","_rearCorner2","_frontCorner","_frontCorner2"]; + private ["_maxWidth","_widthOffset","_maxLength","_lengthOffset","_widthFactor","_lengthFactor"]; - _actionMenu -}; - -SA_Rope_Deploy_Cargo_Ropes = { - private ["_heli","_cargoRopesDeployed","_cargoRopes","_length"]; - _heli = [_this,0] call BIS_fnc_param; - _length = [_this,1] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - _cargoRopesDeployed = _heli getVariable ["sa_rope_cargo_ropes_deployed",false]; - if(!_cargoRopesDeployed) then { - _heli setVariable ["sa_rope_cargo_ropes_deployed",true,true]; - _cargoRopes = _heli getVariable ["sa_rope_cargo_ropes",[]]; - { ropeDestroy _x } forEach _cargoRopes; - _cargoRopes = _cargoRopes + [ropeCreate [_heli, "slingload0", 0]]; - _cargoRopes = _cargoRopes + [ropeCreate [_heli, "slingload0", 0]]; - _cargoRopes = _cargoRopes + [ropeCreate [_heli, "slingload0", 0]]; - _cargoRopes = _cargoRopes + [ropeCreate [_heli, "slingload0", 0]]; - { - ropeUnwind [_x, 5, _length]; - } forEach _cargoRopes; - _heli setVariable ["sa_rope_cargo_ropes",_cargoRopes,true]; - }; + // Correct width and length factor for air + _widthFactor = 0.75; + _lengthFactor = 0.75; + if(_vehicle isKindOf "Air") then { + _widthFactor = 0.3; }; + if(_vehicle isKindOf "Helicopter") then { + _widthFactor = 0.2; + _lengthFactor = 0.45; + }; + + _centerOfMass = getCenterOfMass _vehicle; + _bbr = boundingBoxReal _vehicle; + _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; + _rearCorner = [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) - _lengthOffset, _centerOfMass select 2]; + _rearCorner2 = [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) - _lengthOffset, _centerOfMass select 2]; + _frontCorner = [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) + _lengthOffset, _centerOfMass select 2]; + _frontCorner2 = [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) + _lengthOffset, _centerOfMass select 2]; + + [_rearCorner,_rearCorner2,_frontCorner,_frontCorner2]; }; -SA_Rope_Pickup_Rope_Action_Check = { - isNull (player getVariable ["SA_Rope_Cargo_Ropes_Picked_Up", objNull]) && vehicle player == player; -}; -SA_Rope_Drop_Rope_Action_Check = { - !isNull (player getVariable ["SA_Rope_Cargo_Ropes_Picked_Up", objNull]); -}; - -SA_Rope_Attach_Rope_Action_Check = { - (call SA_Rope_Drop_Rope_Action_Check) && !isNull cursorTarget && cursorTarget distance player < 5; -}; - -SA_Rope_Attach_Cargo_Ropes = { - private ["_target","_bbr","_ropeLength","_objDistance"]; - private ["_heli","_ropes","_player"]; - _heli = [_this,0] call BIS_fnc_param; - _player = [_this,1] call BIS_fnc_param; - _target = [_this,2] call BIS_fnc_param; - _ropes = _heli getVariable ["sa_rope_cargo_ropes",[objNull,objNull,objNull,objNull]]; - if( !isNull _target && _target distance _player < 5 && _target != _heli ) then { - _ropeLength = ropeLength (_ropes select 0); - _objDistance = _target distance _heli; - if( (_objDistance + 2) > _ropeLength ) then { - [{ hint "The ropes are too short. Extend them." },"BIS_fnc_spawn",_player] call BIS_fnc_MP; +ASL_Attach_Ropes = { + params ["_cargo","_player"]; + _vehicle = _player getVariable ["ASL_Ropes_Vehicle", objNull]; + if(!isNull _vehicle) then { + if(local _vehicle) then { + private ["_ropes","_attachmentPoints","_objDistance","_ropeLength"]; + _ropes = _vehicle getVariable ["ASL_Ropes",[]]; + if(count _ropes == 4) then { + _attachmentPoints = [_cargo] call ASL_Get_Corner_Points; + _ropeLength = (ropeLength (_ropes select 0)); + _objDistance = (_cargo distance _vehicle) + 2; + if( _objDistance > _ropeLength ) then { + [["The cargo ropes are too short. Move vehicle closer.", false],"ASL_Hint",_player] call ASL_RemoteExec; + } else { + [_vehicle,_player] call ASL_Drop_Ropes; + [_cargo, _attachmentPoints select 0, [0,0,-1]] ropeAttachTo (_ropes select 0); + [_cargo, _attachmentPoints select 1, [0,0,-1]] ropeAttachTo (_ropes select 1); + [_cargo, _attachmentPoints select 2, [0,0,-1]] ropeAttachTo (_ropes select 2); + [_cargo, _attachmentPoints select 3, [0,0,-1]] ropeAttachTo (_ropes select 3); + if(missionNamespace getVariable ["ASL_HEAVY_LIFTING_ENABLED",true]) then { + [_cargo, _vehicle, _ropes] spawn ASL_Rope_Adjust_Mass; + }; + }; + }; } else { - [_heli,_player] call SA_Rope_Drop_Cargo_Ropes; - - _centerOfMass = getCenterOfMass _target; - _bbr = boundingBoxReal _target; - _p1 = _bbr select 0; - _p2 = _bbr select 1; - _maxWidth = abs ((_p2 select 0) - (_p1 select 0)); - _widthOffset = ((_maxWidth / 2) - abs ( _centerOfMass select 0 )) / 2; - _maxLength = abs ((_p2 select 1) - (_p1 select 1)); - _lengthOffset = ((_maxLength / 2) - abs (_centerOfMass select 1 )) / 2; - _maxHeight = abs ((_p2 select 2) - (_p1 select 2)); - _heightOffset = _maxHeight/6; - - [_target, [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) + _lengthOffset, (_centerOfMass select 2) + _heightOffset], [0,0,-1]] ropeAttachTo (_ropes select 0); - [_target, [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) - _lengthOffset, (_centerOfMass select 2) + _heightOffset], [0,0,-1]] ropeAttachTo (_ropes select 1); - [_target, [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) - _lengthOffset, (_centerOfMass select 2) + _heightOffset], [0,0,-1]] ropeAttachTo (_ropes select 2); - [_target, [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) + _lengthOffset, (_centerOfMass select 2) + _heightOffset], [0,0,-1]] ropeAttachTo (_ropes select 3); - - if(missionNamespace getVariable ["SA_ASL_HEAVY_LIFTING_ENABLED",true]) then { - [_target, _heli, _ropes] spawn SA_Rope_Adjust_Mass; - }; + [_this,"ASL_Attach_Ropes",_vehicle,true] call ASL_RemoteExec; }; }; }; -SA_Rope_Pickup_Cargo_Ropes = { - private ["_heli","_player","_originalMass"]; - _heli = [_this,0] call BIS_fnc_param; - _player = [_this,1] call BIS_fnc_param; - { - _attachedObj = _x; - { - _attachedObj ropeDetach _x; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - } forEach ropeAttachedObjects _heli; - _helper = "Land_Can_V2_F" createVehicle position _player; - { - [_helper, [0, 0, 0], [0,0,-1]] ropeAttachTo _x; - _helper attachTo [_player, [-0.1, 0.1, 0.15], "Pelvis"]; - hideObject _helper; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - _player setVariable ["SA_Rope_Cargo_Ropes_Picked_Up", _heli,true]; - _player setVariable ["SA_Rope_Cargo_Ropes_Picked_Up_Helper", _helper,true]; -}; - -SA_Rope_Drop_Cargo_Ropes = { - private ["_heli","_player"]; - _heli = [_this,0] call BIS_fnc_param; - _player = [_this,1] call BIS_fnc_param; - _helper = (_player getVariable ["SA_Rope_Cargo_Ropes_Picked_Up_Helper", objNull]); - if(!isNull _heli) then { - { - _helper ropeDetach _x; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - detach _helper; - deleteVehicle _helper; +ASL_Attach_Ropes_Action = { + private ["_vehicle","_cargo","_canBeAttached"]; + _cargo = cursorTarget; + _vehicle = player getVariable ["ASL_Ropes_Vehicle", objNull]; + if([_vehicle,_cargo] call ASL_Can_Attach_Ropes) then { + + _canBeAttached = true; + + if!(missionNamespace getVariable ["ASL_LOCKED_VEHICLES_ENABLED",false]) then { + if( locked _cargo > 1 ) then { + ["Cannot attach cargo ropes to locked vehicle",false] call ASL_Hint; + _canBeAttached = false; + }; + }; + + if!(missionNamespace getVariable ["ASL_EXILE_SAFEZONE_ENABLED",false]) then { + if(!isNil "ExilePlayerInSafezone") then { + if( ExilePlayerInSafezone ) then { + ["Cannot attach cargo ropes in safe zone",false] call ASL_Hint; + _canBeAttached = false; + }; + }; + }; + + if(_canBeAttached) then { + [_cargo,player] call ASL_Attach_Ropes; + }; + }; - _player setVariable ["SA_Rope_Cargo_Ropes_Picked_Up", nil,true]; - _player setVariable ["SA_Rope_Cargo_Ropes_Picked_Up_Helper", nil,true]; }; -SA_Rope_Find_Nearby_Cargo_Heli = { - private ["_heli","_nearHelis","_nearCargoRopes","_ends","_end1","_end2"]; - _nearHelis = position player nearObjects ["Helicopter", 30]; - _nearCargoHelis = []; +ASL_Attach_Ropes_Action_Check = { + private ["_vehicle","_cargo"]; + _vehicle = player getVariable ["ASL_Ropes_Vehicle", objNull]; + _cargo = cursorTarget; + [_vehicle,_cargo] call ASL_Can_Attach_Ropes; +}; + +ASL_Can_Attach_Ropes = { + params ["_vehicle","_cargo"]; + if(!isNull _vehicle && !isNull _cargo) then { + [_vehicle,_cargo] call ASL_Is_Supported_Cargo && vehicle player == player && player distance _cargo < 10 && _vehicle != _cargo; + } else { + false; + }; +}; + + +ASL_Drop_Ropes = { + params ["_vehicle","_player"]; + if(local _vehicle) then { + private ["_helper"]; + _helper = (_player getVariable ["ASL_Ropes_Pick_Up_Helper", objNull]); + if(!isNull _helper) then { + { + _helper ropeDetach _x; + } forEach (_vehicle getVariable ["ASL_Ropes",[]]); + detach _helper; + deleteVehicle _helper; + }; + _player setVariable ["ASL_Ropes_Vehicle", nil,true]; + _player setVariable ["ASL_Ropes_Pick_Up_Helper", nil,true]; + } else { + [_this,"ASL_Drop_Ropes",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Drop_Ropes_Action = { + private ["_vehicle"]; + _vehicle = player getVariable ["ASL_Ropes_Vehicle", objNull]; + if([] call ASL_Can_Drop_Ropes) then { + [_vehicle, player] call ASL_Drop_Ropes; + }; +}; + +ASL_Drop_Ropes_Action_Check = { + [] call ASL_Can_Drop_Ropes; +}; + +ASL_Can_Drop_Ropes = { + !isNull (player getVariable ["ASL_Ropes_Vehicle", objNull]) && vehicle player == player; +}; + +ASL_Pickup_Ropes = { + params ["_vehicle","_player"]; + if(local _vehicle) then { + private ["_attachedObj","_helper"]; + { + _attachedObj = _x; + { + _attachedObj ropeDetach _x; + } forEach (_vehicle getVariable ["ASL_Ropes",[]]); + } forEach ropeAttachedObjects _vehicle; + _helper = "Land_Can_V2_F" createVehicle position _player; + { + [_helper, [0, 0, 0], [0,0,-1]] ropeAttachTo _x; + _helper attachTo [_player, [-0.1, 0.1, 0.15], "Pelvis"]; + } forEach (_vehicle getVariable ["ASL_Ropes",[]]); + hideObject _helper; + [[_helper],"ASL_Hide_Object_Global"] call ASL_RemoteExecServer; + _player setVariable ["ASL_Ropes_Vehicle", _vehicle,true]; + _player setVariable ["ASL_Ropes_Pick_Up_Helper", _helper,true]; + } else { + [_this,"ASL_Pickup_Ropes",_vehicle,true] call ASL_RemoteExec; + }; +}; + +ASL_Pickup_Ropes_Action = { + private ["_nearbyVehicles","_canPickupRopes","_vehicle"]; + _nearbyVehicles = missionNamespace getVariable ["ASL_Nearby_Vehicles",[]]; + if([] call ASL_Can_Pickup_Ropes) then { + + _vehicle = _nearbyVehicles select 0; + _canPickupRopes = true; + + if!(missionNamespace getVariable ["ASL_LOCKED_VEHICLES_ENABLED",false]) then { + if( locked _vehicle > 1 ) then { + ["Cannot pick up cargo ropes from locked vehicle",false] call ASL_Hint; + _canPickupRopes = false; + }; + }; + + if!(missionNamespace getVariable ["ASL_EXILE_SAFEZONE_ENABLED",false]) then { + if(!isNil "ExilePlayerInSafezone") then { + if( ExilePlayerInSafezone ) then { + ["Cannot pick up cargo ropes in safe zone",false] call ASL_Hint; + _canPickupRopes = false; + }; + }; + }; + + if(_canPickupRopes) then { + [_nearbyVehicles select 0, player] call ASL_Pickup_Ropes; + }; + + }; +}; + +ASL_Pickup_Ropes_Action_Check = { + [] call ASL_Can_Pickup_Ropes; +}; + +ASL_Can_Pickup_Ropes = { + isNull (player getVariable ["ASL_Ropes_Vehicle", objNull]) && count (missionNamespace getVariable ["ASL_Nearby_Vehicles",[]]) > 0 && vehicle player == player; +}; + +ASL_SUPPORTED_VEHICLES = [ + "Helicopter" +]; + +ASL_Is_Supported_Vehicle = { + params ["_vehicle","_isSupported"]; + _isSupported = false; + if(not isNull _vehicle) then { + { + if(_vehicle isKindOf _x) then { + _isSupported = true; + }; + } forEach (missionNamespace getVariable ["ASL_SUPPORTED_VEHICLES_OVERRIDE",ASL_SUPPORTED_VEHICLES]); + }; + _isSupported; +}; + +ASL_SLING_RULES = [ + ["Helicopter","CAN_SLING","All"] +]; + +ASL_Is_Supported_Cargo = { + params ["_vehicle","_cargo"]; + private ["_canSling"]; + _canSling = false; + if(not isNull _vehicle && not isNull _cargo) then { + { + if(_vehicle isKindOf (_x select 0)) then { + if(_cargo isKindOf (_x select 2)) then { + if( (toUpper (_x select 1)) == "CAN_SLING" ) then { + _canSling = true; + } else { + _canSling = false; + }; + }; + }; + } forEach (missionNamespace getVariable ["ASL_SLING_RULES_OVERRIDE",ASL_SLING_RULES]); + }; + _canSling; +}; + +ASL_Hint = { + params ["_msg",["_isSuccess",true]]; + if(!isNil "ExileClient_gui_notification_event_addNotification") then { + if(_isSuccess) then { + ["Success", [_msg]] call ExileClient_gui_notification_event_addNotification; + } else { + ["Whoops", [_msg]] call ExileClient_gui_notification_event_addNotification; + }; + } else { + hint _msg; + }; +}; + +ASL_Hide_Object_Global = { + params ["_obj"]; + if( _obj isKindOf "Land_Can_V2_F" ) then { + hideObjectGlobal _obj; + }; +}; + +ASL_Find_Nearby_Vehicles = { + private ["_nearVehicles","_nearVehiclesWithRopes","_vehicle","_ends","_end1","_end2"]; + _nearVehicles = []; { - _heli = _x; + _nearVehicles append (position player nearObjects [_x, 30]); + } forEach (missionNamespace getVariable ["ASL_SUPPORTED_VEHICLES_OVERRIDE",ASL_SUPPORTED_VEHICLES]); + _nearVehiclesWithRopes = []; + { + _vehicle = _x; { _ends = ropeEndPosition _x; if(count _ends == 2) then { _end1 = _ends select 0; _end2 = _ends select 1; if(((position player) distance _end1) < 5 || ((position player) distance _end2) < 5 ) then { - if!(_heli in _nearCargoHelis) then { - _nearCargoHelis = _nearCargoHelis + [_heli]; - } + _nearVehiclesWithRopes pushBack _vehicle; } }; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - } forEach _nearHelis; - _nearCargoHelis; + } forEach (_vehicle getVariable ["ASL_Ropes",[]]); + } forEach _nearVehicles; + _nearVehiclesWithRopes; }; -SA_Rope_Rappel_To_Groud = { - private ["_heli","_player"]; - _heli = [_this,0] call BIS_fnc_param; - _player = [_this,1] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - _fastRope = _heli getVariable ["sa_rope_fast_ropes",[objNull]] select 0; - if(!isNull _fastRope) then { - _ends = ropeEndPosition _fastRope; - if(count _ends == 2) then { - unassignVehicle _player; - (_player) action ["getOut", _heli]; - _end1 = _ends select 0; - _end2 = _ends select 1; - if((_end1 select 2) < (_end2 select 2)) then { - _player setPos _end1; - } else { - _player setPos _end2; - }; - }; - }; - }; -}; +ASL_Add_Player_Actions = { -SA_Rope_Deploy_Fast_Ropes = { - private ["_heli","_fastRopesDeployed","_fastRopes"]; - _heli = [_this,0] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - _fastRopesDeployed = _heli getVariable ["sa_rope_fast_ropes_deployed",false]; - if(!_fastRopesDeployed) then { - _heli setVariable ["sa_rope_fast_ropes_deployed",true,true]; - _fastRopes = _heli getVariable ["sa_rope_fast_ropes",[]]; - { ropeDestroy _x } forEach _fastRopes; - _fastRopes = _fastRopes + [ropeCreate [_heli, "fastrope0", 0]]; - { - ropeUnwind [_x, 5, 25]; - } forEach _fastRopes; - _heli setVariable ["sa_rope_fast_ropes",_fastRopes,true]; - }; - }; -}; + player addAction ["Extend Cargo Ropes", { + [] call ASL_Extend_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Extend_Ropes_Action_Check"]; + + player addAction ["Shorten Cargo Ropes", { + [] call ASL_Shorten_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Shorten_Ropes_Action_Check"]; + + player addAction ["Release Cargo", { + [] call ASL_Release_Cargo_Action; + }, nil, 0, false, true, "", "call ASL_Release_Cargo_Action_Check"]; + + player addAction ["Retract Cargo Ropes", { + [] call ASL_Retract_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Retract_Ropes_Action_Check"]; + + player addAction ["Deploy Cargo Ropes", { + [] call ASL_Deploy_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Deploy_Ropes_Action_Check"]; -SA_Rope_Retract_Cargo_Ropes = { - private ["_heli","_cargoRopesDeployed"]; - _heli = [_this,0] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - _cargoRopesDeployed = _heli getVariable ["sa_rope_cargo_ropes_deployed",false]; - if(_cargoRopesDeployed) then { - { - [_x,_heli] spawn { - private ["_rope","_count","_heli"]; - _rope = [_this,0] call BIS_fnc_param; - _heli = [_this,1] call BIS_fnc_param; - _count = 0; - ropeUnwind [_rope, 3, 0]; - while {(!ropeUnwound _rope) && _count < 20} do { - sleep 1; - _count = _count + 1; - }; - ropeDestroy _rope; - _heli setVariable ["sa_rope_cargo_ropes_deployed",false,true]; - _heli setVariable ["sa_rope_cargo_ropes",[],true]; - }; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - }; - }; -}; + player addAction ["Put Away Cargo Ropes", { + [] call ASL_Put_Away_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Put_Away_Ropes_Action_Check"]; -SA_Rope_Extend_Cargo_Ropes = { - private ["_heli","_cargoRopesDeployed","_lengthOffset"]; - _heli = [_this,0] call BIS_fnc_param; - _lengthOffset = [_this,1] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - _cargoRopesDeployed = _heli getVariable ["sa_rope_cargo_ropes_deployed",false]; - if(_cargoRopesDeployed) then { - { - ropeUnwind [_x, 3, _lengthOffset, true]; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - }; - }; -}; + player addAction ["Attach To Cargo Ropes", { + [] call ASL_Attach_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Attach_Ropes_Action_Check"]; -SA_Rope_Shorten_Cargo_Ropes = { - private ["_heli","_cargoRopesDeployed","_lengthOffset"]; - _heli = [_this,0] call BIS_fnc_param; - _lengthOffset = [_this,1] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - _cargoRopesDeployed = _heli getVariable ["sa_rope_cargo_ropes_deployed",false]; - if(_cargoRopesDeployed) then { - { - scopeName "ropeloop"; - if(ropeLength _x <= 2) then { - [_heli] call SA_Rope_Release_Cargo; - breakOut "ropeloop"; - } else { - ropeUnwind [_x, 3, _lengthOffset, true]; - }; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - }; - }; -}; + player addAction ["Drop Cargo Ropes", { + [] call ASL_Drop_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Drop_Ropes_Action_Check"]; -SA_Rope_Release_Cargo = { - private ["_heli","_cargoRopesDeployed","_originalMass"]; - _heli = [_this,0] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - { - _attachedObj = _x; - { - _attachedObj ropeDetach _x; - } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]); - } forEach ropeAttachedObjects _heli; - [_heli] call SA_Rope_Retract_Cargo_Ropes; - }; -}; - -SA_Rope_Retract_Fast_Ropes = { - private ["_heli","_fastRopesDeployed"]; - _heli = [_this,0] call BIS_fnc_param; - if( _heli isKindOf "Helicopter" ) then { - _fastRopesDeployed = _heli getVariable ["sa_rope_fast_ropes_deployed",false]; - if(_fastRopesDeployed) then { - _heli setVariable ["sa_rope_fast_ropes_retracted",true,true]; - { - [_x,_heli] spawn { - private ["_rope","_count","_heli"]; - _rope = [_this,0] call BIS_fnc_param; - _heli = [_this,1] call BIS_fnc_param; - _count = 0; - ropeUnwind [_rope, 3, 0]; - while {(!ropeUnwound _rope) && _count < 20} do { - sleep 1; - _count = _count + 1; - }; - ropeDestroy _rope; - _heli setVariable ["sa_rope_fast_ropes_deployed",false,true]; - _heli setVariable ["sa_rope_fast_ropes",[],true]; - }; - } forEach (_heli getVariable ["sa_rope_fast_ropes",[]]); - }; - }; -}; - -SA_Rope_Action_Check = { - vehicle player isKindOf "Helicopter"; -}; - -if(!isDedicated) then { - player addAction ["Ropes", { - SA_Rope_Action_Menu = call SA_Rope_Build_Action_Menu; - showCommandingMenu "#USER:SA_Rope_Action_Menu"; - }, nil, 0, false, true, "", "call SA_Rope_Action_Check"]; + player addAction ["Pickup Cargo Ropes", { + [] call ASL_Pickup_Ropes_Action; + }, nil, 0, false, true, "", "call ASL_Pickup_Ropes_Action_Check"]; player addEventHandler ["Respawn", { - player addAction ["Ropes", { - SA_Rope_Action_Menu = call SA_Rope_Build_Action_Menu; - showCommandingMenu "#USER:SA_Rope_Action_Menu"; - }, nil, 0, false, true, "", "call SA_Rope_Action_Check"]; + player setVariable ["ASL_Actions_Loaded",false]; }]; + }; if(!isDedicated) then { [] spawn { - private ["_cargoHelisWithActions","_nearCargoHelis","_action","_cargoHelisNotNearbyWithActions"]; - _cargoHelisWithActions = []; while {true} do { - _nearCargoHelis = call SA_Rope_Find_Nearby_Cargo_Heli; - { - if!( _x in _cargoHelisWithActions ) then { - _action = player addAction ["Pick Up Cargo Ropes", { - [[_this select 3, player],"SA_Rope_Pickup_Cargo_Ropes",_this select 3,false,true] spawn BIS_fnc_MP - //[_this select 3] call SA_Rope_Pickup_Cargo_Ropes; - }, _x, 0, false, true, "", "call SA_Rope_Pickup_Rope_Action_Check"]; - _x setVariable ["SA_Rope_Pickup_Action", _action]; - _action = player addAction ["Drop Cargo Ropes", { - [[_this select 3, player],"SA_Rope_Drop_Cargo_Ropes",_this select 3,false,true] spawn BIS_fnc_MP - //[_this select 3] call SA_Rope_Drop_Cargo_Ropes; - }, _x, 0, false, true, "", "call SA_Rope_Drop_Rope_Action_Check"]; - _x setVariable ["SA_Rope_Drop_Action", _action]; - _action = player addAction ["Attach Cargo Ropes", { - [[_this select 3, player, cursorTarget],"SA_Rope_Attach_Cargo_Ropes",_this select 3,false,true] spawn BIS_fnc_MP - //[_this select 3] call SA_Rope_Attach_Cargo_Ropes; - }, _x, 0, false, true, "", "call SA_Rope_Attach_Rope_Action_Check"]; - _x setVariable ["SA_Rope_Attach_Action", _action]; + if(!isNull player && isPlayer player) then { + if!( player getVariable ["ASL_Actions_Loaded",false] ) then { + [] call ASL_Add_Player_Actions; + player setVariable ["ASL_Actions_Loaded",true]; }; - } forEach _nearCargoHelis; - _cargoHelisNotNearbyWithActions = _cargoHelisWithActions - _nearCargoHelis; - { - player removeAction (_x getVariable "SA_Rope_Pickup_Action"); - player removeAction (_x getVariable "SA_Rope_Drop_Action"); - player removeAction (_x getVariable "SA_Rope_Attach_Action"); - } forEach _cargoHelisNotNearbyWithActions; - _cargoHelisWithActions = _nearCargoHelis; + }; + missionNamespace setVariable ["ASL_Nearby_Vehicles", (call ASL_Find_Nearby_Vehicles)]; sleep 2; }; }; }; -} remoteExecCall ["bis_fnc_call", 0,true]; +ASL_RemoteExec = { + params ["_params","_functionName","_target",["_isCall",false]]; + if(!isNil "ExileClient_system_network_send") then { + ["AdvancedSlingLoadingRemoteExecClient",[_params,_functionName,_target,_isCall]] call ExileClient_system_network_send; + } else { + if(_isCall) then { + _params remoteExecCall [_functionName, _target]; + } else { + _params remoteExec [_functionName, _target]; + }; + }; +}; + +ASL_RemoteExecServer = { + params ["_params","_functionName",["_isCall",false]]; + if(!isNil "ExileClient_system_network_send") then { + ["AdvancedSlingLoadingRemoteExecServer",[_params,_functionName,_isCall]] call ExileClient_system_network_send; + } else { + if(_isCall) then { + _params remoteExecCall [_functionName, 2]; + } else { + _params remoteExec [_functionName, 2]; + }; + }; +}; + +if(isServer) then { + + // Adds support for exile network calls (Only used when running exile) // + + ASL_SUPPORTED_REMOTEEXECSERVER_FUNCTIONS = ["ASL_Hide_Object_Global"]; + + ExileServer_AdvancedSlingLoading_network_AdvancedSlingLoadingRemoteExecServer = { + params ["_sessionId", "_messageParameters",["_isCall",false]]; + _messageParameters params ["_params","_functionName"]; + if(_functionName in ASL_SUPPORTED_REMOTEEXECSERVER_FUNCTIONS) then { + if(_isCall) then { + _params call (missionNamespace getVariable [_functionName,{}]); + } else { + _params spawn (missionNamespace getVariable [_functionName,{}]); + }; + }; + }; + + ASL_SUPPORTED_REMOTEEXECCLIENT_FUNCTIONS = ["ASL_Extend_Ropes","ASL_Shorten_Ropes","ASL_Release_Cargo","ASL_Retract_Ropes","ASL_Deploy_Ropes","ASL_Put_Away_Ropes","ASL_Hint","ASL_Attach_Ropes","ASL_Drop_Ropes"]; + + ExileServer_AdvancedSlingLoading_network_AdvancedSlingLoadingRemoteExecClient = { + params ["_sessionId", "_messageParameters"]; + _messageParameters params ["_params","_functionName","_target",["_isCall",false]]; + if(_functionName in ASL_SUPPORTED_REMOTEEXECCLIENT_FUNCTIONS) then { + if(_isCall) then { + _params remoteExecCall [_functionName, _target]; + } else { + _params remoteExec [_functionName, _target]; + }; + }; + }; + + // Install Advanced Sling Loading on all clients (plus JIP) // + + publicVariable "ASL_Advanced_Sling_Loading_Install"; + remoteExecCall ["ASL_Advanced_Sling_Loading_Install", -2,true]; + +}; + +diag_log "Advanced Sling Loading Loaded"; + +}; + +if(isServer) then { + [] call ASL_Advanced_Sling_Loading_Install; +}; +