From cc22e950129160b88ebc18b0bac10b9969a5936e Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 25 Apr 2019 20:31:36 +0200 Subject: [PATCH] Fastroping - Remove FRIES on vehicle deletion / adjust Ghosthawk Fries (#6932) * fastroping_fnc_deequipFRIES, remove FRIES on vehicle deletion * Prevent FRIES from clipping into Ghost Hawk right door * UNequipFRIES * Remove fastroping checkVehicleThread * Document FRIES equip and unequip functions --- addons/fastroping/CfgVehicles.hpp | 2 +- addons/fastroping/XEH_PREP.hpp | 2 +- .../functions/fnc_checkVehicleThread.sqf | 24 ------------------- .../fastroping/functions/fnc_equipFRIES.sqf | 13 +++------- .../fastroping/functions/fnc_unequipFRIES.sqf | 24 +++++++++++++++++++ docs/wiki/framework/fastroping-framework.md | 20 ++++++++++++++++ 6 files changed, 49 insertions(+), 36 deletions(-) delete mode 100644 addons/fastroping/functions/fnc_checkVehicleThread.sqf create mode 100644 addons/fastroping/functions/fnc_unequipFRIES.sqf diff --git a/addons/fastroping/CfgVehicles.hpp b/addons/fastroping/CfgVehicles.hpp index 2d03ddcee0..408db14b99 100644 --- a/addons/fastroping/CfgVehicles.hpp +++ b/addons/fastroping/CfgVehicles.hpp @@ -207,7 +207,7 @@ class CfgVehicles { GVAR(enabled) = 2; GVAR(ropeOrigins)[] = {"ropeOriginRight", "ropeOriginLeft"}; GVAR(friesType) = "ACE_friesAnchorBar"; - GVAR(friesAttachmentPoint)[] = {0.065, 2.2, -0.15}; + GVAR(friesAttachmentPoint)[] = {0.035, 2.2, -0.15}; GVAR(onPrepare) = QFUNC(onPrepareCommon); GVAR(onCut) = QFUNC(onCutCommon); EQUIP_FRIES_ATTRIBUTE; diff --git a/addons/fastroping/XEH_PREP.hpp b/addons/fastroping/XEH_PREP.hpp index 1ad995c598..1a80bfa796 100644 --- a/addons/fastroping/XEH_PREP.hpp +++ b/addons/fastroping/XEH_PREP.hpp @@ -4,7 +4,6 @@ PREP(canDeployRopes); PREP(canFastRope); PREP(canPrepareFRIES); PREP(canStowFRIES); -PREP(checkVehicleThread); PREP(cutRopes); PREP(deployAI); PREP(deployRopes); @@ -18,3 +17,4 @@ PREP(onPrepareCommon); PREP(onRopeBreak); PREP(prepareFRIES); PREP(stowFRIES); +PREP(unequipFRIES); diff --git a/addons/fastroping/functions/fnc_checkVehicleThread.sqf b/addons/fastroping/functions/fnc_checkVehicleThread.sqf deleted file mode 100644 index 7889cdb268..0000000000 --- a/addons/fastroping/functions/fnc_checkVehicleThread.sqf +++ /dev/null @@ -1,24 +0,0 @@ -#include "script_component.hpp" -/* - * Author: BaerMitUmlaut - * Checks if the given helicopter still exits, and if not, destroys the FRIES. - * - * Arguments: - * 0: The helicopter - * 1: The helicopter's FRIES - * - * Return Value: - * None - * - * Example: - * [_vehicle, _fries] call ace_fastroping_fnc_checkVehicleThread - * - * Public: No - */ -params ["_vehicle", "_fries"]; - -if (isNull _vehicle) then { - deleteVehicle _fries; -} else { - [FUNC(checkVehicleThread), _this, 5] call CBA_fnc_waitAndExecute; -}; diff --git a/addons/fastroping/functions/fnc_equipFRIES.sqf b/addons/fastroping/functions/fnc_equipFRIES.sqf index a6dc469749..7b1002db20 100644 --- a/addons/fastroping/functions/fnc_equipFRIES.sqf +++ b/addons/fastroping/functions/fnc_equipFRIES.sqf @@ -12,7 +12,7 @@ * Example: * [_vehicle] call ace_fastroping_fnc_equipFRIES * - * Public: No + * Public: Yes */ params ["_vehicle"]; @@ -24,15 +24,8 @@ if !(isNumber (_config >> QGVAR(enabled))) then { private _fries = (getText (_config >> QGVAR(friesType))) createVehicle [0, 0, 0]; _fries attachTo [_vehicle, (getArray (_config >> QGVAR(friesAttachmentPoint)))]; _vehicle setVariable [QGVAR(FRIES), _fries, true]; - _vehicle addEventHandler ["Killed", { - params ["_vehicle"]; - deleteVehicle (_vehicle getVariable [QGVAR(FRIES), objNull]); - _vehicle setVariable [QGVAR(FRIES), nil, true]; - if !((_vehicle getVariable [QGVAR(deployedRopes), []] isEqualTo [])) then { - [_vehicle] call FUNC(cutRopes); - }; - }]; - [FUNC(checkVehicleThread), [_vehicle, _fries], 5] call CBA_fnc_waitAndExecute; + _vehicle addEventHandler ["Killed", FUNC(unequipFRIES)]; + _vehicle addEventHandler ["Deleted", FUNC(unequipFRIES)]; }; }; diff --git a/addons/fastroping/functions/fnc_unequipFRIES.sqf b/addons/fastroping/functions/fnc_unequipFRIES.sqf new file mode 100644 index 0000000000..e89cacec9e --- /dev/null +++ b/addons/fastroping/functions/fnc_unequipFRIES.sqf @@ -0,0 +1,24 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Removes FRIES from helicopter. + * + * Arguments: + * 0: The helicopter + * + * Return Value: + * None + * + * Example: + * [_vehicle] call ace_fastroping_fnc_unequipFRIES + * + * Public: Yes + */ +params ["_vehicle"]; + +deleteVehicle (_vehicle getVariable [QGVAR(FRIES), objNull]); +_vehicle setVariable [QGVAR(FRIES), nil, true]; + +if !((_vehicle getVariable [QGVAR(deployedRopes), []] isEqualTo [])) then { + [_vehicle] call FUNC(cutRopes); +}; diff --git a/docs/wiki/framework/fastroping-framework.md b/docs/wiki/framework/fastroping-framework.md index 2a906802b3..3979243d7c 100644 --- a/docs/wiki/framework/fastroping-framework.md +++ b/docs/wiki/framework/fastroping-framework.md @@ -80,3 +80,23 @@ To create a custom FRIES you will need to look out for a few things: The `onCut` and `onPrepare` functions are responsible for opening/closing the helicopter doors and animating the FRIES (if equipped) when the FRIES gets prepared and the ropes get cut. ACE3 provides two functions that are compatible with most helicopters and all ACE3 FRIES. It is recommended to use the naming scheme for doors that is present in the base game so you can use the already existing functions `ace_fastroping_fnc_onCutCommon` and `ace_fastroping_fnc_onPrepareCommon`. You can however define your own functions if you so desire. Note that these functions run in the unscheduled environment, so commands like `sleep` and `waitUntil` will not work unless you use `spawn`. It is recommended to use `ace_common_fnc_waitAndExecute` and `ace_common_fnc_waitUntilAndExecute` instead though. + +## 4. Scripting + +### 4.1. Add FRIES to helicopter + +`ace_fastroping_fnc_equipFRIES` + +| | Arguments | Type | Optional (default value) +---| --------- | ---- | ------------------------ +0 | Helicopter | Object | Required +**R** | None | None | Return value + +### 4.2. Remove FRIES from helicopter + +`ace_fastroping_fnc_unequipFRIES` + +| | Arguments | Type | Optional (default value) +---| --------- | ---- | ------------------------ +0 | Helicopter | Object | Required +**R** | None | None | Return value