Jump to content
cobra4v320

AI HALO Jump Example Mission

Recommended Posts

After seeing lots of posts complaining about the AI HALO jumps not working and not finding any solutions I have created a function that will allow AI units to HALO jump, will also work with players. Since there is currently no cargo planes for jumping out of, I start the screen dark and use a C130 sound simulating exiting the aircraft. You can also save your backpack and loadout, you can even jump with your backpack attached to your chest.

Please let me know if this is useful or not, hopefully halo is fixed soon. If there are any errors or any additions that are needed let me know here in this thread.

Parameters

/*
File: fn_halo.sqf
Version: 2.1

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

Description: HALO jumping (works with AI soldiers). Set the altitude of the HALO, add a chemlight,
auto open your parachute at 150m, and save your backpack with its contents, then attach a backpack
to the front of your unit.

Parameters:
0: UNIT - (object) the unit that will be doing the HALO
1: (optional) ALTITUDE  - (number) the altitude where the HALO will start from
2: (optional) CHEMLIGHT - (boolean) true if the units will use chemlights
3: (optional) AUTOOPEN -(boolean) true to auto open parachute at 150m
4: (optional) SAVELOADOUT - (boolean) true to save backpack and its contents, and add a "fake" backpack to the front of the unit.

Example(s):
[this] call COB_fnc_HALO
[this, 2000, true, true, true] call COB_fnc_HALO
*/

Functions

fn_halo.sqf

/*
File: fn_halo.sqf
Version: 2.1

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

Description: HALO jumping (works with AI soldiers). Set the altitude of the HALO, add a chemlight,
auto open your parachute at 150m, and save your backpack with its contents, then attach a backpack
to the front of your unit.

Parameters:
0: UNIT - (object) the unit that will be doing the HALO
1: (optional) ALTITUDE  - (number) the altitude where the HALO will start from
2: (optional) CHEMLIGHT - (boolean) true if the units will use chemlights
3: (optional) AUTOOPEN -(boolean) true to auto open parachute at 150m
4: (optional) SAVELOADOUT - (boolean) true to save backpack and its contents, and add a "fake" backpack to the front of the unit.

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

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

//Validate parameters
if (isNull _unit) exitWith {"Unit parameter must not be objNull. Accepted: OBJECT" call BIS_fnc_error};
if (_altitude < 500) exitWith {"Altitude is too low for HALO. Accepted: 500 and greater." call BIS_fnc_error};

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

//add immersion effects and sound
if (isPlayer _unit) then {
cutText ["", "BLACK FADED",999];
[_unit] spawn {
	private "_unit";
	_unit = _this select 0;

	sleep 2;

	"dynamicBlur" ppEffectEnable true;   
	"dynamicBlur" ppEffectAdjust [6];   
	"dynamicBlur" ppEffectCommit 0;     
	"dynamicBlur" ppEffectAdjust [0.0];  
	"dynamicBlur" ppEffectCommit 5;  

	cutText ["", "BLACK IN", 5];

	private "_heliNear";
	_heliNear = nearestObjects [_unit, ["helicopter"], 50];
	if (count _heliNear == 0) then {playSound "C130_exit"};

	while {animationState _unit != "para_pilot" && alive _unit} do {
		playSound "flapping"; //play flapping sound
		sleep 4.2;
	};
};
};

//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
	if (headgear _unit != "") then {
		_light attachTo [_unit,[-0.07,0.1,0.25],"head"]; //attach light to helmet
		_light setVectorDirAndUp [[0,1,-1],[0,1,0.6]]; //set vector dir and up
	} else {
		_light attachTo [_unit,[0,-0.07,0.06],"LeftShoulder"];
	};

	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
};
};

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

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

[_unit,_class,_magazines,_weapons,_items,_helmet,_altitude] spawn {
	private ["_unit","_class","_magazines","_weapons","_items","_helmet","_altitude"];
	_unit		= _this select 0;
	_class		= _this select 1;
	_magazines	= _this select 2;
	_weapons 	= _this select 3;
	_items 		= _this select 4;
	_helmet		= _this select 5;
	_altitude   = _this select 6;

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

	waitUntil {animationState _unit == "HaloFreeFall_non"};
	_packHolder attachTo [_unit,[-0.12,-0.02,-.74],"pelvis"]; 
	_packHolder setVectorDirAndUp [[0,-1,-0.05],[0,0,-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};
	detach _packHolder;
	deleteVehicle _packHolder; //delete the backpack in front

	_unit addBackpack _class; //return the backpack
	clearAllItemsFromBackpack _unit; //clear all gear from new backpack
	if (_altitude > 3040 && _helmet != "" && _helmet != "H_CrewHelmetHeli_B") then {(unitBackpack _unit) addItemCargoGlobal [_helmet, 1]}; //(not complete) do a check to see if there is available space

	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
};

if (_altitude > 3040 && (headgear _unit) != "H_CrewHelmetHeli_B") then {_unit addHeadgear "H_CrewHelmetHeli_B"};
_unit setPos [(getPos _unit select 0), (getPos _unit select 1), _altitude]; //Set the altitude of the HALO jump

if (!isPlayer _unit) then {
_unit allowDamage FALSE; //god mode :)
_unit switchMove "HaloFreeFall_non"; //place the AI into the free fall animation
_unit disableAI "ANIM"; //disable the AI animation so they cant switch back to standing
};

if (isPlayer _unit) then {
[_unit,_autoOpen] spawn {
	private ["_unit","_autoOpen"];
	_unit 	  = _this select 0;
	_autoOpen = _this select 1;

	if (_autoOpen) then {
		waitUntil {(getPos _unit select 2) < 150 || animationState _unit == "para_pilot" && alive _unit};
		_unit action ["OpenParachute", _unit]; //open parachute if 150m above ground
	};

	waitUntil {animationState _unit == "para_pilot"};

	// 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;

	while {(getPos _unit select 2) > 2} do {
		playSound "para_pilot";
		sleep 4.2;
	};
};
};

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

waitUntil {isTouchingGround _unit || (getPos _unit select 2) < 1 && alive _unit};

if (!isPlayer _unit) then {
	_unit enableAI "ANIM";  //enable the animations
	_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 {	
	// Parachute closing effect for more immersion
	playSound "close_chute";//play chute closing sound
	cutText ["", "BLACK FADED", 999];
	sleep 2;
	cutText ["", "BLACK IN", 2];

	_unit setDamage 0; //heal the unit to 100% in case of injury
};
};

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

//Return Value
_unit;

Change Log

Version 2.1:

  • Fixed: when unit did not have a backpack it would show an error
  • Fixed: Chemlights would attach to the head when the unit had no helmet. It now attaches to the head when wearing a helmet or to the shoulder when not wearing a helmet.
  • Fixed: If you start out with the helicopter crew helmet it will not add another one.
  • Changed: I changed some of the sounds and added new ones.
  • Fixed: If you start out with a parachute and saveloadout selected, it will not add a parachute to the front of the unit.

Version 2.0:

  • Changed: I removed fn_saveLoadOut and just added it directly to fn_halo.
  • Fixed: If you jump out of a helicopter the C130 sound will no longer play.
  • Fixed: when in para_pilot the flapping sound will continue to play until you are approximately 10 meters from the ground, it loops every 7 seconds so if you land just right you wont notice.
  • Added: When you are above 3040 meters or approx. 10,000 feet the helicopter crew helmet is automatically added, its more fitting for a HALO jump, plus your old helmet is added to your backpack automatically so when you land you can pull it out and put it back on.
  • Added: I added a paradrop function to fix the AI.
  • Changed: the example mission no longer has tasks or anything MP related.

Version 1.5:

  • Added: the parachute will now attach to the front of the unit when in animation state para_pilot.
  • Added: sound for when you are in free fall
  • Fixed: using spawn is no longer neccessary. Example: [this] call COB_fnc_HALO
  • Added: more examples to the mission, flagpole and helicopter. Keep in mind that a C130 sound will play when exiting the helicopter, HALO usually doesnt involve helicopters.
  • Changed: the chemlight is now attached to the head.
  • Fixed: AI and players will no longer get hurt, if you do land really hard which should technically hurt you anyways, it will set your damage back to zero. If you hit the ground hard enough it will kill you. AI though are god mode until they get out of their chutes.

Version 1.4:

  • Added: you now have the option to add a backpack to the front of your unit.

Version 1.3:

  • Added: the option to auto open the parachute
  • Added: fn_saveLoadOut.sqf, you can now save your backpack and gear that was in the backpack
  • Added: sound for when landing

Version 1.2:

  • Fixed: _light not defined error

Version 1.1:

  • Removed: Groups
  • Added: Immersion from previous halo.sqs
  • Added: Parachute opening sound - freesound.org

Version 1.0:

  • Released

Download

>>>HALO EXAMPLE Mediafire DOWNLOAD<<<

>>>HALO EXAMPLE Armaholic DOWNLOAD<<<

Addons

There are no required addons, however, ltsThomas made an addon that will add a mask to your HALO unit. Here is what it looks like:

dFWQBWVl.jpg

Here is the download link to Armaholic and his NSW units.

Edited by cobra4v320
  • Like 2

Share this post


Link to post
Share on other sites

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Edited by Foxhound
mirror updated with v1.2

Share this post


Link to post
Share on other sites

Thanks Foxhound, you uploaded after I made some additional changes. Script updated to not include groups anymore, plus added different effects for the parachute opening and landing. Version 1.1 I suppose.

Share this post


Link to post
Share on other sites

Looks like there was an error when not using the chemlight, "_light not defined". I fixed it and will upload a new version shortly. Let me know if you find any errors.

Share this post


Link to post
Share on other sites

Version 1.3

  • Added: the option to auto open the parachute
  • Added: fn_saveLoadOut.sqf, you can now save your backpack and gear that was in the backpack
  • Added: sound for when landing
  • Fixed: removed the check for surfaceiswater, it was removing the parachute and not really needed

[unit, altitude, chemlight, save loadout, auto open ] spawn COB_fnc_HALO

Share this post


Link to post
Share on other sites

Version 1.4 released:

  • Added: the option to add your old backpack to the front of the unit.

yzer.jpg

The idea came from this thread. However, since the latest update you could no longer attach the backpacks. I found a workaround.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Nice script! I have two suggestions though:

- Actions for chemlights while in HALO fall?

- Sound while in HALO fall?

Dirty Haz

Share this post


Link to post
Share on other sites

I would rather use a strobe or the IR Chemlights. The chemlights are optional and disappear once the unit goes into para_pilot mode which is from the animation. A bug maybe?

I was looking into some sounds on freesound.org, I found a flag flapping sound that would work great. I will figure something out tomorrow when Im more awake.

I should also point out that if you land on a roof of any building you will end up on the first floor. This is a bug and I did not see it reported in the feedback tracker. If you land on a roof that has no doors you will be stuck inside.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

is there any way to get this script to enable jumping from a helicopter controlled player in MP?

If yes, how would that work for the backpack stand in front of the character and parachute back?

Share this post


Link to post
Share on other sites

Don't tease me! Did you fix my system? This is fantastic!!! Fingers crossed. Can't

wait to try this out. If this works (in MP), that is just freaking awesome... ;)

update:

A lot different than what I was using. How exactly would you use/install

since you're using functions? Call the sqf's from the init file?

update 2:

:p Never mind. I was too excited and posted in haste. Plus I'm tired! Off to play now!

Edited by Goblin

Share this post


Link to post
Share on other sites

the backpack is a great feature ! you fixed the main problem of any HALO mission

Share this post


Link to post
Share on other sites

Goblin n Cobra, theres a chance to add this "system" in MP whit players start in the ground, whit parachute and the backpack in the front ? And the script only will work when the players jump in Halo of a Helicopter ?

Share this post


Link to post
Share on other sites

Was just going to ask the same thing! How and the heck do you setup so you can start

on the ground? I can't get this working with my Map/System. Need sleep. Will try later...

update:

Fixed! Yeah!!! (Been up for two days; a but punchy)

Edited by Goblin

Share this post


Link to post
Share on other sites
Was just going to ask the same thing! How and the heck do you setup so you can start

on the ground? I can't get this working with my Map/System. Need sleep. Will try later...

I would love it , and having this on respawn too

Edited by HaZZarD

Share this post


Link to post
Share on other sites

I really want to do missions like that for my comunity in Brazil. But, i want start in the ground, whit this equipament, and only make the halo jump when i want from a chopper.

Share this post


Link to post
Share on other sites

Fixed. Got everything working so you can jump from the ground over and over again.

Big thanks to Cobra for the great code. All the basics are there and it WORKS!!! F-Yeah!

I don't want to high-jack his thread since he did all the heavy work. Plus there is a

couple bugs I would need to fix. The Parajump with chute, plus the Backpack with all

its saved contents are good to go. We're back in business. I'll let him address your

questions for now since he deserves all the credit.

Just put the code into an ON ACT (or DEACT) of the Trigger. I'm using a onMapClick

System so you can pick your Drop-Off/Jump Point with different sounds I mixed myself

to simulate the C-130.

Other than the sounds (easy fix), why is it we get hurt everytime we land though?

Odd. Looking forward to playing around with this for the week. Thanks again man!!!!

Share this post


Link to post
Share on other sites

U can pls put the link for that whit a exemple mission ? I really want get work in a mission today, if possible.

Share this post


Link to post
Share on other sites

Goblin please post up your vesion, Im curious. Plus have you tested in MP? I couldnt not fully test this out, please report any bugs. I can also do an sqf version. The backpack attached on the front will only work when you are horizontal, I can figure something out to where it switches vertical also.

Share this post


Link to post
Share on other sites

So, we cant add 2 backpacks yet (front, and back) for simulated long range patrols ?

Share this post


Link to post
Share on other sites

WOU! Verry f**king nice dude. I just want ask u a favor. U can pls make a missions exemplo with players starting in the ground, whit custum loadout. The script will work when player jump in halo from a helicopter. Can do this ? Please ? ;/

Share this post


Link to post
Share on other sites
WOU! Verry f**king nice dude. I just want ask u a favor. U can pls make a missions exemplo with players starting in the ground, whit custum loadout. The script will work when player jump in halo from a helicopter. Can do this ? Please ? ;/

Yeah no problem, I tested the flagpole version, works no problems, helicopter worked also no problems. Im trying to finish up some small stuff first though. I also made it to where the chemlight will remain attached now, same issue when going into para_pilot animation. I also added a flapping sound when in freefall. Release 1.5 out later tonight.

---------- Post added at 20:51 ---------- Previous post was at 20:49 ----------

So, we cant add 2 backpacks yet (front, and back) for simulated long range patrols ?

You can add two backpack front and back, when you have a rifle though it just doesnt look right.

Share this post


Link to post
Share on other sites
Yeah no problem, I tested the flagpole version, works no problems, helicopter worked also no problems. Im trying to finish up some small stuff first though. I also made it to where the chemlight will remain attached now, same issue when going into para_pilot animation. I also added a flapping sound when in freefall. Release 1.5 out later tonight.

---------- Post added at 20:51 ---------- Previous post was at 20:49 ----------

You can add two backpack front and back, when you have a rifle though it just doesnt look right.

yeah yeah, u right, i just want the character have the backpack and the parachute in the ground. And we walk togeter for the helicopter for halo. When u release it, u can pls make the exemple mission for me. When the player start in the ground whit the parachute and the backpack in th ground, and the function activation when we jump for the helicopter ?

I'll aprecieted that so much Cobra.

Share this post


Link to post
Share on other sites

Looking forward to this too. Does this work in MP?

Dirty Haz

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

×