StonedReality

Advanced Sling Load Help

21 posts in this topic

I would love to use the advanced sling load mod in Exile but no matter if I install the addon or script version it doesn't seem to work.  Using the script version, I call the file in the init.sqf with [] execVM "fn_advancedSlingLoadingInit.sqf"; 

I also tried it with:

if(hasInterface) then{
   [] execVM "fn_advancedSlingLoadingInit.sqf"; 
};

Adding it to my server as an addon seems to load ok, no errors. But still nothing in game. 

Does the script itself need editing to make it compatible?  Any help gratefully received.

This is the file for the script version.

Spoiler

{

if(!isNil "SA_ROPE_INIT" || !hasInterface) exitWith {};

SA_ROPE_INIT = true;

SA_Rope_Get_Lift_Capability = {
    private ["_heli","_heliType"];
    _heli = [_this,0] call BIS_fnc_param;
    _heliType = toLower(typeOf _heli);
    _returnVal = [500,0];
    if(
        //(_heliType) == toLower("B_Heli_Transport_01_F") ||
        //(_heliType) == toLower("B_Heli_Transport_01_camo_F") ||
        (_heliType) == toLower("I_Heli_Transport_02_F")
    ) then {
        _returnVal = [4000,100000];
    };
    if(
        (_heliType) == toLower("B_Heli_Transport_03_F") ||
        (_heliType) == toLower("B_Heli_Transport_03_unarmed_F")
    ) then {
        _returnVal = [10000,100000];
    };
    if(
        (_heliType) == toLower("O_Heli_Transport_04_F") ||
        (_heliType) == toLower("O_Heli_Transport_04_ammo_F")
    ) then {
        _returnVal = [12000,100000];
    };
    _returnVal;
};

SA_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 = {
    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];
    // Is mass adjustment needed?
    if( _originalMass >= ((_lift select 0)*0.8) && _originalMass <= _lift select 1 ) then {
        private ["_originalMassSet","_ends","_endDistance","_ropeLength"];
        _originalMassSet = (getMass _obj) == _originalMass;
        while { _obj in (ropeAttachedObjects _heli) && _originalMassSet } do {
            {
                _ends = ropeEndPosition _x;
                _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;
                    _originalMassSet = false;
                };
            } forEach _ropes;
            sleep 0.1;
        };
        while { _obj in (ropeAttachedObjects _heli) } do {
            sleep 0.5;
        };
        [[_obj, _originalMass],"SA_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"]];
            };
            _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 {
                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"]];
                };
            };
                
        };

        /*
        _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"]];
            }
        };
        */
        
    };
    
    _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];
        };
    };
};

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;
        } 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);    
            
            [_target, _heli, _ropes] spawn SA_Rope_Adjust_Mass;        
        };
    };
};

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;
    };
    _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 = [];
    {
        _heli = _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];
                    }
                }
            };
        } forEach (_heli getVariable ["sa_rope_cargo_ropes",[]]);
    } forEach _nearHelis;
    _nearCargoHelis;
};

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;
                };
            };
        };
    };
};

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];
        };
    };
};

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",[]]);
        };
    };
};

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",[]]);
        };
    };
};

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",[]]);
        };
    };
};

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 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"];
    }];
};

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];
                };
            } 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;
            sleep 2;
        };
    };
};

} remoteExecCall ["bis_fnc_call", 0,true];

 

Share this post


Link to post
Share on other sites
Advertisement

This is the reply I got on bohemia forums.  Bit above my paygrade to re-write it.
 

Quote

it is because this script makes use of BIS_fnc_MP which is blocked by exile. you would need to change the script to use RemoteExecCall and whitelist it or disable the whitelist entirely.

 

 

Share this post


Link to post
Share on other sites
1 hour ago, StonedReality said:

This is the reply I got on bohemia forums.  Bit above my paygrade to re-write it.
 

 

I will try to look into it, no promises, my scripting skills aren't exactly the best, nonetheless I'll contact the author and ask permissions to re-write it with RemoteExecCall instead of BIS_fnc_MP. :)

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, StonedReality said:

@ka0s Just wondered if you had any joy with this?

Haven't really got around it yet, Duda the author just released a advanced tow script as well, works in the same way, towing behind your vehicle. Will see if I can merge both of them, but I have had far too many tasks on hand to get a real good look at it yet. :)

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.