Skip to content

Commit

Permalink
Merge pull request #10 from sethduda/1.4
Browse files Browse the repository at this point in the history
Updates to actions
  • Loading branch information
sethduda committed Mar 27, 2016
2 parents d7519b2 + 2e75836 commit 12ae5d1
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 86 deletions.
Binary file modified addons/SA_AdvancedTowing.pbo
Binary file not shown.
Binary file modified addons/SA_AdvancedTowing.pbo.AdvancedTowing.bisign
Binary file not shown.
253 changes: 167 additions & 86 deletions addons/SA_AdvancedTowing/functions/fn_advancedTowingInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -348,24 +348,6 @@ SA_Take_Tow_Ropes = {
};
};

SA_Put_Away_Tow_Ropes = {
params ["_vehicle","_player"];
if(local _vehicle) then {
private ["_existingTowRopes","_hitchPoint","_rope"];
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
if(count _existingTowRopes > 0) then {
_this call SA_Pickup_Tow_Ropes;
_this call SA_Drop_Tow_Ropes;
{
ropeDestroy _x;
} forEach _existingTowRopes;
_vehicle setVariable ["SA_Tow_Ropes",nil,true];
};
} else {
[_this,"SA_Put_Away_Tow_Ropes",_vehicle,true] call SA_RemoteExec;
};
};

SA_Pickup_Tow_Ropes = {
params ["_vehicle","_player"];
if(local _vehicle) then {
Expand All @@ -375,6 +357,7 @@ SA_Pickup_Tow_Ropes = {
{
_attachedObj ropeDetach _x;
} forEach (_vehicle getVariable ["SA_Tow_Ropes",[]]);
deleteVehicle _attachedObj;
} forEach ropeAttachedObjects _vehicle;
_helper = "Land_Can_V2_F" createVehicle position _player;
{
Expand Down Expand Up @@ -409,69 +392,154 @@ SA_Drop_Tow_Ropes = {
};
};

SA_Attach_Tow_Ropes_Action = {
private ["_vehicle","_towVehicle"];
_vehicle = cursorTarget;
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
if([_vehicle] call SA_Can_Attach_Tow_Ropes) then {
[_vehicle,player] call SA_Attach_Tow_Ropes;
SA_Put_Away_Tow_Ropes = {
params ["_vehicle","_player"];
if(local _vehicle) then {
private ["_existingTowRopes","_hitchPoint","_rope"];
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
if(count _existingTowRopes > 0) then {
_this call SA_Pickup_Tow_Ropes;
_this call SA_Drop_Tow_Ropes;
{
ropeDestroy _x;
} forEach _existingTowRopes;
_vehicle setVariable ["SA_Tow_Ropes",nil,true];
};
} else {
false;
[_this,"SA_Put_Away_Tow_Ropes",_vehicle,true] call SA_RemoteExec;
};
};

SA_Attach_Tow_Ropes_Action_Check = {
private ["_vehicle","_towVehicle","_isCargoBeingTowed","_isCargoTowingCargo","_isChainingEnabled","_isTowVehicleBeingTowed","_isTowVehicleTowingCargo"];
_vehicle = cursorTarget;
[_vehicle] call SA_Can_Attach_Tow_Ropes;
};

SA_Can_Attach_Tow_Ropes = {
params ["_cargo"];
private ["_towVehicle","_canBeTowed"];
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
if(!isNull _towVehicle && !isNull _cargo) then {
_canBeTowed = [_towVehicle,_cargo] call SA_Is_Supported_Cargo && vehicle player == player && player distance _cargo < 10 && _towVehicle != _cargo;
SA_Attach_Tow_Ropes_Action = {
private ["_vehicle","_cargo","_canBeTowed"];
_cargo = cursorTarget;
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
if([_vehicle,_cargo] call SA_Can_Attach_Tow_Ropes) then {

_canBeTowed = true;

if!(missionNamespace getVariable ["SA_TOW_LOCKED_VEHICLES_ENABLED",false]) then {
_canBeTowed = _canBeTowed && locked _cargo <= 1;
if( locked _cargo > 1 ) then {
["Cannot attach tow ropes to locked vehicle",false] call SA_Hint;
_canBeTowed = false;
};
};

if!(missionNamespace getVariable ["SA_TOW_IN_EXILE_SAFEZONE_ENABLED",false]) then {
if(!isNil "ExilePlayerInSafezone") then {
_canBeTowed = _canBeTowed && !ExilePlayerInSafezone;
if( ExilePlayerInSafezone ) then {
["Cannot attach tow ropes in safe zone",false] call SA_Hint;
_canBeTowed = false;
};
};
};
_canBeTowed;

if(_canBeTowed) then {
[_cargo,player] call SA_Attach_Tow_Ropes;
};

};
};

SA_Attach_Tow_Ropes_Action_Check = {
private ["_vehicle","_cargo"];
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
_cargo = cursorTarget;
[_vehicle,_cargo] call SA_Can_Attach_Tow_Ropes;
};

SA_Can_Attach_Tow_Ropes = {
params ["_vehicle","_cargo"];
if(!isNull _vehicle && !isNull _cargo) then {
[_vehicle,_cargo] call SA_Is_Supported_Cargo && vehicle player == player && player distance _cargo < 10 && _vehicle != _cargo;
} else {
false;
};
};

SA_Attach_Tow_Ropes_Action_Disabled_Check = {
private ["_vehicle","_towVehicle"];
SA_Take_Tow_Ropes_Action = {
private ["_vehicle","_canTakeTowRopes"];
_vehicle = cursorTarget;
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
if(!isNull _towVehicle && !isNull _vehicle) then {
not([_towVehicle,_vehicle] call SA_Is_Supported_Cargo) && vehicle player == player && player distance _vehicle < 10 && _towVehicle != _vehicle;
} else {
false;
if([_vehicle] call SA_Can_Take_Tow_Ropes) then {

_canTakeTowRopes = true;

if!(missionNamespace getVariable ["SA_TOW_LOCKED_VEHICLES_ENABLED",false]) then {
if( locked _vehicle > 1 ) then {
["Cannot take tow ropes from locked vehicle",false] call SA_Hint;
_canTakeTowRopes = false;
};
};

if!(missionNamespace getVariable ["SA_TOW_IN_EXILE_SAFEZONE_ENABLED",false]) then {
if(!isNil "ExilePlayerInSafezone") then {
if( ExilePlayerInSafezone ) then {
["Cannot take tow ropes in safe zone",false] call SA_Hint;
_canTakeTowRopes = false;
};
};
};

if(_canTakeTowRopes) then {
[_vehicle,player] call SA_Take_Tow_Ropes;
};

};
};

SA_Take_Tow_Ropes_Action_Check = {
private ["_vehicle"];
_vehicle = cursorTarget;
[cursorTarget] call SA_Can_Take_Tow_Ropes;
};

SA_Can_Take_Tow_Ropes = {
params ["_vehicle"];
if([_vehicle] call SA_Is_Supported_Vehicle) then {
private ["_existingVehicle","_existingTowRopes"];
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
vehicle player == player && player distance _vehicle < 10 && (count _existingTowRopes) == 0 && isNull _towVehicle;
_existingVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
vehicle player == player && player distance _vehicle < 10 && (count _existingTowRopes) == 0 && isNull _existingVehicle;
} else {
false;
};
};

SA_Put_Away_Tow_Ropes_Action_Check = {
private ["_vehicle"];
SA_Put_Away_Tow_Ropes_Action = {
private ["_vehicle","_canPutAwayTowRopes"];
_vehicle = cursorTarget;
if([_vehicle] call SA_Can_Put_Away_Tow_Ropes) then {

_canPutAwayTowRopes = true;

if!(missionNamespace getVariable ["SA_TOW_LOCKED_VEHICLES_ENABLED",false]) then {
if( locked _vehicle > 1 ) then {
["Cannot put away tow ropes in locked vehicle",false] call SA_Hint;
_canPutAwayTowRopes = false;
};
};

if!(missionNamespace getVariable ["SA_TOW_IN_EXILE_SAFEZONE_ENABLED",false]) then {
if(!isNil "ExilePlayerInSafezone") then {
if( ExilePlayerInSafezone ) then {
["Cannot put away tow ropes in safe zone",false] call SA_Hint;
_canPutAwayTowRopes = false;
};
};
};

if(_canPutAwayTowRopes) then {
[_vehicle,player] call SA_Put_Away_Tow_Ropes;
};

};
};

SA_Put_Away_Tow_Ropes_Action_Check = {
[cursorTarget] call SA_Can_Put_Away_Tow_Ropes;
};

SA_Can_Put_Away_Tow_Ropes = {
params ["_vehicle"];
private ["_existingTowRopes"];
if([_vehicle] call SA_Is_Supported_Vehicle) then {
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
vehicle player == player && player distance _vehicle < 10 && (count _existingTowRopes) > 0;
Expand All @@ -480,28 +548,62 @@ SA_Put_Away_Tow_Ropes_Action_Check = {
};
};


SA_Drop_Tow_Ropes_Action = {
private ["_vehicle"];
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
if([] call SA_Can_Drop_Tow_Ropes) then {
[_vehicle, player] call SA_Drop_Tow_Ropes;
};
};

SA_Drop_Tow_Ropes_Action_Check = {
!isNull (player getVariable ["SA_Tow_Ropes_Vehicle", objNull]) && vehicle player == player;
[] call SA_Can_Drop_Tow_Ropes;
};

SA_Pickup_Tow_Ropes_Action_Check = {
isNull (player getVariable ["SA_Tow_Ropes_Vehicle", objNull]) && count (missionNamespace getVariable ["SA_Nearby_Tow_Vehicles",[]]) > 0 && vehicle player == player;
SA_Can_Drop_Tow_Ropes = {
!isNull (player getVariable ["SA_Tow_Ropes_Vehicle", objNull]) && vehicle player == player;
};



SA_Pickup_Tow_Ropes_Action = {
private ["_nearbyTowVehicles"];
private ["_nearbyTowVehicles","_canPickupTowRopes","_vehicle"];
_nearbyTowVehicles = missionNamespace getVariable ["SA_Nearby_Tow_Vehicles",[]];
if(count _nearbyTowVehicles > 0) then {
[_nearbyTowVehicles select 0, player] call SA_Pickup_Tow_Ropes;
if([] call SA_Can_Pickup_Tow_Ropes) then {

_vehicle = _nearbyTowVehicles select 0;
_canPickupTowRopes = true;

if!(missionNamespace getVariable ["SA_TOW_LOCKED_VEHICLES_ENABLED",false]) then {
if( locked _vehicle > 1 ) then {
["Cannot pick up tow ropes from locked vehicle",false] call SA_Hint;
_canPickupTowRopes = false;
};
};

if!(missionNamespace getVariable ["SA_TOW_IN_EXILE_SAFEZONE_ENABLED",false]) then {
if(!isNil "ExilePlayerInSafezone") then {
if( ExilePlayerInSafezone ) then {
["Cannot pick up tow ropes in safe zone",false] call SA_Hint;
_canPickupTowRopes = false;
};
};
};

if(_canPickupTowRopes) then {
[_nearbyTowVehicles select 0, player] call SA_Pickup_Tow_Ropes;
};

};
};

SA_Drop_Tow_Ropes_Action = {
private ["_vehicle"];
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
if(!isNull _vehicle) then {
[_vehicle, player] call SA_Drop_Tow_Ropes;
};
SA_Pickup_Tow_Ropes_Action_Check = {
[] call SA_Can_Pickup_Tow_Ropes;
};

SA_Can_Pickup_Tow_Ropes = {
isNull (player getVariable ["SA_Tow_Ropes_Vehicle", objNull]) && count (missionNamespace getVariable ["SA_Nearby_Tow_Vehicles",[]]) > 0 && vehicle player == player;
};

SA_TOW_SUPPORTED_VEHICLES = [
Expand Down Expand Up @@ -575,23 +677,6 @@ SA_Set_Owner = {
_obj setOwner _client;
};

SA_Take_Tow_Ropes_Action = {
private ["_vehicle"];
_vehicle = cursorTarget;
if([_vehicle] call SA_Is_Supported_Vehicle) then {
[_vehicle,player] call SA_Take_Tow_Ropes;
};
};


SA_Put_Away_Tow_Ropes_Action = {
private ["_vehicle"];
_vehicle = cursorTarget;
if([_vehicle] call SA_Is_Supported_Vehicle) then {
[_vehicle,player] call SA_Put_Away_Tow_Ropes;
};
};

SA_Add_Player_Tow_Actions = {

player addAction ["Deploy Tow Ropes", {
Expand All @@ -606,10 +691,6 @@ SA_Add_Player_Tow_Actions = {
[] call SA_Attach_Tow_Ropes_Action;
}, nil, 0, false, true, "", "call SA_Attach_Tow_Ropes_Action_Check"];

player addAction ["Cannot Attach Tow Ropes", {
["Your vehicle not strong enough. Find a larger vehicle!",false] call SA_Hint;
}, nil, 0, false, true, "", "call SA_Attach_Tow_Ropes_Action_Disabled_Check"];

player addAction ["Drop Tow Ropes", {
[] call SA_Drop_Tow_Ropes_Action;
}, nil, 0, false, true, "", "call SA_Drop_Tow_Ropes_Action_Check"];
Expand Down

0 comments on commit 12ae5d1

Please sign in to comment.