mirror of
https://github.com/sethduda/AdvancedTowing.git
synced 2024-08-30 17:32:12 +00:00
Compare commits
59 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5f6c52c72a | ||
|
48330bffdf | ||
|
ce530d525b | ||
|
6c91cb2a04 | ||
|
67faad36a1 | ||
|
ca36b4eec5 | ||
|
3db6dc7fb1 | ||
|
bec973517c | ||
|
2ec8366349 | ||
|
bb98780600 | ||
|
5c731dd626 | ||
|
38c87b3222 | ||
|
c001b01967 | ||
|
89cd91233d | ||
|
bb9e0ff35a | ||
|
f651c1f8d0 | ||
|
f0bcdb2561 | ||
|
bcefc1ff5b | ||
|
1b5e71df70 | ||
|
0cf4313e98 | ||
|
7dd7edede2 | ||
|
58b8ce4657 | ||
|
21a6e95014 | ||
|
311f7d9bbe | ||
|
b701916f51 | ||
|
558b6c4a72 | ||
|
c1a14a31d2 | ||
|
f9092c3f4b | ||
|
22b1924d50 | ||
|
a5eaca9850 | ||
|
12ae5d1221 | ||
|
2e75836d45 | ||
|
d7519b2fff | ||
|
ccd05e9a69 | ||
|
16e9f7637e | ||
|
97431a69ee | ||
|
64e561e375 | ||
|
e98c4a2f97 | ||
|
679ea3fcc5 | ||
|
5ae0345e80 | ||
|
a17a9eee62 | ||
|
102355c52e | ||
|
2f7eee434a | ||
|
ae586e1770 | ||
|
f34ed376cc | ||
|
065ea071f0 | ||
|
32b4dde344 | ||
|
edd64af372 | ||
|
1f16dfa5d5 | ||
|
c9d9f7401f | ||
|
5fd51c6e78 | ||
|
7ddb439fcd | ||
|
10607cc2a6 | ||
|
552dc050ab | ||
|
d9b14db304 | ||
|
b90a1104a6 | ||
|
c223a04cf2 | ||
|
4e013b4572 | ||
|
241d1dd49f |
2
.gitignore
vendored
2
.gitignore
vendored
@ -45,3 +45,5 @@ $RECYCLE.BIN/
|
|||||||
Network Trash Folder
|
Network Trash Folder
|
||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.apdisk
|
||||||
|
*.pbo
|
||||||
|
addons/SA_AdvancedTowing.pbo.AdvancedTowing.bisign
|
||||||
|
126
README.md
126
README.md
@ -1,5 +1,131 @@
|
|||||||
# Advanced Towing
|
# Advanced Towing
|
||||||
|
|
||||||
|
Adds support for towing vehicles using ropes. Works in both SP and MP. Supports Exile.
|
||||||
|
|
||||||
|
Also check out my Advanced Sling Loading addon for more rope features!
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
|
||||||
|
- Tow other vehicles behind Ships, Cars, Trucks and Tanks
|
||||||
|
- The size of the vehicle impacts it's towing capability
|
||||||
|
- Other players (including AI) can tow other players
|
||||||
|
- Supports towing damaged / destroyed vehicles
|
||||||
|
- Supports towing "trains" of vehicles (limited to 2 by default - see below)
|
||||||
|
|
||||||
|
**Installation:**
|
||||||
|
|
||||||
|
1. Subscrive via steam: http://steamcommunity.com/sharedfiles/filedetails/?id=639837898 or dowload latest release from https://github.com/sethduda/AdvancedTowing/releases
|
||||||
|
2. If installing this on a server, add the addon to the -serverMod command line option
|
||||||
|
3. Optionally, this can be installed directly in the mission PBO by calling the advanced towing script via initServer.sqf. You'll find the sqf script (fn_advancedTowingInit.sqf) in the addons directory inside the downloaded addon.
|
||||||
|
|
||||||
|
**Default Towing Rules:**
|
||||||
|
|
||||||
|
- Tanks can tow tanks, cars, ships and air
|
||||||
|
- Cars can tow cars, ships and air
|
||||||
|
- Trucks can tow cars, ships and air
|
||||||
|
- Ships can only tow ships
|
||||||
|
- You can't tow locked vehicles (see settings below)
|
||||||
|
- You can only tow up to two vehicles at a time (see settings below)
|
||||||
|
|
||||||
|
**Notes for Mission Makers:**
|
||||||
|
|
||||||
|
You can enable "trains" of vehicles by defining the SA_MAX_TOWED_CARGO varible in your init.sqf file. By default, this is set to 2. When set, vehicles can tow up to the max number of specified vehicles. If you try to tow more, your vehicle won't be able to move. Note, however, mass of all vehicles will be taken into account. It's going to be slower to two vehicles vs one.
|
||||||
|
|
||||||
|
```SA_MAX_TOWED_CARGO = 3; ```
|
||||||
|
|
||||||
|
You can customize which classes of objects can "deploy" tow ropes by overriding the SA_TOW_SUPPORTED_VEHICLES_OVERRIDE variable in an init.sqf file.
|
||||||
|
|
||||||
|
```SA_TOW_SUPPORTED_VEHICLES_OVERRIDE = [ "Air", "Ship" ]; ```
|
||||||
|
|
||||||
|
This will only allow objects of class Air and Ship deploy tow ropes.
|
||||||
|
|
||||||
|
You can customize what can and can't be towed by defining the SA_TOW_RULES_OVERRIDE variable in the init.sqf file.
|
||||||
|
|
||||||
|
```SA_TOW_RULES_OVERRIDE =
|
||||||
|
[ ["Air", "CAN_TOW", "Ship"],
|
||||||
|
["Air", "CAN_TOW", "Air"],
|
||||||
|
["Ship", "CANT_TOW", "Air"],
|
||||||
|
["Ship", "CAN_TOW", "Ship"]
|
||||||
|
]; ```
|
||||||
|
|
||||||
|
In this example, all objects of class Air can tow Ships and Air. However, Ships can only tow ships.
|
||||||
|
|
||||||
|
You can allow towing of locked vehicles by defining SA_TOW_LOCKED_VEHICLES_ENABLED in your init.sqf file. It defaults to false.
|
||||||
|
|
||||||
|
```SA_TOW_LOCKED_VEHICLES_ENABLED = true; ```
|
||||||
|
|
||||||
|
You can allow towing in an Exile safe zone by defining SA_TOW_IN_EXILE_SAFEZONE_ENABLED in your init.sqf file. It default to false.
|
||||||
|
|
||||||
|
```SA_TOW_IN_EXILE_SAFEZONE_ENABLED = true; ```
|
||||||
|
|
||||||
|
**Not working on your server?**
|
||||||
|
|
||||||
|
Make sure you have the mod listed in the -mod or -serverMod command line option. Only -serverMod is required for this addon. If still not working, check your server log to make sure the addon is found.
|
||||||
|
|
||||||
|
**FAQ**
|
||||||
|
|
||||||
|
*This addon is only required on the server - is it going to slow down my server?*
|
||||||
|
|
||||||
|
No - while this addon is server-side only, it installs itself on all clients without them downloading the addon. Most of the time, the towing code actually runs client-side, even though you installed the addon only on the server. Magic!
|
||||||
|
|
||||||
|
*Why is the vehicle I'm towing jumpy/laggy?*
|
||||||
|
|
||||||
|
If you're towing a vehicle that another player is driving, it's slower to transmit position updates for the towed vehicle. This will result in laggy looking towing. Have the player move to the passenger seat and then re-attach the tow ropes.
|
||||||
|
|
||||||
|
Also, when using this in MP, all other players watching someone tow something will also notice the towed vehicle isn't moving as smoothly. This is also due to network delay. Usually this isn't too noticeable unless moving very fast.
|
||||||
|
|
||||||
|
*Battleye kicks me when I try to do xyz. What do I do?*
|
||||||
|
|
||||||
|
You need to configure Battleye rules on your server. Below are the files you need to configure:
|
||||||
|
|
||||||
|
setvariable.txt
|
||||||
|
|
||||||
|
Add the following exclusions to the end of all lines starting with 4, 5, 6, or 7 if they contain "" (meaning applies to all values):
|
||||||
|
|
||||||
|
!="SA_Cargo" !="SA_Tow_Ropes" !="SA_Tow_Ropes_Vehicle" !="SA_Tow_Ropes_Pick_Up_Helper"
|
||||||
|
|
||||||
|
setvariableval.txt
|
||||||
|
|
||||||
|
If you have any lines starting with 4, 5, 6, or 7 and they contain "" (meaning applies to all values) it's not going to work. Either remove the line or explicitly define the values you want to kick. Since the values of the variables above can vary, I don't know of a good way to define an exclusion rule.
|
||||||
|
|
||||||
|
Also, it's possible there are other battleye filter files that can cause issues. If you check your battleye logs you can figure out which file is causing a problem.
|
||||||
|
|
||||||
|
*The tow actions appear when looking at a vehicle, but do nothing when I select them. How do I fix that?*
|
||||||
|
|
||||||
|
Most likely your server is setup with a white list for remote executions. In order to fix this, you need to modify your mission's description.ext file, adding the following CfgRemoteExec rules. If using InfiStar you should edit your cfgremoteexec.hpp instead of the description.ext file. See https://community.bistudio.com/wiki/Arma_3_Remote_Execution for more details on CfgRemoteExec.
|
||||||
|
|
||||||
|
```
|
||||||
|
class CfgRemoteExec
|
||||||
|
{
|
||||||
|
class Functions
|
||||||
|
{
|
||||||
|
class SA_Simulate_Towing { allowedTargets=0; };
|
||||||
|
class SA_Attach_Tow_Ropes { allowedTargets=0; };
|
||||||
|
class SA_Take_Tow_Ropes { allowedTargets=0; };
|
||||||
|
class SA_Put_Away_Tow_Ropes { allowedTargets=0; };
|
||||||
|
class SA_Pickup_Tow_Ropes { allowedTargets=0; };
|
||||||
|
class SA_Drop_Tow_Ropes { allowedTargets=0; };
|
||||||
|
class SA_Set_Owner { allowedTargets=2; };
|
||||||
|
class SA_Hint { allowedTargets=1; };
|
||||||
|
class SA_Hide_Object_Global { allowedTargets=2; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
**Issues & Feature Requests**
|
||||||
|
|
||||||
|
https://github.com/sethduda/AdvancedTowing/issues
|
||||||
|
|
||||||
|
If anyone wants to help fix any of these, please let me know. You can fork the repo and create a pull request.
|
||||||
|
|
||||||
|
**Special Thanks for Testing & Support:**
|
||||||
|
|
||||||
|
- Stay Alive Tactical Team (http://sa.clanservers.com)
|
||||||
|
- BI forum community: diesel tech jc, TeTeT, belbo
|
||||||
|
- Crimson Gaming for testing on exile (http://crimsongamingau.com)
|
||||||
|
- DirtySanchez & XLD (exilemod.com) for his great ideas & work to make this functional with Exile
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -8,59 +8,28 @@ class CfgPatches
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
class CfgNetworkMessages
|
||||||
class CfgVehicles
|
|
||||||
{
|
{
|
||||||
class Logic;
|
|
||||||
class Module_F: Logic
|
class AdvancedTowingRemoteExecClient
|
||||||
{
|
{
|
||||||
class ArgumentsBaseUnits
|
module = "AdvancedTowing";
|
||||||
{
|
parameters[] = {"ARRAY","STRING","OBJECT","BOOL"};
|
||||||
class Anything;
|
|
||||||
};
|
|
||||||
class ModuleDescription
|
|
||||||
{
|
|
||||||
class Anything;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
class SA_AdvancedSlingLoadingModule: Module_F
|
|
||||||
|
class AdvancedTowingRemoteExecServer
|
||||||
{
|
{
|
||||||
// Standard object definitions
|
module = "AdvancedTowing";
|
||||||
scope = 2; // Editor visibility; 2 will show it in the menu, 1 will hide it.
|
parameters[] = {"ARRAY","STRING","BOOL"};
|
||||||
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)
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
class CfgFunctions
|
class CfgFunctions
|
||||||
{
|
{
|
||||||
class SA
|
class SA
|
||||||
{
|
{
|
||||||
class AdvancedSlingLoading
|
class AdvancedTowing
|
||||||
{
|
{
|
||||||
file = "\SA_AdvancedTowing\functions";
|
file = "\SA_AdvancedTowing\functions";
|
||||||
class advancedTowingInit{postInit=1};
|
class advancedTowingInit{postInit=1};
|
||||||
|
@ -9,35 +9,138 @@ 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.
|
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.
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
|
#define SA_Find_Surface_ASL_Under_Position(_object,_positionAGL,_returnSurfaceASL,_canFloat) \
|
||||||
|
_objectASL = AGLToASL (_object modelToWorldVisual (getCenterOfMass _object)); \
|
||||||
|
_surfaceIntersectStartASL = [_positionAGL select 0, _positionAGL select 1, (_objectASL select 2) + 1]; \
|
||||||
|
_surfaceIntersectEndASL = [_positionAGL select 0, _positionAGL select 1, (_objectASL select 2) - 5]; \
|
||||||
|
_surfaces = lineIntersectsSurfaces [_surfaceIntersectStartASL, _surfaceIntersectEndASL, _object, objNull, true, 5]; \
|
||||||
|
_returnSurfaceASL = AGLToASL _positionAGL; \
|
||||||
|
{ \
|
||||||
|
scopeName "surfaceLoop"; \
|
||||||
|
if( isNull (_x select 2) ) then { \
|
||||||
|
_returnSurfaceASL = _x select 0; \
|
||||||
|
breakOut "surfaceLoop"; \
|
||||||
|
} else { \
|
||||||
|
if!((_x select 2) isKindOf "RopeSegment") then { \
|
||||||
|
_objectFileName = str (_x select 2); \
|
||||||
|
if((_objectFileName find " t_") == -1 && (_objectFileName find " b_") == -1) then { \
|
||||||
|
_returnSurfaceASL = _x select 0; \
|
||||||
|
breakOut "surfaceLoop"; \
|
||||||
|
}; \
|
||||||
|
}; \
|
||||||
|
}; \
|
||||||
|
} forEach _surfaces; \
|
||||||
|
if(_canFloat && (_returnSurfaceASL select 2) < 0) then { \
|
||||||
|
_returnSurfaceASL set [2,0]; \
|
||||||
|
}; \
|
||||||
|
|
||||||
|
#define SA_Find_Surface_ASL_Under_Model(_object,_modelOffset,_returnSurfaceASL,_canFloat) \
|
||||||
|
SA_Find_Surface_ASL_Under_Position(_object, (_object modelToWorldVisual _modelOffset), _returnSurfaceASL,_canFloat);
|
||||||
|
|
||||||
|
#define SA_Find_Surface_AGL_Under_Model(_object,_modelOffset,_returnSurfaceAGL,_canFloat) \
|
||||||
|
SA_Find_Surface_ASL_Under_Model(_object,_modelOffset,_returnSurfaceAGL,_canFloat); \
|
||||||
|
_returnSurfaceAGL = ASLtoAGL _returnSurfaceAGL;
|
||||||
|
|
||||||
|
#define SA_Get_Cargo(_vehicle,_cargo) \
|
||||||
|
if( count (ropeAttachedObjects _vehicle) == 0 ) then { \
|
||||||
|
_cargo = objNull; \
|
||||||
|
} else { \
|
||||||
|
_cargo = ((ropeAttachedObjects _vehicle) select 0) getVariable ["SA_Cargo",objNull]; \
|
||||||
|
};
|
||||||
|
|
||||||
|
SA_Advanced_Towing_Install = {
|
||||||
|
|
||||||
|
// Prevent advanced towing from installing twice
|
||||||
|
if(!isNil "SA_TOW_INIT") exitWith {};
|
||||||
|
SA_TOW_INIT = true;
|
||||||
|
|
||||||
diag_log "Advanced Towing Loading...";
|
diag_log "Advanced Towing Loading...";
|
||||||
|
|
||||||
if(!isNil "SA_TOW_INIT") exitWith {};
|
SA_Simulate_Towing_Speed = {
|
||||||
|
|
||||||
SA_TOW_INIT = true;
|
params ["_vehicle"];
|
||||||
|
|
||||||
|
private ["_runSimulation","_currentCargo","_maxVehicleSpeed","_maxTowedVehicles","_vehicleMass"];
|
||||||
|
|
||||||
|
_maxVehicleSpeed = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "maxSpeed");
|
||||||
|
_vehicleMass = 1000 max (getMass _vehicle);
|
||||||
|
_maxTowedCargo = missionNamespace getVariable ["SA_MAX_TOWED_CARGO",2];
|
||||||
|
_runSimulation = true;
|
||||||
|
|
||||||
|
private ["_currentVehicle","_totalCargoMass","_totalCargoCount","_findNextCargo","_towRopes","_ropeLength"];
|
||||||
|
private ["_ends","_endsDistance","_currentMaxSpeed","_newMaxSpeed"];
|
||||||
|
|
||||||
|
while {_runSimulation} do {
|
||||||
|
|
||||||
|
// Calculate total mass and count of cargo being towed (only takes into account
|
||||||
|
// cargo that's actively being towed (e.g. there's no slack in the rope)
|
||||||
|
|
||||||
|
_currentVehicle = _vehicle;
|
||||||
|
_totalCargoMass = 0;
|
||||||
|
_totalCargoCount = 0;
|
||||||
|
_findNextCargo = true;
|
||||||
|
while {_findNextCargo} do {
|
||||||
|
_findNextCargo = false;
|
||||||
|
SA_Get_Cargo(_currentVehicle,_currentCargo);
|
||||||
|
if(!isNull _currentCargo) then {
|
||||||
|
_towRopes = _currentVehicle getVariable ["SA_Tow_Ropes",[]];
|
||||||
|
if(count _towRopes > 0) then {
|
||||||
|
_ropeLength = ropeLength (_towRopes select 0);
|
||||||
|
_ends = ropeEndPosition (_towRopes select 0);
|
||||||
|
_endsDistance = (_ends select 0) distance (_ends select 1);
|
||||||
|
if( _endsDistance >= _ropeLength - 2 ) then {
|
||||||
|
_totalCargoMass = _totalCargoMass + (1000 max (getMass _currentCargo));
|
||||||
|
_totalCargoCount = _totalCargoCount + 1;
|
||||||
|
_currentVehicle = _currentCargo;
|
||||||
|
_findNextCargo = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
_newMaxSpeed = _maxVehicleSpeed / (1 max ((_totalCargoMass / _vehicleMass) * 2));
|
||||||
|
_newMaxSpeed = (_maxVehicleSpeed * 0.75) min _newMaxSpeed;
|
||||||
|
|
||||||
|
// Prevent vehicle from moving if trying to move more cargo than pre-defined max
|
||||||
|
if(_totalCargoCount > _maxTowedCargo) then {
|
||||||
|
_newMaxSpeed = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
_currentMaxSpeed = _vehicle getVariable ["SA_Max_Tow_Speed",_maxVehicleSpeed];
|
||||||
|
|
||||||
|
if(_currentMaxSpeed != _newMaxSpeed) then {
|
||||||
|
_vehicle setVariable ["SA_Max_Tow_Speed",_newMaxSpeed];
|
||||||
|
};
|
||||||
|
|
||||||
|
sleep 0.1;
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
SA_Simulate_Towing = {
|
SA_Simulate_Towing = {
|
||||||
|
|
||||||
params ["_vehicle","_vehicleHitchModelPos","_cargo","_cargoHitchModelPos","_ropeLength"];
|
params ["_vehicle","_vehicleHitchModelPos","_cargo","_cargoHitchModelPos","_ropeLength"];
|
||||||
|
|
||||||
private ["_lastCargoHitchPosition","_lastCargoVectorDir","_cargoLength","_maxDistanceToCargo","_lastMovedCargoPosition","_cargoHitchPoints"];
|
private ["_lastCargoHitchPosition","_lastCargoVectorDir","_cargoLength","_maxDistanceToCargo","_lastMovedCargoPosition","_cargoHitchPoints"];
|
||||||
private ["_vehicleHitchPosition","_cargoHitchPosition","_newCargoHitchPosition","_cargoVector","_movedCargoVector","_attachedObjects"];
|
private ["_vehicleHitchPosition","_cargoHitchPosition","_newCargoHitchPosition","_cargoVector","_movedCargoVector","_attachedObjects","_currentCargo"];
|
||||||
private ["_newCargoDir","_lastCargoVectorDir","_newCargoPosition","_doExit","_cargoPosition","_vehiclePosition","_maxVehicleSpeed","_vehicleMass","_cargoMass"];
|
private ["_newCargoDir","_lastCargoVectorDir","_newCargoPosition","_doExit","_cargoPosition","_vehiclePosition","_maxVehicleSpeed","_vehicleMass","_cargoMass","_cargoCanFloat"];
|
||||||
private ["_cargoCorner1AGL","_cargoCorner1ASL","_cargoCorner2AGL","_cargoCorner2ASL","_cargoCorner3AGL","_cargoCorner3ASL","_cargoCorner4AGL","_cargoCorner4ASL","_surfaceNormal1","_surfaceNormal2","_surfaceNormal"];
|
private ["_cargoCorner1AGL","_cargoCorner1ASL","_cargoCorner2AGL","_cargoCorner2ASL","_cargoCorner3AGL","_cargoCorner3ASL","_cargoCorner4AGL","_cargoCorner4ASL","_surfaceNormal1","_surfaceNormal2","_surfaceNormal"];
|
||||||
|
private ["_cargoCenterASL","_surfaceHeight","_surfaceHeight2","_maxSurfaceHeight"];
|
||||||
|
|
||||||
// Calculate _cargoModelCenterGroundPosition (This is the model center position that should be set to ground level)
|
_maxVehicleSpeed = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "maxSpeed");
|
||||||
private ["_cargoCenterOfMass","_cargoCenterOfMassAGL","_cargoModelCenterGroundPosition"];
|
_cargoCanFloat = if( getNumber (configFile >> "CfgVehicles" >> typeOf _cargo >> "canFloat") == 1 ) then { true } else { false };
|
||||||
_cargoCenterOfMass = getCenterOfMass _cargo;
|
|
||||||
_cargoCenterOfMassAGL = _cargo modelToWorldVisual _cargoCenterOfMass;
|
private ["_cargoCenterOfMassAGL","_cargoModelCenterGroundPosition"];
|
||||||
_cargoCenterOfMassAGL set [2,0];
|
SA_Find_Surface_AGL_Under_Model(_cargo,getCenterOfMass _cargo,_cargoCenterOfMassAGL,_cargoCanFloat);
|
||||||
_cargoModelCenterGroundPosition = _cargo worldToModelVisual _cargoCenterOfMassAGL;
|
_cargoModelCenterGroundPosition = _cargo worldToModelVisual _cargoCenterOfMassAGL;
|
||||||
_cargoModelCenterGroundPosition set [0,0];
|
_cargoModelCenterGroundPosition set [0,0];
|
||||||
_cargoModelCenterGroundPosition set [1,0];
|
_cargoModelCenterGroundPosition set [1,0];
|
||||||
|
_cargoModelCenterGroundPosition set [2, (_cargoModelCenterGroundPosition select 2) - 0.05]; // Adjust height so that it doesn't ride directly on ground
|
||||||
|
|
||||||
// Calculate cargo model corner points
|
// Calculate cargo model corner points
|
||||||
private ["_cargoCornerPoints"];
|
private ["_cargoCornerPoints"];
|
||||||
_cargoCornerPoints = [_vehicle] call SA_Get_Corner_Points;
|
_cargoCornerPoints = [_cargo] call SA_Get_Corner_Points;
|
||||||
_corner1 = _cargoCornerPoints select 0;
|
_corner1 = _cargoCornerPoints select 0;
|
||||||
_corner2 = _cargoCornerPoints select 1;
|
_corner2 = _cargoCornerPoints select 1;
|
||||||
_corner3 = _cargoCornerPoints select 2;
|
_corner3 = _cargoCornerPoints select 2;
|
||||||
@ -46,7 +149,7 @@ SA_Simulate_Towing = {
|
|||||||
|
|
||||||
// Try to set cargo owner if the towing client doesn't own the cargo
|
// Try to set cargo owner if the towing client doesn't own the cargo
|
||||||
if(local _vehicle && !local _cargo) then {
|
if(local _vehicle && !local _cargo) then {
|
||||||
[_cargo, clientOwner] remoteExec ["setOwner", 2];
|
[[_cargo, clientOwner],"SA_Set_Owner"] call SA_RemoteExecServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
_vehicleHitchModelPos set [2,0];
|
_vehicleHitchModelPos set [2,0];
|
||||||
@ -69,6 +172,9 @@ SA_Simulate_Towing = {
|
|||||||
|
|
||||||
_doExit = false;
|
_doExit = false;
|
||||||
|
|
||||||
|
// Start vehicle speed simulation
|
||||||
|
[_vehicle] spawn SA_Simulate_Towing_Speed;
|
||||||
|
|
||||||
while {!_doExit} do {
|
while {!_doExit} do {
|
||||||
|
|
||||||
_vehicleHitchPosition = _vehicle modelToWorld _vehicleHitchModelPos;
|
_vehicleHitchPosition = _vehicle modelToWorld _vehicleHitchModelPos;
|
||||||
@ -76,8 +182,6 @@ SA_Simulate_Towing = {
|
|||||||
_cargoHitchPosition = _lastCargoHitchPosition;
|
_cargoHitchPosition = _lastCargoHitchPosition;
|
||||||
_cargoHitchPosition set [2,0];
|
_cargoHitchPosition set [2,0];
|
||||||
|
|
||||||
_maxVehicleSpeed = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "maxSpeed");
|
|
||||||
|
|
||||||
_cargoPosition = getPos _cargo;
|
_cargoPosition = getPos _cargo;
|
||||||
_vehiclePosition = getPos _vehicle;
|
_vehiclePosition = getPos _vehicle;
|
||||||
|
|
||||||
@ -88,44 +192,65 @@ SA_Simulate_Towing = {
|
|||||||
_cargoVector = _lastCargoVectorDir vectorMultiply _cargoLength;
|
_cargoVector = _lastCargoVectorDir vectorMultiply _cargoLength;
|
||||||
_movedCargoVector = _newCargoHitchPosition vectorDiff _lastCargoHitchPosition;
|
_movedCargoVector = _newCargoHitchPosition vectorDiff _lastCargoHitchPosition;
|
||||||
_newCargoDir = vectorNormalized (_cargoVector vectorAdd _movedCargoVector);
|
_newCargoDir = vectorNormalized (_cargoVector vectorAdd _movedCargoVector);
|
||||||
|
//if(_isRearCargoHitch) then {
|
||||||
|
// _newCargoDir = _newCargoDir vectorMultiply -1;
|
||||||
|
//};
|
||||||
_lastCargoVectorDir = _newCargoDir;
|
_lastCargoVectorDir = _newCargoDir;
|
||||||
_newCargoPosition = _newCargoHitchPosition vectorAdd (_newCargoDir vectorMultiply -(vectorMagnitude (_cargoHitchModelPos)));
|
_newCargoPosition = _newCargoHitchPosition vectorAdd (_newCargoDir vectorMultiply -(vectorMagnitude (_cargoHitchModelPos)));
|
||||||
_newCargoPosition = AGLToASL _newCargoPosition;
|
|
||||||
_newCargoPosition = _newCargoPosition vectorAdd ( _cargoModelCenterGroundPosition vectorMultiply -1 );
|
SA_Find_Surface_ASL_Under_Position(_cargo,_newCargoPosition,_newCargoPosition,_cargoCanFloat);
|
||||||
|
|
||||||
// Calculate surface normal (up) (more realistic than surfaceNormal function)
|
// Calculate surface normal (up) (more realistic than surfaceNormal function)
|
||||||
_cargoCorner1AGL = _cargo modelToWorldVisual _corner1;
|
SA_Find_Surface_ASL_Under_Model(_cargo,_corner1,_cargoCorner1ASL,_cargoCanFloat);
|
||||||
_cargoCorner1AGL set [2,0];
|
SA_Find_Surface_ASL_Under_Model(_cargo,_corner2,_cargoCorner2ASL,_cargoCanFloat);
|
||||||
_cargoCorner1ASL = AGLToASL _cargoCorner1AGL;
|
SA_Find_Surface_ASL_Under_Model(_cargo,_corner3,_cargoCorner3ASL,_cargoCanFloat);
|
||||||
_cargoCorner2AGL = _cargo modelToWorldVisual _corner2;
|
SA_Find_Surface_ASL_Under_Model(_cargo,_corner4,_cargoCorner4ASL,_cargoCanFloat);
|
||||||
_cargoCorner2AGL set [2,0];
|
|
||||||
_cargoCorner2ASL = AGLToASL _cargoCorner2AGL;
|
|
||||||
_cargoCorner3AGL = _cargo modelToWorldVisual _corner3;
|
|
||||||
_cargoCorner3AGL set [2,0];
|
|
||||||
_cargoCorner3ASL = AGLToASL _cargoCorner3AGL;
|
|
||||||
_cargoCorner4AGL = _cargo modelToWorldVisual _corner4;
|
|
||||||
_cargoCorner4AGL set [2,0];
|
|
||||||
_cargoCorner4ASL = AGLToASL _cargoCorner4AGL;
|
|
||||||
_surfaceNormal1 = (_cargoCorner1ASL vectorFromTo _cargoCorner3ASL) vectorCrossProduct (_cargoCorner1ASL vectorFromTo _cargoCorner2ASL);
|
_surfaceNormal1 = (_cargoCorner1ASL vectorFromTo _cargoCorner3ASL) vectorCrossProduct (_cargoCorner1ASL vectorFromTo _cargoCorner2ASL);
|
||||||
_surfaceNormal2 = (_cargoCorner4ASL vectorFromTo _cargoCorner2ASL) vectorCrossProduct (_cargoCorner4ASL vectorFromTo _cargoCorner3ASL);
|
_surfaceNormal2 = (_cargoCorner4ASL vectorFromTo _cargoCorner2ASL) vectorCrossProduct (_cargoCorner4ASL vectorFromTo _cargoCorner3ASL);
|
||||||
_surfaceNormal = _surfaceNormal1 vectorAdd _surfaceNormal2;
|
_surfaceNormal = _surfaceNormal1 vectorAdd _surfaceNormal2;
|
||||||
|
|
||||||
_cargo allowDamage false;
|
if(missionNamespace getVariable ["SA_TOW_DEBUG_ENABLED", false]) then {
|
||||||
|
if(isNil "sa_tow_debug_arrow_1") then {
|
||||||
|
sa_tow_debug_arrow_1 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
sa_tow_debug_arrow_2 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
sa_tow_debug_arrow_3 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
sa_tow_debug_arrow_4 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
};
|
||||||
|
sa_tow_debug_arrow_1 setPosASL _cargoCorner1ASL;
|
||||||
|
sa_tow_debug_arrow_1 setVectorUp _surfaceNormal;
|
||||||
|
sa_tow_debug_arrow_2 setPosASL _cargoCorner2ASL;
|
||||||
|
sa_tow_debug_arrow_2 setVectorUp _surfaceNormal;
|
||||||
|
sa_tow_debug_arrow_3 setPosASL _cargoCorner3ASL;
|
||||||
|
sa_tow_debug_arrow_3 setVectorUp _surfaceNormal;
|
||||||
|
sa_tow_debug_arrow_4 setPosASL _cargoCorner4ASL;
|
||||||
|
sa_tow_debug_arrow_4 setVectorUp _surfaceNormal;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Calculate adjusted surface height based on surface normal (prevents vehicle from clipping into ground)
|
||||||
|
_cargoCenterASL = AGLtoASL (_cargo modelToWorldVisual [0,0,0]);
|
||||||
|
_cargoCenterASL set [2,0];
|
||||||
|
_surfaceHeight = ((_cargoCorner1ASL vectorAdd ( _cargoCenterASL vectorMultiply -1)) vectorDotProduct _surfaceNormal1) / ([0,0,1] vectorDotProduct _surfaceNormal1);
|
||||||
|
_surfaceHeight2 = ((_cargoCorner1ASL vectorAdd ( _cargoCenterASL vectorMultiply -1)) vectorDotProduct _surfaceNormal2) / ([0,0,1] vectorDotProduct _surfaceNormal2);
|
||||||
|
_maxSurfaceHeight = (_newCargoPosition select 2) max _surfaceHeight max _surfaceHeight2;
|
||||||
|
_newCargoPosition set [2, _maxSurfaceHeight ];
|
||||||
|
|
||||||
|
_newCargoPosition = _newCargoPosition vectorAdd ( _cargoModelCenterGroundPosition vectorMultiply -1 );
|
||||||
|
|
||||||
_cargo setVectorDir _newCargoDir;
|
_cargo setVectorDir _newCargoDir;
|
||||||
_cargo setVectorUp _surfaceNormal;
|
_cargo setVectorUp _surfaceNormal;
|
||||||
_cargo setPosWorld _newCargoPosition;
|
_cargo setPosWorld _newCargoPosition;
|
||||||
_cargo allowDamage true;
|
|
||||||
_lastCargoHitchPosition = _newCargoHitchPosition;
|
_lastCargoHitchPosition = _newCargoHitchPosition;
|
||||||
_maxDistanceToCargo = _vehicleHitchPosition distance _newCargoHitchPosition;
|
_maxDistanceToCargo = _vehicleHitchPosition distance _newCargoHitchPosition;
|
||||||
_lastMovedCargoPosition = _cargoPosition;
|
_lastMovedCargoPosition = _cargoPosition;
|
||||||
|
|
||||||
_massAdjustedMaxSpeed = (0.1 * _maxVehicleSpeed) max ((0.75 * _maxVehicleSpeed) * ( 1 min (_vehicleMass / _cargoMass) ));
|
_massAdjustedMaxSpeed = _vehicle getVariable ["SA_Max_Tow_Speed",_maxVehicleSpeed];
|
||||||
if(speed _vehicle > (_massAdjustedMaxSpeed)+0.1 && _massAdjustedMaxSpeed > 0) then {
|
if(speed _vehicle > (_massAdjustedMaxSpeed)+0.1) then {
|
||||||
_vehicle setVelocity ((vectorNormalized (velocity _vehicle)) vectorMultiply (_massAdjustedMaxSpeed/3.6));
|
_vehicle setVelocity ((vectorNormalized (velocity _vehicle)) vectorMultiply (_massAdjustedMaxSpeed/3.6));
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(_lastMovedCargoPosition distance _cargoPosition > 2) then {
|
if(_lastMovedCargoPosition distance _cargoPosition > 2) then {
|
||||||
_lastCargoHitchPosition = _cargo modelToWorld _cargoHitchModelPos;
|
_lastCargoHitchPosition = _cargo modelToWorld _cargoHitchModelPos;
|
||||||
_lastCargoVectorDir = vectorDir _cargo;
|
_lastCargoVectorDir = vectorDir _cargo;
|
||||||
@ -133,42 +258,65 @@ SA_Simulate_Towing = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If vehicle isn't local to the client, switch client running towing simulation
|
||||||
if(!local _vehicle) then {
|
if(!local _vehicle) then {
|
||||||
_this remoteExec ["SA_Simulate_Towing", _vehicle];
|
[_this,"SA_Simulate_Towing",_vehicle] call SA_RemoteExec;
|
||||||
_doExit = true;
|
_doExit = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
if( count (ropeAttachedObjects _vehicle) == 0 ) then {
|
// If the vehicle isn't towing anything, stop the towing simulation
|
||||||
|
SA_Get_Cargo(_vehicle,_currentCargo);
|
||||||
|
if(isNull _currentCargo) then {
|
||||||
_doExit = true;
|
_doExit = true;
|
||||||
} else {
|
|
||||||
_attachedObjects = ropeAttachedObjects _vehicle;
|
|
||||||
if( (attachedTo (_attachedObjects select 0)) != _cargo ) then {
|
|
||||||
_doExit = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sleep 0.01;
|
sleep 0.01;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SA_Get_Corner_Points = {
|
SA_Get_Corner_Points = {
|
||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
private ["_centerOfMass","_bbr","_p1","_p2","_rearCorner","_rearCorner2","_frontCorner","_frontCorner2"];
|
private ["_centerOfMass","_bbr","_p1","_p2","_rearCorner","_rearCorner2","_frontCorner","_frontCorner2"];
|
||||||
private ["_maxWidth","_widthOffset","_maxLength","_lengthOffset"];
|
private ["_maxWidth","_widthOffset","_maxLength","_lengthOffset","_widthFactor","_lengthFactor"];
|
||||||
|
|
||||||
|
// 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;
|
_centerOfMass = getCenterOfMass _vehicle;
|
||||||
_bbr = boundingBoxReal _vehicle;
|
_bbr = boundingBoxReal _vehicle;
|
||||||
_p1 = _bbr select 0;
|
_p1 = _bbr select 0;
|
||||||
_p2 = _bbr select 1;
|
_p2 = _bbr select 1;
|
||||||
_maxWidth = abs ((_p2 select 0) - (_p1 select 0));
|
_maxWidth = abs ((_p2 select 0) - (_p1 select 0));
|
||||||
_widthOffset = ((_maxWidth / 2) - abs ( _centerOfMass select 0 )) * 0.75;
|
_widthOffset = ((_maxWidth / 2) - abs ( _centerOfMass select 0 )) * _widthFactor;
|
||||||
_maxLength = abs ((_p2 select 1) - (_p1 select 1));
|
_maxLength = abs ((_p2 select 1) - (_p1 select 1));
|
||||||
_lengthOffset = ((_maxLength / 2) - abs (_centerOfMass select 1 )) * 0.75;
|
_lengthOffset = ((_maxLength / 2) - abs (_centerOfMass select 1 )) * _lengthFactor;
|
||||||
_rearCorner = [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) - _lengthOffset, _centerOfMass select 2];
|
_rearCorner = [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) - _lengthOffset, _centerOfMass select 2];
|
||||||
_rearCorner2 = [(_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];
|
_frontCorner = [(_centerOfMass select 0) + _widthOffset, (_centerOfMass select 1) + _lengthOffset, _centerOfMass select 2];
|
||||||
_frontCorner2 = [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) + _lengthOffset, _centerOfMass select 2];
|
_frontCorner2 = [(_centerOfMass select 0) - _widthOffset, (_centerOfMass select 1) + _lengthOffset, _centerOfMass select 2];
|
||||||
|
|
||||||
|
if(missionNamespace getVariable ["SA_TOW_DEBUG_ENABLED", false]) then {
|
||||||
|
if(isNil "sa_tow_debug_arrow_1") then {
|
||||||
|
sa_tow_debug_arrow_1 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
sa_tow_debug_arrow_2 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
sa_tow_debug_arrow_3 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
sa_tow_debug_arrow_4 = "Sign_Arrow_F" createVehicleLocal [0,0,0];
|
||||||
|
};
|
||||||
|
sa_tow_debug_arrow_1 setPosASL AGLtoASL (_vehicle modelToWorldVisual _rearCorner);
|
||||||
|
sa_tow_debug_arrow_2 setPosASL AGLtoASL (_vehicle modelToWorldVisual _rearCorner2);
|
||||||
|
sa_tow_debug_arrow_3 setPosASL AGLtoASL (_vehicle modelToWorldVisual _frontCorner);
|
||||||
|
sa_tow_debug_arrow_4 setPosASL AGLtoASL (_vehicle modelToWorldVisual _frontCorner2);
|
||||||
|
};
|
||||||
|
|
||||||
[_rearCorner,_rearCorner2,_frontCorner,_frontCorner2];
|
[_rearCorner,_rearCorner2,_frontCorner,_frontCorner2];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -183,9 +331,9 @@ SA_Get_Hitch_Points = {
|
|||||||
_frontCorner2 = _cornerPoints select 3;
|
_frontCorner2 = _cornerPoints select 3;
|
||||||
_rearHitchPoint = ((_rearCorner vectorDiff _rearCorner2) vectorMultiply 0.5) vectorAdd _rearCorner2;
|
_rearHitchPoint = ((_rearCorner vectorDiff _rearCorner2) vectorMultiply 0.5) vectorAdd _rearCorner2;
|
||||||
_frontHitchPoint = ((_frontCorner vectorDiff _frontCorner2) vectorMultiply 0.5) vectorAdd _frontCorner2;
|
_frontHitchPoint = ((_frontCorner vectorDiff _frontCorner2) vectorMultiply 0.5) vectorAdd _frontCorner2;
|
||||||
_sideLeftPoint = ((_frontCorner vectorDiff _rearCorner) vectorMultiply 0.5) vectorAdd _frontCorner;
|
//_sideLeftPoint = ((_frontCorner vectorDiff _rearCorner) vectorMultiply 0.5) vectorAdd _frontCorner;
|
||||||
_sideRightPoint = ((_frontCorner2 vectorDiff _rearCorner2) vectorMultiply 0.5) vectorAdd _frontCorner2;
|
//_sideRightPoint = ((_frontCorner2 vectorDiff _rearCorner2) vectorMultiply 0.5) vectorAdd _frontCorner2;
|
||||||
[_frontHitchPoint,_rearHitchPoint,_sideLeftPoint,_sideRightPoint];
|
[_frontHitchPoint,_rearHitchPoint];
|
||||||
};
|
};
|
||||||
|
|
||||||
SA_Attach_Tow_Ropes = {
|
SA_Attach_Tow_Ropes = {
|
||||||
@ -196,35 +344,41 @@ SA_Attach_Tow_Ropes = {
|
|||||||
private ["_towRopes","_vehicleHitch","_cargoHitch","_objDistance","_ropeLength"];
|
private ["_towRopes","_vehicleHitch","_cargoHitch","_objDistance","_ropeLength"];
|
||||||
_towRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
|
_towRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
|
||||||
if(count _towRopes == 1) then {
|
if(count _towRopes == 1) then {
|
||||||
/*_closestCargoHitch = [0,0,0];
|
|
||||||
_closestDistance = -1;
|
/*
|
||||||
{
|
private ["_cargoHitchPoints","_distanceToFrontHitch","_distanceToRearHitch","_isRearCargoHitch"];
|
||||||
_distanceToHitch = player distance (_cargo modelToWorld _x);
|
_cargoHitchPoints = [_cargo] call SA_Get_Hitch_Points;
|
||||||
if(_closestDistance < 0 || _distanceToHitch < _closestCargoHitch) then {
|
_distanceToFrontHitch = player distance (_cargo modelToWorld (_cargoHitchPoints select 0));
|
||||||
_closestCargoHitch = _x;
|
_distanceToRearHitch = player distance (_cargo modelToWorld (_cargoHitchPoints select 1));
|
||||||
_closestDistance = _distanceToHitch;
|
if( _distanceToFrontHitch < _distanceToRearHitch ) then {
|
||||||
};
|
_cargoHitch = _cargoHitchPoints select 0;
|
||||||
} forEach ([_cargo] call SA_Get_Hitch_Points);
|
_isRearCargoHitch = false;
|
||||||
_cargoHitch = _closestCargoHitch;
|
} else {
|
||||||
|
_cargoHitch = _cargoHitchPoints select 1;
|
||||||
|
_isRearCargoHitch = true;
|
||||||
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_cargoHitch = ([_cargo] call SA_Get_Hitch_Points) select 0;
|
_cargoHitch = ([_cargo] call SA_Get_Hitch_Points) select 0;
|
||||||
|
|
||||||
_vehicleHitch = ([_vehicle] call SA_Get_Hitch_Points) select 1;
|
_vehicleHitch = ([_vehicle] call SA_Get_Hitch_Points) select 1;
|
||||||
_ropeLength = (ropeLength (_towRopes select 0));
|
_ropeLength = (ropeLength (_towRopes select 0));
|
||||||
_objDistance = ((_vehicle modelToWorld _vehicleHitch) distance (_cargo modelToWorld _cargoHitch));
|
_objDistance = ((_vehicle modelToWorld _vehicleHitch) distance (_cargo modelToWorld _cargoHitch));
|
||||||
if( _objDistance > _ropeLength ) then {
|
if( _objDistance > _ropeLength ) then {
|
||||||
"The tow ropes are too short. Move vehicle closer." remoteExec ["hint", _player];
|
[["The tow ropes are too short. Move vehicle closer.", false],"SA_Hint",_player] call SA_RemoteExec;
|
||||||
} else {
|
} else {
|
||||||
[_vehicle,_player] call SA_Drop_Tow_Ropes;
|
[_vehicle,_player] call SA_Drop_Tow_Ropes;
|
||||||
_helper = "Land_Can_V2_F" createVehicle position _cargo;
|
_helper = "Land_Can_V2_F" createVehicle position _cargo;
|
||||||
_helper attachTo [_cargo, _cargoHitch];
|
_helper attachTo [_cargo, _cargoHitch];
|
||||||
|
_helper setVariable ["SA_Cargo",_cargo,true];
|
||||||
hideObject _helper;
|
hideObject _helper;
|
||||||
_helper remoteExec ["hideObjectGlobal",2];
|
[[_helper],"SA_Hide_Object_Global"] call SA_RemoteExecServer;
|
||||||
[_helper, [0,0,0], [0,0,-1]] ropeAttachTo (_towRopes select 0);
|
[_helper, [0,0,0], [0,0,-1]] ropeAttachTo (_towRopes select 0);
|
||||||
[_vehicle,_vehicleHitch,_cargo,_cargoHitch,_ropeLength] spawn SA_Simulate_Towing;
|
[_vehicle,_vehicleHitch,_cargo,_cargoHitch,_ropeLength] spawn SA_Simulate_Towing;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
_this remoteExecCall ["SA_Attach_Tow_Ropes", _vehicle];
|
[_this,"SA_Attach_Tow_Ropes",_vehicle,true] call SA_RemoteExec;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -242,25 +396,7 @@ SA_Take_Tow_Ropes = {
|
|||||||
_this call SA_Pickup_Tow_Ropes;
|
_this call SA_Pickup_Tow_Ropes;
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
_this remoteExecCall ["SA_Take_Tow_Ropes", _vehicle];
|
[_this,"SA_Take_Tow_Ropes",_vehicle,true] call SA_RemoteExec;
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
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 remoteExecCall ["SA_Put_Away_Tow_Ropes", _vehicle];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -273,6 +409,7 @@ SA_Pickup_Tow_Ropes = {
|
|||||||
{
|
{
|
||||||
_attachedObj ropeDetach _x;
|
_attachedObj ropeDetach _x;
|
||||||
} forEach (_vehicle getVariable ["SA_Tow_Ropes",[]]);
|
} forEach (_vehicle getVariable ["SA_Tow_Ropes",[]]);
|
||||||
|
deleteVehicle _attachedObj;
|
||||||
} forEach ropeAttachedObjects _vehicle;
|
} forEach ropeAttachedObjects _vehicle;
|
||||||
_helper = "Land_Can_V2_F" createVehicle position _player;
|
_helper = "Land_Can_V2_F" createVehicle position _player;
|
||||||
{
|
{
|
||||||
@ -280,11 +417,11 @@ SA_Pickup_Tow_Ropes = {
|
|||||||
_helper attachTo [_player, [-0.1, 0.1, 0.15], "Pelvis"];
|
_helper attachTo [_player, [-0.1, 0.1, 0.15], "Pelvis"];
|
||||||
} forEach (_vehicle getVariable ["SA_Tow_Ropes",[]]);
|
} forEach (_vehicle getVariable ["SA_Tow_Ropes",[]]);
|
||||||
hideObject _helper;
|
hideObject _helper;
|
||||||
_helper remoteExec ["hideObjectGlobal",2];
|
[[_helper],"SA_Hide_Object_Global"] call SA_RemoteExecServer;
|
||||||
_player setVariable ["SA_Tow_Ropes_Vehicle", _vehicle,true];
|
_player setVariable ["SA_Tow_Ropes_Vehicle", _vehicle,true];
|
||||||
_player setVariable ["SA_Tow_Ropes_Pick_Up_Helper", _helper,true];
|
_player setVariable ["SA_Tow_Ropes_Pick_Up_Helper", _helper,true];
|
||||||
} else {
|
} else {
|
||||||
_this remoteExecCall ["SA_Pickup_Tow_Ropes", _vehicle];
|
[_this,"SA_Pickup_Tow_Ropes",_vehicle,true] call SA_RemoteExec;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -303,62 +440,158 @@ SA_Drop_Tow_Ropes = {
|
|||||||
_player setVariable ["SA_Tow_Ropes_Vehicle", nil,true];
|
_player setVariable ["SA_Tow_Ropes_Vehicle", nil,true];
|
||||||
_player setVariable ["SA_Tow_Ropes_Pick_Up_Helper", nil,true];
|
_player setVariable ["SA_Tow_Ropes_Pick_Up_Helper", nil,true];
|
||||||
} else {
|
} else {
|
||||||
_this remoteExecCall ["SA_Drop_Tow_Ropes", _vehicle];
|
[_this,"SA_Drop_Tow_Ropes",_vehicle,true] call SA_RemoteExec;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
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_Attach_Tow_Ropes_Action = {
|
SA_Attach_Tow_Ropes_Action = {
|
||||||
private ["_vehicle","_towVehicle"];
|
private ["_vehicle","_cargo","_canBeTowed"];
|
||||||
_vehicle = cursorTarget;
|
_cargo = cursorTarget;
|
||||||
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
||||||
if(!isNull _towVehicle && !isNull _vehicle) then {
|
if([_vehicle,_cargo] call SA_Can_Attach_Tow_Ropes) then {
|
||||||
if([_towVehicle,_vehicle] call SA_Is_Supported_Cargo && vehicle player == player && player distance _vehicle < 10 && _towVehicle != _vehicle) then {
|
|
||||||
[_vehicle,player] call SA_Attach_Tow_Ropes;
|
_canBeTowed = true;
|
||||||
} else {
|
|
||||||
false;
|
if!(missionNamespace getVariable ["SA_TOW_LOCKED_VEHICLES_ENABLED",false]) then {
|
||||||
|
if( locked _cargo > 1 ) then {
|
||||||
|
["Cannot attach tow ropes to locked vehicle",false] call SA_Hint;
|
||||||
|
_canBeTowed = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
false;
|
if!(missionNamespace getVariable ["SA_TOW_IN_EXILE_SAFEZONE_ENABLED",false]) then {
|
||||||
|
if(!isNil "ExilePlayerInSafezone") then {
|
||||||
|
if( ExilePlayerInSafezone ) then {
|
||||||
|
["Cannot attach tow ropes in safe zone",false] call SA_Hint;
|
||||||
|
_canBeTowed = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if(_canBeTowed) then {
|
||||||
|
[_cargo,player] call SA_Attach_Tow_Ropes;
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
SA_Attach_Tow_Ropes_Action_Check = {
|
SA_Attach_Tow_Ropes_Action_Check = {
|
||||||
private ["_vehicle","_towVehicle"];
|
private ["_vehicle","_cargo"];
|
||||||
_vehicle = cursorTarget;
|
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
||||||
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
_cargo = cursorTarget;
|
||||||
if(!isNull _towVehicle && !isNull _vehicle) then {
|
[_vehicle,_cargo] call SA_Can_Attach_Tow_Ropes;
|
||||||
[_towVehicle,_vehicle] call SA_Is_Supported_Cargo && vehicle player == player && player distance _vehicle < 10 && _towVehicle != _vehicle;
|
};
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
false;
|
false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
SA_Attach_Tow_Ropes_Action_Disabled_Check = {
|
SA_Take_Tow_Ropes_Action = {
|
||||||
private ["_vehicle","_towVehicle"];
|
private ["_vehicle","_canTakeTowRopes"];
|
||||||
_vehicle = cursorTarget;
|
_vehicle = cursorTarget;
|
||||||
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
if([_vehicle] call SA_Can_Take_Tow_Ropes) then {
|
||||||
if(!isNull _towVehicle && !isNull _vehicle) then {
|
|
||||||
not([_towVehicle,_vehicle] call SA_Is_Supported_Cargo) && vehicle player == player && player distance _vehicle < 10 && _towVehicle != _vehicle;
|
_canTakeTowRopes = true;
|
||||||
} else {
|
|
||||||
false;
|
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 = {
|
SA_Take_Tow_Ropes_Action_Check = {
|
||||||
private ["_vehicle"];
|
[cursorTarget] call SA_Can_Take_Tow_Ropes;
|
||||||
_vehicle = cursorTarget;
|
};
|
||||||
|
|
||||||
|
SA_Can_Take_Tow_Ropes = {
|
||||||
|
params ["_vehicle"];
|
||||||
if([_vehicle] call SA_Is_Supported_Vehicle) then {
|
if([_vehicle] call SA_Is_Supported_Vehicle) then {
|
||||||
|
private ["_existingVehicle","_existingTowRopes"];
|
||||||
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
|
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
|
||||||
_towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
_existingVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
||||||
vehicle player == player && player distance _vehicle < 10 && (count _existingTowRopes) == 0 && isNull _towVehicle;
|
vehicle player == player && player distance _vehicle < 10 && (count _existingTowRopes) == 0 && isNull _existingVehicle;
|
||||||
} else {
|
} else {
|
||||||
false;
|
false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
SA_Put_Away_Tow_Ropes_Action_Check = {
|
SA_Put_Away_Tow_Ropes_Action = {
|
||||||
private ["_vehicle"];
|
private ["_vehicle","_canPutAwayTowRopes"];
|
||||||
_vehicle = cursorTarget;
|
_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 {
|
if([_vehicle] call SA_Is_Supported_Vehicle) then {
|
||||||
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
|
_existingTowRopes = _vehicle getVariable ["SA_Tow_Ropes",[]];
|
||||||
vehicle player == player && player distance _vehicle < 10 && (count _existingTowRopes) > 0;
|
vehicle player == player && player distance _vehicle < 10 && (count _existingTowRopes) > 0;
|
||||||
@ -367,30 +600,64 @@ SA_Put_Away_Tow_Ropes_Action_Check = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
SA_Drop_Tow_Ropes_Action_Check = {
|
|
||||||
!isNull (player getVariable ["SA_Tow_Ropes_Vehicle", objNull]) && vehicle player == player;
|
|
||||||
};
|
|
||||||
|
|
||||||
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_Pickup_Tow_Ropes_Action = {
|
|
||||||
private ["_nearbyTowVehicles"];
|
|
||||||
_nearbyTowVehicles = missionNamespace getVariable ["SA_Nearby_Tow_Vehicles",[]];
|
|
||||||
if(count _nearbyTowVehicles > 0) then {
|
|
||||||
[_nearbyTowVehicles select 0, player] call SA_Pickup_Tow_Ropes;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
SA_Drop_Tow_Ropes_Action = {
|
SA_Drop_Tow_Ropes_Action = {
|
||||||
private ["_vehicle"];
|
private ["_vehicle"];
|
||||||
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
_vehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull];
|
||||||
if(!isNull _vehicle) then {
|
if([] call SA_Can_Drop_Tow_Ropes) then {
|
||||||
[_vehicle, player] call SA_Drop_Tow_Ropes;
|
[_vehicle, player] call SA_Drop_Tow_Ropes;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SA_Drop_Tow_Ropes_Action_Check = {
|
||||||
|
[] call SA_Can_Drop_Tow_Ropes;
|
||||||
|
};
|
||||||
|
|
||||||
|
SA_Can_Drop_Tow_Ropes = {
|
||||||
|
!isNull (player getVariable ["SA_Tow_Ropes_Vehicle", objNull]) && vehicle player == player;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SA_Pickup_Tow_Ropes_Action = {
|
||||||
|
private ["_nearbyTowVehicles","_canPickupTowRopes","_vehicle"];
|
||||||
|
_nearbyTowVehicles = missionNamespace getVariable ["SA_Nearby_Tow_Vehicles",[]];
|
||||||
|
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_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 = [
|
SA_TOW_SUPPORTED_VEHICLES = [
|
||||||
"Tank", "Car", "Ship"
|
"Tank", "Car", "Ship"
|
||||||
];
|
];
|
||||||
@ -403,7 +670,7 @@ SA_Is_Supported_Vehicle = {
|
|||||||
if(_vehicle isKindOf _x) then {
|
if(_vehicle isKindOf _x) then {
|
||||||
_isSupported = true;
|
_isSupported = true;
|
||||||
};
|
};
|
||||||
} forEach SA_TOW_SUPPORTED_VEHICLES;
|
} forEach (missionNamespace getVariable ["SA_TOW_SUPPORTED_VEHICLES_OVERRIDE",SA_TOW_SUPPORTED_VEHICLES]);
|
||||||
};
|
};
|
||||||
_isSupported;
|
_isSupported;
|
||||||
};
|
};
|
||||||
@ -413,18 +680,13 @@ SA_TOW_RULES = [
|
|||||||
["Tank","CAN_TOW","Car"],
|
["Tank","CAN_TOW","Car"],
|
||||||
["Tank","CAN_TOW","Ship"],
|
["Tank","CAN_TOW","Ship"],
|
||||||
["Tank","CAN_TOW","Air"],
|
["Tank","CAN_TOW","Air"],
|
||||||
["Tank","CAN_TOW","Cargo_base_F"],
|
["Car","CAN_TOW","Tank"],
|
||||||
["Car","CAN_TOW","Car"],
|
["Car","CAN_TOW","Car"],
|
||||||
["Car","CAN_TOW","Ship"],
|
["Car","CAN_TOW","Ship"],
|
||||||
["Car","CAN_TOW","Air"],
|
["Car","CAN_TOW","Air"],
|
||||||
["Car","CANT_TOW","Helicopter"],
|
|
||||||
["Truck_F","CAN_TOW","Helicopter"],
|
|
||||||
["Truck_F","CAN_TOW","Cargo_base_F"],
|
|
||||||
["Ship","CAN_TOW","Ship"]
|
["Ship","CAN_TOW","Ship"]
|
||||||
];
|
];
|
||||||
|
|
||||||
SA_TOW_RULES_OVERRIDE = [];
|
|
||||||
|
|
||||||
SA_Is_Supported_Cargo = {
|
SA_Is_Supported_Cargo = {
|
||||||
params ["_vehicle","_cargo"];
|
params ["_vehicle","_cargo"];
|
||||||
private ["_canTow"];
|
private ["_canTow"];
|
||||||
@ -440,88 +702,60 @@ SA_Is_Supported_Cargo = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} forEach (SA_TOW_RULES + SA_TOW_RULES_OVERRIDE);
|
} forEach (missionNamespace getVariable ["SA_TOW_RULES_OVERRIDE",SA_TOW_RULES]);
|
||||||
};
|
};
|
||||||
_canTow;
|
_canTow;
|
||||||
};
|
};
|
||||||
|
|
||||||
SA_Take_Tow_Ropes_Action = {
|
SA_Hint = {
|
||||||
private ["_vehicle"];
|
params ["_msg",["_isSuccess",true]];
|
||||||
_vehicle = cursorTarget;
|
if(!isNil "ExileClient_gui_notification_event_addNotification") then {
|
||||||
if([_vehicle] call SA_Is_Supported_Vehicle) then {
|
if(_isSuccess) then {
|
||||||
[_vehicle,player] call SA_Take_Tow_Ropes;
|
["Success", [_msg]] call ExileClient_gui_notification_event_addNotification;
|
||||||
|
} else {
|
||||||
|
["Whoops", [_msg]] call ExileClient_gui_notification_event_addNotification;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
hint _msg;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
SA_Hide_Object_Global = {
|
||||||
|
params ["_obj"];
|
||||||
|
if( _obj isKindOf "Land_Can_V2_F" ) then {
|
||||||
|
hideObjectGlobal _obj;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SA_Set_Owner = {
|
||||||
SA_Put_Away_Tow_Ropes_Action = {
|
params ["_obj","_client"];
|
||||||
private ["_vehicle"];
|
_obj setOwner _client;
|
||||||
_vehicle = cursorTarget;
|
|
||||||
if([_vehicle] call SA_Is_Supported_Vehicle) then {
|
|
||||||
[_vehicle,player] call SA_Put_Away_Tow_Ropes;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if(hasInterface) then {
|
SA_Add_Player_Tow_Actions = {
|
||||||
|
|
||||||
player addAction ["Deploy Tow Ropes", {
|
player addAction ["Deploy Tow Ropes", {
|
||||||
[] call SA_Take_Tow_Ropes_Action;
|
[] call SA_Take_Tow_Ropes_Action;
|
||||||
}, nil, 0, false, true, "", "call SA_Take_Tow_Ropes_Action_Check"];
|
}, nil, 0, false, true, "", "call SA_Take_Tow_Ropes_Action_Check"];
|
||||||
|
|
||||||
player addEventHandler ["Respawn", {
|
|
||||||
player addAction ["Deploy Tow Ropes", {
|
|
||||||
[] call SA_Take_Tow_Ropes_Action;
|
|
||||||
}, nil, 0, false, true, "", "call SA_Take_Tow_Ropes_Action_Check"];
|
|
||||||
}];
|
|
||||||
|
|
||||||
player addAction ["Put Away Tow Ropes", {
|
player addAction ["Put Away Tow Ropes", {
|
||||||
[] call SA_Put_Away_Tow_Ropes_Action;
|
[] call SA_Put_Away_Tow_Ropes_Action;
|
||||||
}, nil, 0, false, true, "", "call SA_Put_Away_Tow_Ropes_Action_Check"];
|
}, nil, 0, false, true, "", "call SA_Put_Away_Tow_Ropes_Action_Check"];
|
||||||
|
|
||||||
player addEventHandler ["Respawn", {
|
|
||||||
player addAction ["Put Away Tow Ropes", {
|
|
||||||
[] call SA_Put_Away_Tow_Ropes_Action;
|
|
||||||
}, nil, 0, false, true, "", "call SA_Put_Away_Tow_Ropes_Action_Check"];
|
|
||||||
}];
|
|
||||||
|
|
||||||
player addAction ["Attach To Tow Ropes", {
|
player addAction ["Attach To Tow Ropes", {
|
||||||
[] call SA_Attach_Tow_Ropes_Action;
|
[] call SA_Attach_Tow_Ropes_Action;
|
||||||
}, nil, 0, false, true, "", "call SA_Attach_Tow_Ropes_Action_Check"];
|
}, nil, 0, false, true, "", "call SA_Attach_Tow_Ropes_Action_Check"];
|
||||||
|
|
||||||
player addEventHandler ["Respawn", {
|
|
||||||
player addAction ["Attach To Tow Ropes", {
|
|
||||||
[] call SA_Attach_Tow_Ropes_Action;
|
|
||||||
}, nil, 0, false, true, "", "call SA_Attach_Tow_Ropes_Action_Check"];
|
|
||||||
}];
|
|
||||||
|
|
||||||
player addAction ["Cannot Attach Tow Ropes", {
|
|
||||||
hint "Your vehicle is not strong enough to tow this. Find a larger vehicle!";
|
|
||||||
}, nil, 0, false, true, "", "call SA_Attach_Tow_Ropes_Action_Disabled_Check"];
|
|
||||||
|
|
||||||
player addEventHandler ["Respawn", {
|
|
||||||
player addAction ["Cannot Attach Tow Ropes", {
|
|
||||||
hint "Your vehicle is not strong enough to tow this. Find a larger vehicle!";
|
|
||||||
}, nil, 0, false, true, "", "call SA_Attach_Tow_Ropes_Action_Disabled_Check"];
|
|
||||||
}];
|
|
||||||
|
|
||||||
player addAction ["Drop Tow Ropes", {
|
player addAction ["Drop Tow Ropes", {
|
||||||
[] call SA_Drop_Tow_Ropes_Action;
|
[] call SA_Drop_Tow_Ropes_Action;
|
||||||
}, nil, 0, false, true, "", "call SA_Drop_Tow_Ropes_Action_Check"];
|
}, nil, 0, false, true, "", "call SA_Drop_Tow_Ropes_Action_Check"];
|
||||||
|
|
||||||
player addEventHandler ["Respawn", {
|
|
||||||
player addAction ["Drop Tow Ropes", {
|
|
||||||
[] call SA_Drop_Tow_Ropes_Action;
|
|
||||||
}, nil, 0, false, true, "", "call SA_Drop_Tow_Ropes_Action_Check"];
|
|
||||||
}];
|
|
||||||
|
|
||||||
player addAction ["Pickup Tow Ropes", {
|
player addAction ["Pickup Tow Ropes", {
|
||||||
[] call SA_Pickup_Tow_Ropes_Action;
|
[] call SA_Pickup_Tow_Ropes_Action;
|
||||||
}, nil, 0, false, true, "", "call SA_Pickup_Tow_Ropes_Action_Check"];
|
}, nil, 0, false, true, "", "call SA_Pickup_Tow_Ropes_Action_Check"];
|
||||||
|
|
||||||
player addEventHandler ["Respawn", {
|
player addEventHandler ["Respawn", {
|
||||||
player addAction ["Pickup Tow Ropes", {
|
player setVariable ["SA_Tow_Actions_Loaded",false];
|
||||||
[] call SA_Pickup_Tow_Ropes_Action;
|
|
||||||
}, nil, 0, false, true, "", "call SA_Pickup_Tow_Ropes_Action_Check"];
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -531,7 +765,7 @@ SA_Find_Nearby_Tow_Vehicles = {
|
|||||||
_nearVehicles = [];
|
_nearVehicles = [];
|
||||||
{
|
{
|
||||||
_nearVehicles append (position player nearObjects [_x, 30]);
|
_nearVehicles append (position player nearObjects [_x, 30]);
|
||||||
} forEach SA_TOW_SUPPORTED_VEHICLES;
|
} forEach (missionNamespace getVariable ["SA_TOW_SUPPORTED_VEHICLES_OVERRIDE",SA_TOW_SUPPORTED_VEHICLES]);
|
||||||
_nearVehiclesWithTowRopes = [];
|
_nearVehiclesWithTowRopes = [];
|
||||||
{
|
{
|
||||||
_vehicle = _x;
|
_vehicle = _x;
|
||||||
@ -549,16 +783,90 @@ SA_Find_Nearby_Tow_Vehicles = {
|
|||||||
_nearVehiclesWithTowRopes;
|
_nearVehiclesWithTowRopes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if(!isDedicated) then {
|
if(!isDedicated) then {
|
||||||
[] spawn {
|
[] spawn {
|
||||||
while {true} do {
|
while {true} do {
|
||||||
|
if(!isNull player && isPlayer player) then {
|
||||||
|
if!( player getVariable ["SA_Tow_Actions_Loaded",false] ) then {
|
||||||
|
[] call SA_Add_Player_Tow_Actions;
|
||||||
|
player setVariable ["SA_Tow_Actions_Loaded",true];
|
||||||
|
};
|
||||||
|
};
|
||||||
missionNamespace setVariable ["SA_Nearby_Tow_Vehicles", (call SA_Find_Nearby_Tow_Vehicles)];
|
missionNamespace setVariable ["SA_Nearby_Tow_Vehicles", (call SA_Find_Nearby_Tow_Vehicles)];
|
||||||
sleep 2;
|
sleep 2;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SA_RemoteExec = {
|
||||||
|
params ["_params","_functionName","_target",["_isCall",false]];
|
||||||
|
if(!isNil "ExileClient_system_network_send") then {
|
||||||
|
["AdvancedTowingRemoteExecClient",[_params,_functionName,_target,_isCall]] call ExileClient_system_network_send;
|
||||||
|
} else {
|
||||||
|
if(_isCall) then {
|
||||||
|
_params remoteExecCall [_functionName, _target];
|
||||||
|
} else {
|
||||||
|
_params remoteExec [_functionName, _target];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
SA_RemoteExecServer = {
|
||||||
|
params ["_params","_functionName",["_isCall",false]];
|
||||||
|
if(!isNil "ExileClient_system_network_send") then {
|
||||||
|
["AdvancedTowingRemoteExecServer",[_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) //
|
||||||
|
|
||||||
|
SA_SUPPORTED_REMOTEEXECSERVER_FUNCTIONS = ["SA_Set_Owner","SA_Hide_Object_Global"];
|
||||||
|
|
||||||
|
ExileServer_AdvancedTowing_network_AdvancedTowingRemoteExecServer = {
|
||||||
|
params ["_sessionId", "_messageParameters",["_isCall",false]];
|
||||||
|
_messageParameters params ["_params","_functionName"];
|
||||||
|
if(_functionName in SA_SUPPORTED_REMOTEEXECSERVER_FUNCTIONS) then {
|
||||||
|
if(_isCall) then {
|
||||||
|
_params call (missionNamespace getVariable [_functionName,{}]);
|
||||||
|
} else {
|
||||||
|
_params spawn (missionNamespace getVariable [_functionName,{}]);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
SA_SUPPORTED_REMOTEEXECCLIENT_FUNCTIONS = ["SA_Simulate_Towing","SA_Attach_Tow_Ropes","SA_Take_Tow_Ropes","SA_Put_Away_Tow_Ropes","SA_Pickup_Tow_Ropes","SA_Drop_Tow_Ropes","SA_Hint"];
|
||||||
|
|
||||||
|
ExileServer_AdvancedTowing_network_AdvancedTowingRemoteExecClient = {
|
||||||
|
params ["_sessionId", "_messageParameters"];
|
||||||
|
_messageParameters params ["_params","_functionName","_target",["_isCall",false]];
|
||||||
|
if(_functionName in SA_SUPPORTED_REMOTEEXECCLIENT_FUNCTIONS) then {
|
||||||
|
if(_isCall) then {
|
||||||
|
_params remoteExecCall [_functionName, _target];
|
||||||
|
} else {
|
||||||
|
_params remoteExec [_functionName, _target];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Install Advanced Towing on all clients (plus JIP) //
|
||||||
|
|
||||||
|
publicVariable "SA_Advanced_Towing_Install";
|
||||||
|
remoteExecCall ["SA_Advanced_Towing_Install", -2,true];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
diag_log "Advanced Towing Loaded";
|
diag_log "Advanced Towing Loaded";
|
||||||
|
|
||||||
} remoteExecCall ["bis_fnc_call", 0,true];
|
};
|
||||||
|
|
||||||
|
if(isServer) then {
|
||||||
|
[] call SA_Advanced_Towing_Install;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user