Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions addons/advancedslingloading/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
PREP(addPlayerActions);
PREP(attachRopes);
PREP(attachRopesAction);
PREP(attachRopesActionCheck);
PREP(canAttachRopes);
PREP(canDeployRopes);
PREP(canDropRopes);
PREP(canExtendRopes);
PREP(canPickupRopes);
PREP(canReleaseCargo);
PREP(canRetractRopes);
PREP(canShortenRopes);
PREP(deployRopes);
PREP(deployRopesAction);
PREP(deployRopesActionCheck);
PREP(deployRopesCountAction);
PREP(deployRopesIndex);
PREP(deployRopesIndexAction);
PREP(dropRopes);
PREP(dropRopesAction);
PREP(dropRopesActionCheck);
PREP(extendRopes);
PREP(extendRopesAction);
PREP(extendRopesActionCheck);
PREP(extendRopesIndexAction);
PREP(findNearbyVehicles);
PREP(getActiveRopes);
PREP(getActiveRopesWithCargo);
PREP(getActiveRopesWithoutCargo);
PREP(getCargo);
PREP(getClosestRope);
PREP(getCornerPoints);
PREP(getInactiveRopes);
PREP(getRopes);
PREP(getRopesAndCargo);
PREP(getRopesCount);
PREP(getSlingLoadPoints);
PREP(hideObjectGlobal);
PREP(hint);
PREP(initAdvancedSlingLoading);
PREP(isSupportedCargo);
PREP(isSupportedVehicle);
PREP(pickupRopes);
PREP(pickupRopesAction);
PREP(pickupRopesActionCheck);
PREP(releaseCargo);
PREP(releaseCargoAction);
PREP(releaseCargoActionCheck);
PREP(releaseCargoIndexAction);
PREP(remoteExec);
PREP(remoteExecServer);
PREP(retractRopes);
PREP(retractRopesAction);
PREP(retractRopesActionCheck);
PREP(retractRopesIndexAction);
PREP(ropeAdjustMass);
PREP(ropeGetLiftCapability);
PREP(ropeSetMass);
PREP(shortenRopes);
PREP(shortenRopesAction);
PREP(shortenRopesActionCheck);
PREP(shortenRopesIndexAction);
PREP(showSelectRopesMenu);
2 changes: 1 addition & 1 deletion addons/advancedslingloading/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ class CfgPatches {
};
};

#include "CfgFunctions.hpp"
#include "CfgEventhandlers.hpp"
#include "CfgNetworkMessages.hpp"
52 changes: 52 additions & 0 deletions addons/advancedslingloading/functions/fnc_addPlayerActions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Adds player actions for advanced sling loading
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ttt_advancedslingloading_fnc_addPlayerActions
*
* Public: No
*/

player addAction ["Extend Cargo Ropes", {
[] call FUNC(extendRopesAction);
}, nil, 0, false, true, "", "call FUNC(extendRopesActionCheck)"];

player addAction ["Shorten Cargo Ropes", {
[] call FUNC(shortenRopesAction);
}, nil, 0, false, true, "", "call FUNC(shortenRopesActionCheck)"];

player addAction ["Release Cargo", {
[] call FUNC(releaseCargoAction);
}, nil, 0, false, true, "", "call FUNC(releaseCargoActionCheck)"];

player addAction ["Retract Cargo Ropes", {
[] call FUNC(retractRopesAction);
}, nil, 0, false, true, "", "call FUNC(retractRopesActionCheck)"];

player addAction ["Deploy Cargo Ropes", {
[] call FUNC(deployRopesAction);
}, nil, 0, false, true, "", "call FUNC(deployRopesActionCheck)"];

player addAction ["Attach To Cargo Ropes", {
[] call FUNC(attachRopesAction);
}, nil, 0, false, true, "", "call FUNC(attachRopesActionCheck)"];

player addAction ["Drop Cargo Ropes", {
[] call FUNC(dropRopesAction);
}, nil, 0, false, true, "", "call FUNC(dropRopesActionCheck)"];

player addAction ["Pickup Cargo Ropes", {
[] call FUNC(pickupRopesAction);
}, nil, 0, false, true, "", "call FUNC(pickupRopesActionCheck)"];

player addEventHandler ["Respawn", {
player setVariable ["ASL_Actions_Loaded", false];
}];
48 changes: 48 additions & 0 deletions addons/advancedslingloading/functions/fnc_attachRopes.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Attaches ropes to cargo
*
* Arguments:
* 0: Cargo <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_cargo, player] call ttt_advancedslingloading_fnc_attachRopes
*
* Public: No
*/

params ["_cargo", "_player"];
_vehicleWithIndex = _player getVariable ["ASL_Ropes_Vehicle", [objNull, 0]];
_vehicle = _vehicleWithIndex select 0;
if (!isNull _vehicle) then {
if (local _vehicle) then {
private _ropes = [_vehicle, (_vehicleWithIndex select 1)] call FUNC(getRopes);
if (count _ropes == 4) then {
private _attachmentPoints = [_cargo] call FUNC(getCornerPoints);
private _ropeLength = (ropeLength (_ropes select 0));
private _objDistance = (_cargo distance _vehicle) + 2;
if (_objDistance > _ropeLength) then {
[["The cargo ropes are too short. Move vehicle closer.", false], "ASL_Hint", _player] call FUNC(remoteExec);
} else {
[_vehicle, _player, (_vehicleWithIndex select 1)] call FUNC(dropRopes);
[_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);
private _allCargo = _vehicle getVariable ["ASL_Cargo", []];
_allCargo set [(_vehicleWithIndex select 1), _cargo];
_vehicle setVariable ["ASL_Cargo", _allCargo, true];
if (missionNamespace getVariable ["ASL_HEAVY_LIFTING_ENABLED", false]) then {
[_cargo, _vehicle, _ropes] spawn FUNC(ropeAdjustMass);
};
};
};
} else {
[_this, "ASL_Attach_Ropes", _vehicle, true] call FUNC(remoteExec);
};
};
45 changes: 45 additions & 0 deletions addons/advancedslingloading/functions/fnc_attachRopesAction.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Action handler for attaching ropes to cargo
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ttt_advancedslingloading_fnc_attachRopesAction
*
* Public: No
*/

private ["_vehicle", "_cargo", "_canBeAttached"];
_cargo = cursorTarget;
_vehicle = (player getVariable ["ASL_Ropes_Vehicle", [objNull, 0]]) select 0;
if ([_vehicle, _cargo] call FUNC(canAttachRopes)) 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 FUNC(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 FUNC(hint);
_canBeAttached = false;
};
};
};

if (_canBeAttached) then {
[_cargo, player] call FUNC(attachRopes);
};

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Action check for attaching ropes
*
* Arguments:
* None
*
* Return Value:
* Can attach ropes <BOOL>
*
* Example:
* [] call ttt_advancedslingloading_fnc_attachRopesActionCheck
*
* Public: No
*/

private ["_vehicleWithIndex", "_cargo"];
_vehicleWithIndex = player getVariable ["ASL_Ropes_Vehicle", [objNull, 0]];
_cargo = cursorTarget;
[_vehicleWithIndex select 0, _cargo] call FUNC(canAttachRopes);
24 changes: 24 additions & 0 deletions addons/advancedslingloading/functions/fnc_canAttachRopes.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Checks if ropes can be attached to cargo
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Cargo <OBJECT>
*
* Return Value:
* Can attach ropes <BOOL>
*
* Example:
* [_vehicle, _cargo] call ttt_advancedslingloading_fnc_canAttachRopes
*
* Public: No
*/

params ["_vehicle", "_cargo"];
if (!isNull _vehicle && !isNull _cargo) then {
[_vehicle, _cargo] call FUNC(isSupportedCargo) && isNull objectParent player && player distance _cargo < ASL_PICKUP_DISTANCE && _vehicle != _cargo;
} else {
false;
};
27 changes: 27 additions & 0 deletions addons/advancedslingloading/functions/fnc_canDeployRopes.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Checks if ropes can be deployed
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* Can deploy ropes <BOOL>
*
* Example:
* [_vehicle] call ttt_advancedslingloading_fnc_canDeployRopes
*
* Public: No
*/

params ["_vehicle"];
if (player distance _vehicle > ASL_PICKUP_DISTANCE) exitWith { false };
if !([_vehicle] call FUNC(isSupportedVehicle)) exitWith { false };
_existingVehicle = player getVariable ["ASL_Ropes_Vehicle", []];
if (count _existingVehicle > 0) exitWith { false };
private _existingRopes = _vehicle getVariable ["ASL_Ropes", []];
if ((count _existingRopes) == 0) exitWith { true };
private _activeRopes = [_vehicle] call FUNC(getActiveRopes);
if ((count _existingRopes) > 0 && (count _existingRopes) == (count _activeRopes)) exitWith { false };
true;
18 changes: 18 additions & 0 deletions addons/advancedslingloading/functions/fnc_canDropRopes.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Checks if ropes can be dropped
*
* Arguments:
* None
*
* Return Value:
* Can drop ropes <BOOL>
*
* Example:
* [] call ttt_advancedslingloading_fnc_canDropRopes
*
* Public: No
*/

count (player getVariable ["ASL_Ropes_Vehicle", []]) > 0 && isNull objectParent player;
25 changes: 25 additions & 0 deletions addons/advancedslingloading/functions/fnc_canExtendRopes.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Checks if ropes can be extended
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* Can extend ropes <BOOL>
*
* Example:
* [_vehicle] call ttt_advancedslingloading_fnc_canExtendRopes
*
* Public: No
*/

params ["_vehicle"];
if (player distance _vehicle > ASL_PICKUP_DISTANCE) exitWith { false };
if !([_vehicle] call FUNC(isSupportedVehicle)) exitWith { false };
private _existingRopes = _vehicle getVariable ["ASL_Ropes", []];
if ((count _existingRopes) == 0) exitWith { false };
private _activeRopes = [_vehicle] call FUNC(getActiveRopes);
if ((count _activeRopes) == 0) exitWith { false };
true;
18 changes: 18 additions & 0 deletions addons/advancedslingloading/functions/fnc_canPickupRopes.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Checks if ropes can be picked up
*
* Arguments:
* None
*
* Return Value:
* Can pickup ropes <BOOL>
*
* Example:
* [] call ttt_advancedslingloading_fnc_canPickupRopes
*
* Public: No
*/

count (player getVariable ["ASL_Ropes_Vehicle", []]) == 0 && count (missionNamespace getVariable ["ASL_Nearby_Vehicles", []]) > 0 && isNull objectParent player;
25 changes: 25 additions & 0 deletions addons/advancedslingloading/functions/fnc_canReleaseCargo.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "..\script_component.hpp"
/*
* Author: Seth Duda
* Checks if cargo can be released
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* Can release cargo <BOOL>
*
* Example:
* [_vehicle] call ttt_advancedslingloading_fnc_canReleaseCargo
*
* Public: No
*/

params ["_vehicle"];
if (player distance _vehicle > ASL_PICKUP_DISTANCE) exitWith { false };
if !([_vehicle] call FUNC(isSupportedVehicle)) exitWith { false };
private _existingRopes = _vehicle getVariable ["ASL_Ropes", []];
if ((count _existingRopes) == 0) exitWith { false };
private _activeRopes = [_vehicle] call FUNC(getActiveRopesWithCargo);
if ((count _activeRopes) == 0) exitWith { false };
true;
Loading
Loading