Jump to content
Sign in to follow this  
Rydygier

Heli stops after ejecting cargo units

Recommended Posts

Supposedly simple thingy: I have a chopper (Mohawk) flying straight&steady from A to B. In the cargo is placed another group of 8 infantry. In the middle each unit of that group performs "eject" action, chute is added etc. , all fine here. What's not fine, happens with the chopper then - instead of continuing straight&steady toward B, he is stopping rapidly, breaking flyInHeight level by the way, as soon first unit is ejected, with some maneuvers and hovers indefinitely (if used LeaveVeghicle for cargo group) or lands and after longer while resumes his path. Without ejecting the crew route is completed just fine. Like "eject" action of assigned cargo triggers landing behaviour, that is broken, if in the middle of it group will be unassigned/leave the helicopter - how to prevent that behaviour and keep chopper flying straight?

Repro without irrelevant parts.

Code itself:

sleep 2;
_heli = h1;

_wp = (group _heli) addWaypoint [(position t1),0];
_wp setWaypointType "MOVE";


_pos = position player;

waitUntil
{
_dst1 = _heli distance _pos;
sleep 1;
_dst2 = _heli distance _pos;

((_dst2 > _dst1) and {_dst2 < 1000})
};

{
//_x leaveVehicle _heli;
//moveOut _x;
//_x action ["GETOUT", _heli];
_x action ["EJECT", _heli];
}
foreach (units G1);

G1 leaveVehicle _heli;

Commenting out eject line will make chooper continue straight flight. Commenintg out leaveVehicle line instead will make it land, wait, continue then. In current form - infinite hovering occurs.

I would like to avoid manual setposing cargo units outside (not tested yet if that even solves the problem though)...

EDIT: Nope. Even using setpos instead triggers that heli behaviour. Weird.

But using unassignVehicle instead of leaveVehicle seems to solve the problem... Also seem to require 0.5-1 sleep between ejects. Hmm. And not always. :/

Anyway, most reliable version preventing that:

sleep 2;
_heli = h1;

_wp = (group _heli) addWaypoint [(position t1),0];
_wp setWaypointType "MOVE";


_pos = position player;

waitUntil
{
_dst1 = _heli distance _pos;
sleep 1;
_dst2 = _heli distance _pos;

((_dst2 > _dst1) and {_dst2 < 1000})
};

{
unassignVehicle _x;
_x setPos (_heli modelToWorld [(random 4) - (random 4),-4,-2]);
sleep (0.75 + (random 0.25))
}
foreach (units G1);

Edited by Rydygier

Share this post


Link to post
Share on other sites

Regarding that additional sleep: BI seems to have changed the "Eject" and "GetOut" actions.

Furthermore, I'm using a script made by cobra4v320 for the paradrop itself. There might be something helpful for you in it:

/*
File: fn_paradrop.sqf
Version: 1.1

Author(s): cobra4v320 - effects adapted from old halo.sqs, sounds from freesound.org

Description: allows AI units and players to paradrop - fixes AI bug

Parameters:
0: UNIT    - (object) the unit that will be doing the paradrop
1: VEHICLE - (object) the vehicle that will be doing the paradrop
2: (optional) SAVELOADOUT - (boolean) true to save backpack and its contents, and add a "fake" backpack to the front of the unit.
3: (optional) CHEMLIGHT - (boolean) true if the units will use chemlights

Example(s):
[this, helo_1, true, true] call COB_fnc_paradrop
*/
if (!isServer || isDedicated) exitWith {};

//Parameters
private ["_unit","_vehicle","_saveLoadOut","_chemLight"]; 
_unit 	 	 = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
_vehicle 	 = [_this, 1, objNull, [objNull]] call BIS_fnc_param;
_saveLoadOut = [_this, 2, true, [true]] call BIS_fnc_param;
_chemLight	 = [_this, 3, false, [false]] call BIS_fnc_param;

//Validate parameters
if (isNull _unit) exitWith {"Unit parameter must not be objNull. Accepted: OBJECT" call BIS_fnc_error};
if (isNull _vehicle) exitWith {"Vehicle parameter must not be objNull. Accepted: OBJECT" call BIS_fnc_error};

//create a log entry
["Paradrop function has started"] call BIS_fnc_log;

//save the backpack and its contents, also adds fake pack to front of unit
if (_saveLoadOut && !isNull (unitBackpack _unit)) then {
private ["_pack","_class","_magazines","_weapons","_items"];
_pack	   = unitBackpack _unit;
_class	   = typeOf _pack;
_magazines = getMagazineCargo _pack;
_weapons   = getWeaponCargo _pack;
_items	   = getItemCargo _pack;

removeBackpack _unit; //remove the backpack
_unit addBackpack "b_parachute";

//attach the bacpack to the unit
[_unit,_class,_magazines,_weapons,_items] spawn {
	private ["_unit","_class","_magazines","_weapons","_items"];
	_unit		= _this select 0;
	_class		= _this select 1;
	_magazines	= _this select 2;
	_weapons 	= _this select 3;
	_items 		= _this select 4;

	private "_packHolder";
	_packHolder = createVehicle ["groundWeaponHolder", [0,0,0], [], 0, "can_collide"];
	_packHolder addBackpackCargoGlobal [_class, 1];

	waitUntil {animationState _unit == "para_pilot"};
	_packHolder attachTo [vehicle _unit,[-0.07,0.67,-0.13],"pelvis"]; 
	_packHolder setVectorDirAndUp [[0,-0.2,-1],[0,1,0]];

	waitUntil {isTouchingGround _unit || (getPos _unit select 2) < 1};
	deleteVehicle _packHolder; //delete the backpack in front
	_unit addBackpack _class; //return the backpack
	clearAllItemsFromBackpack _unit; //clear all gear from new backpack

	for "_i" from 0 to (count (_magazines select 0) - 1) do {
		(unitBackpack _unit) addMagazineCargoGlobal [(_magazines select 0) select _i,(_magazines select 1) select _i]; //return the magazines
	};
	for "_i" from 0 to (count (_weapons select 0) - 1) do {
		(unitBackpack _unit) addWeaponCargoGlobal [(_weapons select 0) select _i,(_weapons select 1) select _i]; //return the weapons
	};
	for "_i" from 0 to (count (_items select 0) - 1) do {
		(unitBackpack _unit) addItemCargoGlobal [(_items select 0) select _i,(_items select 1) select _i]; //return the items
	};
};
} else {
if ((backpack _unit) != "b_parachute") then {_unit addBackpack "B_parachute"}; //add the parachute if unit has no backpack
};

//eject from vehicle
[_unit,_vehicle] spawn {
private ["_unit","_vehicle","_altitude"];
_unit = _this select 0;
_vehicle = _this select 1;

_altitude = (getPos _vehicle select 2);
_unit allowDamage false; //keep the AI from being injured when in para_pilot, its an AI bug

if (_altitude > 3040 && (headgear _unit) != "H_CrewHelmetHeli_B") then {_unit addHeadgear "H_CrewHelmetHeli_B"};

unassignVehicle _unit;
_unit action ["EJECT", _vehicle];
_unit setDir getDir _vehicle;
_unit setPos [(getPos _vehicle select 0), (getPos _vehicle select 1) - random 15 + random 30, _altitude - 4];
_unit setVelocity [0,20,-20];

if (isPlayer _unit) then {	
	_unit action ["OpenParachute",_unit];

	// Parachute opening effect for more immersion
	playSound "open_chute"; //play chute opening sound
	setAperture 0.05; 
	setAperture -1;
	"DynamicBlur" ppEffectEnable true;  
	"DynamicBlur" ppEffectAdjust [8.0];  
	"DynamicBlur" ppEffectCommit 0.01;
	sleep 1;
	"DynamicBlur" ppEffectAdjust [0.0]; 
	"DynamicBlur" ppEffectCommit 3;
	sleep 3;
	"DynamicBlur" ppEffectEnable false;
	"RadialBlur" ppEffectAdjust [0.0, 0.0, 0.0, 0.0]; 
	"RadialBlur" ppEffectCommit 1.0; 
	"RadialBlur" ppEffectEnable false;

	[_unit] spawn {
		private "_unit";
		_unit = _this select 0;

		while {(getPos _unit select 2) > 2 && alive _unit} do {
			playSound "para_pilot"; //play sound
			sleep 4.2;
		};
	};
};

waitUntil {isTouchingGround _unit || (getPos _unit select 2) < 1}; //wait for unit to touch ground

if (!isPlayer _unit) then {
	_unit setPos [(getPos _unit select 0), (getPos _unit select 1), 0]; //this removes the unit from the parachute
	_unit setVelocity [0,0,0]; //set speed to zero
	_unit setVectorUp [0,0,1]; //set the unit upright
	sleep 1;
	_unit allowDamage TRUE; //allow unit to be damaged again
} else {
	playSound "close_chute";//play chute closing sound
	cutText ["", "BLACK FADED", 999];
	sleep 2;
	cutText ["", "BLACK IN", 2];
	_unit allowDamage TRUE; //allow unit to be damaged again
};
};

//add a chemlight to helmet
if (_chemLight) then {
[_chemLight,_unit] spawn {
	private ["_chemlight","_unit","_light"];
	_chemLight = _this select 0;
	_unit	   = _this select 1;

	_light = "chemlight_red" createVehicle [0,0,0]; //create the chemlight

	waitUntil {animationState _unit == "para_pilot"};

	if (headgear _unit != "") then {
		_light attachTo [vehicle _unit,[0,0.14,0.84],"head"]; 
		_light setVectorDirAndUp [[0,1,-1],[0,1,0.6]];
	} else {
		_light attachTo [vehicle _unit,[-0.13,-0.09,0.56],"LeftShoulder"];  
		_light setVectorDirAndUp [[0,0,1],[0,1,0]];
	};

	waitUntil {isTouchingGround _unit || (getPos _unit select 2) < 1};
	detach _light;
	deleteVehicle _light; //delete the chemlight
};
};

//create a log entry
["Paradrop function has completed"] call BIS_fnc_log;

//Return Value
_unit;

Share this post


Link to post
Share on other sites

Thanks. For now implemented the second code, and seem to work good enough. I do however seen some units died at land, maybe that's the bug, your snippet mentions? Anyway, IMO worse is keep them invulnerable till land - too much fun with hitting them in the air would be lost. :) Seems, that's just another buggy part of Arma 3. Indeed - eject works one-by-one + that strange heli behaviour. But get out is even worse for me - AFAIR no one is ejected till heli land. Setposing works though as I wanted.

Edited by Rydygier

Share this post


Link to post
Share on other sites

That thing I saw, when I placed all chutes in the same area at once, just as on the pic. Assumed, is due to collisions between chutes...

Share this post


Link to post
Share on other sites

You have to unassign the units from the chopper first. I've posted more about this here some time ago.

Share this post


Link to post
Share on other sites

Yes, this + some sleep between ejects was my so far best solution (without the sleep heli still often stops to land or hover though). Before this I tried with leaveVehicle instead unassign, and this wasn't working.

Share this post


Link to post
Share on other sites

Occasionally when units were ejecting the helicopter would explode. Too bad BI still has not fixed paradrop, exploding parachutes and what not.

Share this post


Link to post
Share on other sites

Yeah, this is a line of BIS code from the final Survive mission where CSAT troops eject from helicopters:

//_para allowDamage true;	(ToDo: re-enable when parachutes no longer burst into flames)

Presumably this parachute thing messes up the mission now, I haven't played it in a while.

Anyway, I was having this problem in a mission too, but I think it was happening long before BIS made that eject action change. My solution was to do this as soon as all the units were dropped:

_heli land "NONE";

This allowed the chopper to continue on its way. I haven't tested this in a while though, the eject change might have messed it up again.

Share this post


Link to post
Share on other sites

BTW just saw, what causes occasional paratrooper death at land - apparently, when parachute is auto-deleted, soldier may get physX-like punch (vector) that makes him fly few meters aside and kills him.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×