kingofnuthin1980 53 Posted December 19, 2021 [RELEASE] Script to para jump and land with your squad in formation When using steerable parachutes, my squad never followed me. They were spinning around, hanging in their parachutes, and they were landing wherever they want. I got tired to catch up with my squad after every jump, so I wrote this script. WHAT IT DOES: If you go into freefall, your squad will drop out of the aircraft. When not looking at your squad, it gets repositioned behind you. In freefall and when they are in their parachutes. Your squad opens the parachute when you do, or when they reach a height between 100 and 75 meters. Your squad should land close to you. To make the units not spin around in their parachutes, the simulation of the parachute is disabled. THE SCRIPTS: Add this eventhandler for your player unit, to check for freefall animation: Spoiler //--- auto parachute player addEventHandler ["AnimStateChanged", { params ["_unit", "_anim"]; //--- check if unit is in freefall, if auto parachute is enabled, and freefall variable inactive if ("freefall" in (toLower _anim) && (AIM_VAR_GAMEPLAY_SETTINGS select 17) && !(_unit getVariable ["#freefall", FALSE])) then { //--- set freefall variable active to disable this eventhandler _unit setVariable ["#freefall", TRUE]; //--- init para drop _null = [_unit] call AIM_fnc_paraDropInit; }; //--- check if unit landed, is not in freefall, and freefall variable active if (isTouchingGround _unit || !("freefall" in (toLower _anim)) && (_unit getVariable ["#freefall", FALSE])) then { //--- set freefall variable inactive to re-enable this eventhandler _unit setVariable ["#freefall", FALSE]; }; }]; AIM_fnc_paraDropInit (this adds the action to open your parachute, handles your squad exit out of the aircraft, and initializes the formation) Spoiler /* ---------------------------------------------------------------------------- Author: ai-mods Description: adds action to open parachute to player and handles the squad for the para jump Parameter(s): 0 - OBJECT: unit (player) Returns: BOOLEAN Example: _null = [player] call AIM_fnc_paraDropInit; ---------------------------------------------------------------------------- */ params ["_leader"]; //--- exit if parachute action is already in players action menu if ((actionIDs _leader) findIf { ((_leader actionParams _x) select 0) == "OPEN PARACHUTE" } != -1) exitWith { FALSE }; //--- add parachute action _leader addAction ["OPEN PARACHUTE", { params ["_unit", "_caller", "_actionId"]; //--- remove the parachute action _unit removeAction _actionId; //--- create parachute and move unit into it _null = [_unit, _unit] spawn AIM_fnc_paraDropParachute; //--- finish TRUE },[],6,true,true,"",""]; //--- handle squad para drop _null = [_leader] spawn { params ["_leader"]; //--- get group private ["_grp", "_grpUnits"]; _grp = group _leader; _grpUnits = (units _grp) - [_leader]; //--- exit if leader has no squad if (count _grpUnits > 0) then { //--- handle para drop of each unit { //--- get unit, index in squad and vehicle private ["_index", "_unit", "_veh"]; _index = _forEachIndex; _unit = _x; _veh = vehicle _unit; //--- check if unit is in aircraft if (_veh != _unit) then { //--- disable collission and damage _unit disableCollisionWith _veh; _unit allowDamage FALSE; //--- move unit out of aircraft unassignVehicle _unit; moveOut _unit; //--- handle parachute opening _null = [_unit, _leader, FALSE] spawn AIM_fnc_paraDropParachute; //--- short delay to spread out the team uiSleep 0.2; }; } forEach _grpUnits; //--- handle formation during jump _null = [_grp, _grpUnits, _leader] spawn AIM_fnc_paraDropFormation; }; //--- finish TRUE }; //---make sure parachute action gets removed _null = [] spawn { //--- wait until player landed [{(getPosATL player) select 2 < 5 || isTouchingGround player || vehicle player != player}, 3] call BIS_fnc_CPWaitUntil; //--- remove parachute action from player action menu private ["_index"]; _index = (actionIDs player) findIf { ((player actionParams _x) select 0) == "OPEN PARACHUTE" }; if (_index != -1) then { player removeAction _index; }; //--- finish TRUE }; //--- finish TRUE AIM_fnc_paraDropParachute (this opens your parachute, and for squad members it waits until you have opened your parachute) Spoiler /* ---------------------------------------------------------------------------- Author: ai-mods Description: spawn parachute and moves unit into it Parameter(s): 0 - OBJECT: unit Returns: BOOL Example: _null = [player] call AIM_fnc_paraDropParachute; ---------------------------------------------------------------------------- */ params [ "_unit", "_leader", ["_simulate", TRUE] ]; //--- check if unit is player if (_unit isEqualTo player) then { //--- play parachute open sound and add cam shake for pulling out playSound3D ['a3\sounds_f\characters\parachute\parachute_open.wss', _unit, false, getPosASL _unit,5, 1, 250]; addCamShake [4, 1, 10]; }; //--- check if unit is not leader if (_unit != _leader) then { //--- wait until leader has opened parachute or minimum height reached [{(vehicle _leader) != _leader || (((getPosATL _unit) select 2) < (100 - (random 25)))}, 1] call BIS_fnc_CPWaitUntil; }; //--- create parachute and move player into it private ["_para", "_vel"]; _para = createVehicle ["Steerable_Parachute_F", position _unit, [], 0, "FLY"]; _para setpos position _unit; _para setdir direction _unit; _vel = velocity _unit; _para setvelocity [(_vel select 0), (_vel select 1), (_vel select 2)]; _unit moveindriver _para; _para lock false; //--- check if unit is player if (_unit isEqualTo player) then { //--- another stronger camshake and blur effect for opening parachute addCamShake [6, 2, 20]; //--- screen effect for opening parachute private ["_effect"]; _effect = ppeffectcreate ["DynamicBlur",464]; _effect ppEffectEnable true; _effect ppEffectAdjust [6.0]; _effect ppEffectCommit 0; _effect ppEffectAdjust [0.0]; _effect ppEffectCommit 1; //--- delete screen effect after delay _null = _effect spawn { uiSleep 4; ppeffectdestroy _this; TRUE }; }; //--- check if unit should steer parachute if !(_simulate) then { //--- disable simulation for parachute, so the unit doesn't spin around and formation can be applied _para enableSimulation FALSE; //--- wait until unit is close to ground, then enable simulation for landing [{ ((((getPosATL _unit) select 2) < 30) || (isTouchingGround _leader)) }, 1] call BIS_fnc_CPWaitUntil; { _x enableSimulation TRUE; } forEach [_para, _unit]; //--- wait until the unit touches ground, give it a few seconds and then re-enable damage for unit [{isTouchingGround _unit}, 1] call BIS_fnc_CPWaitUntil; uiSleep 3; _unit allowDamage TRUE; }; //--- finish TRUE AIM_fnc_paraDropFormation (keeps your squad close to you, until you landed) Spoiler /* ---------------------------------------------------------------------------- Author: ai-mods Description: keeps the squad behind leader Parameter(s): 0 - GROUP: squad 1 - OBJECT: squad leader (optional) Returns: BOOL Example: _null = [group player, units (group player), player] call AIM_fnc_paraDropFormation; ---------------------------------------------------------------------------- */ params [ ["_grp", grpNull], "_grpUnits", ["_leader", objNull] ]; //--- exit if group doesn't exist if (_grp isEqualTo grpNull) exitWith { TRUE }; //--- check if leader is known _leader = [_leader, leader _grp] select (_leader isEqualTo objNull); //--- loop while leader is not touching ground while {!(isTouchingGround _leader) && alive _leader} do { //--- exit if all units are close to ground if ({alive _x && ((getPosATL _x) select 2) > 25} count _grpUnits == 0) exitWith { TRUE }; //--- handle position of group units { //--- get unit private ["_unit"]; _unit = _x; _index = _forEachIndex; //--- check if unit is visible on screen _screenPos = worldtoscreen (position _unit); //--- only handle if unit is still parachuting if (((getPosATL _x) select 2) > 30) then { //--- get new position behind leader private ["_xDiff", "_yDiff", "_zDiff", "_posUnitNew"]; _xDiff = [(4 * (_index + 1)), -(4* (_index + 1))] select (_index % 2 == 0); _yDiff = (-16 - (4 * (_index + 1))); _zDiff = -4; _posUnitNew = _leader modelToWorld [_xDiff, _yDiff, _zDiff]; //--- if not seen by leader, set new position for unit if (count _screenPos == 0) then { //--- unit is in freefall if (vehicle _unit == _unit) then { //--- match unit direction and velocity with leader _unit setPos _posUnitNew; _unit setVectorDir (vectorDir _leader); _unit setVelocity (velocity _leader); //--- unit is in parachute } else { //--- match unit direction and velocity with leader and keep unit in parachute private ["_para"]; _para = vehicle _unit; _unit setPos _posUnitNew; _para setpos position _unit; { _x setVectorDir (vectorDir _leader); _x setVelocityModelSpace (velocity _leader); } forEach [_unit, _para]; _unit moveindriver _para; _para lock false; }; }; } else { //--- enable simulation private ["_para"]; _para = vehicle _unit; { _x enableSimulation TRUE; } forEach [_para, _unit]; }; //--- short delay after each unit uiSleep 0.1; } forEach _grpUnits; //--- check interval uiSleep 2; }; //--- finish TRUE YOU HAVE FOUND ISSUES OR YOU HAVE OPTIMIZATION SUGGESTIONS? Don't hesitate to tell me your feedback, down in the comments below. ANYTHING ELSE? No. Just have fun! 🙂 MAKE ARMA, NOT WAR! ...and maybe check out... "OPCOM - OPERATION COMMAND" 3 1 Share this post Link to post Share on other sites
johnnyboy 3791 Posted December 20, 2021 Great idea. Thanks! 1 Share this post Link to post Share on other sites
stburr91 1002 Posted December 20, 2021 First let me say nice job on the script, it must have taken quite a bit of time to create, so thanks for the effort. However, I solved the same problem with 3 lines of code, by simply attaching the AI to the player after jumping out of the plane, and putting them into the free fall animation, then detaching them at 120 meter above the ground, where they open their chutes on their own, and land within 50 meters of the player. This worked perfectly in the mission that I used it in. 2 Share this post Link to post Share on other sites
kingofnuthin1980 53 Posted December 20, 2021 1 hour ago, stburr91 said: First let me say nice job on the script, it must have taken quite a bit of time to create, so thanks for the effort. However, I solved the same problem with 3 lines of code, by simply attaching the AI to the player after jumping out of the plane, and putting them into the free fall animation, then detaching them at 120 meter above the ground, where they open their chutes on their own, and land within 50 meters of the player. This worked perfectly in the mission that I used it in. I did that, too. But I didn't like, when the units are glued to their position behind me, when turning around while looking at them in third person. If you want to solve that with an attach code, I bet you'll need more than three lines, too. 😉 Edit: Not saying my approach is perfect, because it's not. It's just a matter of taste on how it plays out in the end. 2 Share this post Link to post Share on other sites