Add Vehicle Towing (#8380)

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Brandon Danyluk 2021-10-12 03:33:05 -06:00 committed by GitHub
parent 65b9cf3754
commit ca7fbe742c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 889 additions and 147 deletions

View File

@ -48,6 +48,16 @@ class CfgVehicles {
condition = QUOTE([_target] call FUNC(canStowFRIES));
statement = QUOTE([_target] call FUNC(stowFRIES));
};
class ACE_deployRopes3 {
displayName = CSTRING(Interaction_deployRopes3);
condition = QUOTE([ARR_3(_target,_player,'ACE_rope3')] call FUNC(canDeployRopes));
statement = QUOTE([ARR_2(QQGVAR(deployRopes),[ARR_3(_target,_player,'ACE_rope3')])] call CBA_fnc_serverEvent);
};
class ACE_deployRopes6 {
displayName = CSTRING(Interaction_deployRopes6);
condition = QUOTE([ARR_3(_target,_player,'ACE_rope6')] call FUNC(canDeployRopes));
statement = QUOTE([ARR_2(QQGVAR(deployRopes),[ARR_3(_target,_player,'ACE_rope6')])] call CBA_fnc_serverEvent);
};
class ACE_deployRopes12 {
displayName = CSTRING(Interaction_deployRopes12);
condition = QUOTE([ARR_3(_target,_player,'ACE_rope12')] call FUNC(canDeployRopes));

View File

@ -1,60 +0,0 @@
class CfgWeapons {
class ACE_ItemCore;
class CBA_MiscItem_ItemInfo;
class ACE_rope12: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 12.2;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_12_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 36;
};
};
class ACE_rope15: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 15.2;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_15_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 45;
};
};
class ACE_rope18: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 18.3;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_18_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 54;
};
};
class ACE_rope27: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 27.4;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_27_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 81;
};
};
class ACE_rope36: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 36.6;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_36_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 108;
};
};
};

View File

@ -6,7 +6,7 @@ class CfgPatches {
units[] = {"ACE_fastropingSupplyCrate"};
weapons[] = {"ACE_rope12","ACE_rope15","ACE_rope18","ACE_rope27","ACE_rope36"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
requiredAddons[] = {"ace_interaction","ace_logistics_rope"};
author = ECSTRING(common,ACETeam);
authors[] = {"KoffeinFlummi", "BaerMitUmlaut", "Pokertour"};
url = ECSTRING(main,URL);
@ -19,4 +19,4 @@ class CfgPatches {
#include "CfgSounds.hpp"
#include "CfgVehicles.hpp"
#include "CfgWaypoints.hpp"
#include "CfgWeapons.hpp"

View File

@ -26,7 +26,7 @@ private _ropeOrigins = getArray (_config >> QGVAR(ropeOrigins));
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
private _hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
private _ropeLength = getNumber (configfile >> "CfgWeapons" >> _ropeClass >> QGVAR(ropeLength));
private _ropeLength = getNumber (configfile >> "CfgWeapons" >> _ropeClass >> QEGVAR(logistics_rope,length));
if (_ropeLength <= 0) then {
_ropeLength = DEFAULT_ROPE_LENGTH;

View File

@ -156,6 +156,30 @@
<Czech>UMOŽNIT JEDNOTKÁM SLAŇOVAT</Czech>
<Spanish>INDICAR A LAS UNIDADES DESCENDER POR LA CUERDA</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes3">
<English>Deploy 3m ropes</English>
<German>3m Seile einsetzen</German>
<French>Déployer les cordes de 3 m</French>
<Polish>Wysuń linę o długości 3 m.</Polish>
<Russian>Выпустить 3 м канат</Russian>
<Portuguese>Jogar cordar (3m)</Portuguese>
<Italian>Dispiegamento corde 3m</Italian>
<Czech>Připravit 3m lana</Czech>
<Turkish>3m halat sal</Turkish>
<Spanish>Desplegar cuerdas de 3m</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes6">
<English>Deploy 6m ropes</English>
<German>6m Seile einsetzen</German>
<French>Déployer les cordes de 6 m</French>
<Polish>Wysuń linę o długości 6 m.</Polish>
<Russian>Выпустить 6 м канат</Russian>
<Portuguese>Jogar cordar (6m)</Portuguese>
<Italian>Dispiegamento corde 6m</Italian>
<Czech>Připravit 6m lana</Czech>
<Turkish>6m halat sal</Turkish>
<Spanish>Desplegar cuerdas de 6m</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes12">
<English>Deploy 12m ropes</English>
<German>12m Seile einsetzen</German>
@ -240,90 +264,6 @@
<Turkish>[ACE] Halat Sandığı</Turkish>
<Spanish>[ACE] Caja de suministros - cuerdas</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_descriptionShort">
<English>Used to do deploy ropes from a compatibile helicopter</English>
<German>Wird zum Bereitstellen von Seilen aus einem kompatiblen Hubschrauber verwendet</German>
<French>Utilisé pour déployer des cordes depuis un hélicoptère compatible.</French>
<Japanese>対応するヘリコプターからロープを展開する為に使用されます</Japanese>
<Polish>Używane do opuszczania lin z kompatybilnych smigłowców</Polish>
<Russian>Используется для выпуска канатов с совместимого вертолета</Russian>
<Portuguese>Usado para fazer descida rápida de corda em helicópteros compatíveis com FRIES</Portuguese>
<Chinese>在可相容的直升機上部屬繩索</Chinese>
<Italian>Utilizzato per distribuire corde da un elicottero compatibile</Italian>
<Czech>Používané na přípravu lan na slaňování z kompatibilních helikoptér</Czech>
<Spanish>Usar para desplegar cuerdas desde helicopteros compatibles</Spanish>
<Turkish>Halatları uyumlu helikopterlerden salmak için kullanır</Turkish>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_12_Display">
<English>Rope 12.2 meters</English>
<German>12.2 Meter Seil</German>
<French>Corde de 12,2 mètres</French>
<Japanese>ロープ (12.2 メートル)</Japanese>
<Polish>Lina, długość 12,2 m.</Polish>
<Russian>Канат 12.2 метров</Russian>
<Portuguese>Corda (12.2m)</Portuguese>
<Chinese>繩索12.2公尺長)</Chinese>
<Italian>Corda da 12.2 metri</Italian>
<Czech>Lano 12.2 metrů</Czech>
<Turkish>12.2 metre halat</Turkish>
<Spanish>Cuerda de 12.2 metros</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_15_Display">
<English>Rope 15.2 meters</English>
<German>15.2 Meter Seil</German>
<French>Corde de 15,2 mètres</French>
<Japanese>ロープ (15.2 メートル)</Japanese>
<Polish>Lina, długość 15,2 m.</Polish>
<Russian>Канат 15.2 метров</Russian>
<Portuguese>Corda (15.2m)</Portuguese>
<Chinese>繩索15.2公尺長)</Chinese>
<Italian>Corda da 15.2 metri</Italian>
<Czech>Lano 15.2 metrů</Czech>
<Turkish>15.2 metre halat</Turkish>
<Spanish>Cuerda de 15.2 metros</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_18_Display">
<English>Rope 18.3 meters</English>
<German>18.3 Meter Seil</German>
<French>Corde de 18,3 mètres</French>
<Japanese>ロープ (18.3 メートル)</Japanese>
<Polish>Lina, długość 18,3 m.</Polish>
<Russian>Канат 18.3 метров</Russian>
<Portuguese>Corda (18.3m)</Portuguese>
<Chinese>繩索18.3公尺長)</Chinese>
<Italian>Corda da 18.3 metri</Italian>
<Czech>Lano 18.3 metrů</Czech>
<Turkish>18.3 metre halat</Turkish>
<Spanish>Cuerda de 18.3 metros</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_27_Display">
<English>Rope 27.4 meters</English>
<German>27.4 Meter Seil</German>
<French>Corde de 27,4 mètres</French>
<Japanese>ロープ (27.4 メートル)</Japanese>
<Polish>Lina, długość 27,4 m.</Polish>
<Russian>Канат 27.4 метров</Russian>
<Portuguese>Corda (27.4m)</Portuguese>
<Chinese>繩索27.4公尺長)</Chinese>
<Italian>Corda da 27.4 metri</Italian>
<Czech>Lano 27.4 metrů</Czech>
<Turkish>27.4 metre halat</Turkish>
<Spanish>Cuerda de 27.4 metros</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_36_Display">
<English>Rope 36.6 meters</English>
<German>36.6 Meter Seil</German>
<French>Corde de 36,6 mètres</French>
<Japanese>ロープ (36.6 メートル)</Japanese>
<Polish>Lina, długość 36,6 m.</Polish>
<Russian>Канат 36.6 метров</Russian>
<Portuguese>Corda (36.6m)</Portuguese>
<Chinese>繩索36.6公尺長)</Chinese>
<Italian>Corda da 36.6 metri</Italian>
<Czech>Lano 36.6 metrů</Czech>
<Turkish>36.6 metre halat</Turkish>
<Spanish>Cuerda 36.6 metros</Spanish>
</Key>
<Key ID="STR_ACE_Fastroping_setting_categoryMenu_displayName">
<English>Fast-roping</English>
<French>Hélicordage</French>

View File

@ -0,0 +1 @@
z\ace\addons\logistics_rope

View File

@ -0,0 +1,67 @@
class CfgWeapons {
class CBA_MiscItem_ItemInfo;
class ACE_ItemCore;
class ACE_ropeBase: ACE_ItemCore {
scope = 1;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
descriptionShort = CSTRING(descriptionShort);
};
class ACE_rope3: ACE_ropeBase {
scope = 2;
GVAR(length) = 3.2;
displayName = CSTRING(Rope_3_Display);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 6;
};
};
class ACE_rope6: ACE_ropeBase {
scope = 2;
GVAR(length) = 6.2;
displayName = CSTRING(Rope_6_Display);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 18;
};
};
class ACE_rope12: ACE_ropeBase {
scope = 2;
GVAR(length) = 12.2;
displayName = CSTRING(Rope_12_Display);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 36;
};
};
class ACE_rope15: ACE_ropeBase {
scope = 2;
GVAR(length) = 15.2;
displayName = CSTRING(Rope_15_Display);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 45;
};
};
class ACE_rope18: ACE_ropeBase {
scope = 2;
GVAR(length) = 18.3;
displayName = CSTRING(Rope_18_Display);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 54;
};
};
class ACE_rope27: ACE_ropeBase {
scope = 2;
GVAR(length) = 27.4;
displayName = CSTRING(Rope_27_Display);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 81;
};
};
class ACE_rope36: ACE_ropeBase {
scope = 2;
GVAR(length) = 36.6;
displayName = CSTRING(Rope_36_Display);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 108;
};
};
};

View File

@ -0,0 +1,11 @@
ace_logistics_rope
===================
Adds ropes.
## Maintainers
The people responsible for merging changes to this component or answering potential questions.
- [Brandon (TCVM)](https://github.com/TheCandianVendingMachine)

View File

@ -0,0 +1,18 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author = ECSTRING(common,ACETeam);
authors[] = {""};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};
#include "CfgWeapons.hpp"

View File

@ -0,0 +1,17 @@
#define COMPONENT logistics_rope
#define COMPONENT_BEAUTIFIED Rope
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_LOGISTICS_ROPE
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_LOGISTICS_ROPE
#define DEBUG_SETTINGS DEBUG_SETTINGS_LOGISTICS_ROPE
#endif
#include "\z\ace\addons\main\script_macros.hpp"

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Logistics_Rope">
<Key ID="STR_ACE_Logistics_Rope_descriptionShort">
<English>A twisted braid of fibers. Usually used for rappelling or towing.</English>
</Key>
<Key ID="STR_ACE_Logistics_Rope_Rope_3_Display">
<English>Rope 3.2 meters</English>
<German>3.2 Meter Seil</German>
<French>Corde de 3,2 mètres</French>
<Polish>Lina, długość 3,2 m.</Polish>
<Russian>Канат 3.2 метров</Russian>
<Portuguese>Corda (3.2m)</Portuguese>
<Italian>Corda da 3.2 metri</Italian>
<Czech>Lano 3.2 metrů</Czech>
<Turkish>3.2 metre halat</Turkish>
<Spanish>Cuerda de 3.2 metros</Spanish>
</Key>
<Key ID="STR_ACE_Logistics_Rope_Rope_6_Display">
<English>Rope 6.2 meters</English>
<German>6.2 Meter Seil</German>
<French>Corde de 6,2 mètres</French>
<Polish>Lina, długość 6,2 m.</Polish>
<Russian>Канат 6.2 метров</Russian>
<Portuguese>Corda (6.2m)</Portuguese>
<Italian>Corda da 6.2 metri</Italian>
<Czech>Lano 6.2 metrů</Czech>
<Turkish>6.2 metre halat</Turkish>
<Spanish>Cuerda de 6.2 metros</Spanish>
</Key>
<Key ID="STR_ACE_Logistics_Rope_Rope_12_Display">
<English>Rope 12.2 meters</English>
<German>12.2 Meter Seil</German>
<French>Corde de 12,2 mètres</French>
<Japanese>ロープ (12.2 メートル)</Japanese>
<Polish>Lina, długość 12,2 m.</Polish>
<Russian>Канат 12.2 метров</Russian>
<Portuguese>Corda (12.2m)</Portuguese>
<Chinese>繩索12.2公尺長)</Chinese>
<Italian>Corda da 12.2 metri</Italian>
<Czech>Lano 12.2 metrů</Czech>
<Turkish>12.2 metre halat</Turkish>
<Spanish>Cuerda de 12.2 metros</Spanish>
</Key>
<Key ID="STR_ACE_Logistics_Rope_Rope_15_Display">
<English>Rope 15.2 meters</English>
<German>15.2 Meter Seil</German>
<French>Corde de 15,2 mètres</French>
<Japanese>ロープ (15.2 メートル)</Japanese>
<Polish>Lina, długość 15,2 m.</Polish>
<Russian>Канат 15.2 метров</Russian>
<Portuguese>Corda (15.2m)</Portuguese>
<Chinese>繩索15.2公尺長)</Chinese>
<Italian>Corda da 15.2 metri</Italian>
<Czech>Lano 15.2 metrů</Czech>
<Turkish>15.2 metre halat</Turkish>
<Spanish>Cuerda de 15.2 metros</Spanish>
</Key>
<Key ID="STR_ACE_Logistics_Rope_Rope_18_Display">
<English>Rope 18.3 meters</English>
<German>18.3 Meter Seil</German>
<French>Corde de 18,3 mètres</French>
<Japanese>ロープ (18.3 メートル)</Japanese>
<Polish>Lina, długość 18,3 m.</Polish>
<Russian>Канат 18.3 метров</Russian>
<Portuguese>Corda (18.3m)</Portuguese>
<Chinese>繩索18.3公尺長)</Chinese>
<Italian>Corda da 18.3 metri</Italian>
<Czech>Lano 18.3 metrů</Czech>
<Turkish>18.3 metre halat</Turkish>
<Spanish>Cuerda de 18.3 metros</Spanish>
</Key>
<Key ID="STR_ACE_Logistics_Rope_Rope_27_Display">
<English>Rope 27.4 meters</English>
<German>27.4 Meter Seil</German>
<French>Corde de 27,4 mètres</French>
<Japanese>ロープ (27.4 メートル)</Japanese>
<Polish>Lina, długość 27,4 m.</Polish>
<Russian>Канат 27.4 метров</Russian>
<Portuguese>Corda (27.4m)</Portuguese>
<Chinese>繩索27.4公尺長)</Chinese>
<Italian>Corda da 27.4 metri</Italian>
<Czech>Lano 27.4 metrů</Czech>
<Turkish>27.4 metre halat</Turkish>
<Spanish>Cuerda de 27.4 metros</Spanish>
</Key>
<Key ID="STR_ACE_Logistics_Rope_Rope_36_Display">
<English>Rope 36.6 meters</English>
<German>36.6 Meter Seil</German>
<French>Corde de 36,6 mètres</French>
<Japanese>ロープ (36.6 メートル)</Japanese>
<Polish>Lina, długość 36,6 m.</Polish>
<Russian>Канат 36.6 метров</Russian>
<Portuguese>Corda (36.6m)</Portuguese>
<Chinese>繩索36.6公尺長)</Chinese>
<Italian>Corda da 36.6 metri</Italian>
<Czech>Lano 36.6 metrů</Czech>
<Turkish>36.6 metre halat</Turkish>
<Spanish>Cuerda 36.6 metros</Spanish>
</Key>
</Package>
</Project>

View File

@ -0,0 +1 @@
z\ace\addons\towing

View File

@ -0,0 +1,17 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

View File

@ -0,0 +1,85 @@
#define TOW_ACTION \
class ACE_Actions {\
class ACE_MainActions {\
class ADDON {\
displayName = CSTRING(displayName);\
distance = TOW_ACTION_DISTANCE;\
condition = QUOTE([ARR_1(_target)] call FUNC(isSuitableSimulation));\
statement = "";\
exceptions[] = { INTERACTION_EXCEPTIONS };\
showDisabled = 0;\
icon = "";\
class GVAR(startTow3) {\
displayName = CSTRING(start3);\
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(canStartTow)) && [ARR_2(_player, 'ACE_rope3')] call EFUNC(common,hasItem));\
statement = QUOTE([ARR_3(_player,_target,'ACE_rope3')] call FUNC(startTow));\
exceptions[] = { INTERACTION_EXCEPTIONS };\
};\
class GVAR(startTow6) {\
displayName = CSTRING(start6);\
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(canStartTow)) && [ARR_2(_player, 'ACE_rope6')] call EFUNC(common,hasItem));\
statement = QUOTE([ARR_3(_player,_target,'ACE_rope6')] call FUNC(startTow));\
exceptions[] = { INTERACTION_EXCEPTIONS };\
};\
class GVAR(startTow12) {\
displayName = CSTRING(start12);\
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(canStartTow)) && [ARR_2(_player, 'ACE_rope12')] call EFUNC(common,hasItem));\
statement = QUOTE([ARR_3(_player,_target,'ACE_rope12')] call FUNC(startTow));\
exceptions[] = { INTERACTION_EXCEPTIONS };\
};\
class GVAR(startTow15) {\
displayName = CSTRING(start15);\
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(canStartTow)) && [ARR_2(_player, 'ACE_rope15')] call EFUNC(common,hasItem));\
statement = QUOTE([ARR_3(_player,_target,'ACE_rope15')] call FUNC(startTow));\
exceptions[] = { INTERACTION_EXCEPTIONS };\
};\
class GVAR(startTow18) {\
displayName = CSTRING(start18);\
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(canStartTow)) && [ARR_2(_player, 'ACE_rope18')] call EFUNC(common,hasItem));\
statement = QUOTE([ARR_3(_player,_target,'ACE_rope18')] call FUNC(startTow));\
exceptions[] = { INTERACTION_EXCEPTIONS };\
};\
class GVAR(startTow27) {\
displayName = CSTRING(start27);\
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(canStartTow)) && [ARR_2(_player, 'ACE_rope27')] call EFUNC(common,hasItem));\
statement = QUOTE([ARR_3(_player,_target,'ACE_rope27')] call FUNC(startTow));\
exceptions[] = { INTERACTION_EXCEPTIONS };\
};\
class GVAR(startTow36) {\
displayName = CSTRING(start36);\
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(canStartTow)) && [ARR_2(_player, 'ACE_rope36')] call EFUNC(common,hasItem));\
statement = QUOTE([ARR_3(_player,_target,'ACE_rope36')] call FUNC(startTow));\
exceptions[] = { INTERACTION_EXCEPTIONS };\
};\
};\
};\
}
class CfgVehicles {
class LandVehicle;
class Car: LandVehicle {
TOW_ACTION;
};
class Tank: LandVehicle {
TOW_ACTION;
};
class ThingX;
class GVAR(hook): ThingX {
displayName = "hook"; // not publicly visible, no stringtable needed
scope = 1;
scopeCurator = 1;
model = "\a3\Structures_F_Orange\VR\Helpers\Sign_sphere10cm_Geometry_F.p3d";
destrType = "DestructNo";
class ACE_Actions {
class ACE_MainActions {
displayName = CSTRING(detach);
condition = "true";
statement = QUOTE(private _parent = _target getVariable [ARR_2(QQGVAR(parent), objNull)]; private _child = _target getVariable [ARR_2(QQGVAR(child), objNull)]; [ARR_3(_player,_parent,_child)] call FUNC(detach));
distance = 2;
};
};
};
};

11
addons/towing/README.md Normal file
View File

@ -0,0 +1,11 @@
ace_towing
===================
Adds the ability to tow vehicles.
## Maintainers
The people responsible for merging changes to this component or answering potential questions.
- [Brandon (TCVM)](https://github.com/TheCandianVendingMachine)

View File

@ -0,0 +1,8 @@
PREP(attachRopePFH);
PREP(canStartTow);
PREP(detach);
PREP(isSuitableSimulation);
PREP(onMouseButtonDown);
PREP(onMouseButtonUp);
PREP(startTow);
PREP(towStateMachinePFH);

View File

@ -0,0 +1,14 @@
#include "script_component.hpp"
["MouseButtonDown", LINKFUNC(onMouseButtonDown)] call CBA_fnc_addDisplayHandler;
["MouseButtonUp", LINKFUNC(onMouseButtonUp)] call CBA_fnc_addDisplayHandler;
GVAR(mouseLeft) = false;
GVAR(mouseRight) = false;
GVAR(cancel) = false;
GVAR(canAttach) = false;
[QGVAR(setTowParent), {
params ["_parent", "_child"];
_child setTowParent _parent;
}] call CBA_fnc_addEventHandler;

View File

@ -0,0 +1,9 @@
#include "script_component.hpp"
ADDON = false;
PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
ADDON = true;

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

19
addons/towing/config.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common", "ace_logistics_rope"};
author = ECSTRING(common,ACETeam);
authors[] = {"Brandon (TCVM)"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"

View File

@ -0,0 +1,79 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* PFH which allows the user to attach a rope to the given target vehicle
*
* Arguments:
* 0: Unit wanting to attach rope <OBJECT>
* 1: Vehicle to attach rope <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_towing_fnc_attachRopePFH
*
* Public: No
*/
params ["_unit", "_target", "_ignoreParent", "_ignoreRope", "_source", "_maxRange"];
private _viewDirection = getCameraViewDirection _unit;
GVAR(attachHelper) setPosASL (_unit modelToWorldVisualWorld [0, 1, 1.5]);
private _hintLMB = "";
private _hintRMB = localize ELSTRING(dragging,Drop);
private _startPos = eyePos _unit;
private _endPos = _startPos vectorAdd (_viewDirection vectorMultiply TOW_ACTION_DISTANCE);
private _intersections = lineIntersectsSurfaces [_startPos, _endPos, _unit, GVAR(attachHelper), true, 2];
GVAR(canAttach) = false;
if (_intersections isNotEqualTo []) then {
private _intersectionToUse = [];
{
_x params ["", "", "_object"];
if (_object isKindOf "AllVehicles" && { _object isNotEqualTo _ignoreRope && { _object isNotEqualTo _ignoreParent } }) exitWith {
_intersectionToUse = _x;
};
} forEach _intersections;
if (_intersectionToUse isEqualTo []) exitWith {};
_intersectionToUse params ["_intersectPosition", "", "_intersectObject"];
// if we have a target object, we assume we are attaching to the parent. If no target object, we are attaching to child
GVAR(canAttach) = (_intersectObject isNotEqualTo _ignoreParent) && { (!isNull _target && { _intersectObject isEqualTo _target }) || { isNull _target && { [_intersectObject] call FUNC(isSuitableSimulation) }}} && { !(_intersectObject getVariable [QGVAR(towing), false]) };
if (GVAR(canAttach)) then {
TRACE_4("can attach",_target,_intersectObject,_ignoreParent,_ignoreRope);
GVAR(attachHelper) setPosASL _intersectPosition;
_hintLMB = localize LSTRING(attach);
GVAR(attachHelper) setVariable [QGVAR(object), _intersectObject];
};
};
if (_source isNotEqualTo [0, 0, 0]) then {
private _distanceFromSource = _source vectorDistance getPosASLVisual GVAR(attachHelper);
if (_distanceFromSource > _maxRange) then {
GVAR(canAttach) = false;
private _direction = _source vectorFromTo getPosASLVisual GVAR(attachHelper);
GVAR(attachHelper) setPosASL (_source vectorAdd (_direction vectorMultiply _maxRange));
_hintLMB = "";
if (_distanceFromSource > _maxRange + 2) then {
GVAR(cancel) = true;
} else {
GVAR(cancel) = false;
};
};
};
private _hint = [_hintLMB, _hintRMB];
if (_hint isNotEqualTo (_unit getVariable [QGVAR(hint), []])) then {
_unit setVariable [QGVAR(hint), _hint];
_hint call EFUNC(interaction,showMouseHint);
};

View File

@ -0,0 +1,21 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Condition for whether or not we can tow from this object
*
* Arguments:
* 0: Unit wanting to start towing <OBJECT>
* 1: Vehicle to tow from <OBJECT>
*
* Return Value:
* Whether or not we can start towing <BOOLEAN>
*
* Example:
* [player, cursorObject] call ace_towing_fnc_canStartTow
*
* Public: No
*/
params ["_unit", "_target"];
private _isTowing = _target getVariable [QGVAR(towing), false];
TRACE_1("is towing",_isTowing);
!_isTowing

View File

@ -0,0 +1,48 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Detaches child from parent, and gives rope item back
*
* Arguments:
* 0: Parent <OBJECT>
* 1: Child <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_towing_fnc_detach
*
* Public: No
*/
params ["_unit", "_parent", "_child"];
TRACE_3("detach",_unit,_parent,_child);
private _hook = _child getVariable [QGVAR(hook), objNull];
_parent removeEventHandler ["Deleted", _hook getVariable QGVAR(parentDeleteEventHandler)];
_hook setVariable [QGVAR(parentDeleteEventHandler), -1];
_child removeEventHandler ["Deleted", _hook getVariable QGVAR(childDeleteEventHandler)];
_hook setVariable [QGVAR(childDeleteEventHandler), -1];
_parent removeEventHandler ["RopeBreak", _parent getVariable QGVAR(ropeBreakEventHandler)];
_parent setVariable [QGVAR(ropeBreakEventHandler), -1];
private _rope = _child getVariable [QGVAR(rope), objNull];
ropeDestroy _rope;
private _ropeClass = _hook getVariable [QGVAR(ropeClass), ""];
deleteVehicle _hook;
TRACE_1("rope",_ropeClass);
if (_ropeClass isNotEqualTo "") then {
[_unit, _ropeClass, true] call CBA_fnc_addItem;
};
[QGVAR(setTowParent), [objNull, _child], _child] call CBA_fnc_targetEvent;
_child setVariable [QGVAR(towing), false, true];
_parent setVariable [QGVAR(towing), false, true];

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Condition for whether or not this object is a simulation type which can be a tow parent (TankX or CarX)
*
* Arguments:
* 0: Vehicle to tow from <OBJECT>
* 1: Check type - Parent or Child <NUMBER>
*
* Return Value:
* Whether or not this vehicle can tow <BOOLEAN>
*
* Example:
* [cursorObject] call ace_towing_fnc_isSuitableSimulation
*
* Public: No
*/
params ["_target"];
// need toLower since apparently this isn't case sensitive
private _simulationType = getText ((configOf _target) >> "simulation");
TRACE_1("sim type",_simulationType);
// Biki lies, you can both tow and tow as either TankX or CarX
(toLower _simulationType) in ["tankx", "carx"]

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Handles mouse interaction for attaching rope
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_towing_fnc_onMouseButtonDown
*
* Public: No
*/
params ["", "_button"];
if (_button > 1) exitWith {};
if (_button == 1) then {
GVAR(mouseRight) = true;
} else {
GVAR(mouseLeft) = true;
}

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Handles mouse interaction for attaching rope
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_towing_fnc_onMouseButtonUp
*
* Public: No
*/
params ["", "_button"];
if (_button > 1) exitWith {};
if (_button == 1) then {
GVAR(mouseRight) = false;
} else {
GVAR(mouseLeft) = false;
}

View File

@ -0,0 +1,33 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Start rope attach PFH
*
* Arguments:
* 0: Unit wanting to start towing <OBJECT>
* 1: Vehicle to tow from <OBJECT>
* 2: Rope Classname <STRING>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject, "ACE_rope3"] call ace_towing_fnc_startTow
*
* Public: No
*/
params ["_unit", "_target", "_ropeClass"];
GVAR(attachHelper) = "Sign_Sphere10cm_F" createVehicleLocal [0, 0, 0];
[_unit] call EFUNC(weaponselect,putWeaponAway);
private _ropeLength = getNumber (configFile >> "CfgWeapons" >> _ropeClass >> QEGVAR(logistics_rope,length));
if (_ropeLength == 0) then {
_ropeLength = 3;
};
_unit removeItem _ropeClass;
GVAR(canAttach) = false;
[LINKFUNC(towStateMachinePFH), 0, [TOW_STATE_ATTACH_PARENT, _unit, _target, objNull, _ropeLength, _ropeClass]] call CBA_fnc_addPerFrameHandler;

View File

@ -0,0 +1,144 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Called per frame. Handles current unit state for attaching a rope to two vehicles
*
* Arguments:
* 0: PFEH Args <ARRAY>
* 1: PFID <NUMBER>
*
* Return Value:
* None
*
* Example:
* [[],0]] call ace_towing_fnc_towStateMachinePFH
*
* Public: No
*/
params ["_args", "_handle"];
_args params ["_state", "_unit", "_parent", "_rope", "_length", "_ropeClass"];
private _exitCondition = !(
(alive GVAR(attachHelper)) &&
{ alive _target } &&
{ alive _unit } &&
{ "" isEqualTo currentWeapon _unit || { _unit call EFUNC(common,isSwimming) }} &&
{ [_unit, objNull, [INTERACTION_EXCEPTIONS]] call EFUNC(common,canInteractWith) } &&
{ "unconscious" isNotEqualTo toLower animationState _unit } &&
{ !(_unit getVariable ["ACE_isUnconscious", false]) }
);
if (_exitCondition) then {
_state = TOW_STATE_CANCEL;
};
switch (_state) do {
case TOW_STATE_ATTACH_PARENT: {
TRACE_2("state attach parent",_unit,_parent);
[_unit, _parent, objNull, objNull, [0, 0, 0], _length] call FUNC(attachRopePFH);
if (GVAR(canAttach) && { GVAR(mouseLeft) }) then {
_args set [0, TOW_STATE_ATTACH_CHILD];
_rope = ropeCreate [_parent, _parent worldToModelVisual ASLtoAGL getPosASLVisual GVAR(attachHelper), _length];
[GVAR(attachHelper), [0, 0, 0]] ropeAttachTo _rope;
_args set [3, _rope];
};
if (GVAR(mouseRight)) then {
_args set [0, TOW_STATE_CANCEL];
};
};
case TOW_STATE_ATTACH_CHILD: {
TRACE_3("state attach child",_unit,_parent,_rope);
[_unit, objNull, _parent, _rope, getPosASLVisual _rope, _length] call FUNC(attachRopePFH);
if (GVAR(canAttach) && { GVAR(mouseLeft) }) then {
_args set [0, TOW_STATE_ATTACH];
};
if (GVAR(mouseRight) || GVAR(cancel)) then {
_args set [0, TOW_STATE_CANCEL];
GVAR(cancel) = false;
};
};
case TOW_STATE_ATTACH: {
TRACE_3("state attach",GVAR(attachHelper),_parent,_rope);
private _child = GVAR(attachHelper) getVariable [QGVAR(object), objNull];
private _relativeAttachPos = _child worldToModelVisual ASLtoAGL getPosASLVisual GVAR(attachHelper);
TRACE_3("child&pos",_parent,_child,_relativeAttachPos);
if (_child isEqualTo _parent) exitWith {
_args set [0, TOW_STATE_CANCEL];
ERROR_MSG("_child isEqualTo _parent");
};
[QGVAR(setTowParent), [_parent, _child], _parent] call CBA_fnc_targetEvent;
GVAR(attachHelper) ropeDetach _rope;
[_child, _relativeAttachPos] ropeAttachTo _rope;
private _hook = createVehicle [QGVAR(hook), [0, 0, 0], [], 0, "NONE"];
_hook attachTo [_child, _relativeAttachPos];
_hook setVariable [QGVAR(parent), _parent, true];
_hook setVariable [QGVAR(child), _child, true];
_child setVariable [QGVAR(rope), _rope, true];
_child setVariable [QGVAR(hook), _hook, true];
_parent setVariable [QGVAR(hook), _hook, true];
_hook setVariable [QGVAR(ropeClass), _ropeClass, true];
_child setVariable [QGVAR(towing), true, true];
_parent setVariable [QGVAR(towing), true, true];
_hook setVariable [QGVAR(parentDeleteEventHandler), _parent addEventHandler ["Deleted", {
params ["_entity"];
private _hook = _entity getVariable [QGVAR(hook), objNull];
private _child = _hook getVariable [QGVAR(child), objNull];
private _parent = _hook getVariable [QGVAR(parent), objNull];
[objNull, _parent, _child] call FUNC(detach);
}], true];
_hook setVariable [QGVAR(childDeleteEventHandler), _child addEventHandler ["Deleted", {
params ["_entity"];
private _hook = _entity getVariable [QGVAR(hook), objNull];
private _child = _hook getVariable [QGVAR(child), objNull];
private _parent = _hook getVariable [QGVAR(parent), objNull];
[objNull, _parent, _child] call FUNC(detach);
}], true];
_parent setVariable [QGVAR(ropeBreakEventHandler), _parent addEventHandler ["RopeBreak", {
params ["_parent", "_rope", "_child"];
[objNull, _parent, _child] call FUNC(detach);
_parent removeEventHandler ["RopeBreak", _parent getVariable QGVAR(ropeBreakEventHandler)];
_parent setVariable [QGVAR(ropeBreakEventHandler), -1];
}], true];
_args set [0, TOW_STATE_CLEANUP];
};
case TOW_STATE_CANCEL: {
TRACE_1("state cancel",_rope);
ropeDestroy _rope;
[_unit, _ropeClass, true] call CBA_fnc_addItem;
_args set [0, TOW_STATE_CLEANUP];
(localize LSTRING(canceled)) call CBA_fnc_notify;
};
case TOW_STATE_CLEANUP: {
TRACE_2("state cleanup",GVAR(attachHelper),_handle);
deleteVehicle GVAR(attachHelper);
[_handle] call CBA_fnc_removePerFrameHandler;
_unit setVariable [QGVAR(hint), []];
call EFUNC(interaction,hideMouseHint);
};
};

View File

@ -0,0 +1 @@
#include "\z\ace\addons\towing\script_component.hpp"

View File

@ -0,0 +1,27 @@
#define COMPONENT towing
#define COMPONENT_BEAUTIFIED Towing
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_TOWING
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_TOWING
#define DEBUG_SETTINGS DEBUG_SETTINGS_TOWING
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define TOW_ACTION_DISTANCE 3
#define INTERACTION_EXCEPTIONS "isNotInside", "isNotOnLadder", "isNotSwimming"
#define TOW_STATE_ATTACH_PARENT 0
#define TOW_STATE_ATTACH_CHILD 1
#define TOW_STATE_ATTACH 2
#define TOW_STATE_CANCEL 3
#define TOW_STATE_CLEANUP 4

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Towing">
<Key ID="STR_ACE_Towing_displayName">
<English>Towing</English>
</Key>
<Key ID="STR_ACE_Towing_attach">
<English>Attach Tow Rope</English>
</Key>
<Key ID="STR_ACE_Towing_canceled">
<English>Attaching Cancelled</English>
</Key>
<Key ID="STR_ACE_Towing_start3">
<English>Attach Tow Rope (3.2m)</English>
</Key>
<Key ID="STR_ACE_Towing_start6">
<English>Attach Tow Rope (6.2m)</English>
</Key>
<Key ID="STR_ACE_Towing_start12">
<English>Attach Tow Rope (12.2m)</English>
</Key>
<Key ID="STR_ACE_Towing_start15">
<English>Attach Tow Rope (15.2m)</English>
</Key>
<Key ID="STR_ACE_Towing_start18">
<English>Attach Tow Rope (18.2m)</English>
</Key>
<Key ID="STR_ACE_Towing_start27">
<English>Attach Tow Rope (27.2m)</English>
</Key>
<Key ID="STR_ACE_Towing_start36">
<English>Attach Tow Rope (36.2m)</English>
</Key>
<Key ID="STR_ACE_Towing_detach">
<English>Detach Tow Rope</English>
</Key>
</Package>
</Project>