OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: snozzdog on 11 Oct 2008, 13:58:47

Title: Eject from helicopter
Post by: snozzdog on 11 Oct 2008, 13:58:47
Does anyone now how i can make a group eject from a helicopter over a target?

Like if i had a group board a helicopter, then the helicopter fly to a certain point, then go through a waypoint that makes the squad eject but leaves the crew inside to fly off?


Cheers
Title: Re: Eject from helicopter
Post by: Wolfrug on 11 Oct 2008, 16:04:54
You'll need an ejection script for that, of which there are legion available everywhere. But to ease your passing, here's one I've written earlier (that works) and does all you need (copy script into a .txt file, name it e.g. parajump.sqf, and then call it from in-game, for instance a waypoint's On Activation field):

Code: [Select]
//Parajump script by Wolfrug @ OFPEC.com. Called: nul = [groupName, vehicleName] execVM "parajump.sqf"

_group = _this;
_veh = vehicle (leader _group);

_veh flyInHeight 200;
_veh forcespeed 50;

//Grab everyone but gunner/driver/commander
_ejectables = [];

for "_i" from 0 to ((count units _group) - 1) do
{
private ["_curUnit"];
_curUnit = (units _group) select _i;
if (_curUnit !=driver _veh && _curUnit !=gunner _Veh && _curUnit !=commander _veh) then
{
_ejectables = _ejectables + [_curUnit];
};
};

// Eject units one by one.

for "_i" from 0 to ((count _ejectables) - 1) do
{
private ["_curUnit"];
_curUnit = _ejectables select _i;
_veh flyinheight 200;
if ((position _veh select 2) < 150) then {waitUntil {position _veh select 2 > 150}};
unAssignVehicle _curUnit;
_curUnit action ["eject", _veh];
sleep 0.8;
};

//Script done!

Some particularities: it won't eject anyone unless the chopper is higher than 150 meters in the air - otherwise the parachutees will often get killed. There's also a small delay between jumps, to make sure they don't hit each other. The beginning of the script also obliges the chopper to fly at 200 meters height and, hopefully, limit its speed to 50 (although that doesn't really work). Anyway, should work just fine!

Wolfrug out.
Title: Re: Eject from helicopter
Post by: snozzdog on 11 Oct 2008, 19:36:28
Ahh mate it didnt work, when i saved the text file as parajump.sqm it stayed as a text file just called 'parajump.sqm' and couldnt locate to script even though i put it in the correct mission folder.
Title: Re: Eject from helicopter
Post by: Wolfrug on 11 Oct 2008, 22:40:30
Quoting myself:

"copy script into a .txt file, name it e.g. parajump.sqf"

/quote

.sqf is the proper ending for an ArmA script file. .sqm is the shortcut for an ArmA/OFP mission file; although in -principle- I suppose if you called the script with execvm "parajump.sqm" it could work, but...yeah. Please don't do that ;) Just rename the file parajump.sqf.

Did you also name the helicopter and the group something? To name a group just put 'groupName = group this' (without the quotes) into any group member's initialization (NOT description!) field.

I know it works, so it's just up to you to call it correctly :) Good luck!

Wolfrug out.
Title: Re: Eject from helicopter
Post by: egwal on 12 Oct 2008, 14:14:56
Now im still pretty bad at all this scripting stuff but it didnt work for me either. Says theres an error at line 4. And again i fought with it for a while until i added VM to "nul = [groupName, vehicleName] exec "parajump.sqf"" Because for at least me arma wont even accept the nul = [groupName, vehicleName] exec "parajump.sqf" that you have in the sqf.
Title: Re: Eject from helicopter
Post by: Wolfrug on 12 Oct 2008, 22:59:25
>_>

That's embaressing. Yes: of course, you need to use execVM to run this script, not exec, obviously. Eech.

Changed the script header in the code batch  :whistle:

Wolfrug out.
Title: Re: Eject from helicopter
Post by: Crowey on 22 Dec 2008, 12:19:42
Do the names in the top line only need to be changed?
Title: Re: Eject from helicopter
Post by: Wolfrug on 22 Dec 2008, 12:48:51
Hi there!

No names need to be changed, you can call the script from e.g. a trigger or a waypoint's on activation field, by putting in:

Code: [Select]
nul = [nameOfGroup, nameOfVehicle] execvm "parajump.sqf"
You can give a group a name by using
Code: [Select]
nameOfGroup = group this in any group member's init field (just change nameOfGroup to whatever you want). You name the vehicle normally in the 'name' field. :)

Wolfrug out.
Title: Re: Eject from helicopter
Post by: Ext3rmin4tor on 22 Dec 2008, 19:07:19
What about learning some basic things about scripting before using scripts?
Title: Re: Eject from helicopter
Post by: hoz on 22 Dec 2008, 19:43:11
Ext3rmin4tor everyone learns in their own way at their own pace. OFPEC is here to help people at all sorts of levels of experience.

@Wolf there isn't a ArmA example in the ED perhaps you could package that puppy up. :)
Title: Re: Eject from helicopter
Post by: Crowey on 22 Dec 2008, 22:06:02
I am trying to learn isnt actually using scripts the best way? otherwise why have these forums?
Title: Re: Eject from helicopter
Post by: Ext3rmin4tor on 23 Dec 2008, 10:54:38
It was just an opinion. Imo using scripts isn't the best way to learn, and this is generally true for everything concerning computer programming. You should read tutorials, try making your own scripts (first start with easy things, then go for more difficult stuff), I've learnt doing that, and I still have much to learn. If you start using difficult scripts without understanding them you learn nothing. But this is just my opinion. I wasn't going to flame you in any way, it was just a suggestion. This forum exists (for me, but I might mistake) to help people with problems concerning ArmA programming. Sorry for the OT, if you want we can continue with PMs
Title: Re: Eject from helicopter
Post by: Mandoble on 23 Dec 2008, 12:20:18
It was just an opinion. Imo using scripts isn't the best way to learn, and this is generally true for everything concerning computer programming. You should read tutorials, try making your own scripts (first start with easy things, then go for more difficult stuff)

OT, but fully agree with that.