From b8a4349c10142a6c04bab723758817b4640093db Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sat, 5 Mar 2016 20:25:35 +0100 Subject: [PATCH] Added deployment API and waypoint --- addons/fastroping/CfgWaypoints.hpp | 11 ++ addons/fastroping/UI/Icon_Waypoint.paa | Bin 0 -> 5625 bytes addons/fastroping/XEH_preInit.sqf | 1 + addons/fastroping/config.cpp | 1 + addons/fastroping/functions/fnc_deployAI.sqf | 95 ++++++++++++++++++ .../functions/fnc_deployAIWaypoint.sqf | 42 ++++++++ addons/fastroping/stringtable.xml | 4 + 7 files changed, 154 insertions(+) create mode 100644 addons/fastroping/CfgWaypoints.hpp create mode 100644 addons/fastroping/UI/Icon_Waypoint.paa create mode 100644 addons/fastroping/functions/fnc_deployAI.sqf create mode 100644 addons/fastroping/functions/fnc_deployAIWaypoint.sqf diff --git a/addons/fastroping/CfgWaypoints.hpp b/addons/fastroping/CfgWaypoints.hpp new file mode 100644 index 0000000000..4c4da2a7cb --- /dev/null +++ b/addons/fastroping/CfgWaypoints.hpp @@ -0,0 +1,11 @@ +class CfgWaypoints { + class ACE { + displayName = "ACE"; + class Fastrope { + displayName = CSTRING(Waypoint_Fastrope); + displayNameDebug = "Fastrope"; + file = QUOTE(PATHTOF(functions\fnc_deployAIWaypoint.sqf)); + icon = QUOTE(PATHTOF(UI\Icon_Waypoint.paa)); + }; + }; +}; diff --git a/addons/fastroping/UI/Icon_Waypoint.paa b/addons/fastroping/UI/Icon_Waypoint.paa new file mode 100644 index 0000000000000000000000000000000000000000..4f7d9086aea0e9e86ad854091a1257e9b6c50653 GIT binary patch literal 5625 zcmeHL4Nz3q6+Um-2dIM}vckq}L4_hl3Q6i#$7Fbfh`dY*i|(UN`UguBMfropiKwtdvbsIz-o5;+^(Qm6 z%}je|7x>;e_x#>-&V9(HmfC7LL{=fdWBQS&9Pquo!0Gg)3Op{*Z(nIbO_^yQv z-z)Gv4-o$45`oiJPo+Qh)KvPG-3k|7FO$&AxKK83>l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)rTqKDXP zvVv_q@H_g31NsJb4aY7mhxX!(ZsB7G$qIDSHE{aNv|mDoMZ*QNpWpctGm{5lVSSL% z5&K9v8*A7WZAYMM%C$1^gVulr$p$9hhzrg}{`lS=?j8Np=!ucsDc87KZ$dS{rgIIc zN1Cr}BX-nJ{DIDWBT<1oRlI5 zUYKRxFEjb5J|gC1nWe8KlgUT*_P}gCf3u#)FosKW0S2e^KBkZCi-3eW@fspw8{GlX zCrdP_UBH?zNX zJfGuZThKA2Y{lSD;WItB5l%Z~E!d^6XZfUS2=UU2!7uF(qbx~~$&Ptw2AN5-Vh`cB zzdu*t*~{@5*OyuaX8cZiyXE`=l~~444E~&9oW9Tt_giJVLRf~dh^+S;8y;P-@g=q zHf%))D)R8HgLM}O?A9MtXDw!zE=pC@Usio1;a7R=r4nKG-6t+YWHcAP$Bl#)M(n5< S&sT!H-eZAdXN9%MitC?n9qNey literal 0 HcmV?d00001 diff --git a/addons/fastroping/XEH_preInit.sqf b/addons/fastroping/XEH_preInit.sqf index 83bb997eac..33f7b7b44e 100644 --- a/addons/fastroping/XEH_preInit.sqf +++ b/addons/fastroping/XEH_preInit.sqf @@ -8,6 +8,7 @@ PREP(canFastRope); PREP(canPrepareFRIES); PREP(checkVehicleThread); PREP(cutRopes); +PREP(deployAI); PREP(deployRopes); PREP(equipFRIES); PREP(fastRope); diff --git a/addons/fastroping/config.cpp b/addons/fastroping/config.cpp index 25ec1876fa..a74abeb3b8 100644 --- a/addons/fastroping/config.cpp +++ b/addons/fastroping/config.cpp @@ -15,3 +15,4 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgMoves.hpp" #include "CfgVehicles.hpp" +#include "CfgWaypoints.hpp" diff --git a/addons/fastroping/functions/fnc_deployAI.sqf b/addons/fastroping/functions/fnc_deployAI.sqf new file mode 100644 index 0000000000..6d77259fa6 --- /dev/null +++ b/addons/fastroping/functions/fnc_deployAI.sqf @@ -0,0 +1,95 @@ +/* + * Author: BaerMitUmlaut + * Auomatically deploy a helicopter filled with AI units. + * + * Arguments: + * 0: The helicopter + * 1: Deploy special roles (gunners, copilot) (default: false) + * 2: Create deployment group (default: true) + * + * Return Value: + * None + * + * Example: + * [_vehicle] call ace_fastroping_fnc_deployAI + * + * Public: Yes + */ + +#include "script_component.hpp" +params [["_vehicle", objNull, [objNull]], ["_deploySpecial", false, [true]], ["_createDeploymentGroup", true, [true]]]; +private ["_config", "_configEnabled", "_deployTime", "_unitsToDeploy", "_deployGroup"]; + +if (isNull _vehicle || {!(_vehicle isKindOf "Helicopter")}) exitWith { + if (hasInterface) then { + ["deployAI was called with an invalid or non-existant vehicle.", QFUNC(deployAI)] spawn BIS_fnc_guiMessage; + }; + ACE_LOGERROR('FUNC(deployAI): deployAI was called with an invalid or non-existant vehicle.'); +}; + +_config = configFile >> "CfgVehicles" >> typeOf _vehicle; +_configEnabled = getNumber (_config >> QGVAR(enabled)); +if (_configEnabled == 0) exitWith { + if (hasInterface) then { + [format ["You cannot fast rope from a ""%1"" helicopter.", getText (_config >> "DisplayName")], QFUNC(deployAI)] spawn BIS_fnc_guiMessage; + }; + ACE_LOGERROR_1('FUNC(deployAI): You cannot fast rope from a "%1" helicopter.',getText (_config >> "DisplayName")); +}; + +if (_configEnabled == 2 && {isNull (_vehicle getVariable [QGVAR(FRIES), objNull])}) exitWith { + if (hasInterface) then { + [format ["""%1"" requires a FRIES for fastroping, but has not been equipped with one.", getText (_config >> "DisplayName")], QFUNC(deployAI)] spawn BIS_fnc_guiMessage; + }; + ACE_LOGERROR_1('FUNC(deployAI): "%1" requires a FRIES for fastroping but has not been equipped with one.',getText (_config >> "DisplayName")); +}; + +_unitsToDeploy = crew _vehicle; +if (_deploySpecial) then { + _unitsToDeploy deleteAt (_unitsToDeploy find driver _vehicle); +} else { + _unitsToDeploy = _unitsToDeploy select {(assignedVehicleRole _x) select 0 == "cargo"}; +}; + +if (_unitsToDeploy isEqualTo []) exitWith { + ACE_LOGWARNING_1('FUNC(deployAI): Found no units to deploy in "%1".',getText (_config >> "DisplayName")); +}; + +if (_createDeploymentGroup) then { + _deployGroup = createGroup side (_unitsToDeploy select 0); + _unitsToDeploy joinSilent _deployGroup; +}; + +_deployTime = 0; +if (getText (_config >> QGVAR(onPrepare)) != "") then { + _deployTime = [_vehicle] call (missionNamespace getVariable (getText (_config >> QGVAR(onPrepare)))); +}; +[{[_this] call FUNC(deployRopes)}, _vehicle, _deployTime] call EFUNC(common,waitAndExecute); +driver _vehicle disableAI "MOVE"; + +DFUNC(deployAIRecursive) = { + params ["_vehicle", "_unitsToDeploy"]; + + private _unit = _unitsToDeploy deleteAt 0; + unassignVehicle _unit; + [_unit, _vehicle] call FUNC(fastRope); + + if !(_unitsToDeploy isEqualTo []) then { + [{ + [{ + params ["_vehicle"]; + private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; + ({!(_x select 5)} count (_deployedRopes)) > 0 + }, FUNC(deployAIRecursive), _this] call EFUNC(common,waitUntilAndExecute); + }, [_vehicle, _unitsToDeploy], 1] call EFUNC(common,waitAndExecute); + } else { + [{ + private _deployedRopes = _this getVariable [QGVAR(deployedRopes), []]; + ({_x select 5} count (_deployedRopes)) == 0 + }, { + [_this] call FUNC(cutRopes); + driver _this enableAI "MOVE"; + }, _vehicle] call EFUNC(common,waitUntilAndExecute); + }; +}; + +[FUNC(deployAIRecursive), [_vehicle, _unitsToDeploy], _deployTime + 4] call EFUNC(common,waitAndExecute); diff --git a/addons/fastroping/functions/fnc_deployAIWaypoint.sqf b/addons/fastroping/functions/fnc_deployAIWaypoint.sqf new file mode 100644 index 0000000000..9d8f4a03e2 --- /dev/null +++ b/addons/fastroping/functions/fnc_deployAIWaypoint.sqf @@ -0,0 +1,42 @@ +/* + * Author: BaerMitUmlaut + * Waypoint function for the fast rope waypoint. + * + * Arguments: + * 0: Group + * 1: Waypoint position + * + * Return Value: + * true + * + * Example: + * [_group, [6560, 12390, 0]] call ace_fastroping_fnc_deployAIWayoint + * + * Public: No + */ + +#include "script_component.hpp" +params [["_group", grpNull, [grpNull]], ["_position", [0, 0, 0], [[]], 3]]; +private ["_vehicle", "_commander", "_speedMode"]; + +_vehicle = vehicle leader _group; +_commander = effectiveCommander _vehicle; +_speedMode = speedMode _group; + +// - Approach ----------------------------------------------------------------- +if (_vehicle distance2D _position > 50) then { + _group setSpeedMode "LIMITED"; + _vehicle flyInHeight 20; + _commander doMove _position; + waitUntil {_vehicle distance2D _position < 50}; + waitUntil {vectorMagnitude (velocity _vehicle) < 3}; + //doStop _commander; +}; + +// - Deployment --------------------------------------------------------------- +[_vehicle] call FUNC(deployAI); +waitUntil {!((_vehicle getVariable [QGVAR(deployedRopes), []]) isEqualTo [])}; +waitUntil {(_vehicle getVariable [QGVAR(deployedRopes), []]) isEqualTo []}; +_group setSpeedMode _speedMode; + +true diff --git a/addons/fastroping/stringtable.xml b/addons/fastroping/stringtable.xml index 5394cf9b63..f6c0f34826 100644 --- a/addons/fastroping/stringtable.xml +++ b/addons/fastroping/stringtable.xml @@ -57,5 +57,9 @@ Equipe l'hélicoptère sélectionné avec un Fast Rope Insertion Extraction System Equipa el helicoptero seleccionado con un Sistema de Inserción Extracción Fast Rope + + LET UNITS FAST ROPE + EINHEITEN ABSEILEN LASSEN +