diff --git a/optionals/compat_rhs_gref3/CfgEventHandlers.hpp b/optionals/compat_rhs_gref3/CfgEventHandlers.hpp new file mode 100644 index 0000000000..865276cfba --- /dev/null +++ b/optionals/compat_rhs_gref3/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; diff --git a/optionals/compat_rhs_gref3/CfgVehicles.hpp b/optionals/compat_rhs_gref3/CfgVehicles.hpp index b800d8b881..70bc28eb52 100644 --- a/optionals/compat_rhs_gref3/CfgVehicles.hpp +++ b/optionals/compat_rhs_gref3/CfgVehicles.hpp @@ -1,3 +1,16 @@ +#define EQUIP_FRIES_ATTRIBUTE class Attributes { \ + class EGVAR(fastroping,equipFRIES) { \ + property = QEGVAR(fastroping,equipFRIES); \ + control = "Checkbox"; \ + displayName = ECSTRING(fastroping,Eden_equipFRIES); \ + tooltip = ECSTRING(fastroping,Eden_equipFRIES_Tooltip); \ + expression = QUOTE([_this] call EFUNC(fastroping,equipFRIES)); \ + typeName = "BOOL"; \ + condition = "objectVehicle"; \ + defaultValue = false; \ + }; \ +} + class CfgVehicles { class Rubber_duck_base_F; class rhsgref_canoe_base: Rubber_duck_base_F { @@ -37,6 +50,62 @@ class CfgVehicles { }; }; + class Helicopter_Base_H; + class rhs_uh1h_base: Helicopter_Base_H { + EGVAR(fastroping,enabled) = 2; + EGVAR(fastroping,friesType) = "ACE_friesAnchorBar"; + EGVAR(fastroping,friesAttachmentPoint)[] = {0, 1.95, -0.26}; + EGVAR(fastroping,onCut) = QFUNC(onCut); + EGVAR(fastroping,onPrepare) = QFUNC(onPrepare); + EGVAR(fastroping,ropeOrigins)[] = {"ropeOriginLeft", "ropeOriginRight"}; + }; + + class rhs_uh1h_hidf: rhs_uh1h_base { + EQUIP_FRIES_ATTRIBUTE; + }; + + class rhs_uh1h_hidf_unarmed: rhs_uh1h_hidf { + EGVAR(fastroping,friesAttachmentPoint)[] = {0, 1.8, -0.27}; + + class UserActions { + class Open_Side_Doors; + + class Close_Side_Doors: Open_Side_Doors { + condition = QUOTE([ARR_2(this,'close_cargo_doors')] call FUNC(canCloseDoor)); + }; + }; + + EQUIP_FRIES_ATTRIBUTE; + }; + + class rhs_uh1h_idap: rhs_uh1h_base { + EGVAR(fastroping,friesAttachmentPoint)[] = {0, 1.8, -0.27}; + + class UserActions { + class Open_Side_Doors; + + class Close_Side_Doors: Open_Side_Doors { + condition = QUOTE([ARR_2(this,'close_cargo_doors')] call FUNC(canCloseDoor)); + }; + }; + + EQUIP_FRIES_ATTRIBUTE; + }; + + class rhs_uh1h_un: rhs_uh1h_base { + EGVAR(fastroping,friesAttachmentPoint)[] = {0, 1.8, -0.27}; + + class UserActions { + class Open_Side_Doors; + + class Close_Side_Doors: Open_Side_Doors { + condition = QUOTE([ARR_2(this,'close_cargo_doors')] call FUNC(canCloseDoor)); + }; + }; + + EQUIP_FRIES_ATTRIBUTE; + }; + // ACE Explosives class Items_base_F; class ACE_Explosives_Place: Items_base_F { diff --git a/optionals/compat_rhs_gref3/XEH_PREP.hpp b/optionals/compat_rhs_gref3/XEH_PREP.hpp new file mode 100644 index 0000000000..821ee657be --- /dev/null +++ b/optionals/compat_rhs_gref3/XEH_PREP.hpp @@ -0,0 +1,3 @@ +PREP(canCloseDoor); +PREP(onCut); +PREP(onPrepare); diff --git a/optionals/compat_rhs_gref3/XEH_preInit.sqf b/optionals/compat_rhs_gref3/XEH_preInit.sqf new file mode 100644 index 0000000000..b47cf6628d --- /dev/null +++ b/optionals/compat_rhs_gref3/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; diff --git a/optionals/compat_rhs_gref3/XEH_preStart.sqf b/optionals/compat_rhs_gref3/XEH_preStart.sqf new file mode 100644 index 0000000000..022888575e --- /dev/null +++ b/optionals/compat_rhs_gref3/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/optionals/compat_rhs_gref3/config.cpp b/optionals/compat_rhs_gref3/config.cpp index 5e9f6d21a0..a836906329 100644 --- a/optionals/compat_rhs_gref3/config.cpp +++ b/optionals/compat_rhs_gref3/config.cpp @@ -7,7 +7,7 @@ class CfgPatches { units[] = {}; weapons[] = {QGVAR(dshkm_carry)}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_explosives", "ace_csw", "rhsgref_main_loadorder"}; + requiredAddons[] = {"ace_fastroping", "ace_explosives", "ace_csw", "rhsgref_main_loadorder"}; author = ECSTRING(common,ACETeam); authors[] = {"PabstMirror", "Ruthberg", "Anton"}; url = ECSTRING(main,URL); @@ -16,6 +16,7 @@ class CfgPatches { }; #include "CfgAmmo.hpp" +#include "CfgEventHandlers.hpp" #include "CfgMagazines.hpp" #include "CfgWeapons.hpp" #include "CfgVehicles.hpp" diff --git a/optionals/compat_rhs_gref3/functions/fnc_canCloseDoor.sqf b/optionals/compat_rhs_gref3/functions/fnc_canCloseDoor.sqf new file mode 100644 index 0000000000..303f7d2d44 --- /dev/null +++ b/optionals/compat_rhs_gref3/functions/fnc_canCloseDoor.sqf @@ -0,0 +1,34 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Checks if the door can be closed. + * + * Arguments: + * 0: Helicopter + * 1: Door + * + * Return Value: + * Door can be closed + * + * Example: + * [_vehicle, "DoorLB"] call ace_compat_rhs_gref3_fnc_canCloseDoor + * + * Public: No + */ + +params ["_vehicle", "_door"]; + +(alive _vehicle) && +{!(_vehicle getVariable [QEGVAR(fastroping,doorsLocked),false])} && +{ + switch (true) do { + case (_vehicle isKindOf "rhs_uh1h_base"): { + ((_vehicle doorPhase _door) == 0) && + {ACE_player in _vehicle} + }; + default { + ((_vehicle doorPhase _door) > 0) && + {ACE_player in _vehicle} + }; + } +} diff --git a/optionals/compat_rhs_gref3/functions/fnc_onCut.sqf b/optionals/compat_rhs_gref3/functions/fnc_onCut.sqf new file mode 100644 index 0000000000..20385a7f36 --- /dev/null +++ b/optionals/compat_rhs_gref3/functions/fnc_onCut.sqf @@ -0,0 +1,41 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Function for closing doors and retracting the hooks for RHS USF helos. + * + * Arguments: + * 0: Helicopter + * + * Return Value: + * Amount of time to wait before cutting ropes + * + * Example: + * [_vehicle] call ace_compat_rhs_gref3_fnc_onCut + * + * Public: No + */ +params ["_vehicle"]; + +_vehicle setVariable [QEGVAR(fastroping,doorsLocked), false, true]; + +private _fries = _vehicle getVariable [QEGVAR(fastroping,FRIES), objNull]; +if !(isNull _fries) then { + _fries animate ["extendHookRight", 0]; + _fries animate ["extendHookLeft", 0]; + [{ + _this animateDoor ["doorRB", 0]; + _this animateDoor ["doorLB", 0]; + _this animate ["doorHandler_R",0]; + _this animate ["doorHandler_L",0]; + _this animateDoor ["close_cargo_doors", 1]; + + }, _vehicle, 2] call CBA_fnc_waitAndExecute; + + 4 +} else { + _vehicle animateDoor ["ramp_anim", 0]; + _vehicle animate ["ramp_bottom",0]; + _vehicle animate ["ramp_top",0]; + + 2 +}; diff --git a/optionals/compat_rhs_gref3/functions/fnc_onPrepare.sqf b/optionals/compat_rhs_gref3/functions/fnc_onPrepare.sqf new file mode 100644 index 0000000000..349f0b53e7 --- /dev/null +++ b/optionals/compat_rhs_gref3/functions/fnc_onPrepare.sqf @@ -0,0 +1,41 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Function for opening doors and extending the hook for most vanilla helos. + * + * Arguments: + * 0: Helicopter + * + * Return Value: + * Amount of time to wait before deploying ropes + * + * Example: + * [_vehicle] call ace_compat_rhs_gref3_fnc_onPrepare + * + * Public: No + */ +params ["_vehicle"]; + +_vehicle setVariable [QEGVAR(fastroping,doorsLocked), true, true]; + +private _waitTime = 2; + +_vehicle animateDoor ["doorRB", 1]; +_vehicle animateDoor ["doorLB", 1]; +_vehicle animate ["doorHandler_R",1]; +_vehicle animate ["doorHandler_L",1]; +_vehicle animateDoor ["ramp_anim", 1]; +_vehicle animate ["ramp_bottom",0.56]; +_vehicle animate ["ramp_top",1]; +_vehicle animateDoor ["close_cargo_doors", 0]; + +private _fries = _vehicle getVariable [QEGVAR(fastroping,FRIES), objNull]; +if !(isNull _fries) then { + [{ + _this animate ["extendHookRight", 1]; + _this animate ["extendHookLeft", 1]; + }, _fries, 2] call CBA_fnc_waitAndExecute; + _waitTime = 4; +}; + +_waitTime diff --git a/optionals/compat_rhs_gref3/functions/script_component.hpp b/optionals/compat_rhs_gref3/functions/script_component.hpp new file mode 100644 index 0000000000..cb8dda624c --- /dev/null +++ b/optionals/compat_rhs_gref3/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\compat_rhs_gref3\script_component.hpp"