Home   Help Search Login Register  

Author Topic: Eject from helicopter  (Read 2630 times)

0 Members and 1 Guest are viewing this topic.

Offline snozzdog

  • Members
  • *
Eject from helicopter
« 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

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Eject from helicopter
« Reply #1 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.
« Last Edit: 12 Oct 2008, 22:58:24 by Wolfrug »
"When 900 years YOU reach, look as good you will not!"

Offline snozzdog

  • Members
  • *
Re: Eject from helicopter
« Reply #2 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.
« Last Edit: 11 Oct 2008, 19:47:09 by snozzdog »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Eject from helicopter
« Reply #3 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.
"When 900 years YOU reach, look as good you will not!"

Offline egwal

  • Members
  • *
Re: Eject from helicopter
« Reply #4 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.
« Last Edit: 12 Oct 2008, 14:18:09 by bedges »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Eject from helicopter
« Reply #5 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.
"When 900 years YOU reach, look as good you will not!"

Offline Crowey

  • Members
  • *
Re: Eject from helicopter
« Reply #6 on: 22 Dec 2008, 12:19:42 »
Do the names in the top line only need to be changed?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Eject from helicopter
« Reply #7 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.
"When 900 years YOU reach, look as good you will not!"

Offline Ext3rmin4tor

  • Members
  • *
Re: Eject from helicopter
« Reply #8 on: 22 Dec 2008, 19:07:19 »
What about learning some basic things about scripting before using scripts?
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Eject from helicopter
« Reply #9 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. :)
Xbox Rocks

Offline Crowey

  • Members
  • *
Re: Eject from helicopter
« Reply #10 on: 22 Dec 2008, 22:06:02 »
I am trying to learn isnt actually using scripts the best way? otherwise why have these forums?

Offline Ext3rmin4tor

  • Members
  • *
Re: Eject from helicopter
« Reply #11 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
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Eject from helicopter
« Reply #12 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.