diff --git a/addons/fastroping/$PBOPREFIX$ b/addons/fastroping/$PBOPREFIX$ new file mode 100644 index 0000000000..352dc2c83a --- /dev/null +++ b/addons/fastroping/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\fastroping diff --git a/addons/fastroping/CfgEventHandlers.hpp b/addons/fastroping/CfgEventHandlers.hpp new file mode 100644 index 0000000000..b928bc2de6 --- /dev/null +++ b/addons/fastroping/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/fastroping/CfgMoves.hpp b/addons/fastroping/CfgMoves.hpp new file mode 100644 index 0000000000..63e18f2c2b --- /dev/null +++ b/addons/fastroping/CfgMoves.hpp @@ -0,0 +1,19 @@ +class CfgMovesBasic { + class DefaultDie; + class ManActions { + ACE_FastRoping = "ACE_FastRoping"; + }; +}; + +class CfgMovesMaleSdr: CfgMovesBasic { + class States { + class Crew; + class ACE_FastRoping: Crew { + file = PATHTOF(anim\fastroping.rtm); + interpolateTo[] = {"Unconscious",1}; + disableWeapons = 1; + disableWeaponsLong = 1; + canReload = 0; + }; + }; +}; diff --git a/addons/fastroping/CfgVehicles.hpp b/addons/fastroping/CfgVehicles.hpp new file mode 100644 index 0000000000..04f771d8b3 --- /dev/null +++ b/addons/fastroping/CfgVehicles.hpp @@ -0,0 +1,42 @@ +class CfgVehicles { + class UAV_01_base_F; + class GVAR(helper): UAV_01_base_F { + author = "KoffeinFlummi"; + scope = 1; + model = PATHTOF(data\helper.p3d); + isUAV = 0; + }; + + class Air; + class Helicopter: Air { + class ACE_SelfActions { + class ACE_deployRopes { + displayName = "Deploy ropes"; + condition = [_player, vehicle _player] call FUNC(canDeployRopes); + statement = [_player, vehicle _player] call FUNC(deployRopes); + showDisabled = 0; + priority = 1; + }; + class ACE_cutRopes { + displayName = "Cut ropes"; + condition = [_player, vehicle _player] call FUNC(canCutRopes); + statement = [vehicle _player] call FUNC(cutRopes); + showDisabled = 0; + priority = 1; + }; + class ACE_fastRope { + displayName = "Fast rope"; + condition = [_player, vehicle _player] call FUNC(canFastRope); + statement = [_player, vehicle _player] call FUNC(fastRope); + showDisabled = 0; + priority = 1; + }; + }; + }; + + class Helicopter_Base_H; + class Heli_Transport_01_base_F: Helicopter_Base_H { + GVAR(enabled) = 1; + GVAR(ropeOrigins[]) = {{1.1, 2.5, 0.25}, {-1.1, 2.5, 0.25}}; + }; +}; diff --git a/addons/fastroping/XEH_preInit.sqf b/addons/fastroping/XEH_preInit.sqf new file mode 100644 index 0000000000..c425670c06 --- /dev/null +++ b/addons/fastroping/XEH_preInit.sqf @@ -0,0 +1,13 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(canCutRopes); +PREP(canDeployRopes); +PREP(canFastRope); +PREP(cutRopes); +PREP(deployRopes); +PREP(fastRope); +PREP(fastRopePFH); + +ADDON = true; diff --git a/addons/fastroping/anim/fastroping.rtm b/addons/fastroping/anim/fastroping.rtm new file mode 100644 index 0000000000..9742732a56 Binary files /dev/null and b/addons/fastroping/anim/fastroping.rtm differ diff --git a/addons/fastroping/config.cpp b/addons/fastroping/config.cpp new file mode 100644 index 0000000000..a53d75163a --- /dev/null +++ b/addons/fastroping/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"KoffeinFlummi", "BaerMitUmlaut"}; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgMoves.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/fastroping/data/helper.p3d b/addons/fastroping/data/helper.p3d new file mode 100644 index 0000000000..e473e619e8 Binary files /dev/null and b/addons/fastroping/data/helper.p3d differ diff --git a/addons/fastroping/functions/fnc_canCutRopes.sqf b/addons/fastroping/functions/fnc_canCutRopes.sqf new file mode 100644 index 0000000000..2fa33dec93 --- /dev/null +++ b/addons/fastroping/functions/fnc_canCutRopes.sqf @@ -0,0 +1,26 @@ +/* + * Author: BaerMitUmlaut + * Checks if the unit can cut deployed ropes. + * + * Arguments: + * 0: Unit occupying the helicopter + * 1: The helicopter itself + * + * Return Value: + * Able to cut ropes + * + * Example: + * [_player, _vehicle] call ace_fastroping_canCutRopes + * + * Public: No + */ + +#include "script_component.hpp" +params ["_unit", "_vehicle"]; +private ["_deployedRopes"]; + +_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; +if ((driver _vehicle != _unit) && + {!(_deployedRopes isEqualTo [])} && + {{_x select 5} count (_deployedRopes) == 0}) exitWith {true}; +false diff --git a/addons/fastroping/functions/fnc_canDeployRopes.sqf b/addons/fastroping/functions/fnc_canDeployRopes.sqf new file mode 100644 index 0000000000..4db45cff24 --- /dev/null +++ b/addons/fastroping/functions/fnc_canDeployRopes.sqf @@ -0,0 +1,26 @@ +/* + * Author: BaerMitUmlaut + * Checks if the unit can deploy ropes from the helicopter. + * + * Arguments: + * 0: Unit occupying the helicopter + * 1: The helicopter itself + * + * Return Value: + * Able to deploy ropes + * + * Example: + * [_player, _vehicle] call ace_fastroping_canDeployRopes + * + * Public: No + */ + +#include "script_component.hpp" +params ["_unit", "_vehicle"]; +private ["_deployedRopes"]; + +_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; +if (isNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(enabled)) && + {getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(enabled)) == 1} && + {_deployedRopes isEqualTo []}) exitWith {true}; +false diff --git a/addons/fastroping/functions/fnc_canFastRope.sqf b/addons/fastroping/functions/fnc_canFastRope.sqf new file mode 100644 index 0000000000..910d3cccc9 --- /dev/null +++ b/addons/fastroping/functions/fnc_canFastRope.sqf @@ -0,0 +1,26 @@ +/* + * Author: BaerMitUmlaut + * Checks if the unit can fast rope from the helicopter. + * + * Arguments: + * 0: Unit occupying the helicopter + * 1: The helicopter itself + * + * Return Value: + * Able to fast ropes + * + * Example: + * [_player, _vehicle] call ace_fastroping_canDeployRopes + * + * Public: No + */ + +#include "script_component.hpp" +params ["_unit", "_vehicle"]; +private ["_deployedRopes"]; + +_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; +if ((driver _vehicle != _unit) && + {!(_deployedRopes isEqualTo [])} && + {{!(_x select 5)} count (_deployedRopes) > 0}) exitWith {true}; +false diff --git a/addons/fastroping/functions/fnc_cutRopes.sqf b/addons/fastroping/functions/fnc_cutRopes.sqf new file mode 100644 index 0000000000..9ec88da7c0 --- /dev/null +++ b/addons/fastroping/functions/fnc_cutRopes.sqf @@ -0,0 +1,29 @@ +/* + * Author: BaerMitUmlaut + * Cut deployed ropes. + * + * Arguments: + * 0: A helicopter with deployed ropes + * + * Return Value: + * None + * + * Example: + * [_vehicle] call ace_fastroping_cutRopes + * + * Public: No + */ + +#include "script_component.hpp" +params ["_vehicle"]; +private ["_deployedRopes"]; + +_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; +{ + _x params ["_attachmentPoint", "_ropeTop", "_ropeBottom", "_dummy", "_anchor", "_occupied"]; + + deleteVehicle _ropeTop; + [{{deleteVehicle _x} count _this}, [_dummy, _anchor, _ropeBottom], 60] call EFUNC(common,waitAndExecute); +} count _deployedRopes; + +_vehicle setVariable [QGVAR(deployedRopes), [], true]; diff --git a/addons/fastroping/functions/fnc_deployRopes.sqf b/addons/fastroping/functions/fnc_deployRopes.sqf new file mode 100644 index 0000000000..6cdf71c868 --- /dev/null +++ b/addons/fastroping/functions/fnc_deployRopes.sqf @@ -0,0 +1,43 @@ +/* + * Author: BaerMitUmlaut + * Deploy ropes from the helicopter. + * + * Arguments: + * 0: Unit occupying the helicopter + * 1: The helicopter itself + * + * Return Value: + * None + * + * Example: + * [_player, _vehicle] call ace_fastroping_deployRopes + * + * Public: No + */ + +#include "script_component.hpp" +params ["_unit", "_vehicle"]; +private ["_ropeOrigins", "_deployedRopes", "_origin", "_dummy", "_anchor", "_ropeTop", "_ropeBottom"]; + +_ropeOrigins = getArray (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(ropeOrigins)); +_deployedRopes = []; +{ + _origin = AGLtoASL (_vehicle modelToWorld _x); + + _dummy = QGVAR(helper) createVehicle [0, 0, 0]; + _dummy allowDamage false; + _dummy setPosASL (_origin vectorAdd [0, 0, -2]); + + _anchor = QGVAR(helper) createVehicle [0, 0, 0]; + _anchor allowDamage false; + _anchor setPosASL (_origin vectorAdd [0, 0, -2.5]); + + _ropeTop = ropeCreate [_vehicle, _x, _dummy, [0, 0, 0], 2]; + _ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 33]; + + //deployedRopes format: attachment point, top part of the rope, bottom part of the rope, attachTo helper object, anchor helper object, occupied + _deployedRopes pushBack [_x, _ropeTop, _ropeBottom, _dummy, _anchor, false]; + false +} count _ropeOrigins; + +_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true]; diff --git a/addons/fastroping/functions/fnc_fastRope.sqf b/addons/fastroping/functions/fnc_fastRope.sqf new file mode 100644 index 0000000000..69043b3cf8 --- /dev/null +++ b/addons/fastroping/functions/fnc_fastRope.sqf @@ -0,0 +1,38 @@ +/* + * Author: BaerMitUmlaut + * Lets the unit fast rope. + * + * Arguments: + * 0: Unit occupying the helicopter + * 1: The helicopter itself + * + * Return Value: + * None + * + * Example: + * [_player, _vehicle] call ace_fastroping_fastRope + * + * Public: No + */ + +#include "script_component.hpp" +params ["_unit", "_vehicle"]; +private ["_deployedRopes", "_usableRope", "_usableRopeIndex"]; + +//Select unoccupied rope +_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; +_usableRope = _deployedRopes select 0; +_usableRopeIndex = 0; +{ + if !(_x select 5) exitWith { + _usableRope = _x; + _usableRopeIndex = _forEachIndex; + }; +} forEach _deployedRopes; + +_usableRope set [5, true]; +_deployedRopes set [_usableRopeIndex, _usableRope]; +_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true]; + +moveOut _unit; +[FUNC(fastRopePFH), 0, [_unit, _vehicle, _usableRope, _usableRopeIndex]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/fastroping/functions/fnc_fastRopePFH.sqf b/addons/fastroping/functions/fnc_fastRopePFH.sqf new file mode 100644 index 0000000000..9afd7568a0 --- /dev/null +++ b/addons/fastroping/functions/fnc_fastRopePFH.sqf @@ -0,0 +1,59 @@ +/* + * Author: BaerMitUmlaut + * PerFrameHandler during fast roping. + * + * Arguments: + * 0: PFH arguments + * 1: PFH handle + * + * Return Value: + * None + * + * Example: + * [[_unit, _vehicle, _rope, _ropeIndex], 0] call ace_fastroping_fastRopePFH + * + * Public: No + */ + +#include "script_component.hpp" +params ["_arguments", "_pfhHandle"]; +_arguments params ["_unit", "_vehicle", "_rope", "_ropeIndex"]; +_rope params ["_attachmentPoint", "_ropeTop", "_ropeBottom", "_dummy", "_anchor", "_occupied"]; +private ["_origin"]; + +//Wait until the unit is actually outside of the helicopter +if (vehicle _unit != _unit) exitWith {}; + +//Start fast roping +if (isNull attachedTo _unit) exitWith { + _dummy setVectorUp [0, 0, 1]; + _unit attachTo [_dummy, [0, 0, -1.2]]; + [_unit, "ACE_FastRoping", 2] call EFUNC(common,doAnimation); + systemChat str _ropeTop; + systemChat str _ropeBottom; + ropeUnwind [_ropeTop, 6, 35]; + ropeUnwind [_ropeBottom, 6, 0]; +}; + +//Check if fast rope is finished +if (((getPos _unit select 2) < 0.5) || {ropeUnwound _ropeTop} || {vectorMagnitude (velocity _vehicle) > 5}) exitWith { + detach _unit; + [_unit, "", 2] call EFUNC(common,doAnimation); + + //Reset rope + deleteVehicle _ropeTop; + deleteVehicle _ropeBottom; + + _origin = AGLtoASL (_vehicle modelToWorld _attachmentPoint); + _dummy setPosASL (_origin vectorAdd [0, 0, -2]); + + _ropeTop = ropeCreate [_vehicle, _attachmentPoint, _dummy, [0, 0, 0], 2]; + _ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 33]; + + //Update deployedRopes array + _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; + _deployedRopes set [_ropeIndex, [_attachmentPoint, _ropeTop, _ropeBottom, _dummy, _anchor, false]]; + _vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true]; + + [_pfhHandle] call CBA_fnc_removePerFrameHandler; +}; diff --git a/addons/fastroping/functions/script_component.hpp b/addons/fastroping/functions/script_component.hpp new file mode 100644 index 0000000000..00e1b5bb76 --- /dev/null +++ b/addons/fastroping/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\fastroping\script_component.hpp" diff --git a/addons/fastroping/script_component.hpp b/addons/fastroping/script_component.hpp new file mode 100644 index 0000000000..661de4b703 --- /dev/null +++ b/addons/fastroping/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT fastroping +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_BLANK + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_BLANK + #define DEBUG_SETTINGS DEBUG_SETTINGS_BLANK +#endif + +#include "\z\ace\addons\main\script_macros.hpp"