Home   Help Search Login Register  

Author Topic: Ejector seats in cars  (Read 672 times)

0 Members and 1 Guest are viewing this topic.

Nobby

  • Guest
Ejector seats in cars
« on: 23 Oct 2002, 16:42:48 »
I've been trying to fathom the air ejector seat script in snippets section, to change it so that it applies to cars, but I'm not succeeding.
Does anyone know of a way to put an ejector seat into a car and get it to work the way the air ejector seat gets it to work?

Cheers

Nobby

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re:Ejector seats in cars
« Reply #1 on: 23 Oct 2002, 18:06:32 »
hmm, the script is in a bit of an odd format, and I don't have ofp here anyway, so there's no way I can check what the script looks like....hmm, but I did read that it's supposed to work for all vehicles, so maybe it says somewhere in the readme (or equilavent, try the inside of the script, people hide comments there all the time).

Other than that, it shouldn't be too hard. A script, looking something like this should do the job:

Code: [Select]
;this determines the unit triggering the action, and the vehicle of the unit
_ejector=_this select 0
_car= vehicle _ejector

;this gives the ejector an initial height of 5 m above the designated vehicle (change this to whatever you want)
_ejector setpos [(getpos _car select 0), (getpos _car select 1), 5]

;this is a gradual gain in height, going at a speed of 1 m /0.1 seconds (10m/second). change this by chanding the _height variable or by lessening the speed. When reached 100 meters, the parachute opens (change this as you see fit)
#HeightGain
?getpos _ejector select 2>100 : goto "Parachute"
_height=(getpos _ejector select 2) +1
~0.1
_ejector setpos [(getpos _ejector select 0), (getpos _ejector select 1), _height]
goto "HeightGain"

;a parachute is created and the ejector is moved into it
#Parachute
_para="Parachute" CamCreate getpos _ejector
_ejector moveInDriver _para

exit

Well, yes. Now just cut & copy this into a notepad file, name it something like "ejectorseat.sqs" and save it to your mission file, and finally call it in game by a custom action (Player addAction["Eject", "ejectorseat.sqs"]). You might want to remove the action once ejected too (give the action an Id by putting nameOfAction=PLayer addaction... in front), just put a Player removeAction ActionId at the start of the script...

Right, well, heh. That was fun ;) Shout if you need more help.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Nobby

  • Guest
Re:Ejector seats in cars
« Reply #2 on: 23 Oct 2002, 19:09:37 »
I'm not having much luck with this script mate, if I gave you the ejector and vehicle name and didn't care about the speed or height of ejection could you re-write it for me?

The ejectors name is "BOND" and the cars name is "CAR"

Cheers

Nobby

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re:Ejector seats in cars
« Reply #3 on: 23 Oct 2002, 22:33:53 »
Heh, yeah, sorry, I made some fatal mistakes there ;) Now that I've got OFP with me though, I could empirically test my horrible autrocity. In the original, only the car would shoot off  ::) And, the speed was all too slow, which made the whole thing look...awful :P

Any case, here's the new version:

Code: [Select]
;this determines the unit triggering the action, and the vehicle of the unit
_car=_this select 0

;checks who in the crew is the Player
_i=0
_j=count crew _car
#PlayerCheck
?crew _car select _i==Player: _ejector= crew _car select _i ; goto "Start"
~0.1
_i=_i+1
?_j==_i : hint "Error: Player not in vehicle; exit
goto "PlayerCheck"

#Start
;this gives the ejector an initial height of 5 m above the designated vehicle (change this to whatever you want)
_ejector action ["EJECT", _car]
_ejector setpos [(getpos _car select 0), (getpos _car select 1), 5]

;this is a gradual gain in height, going at a speed of 2 m /0.01 seconds (200m/second). change this by chanding the _height variable or by lessening the speed. When reached 100 meters, the parachute opens (change this as you see fit)
#HeightGain
?getpos _ejector select 2>100 : goto "Parachute"
_height=(getpos _ejector select 2) +2
~0.01
_ejector setpos [(getpos _ejector select 0), (getpos _ejector select 1), _height]
goto "HeightGain"

;a parachute is created and the ejector is moved into it
#Parachute
_para="Parachute" CamCreate getpos _ejector
_ejector moveInDriver _para

exit

Right, so, my suggestion on how to work this:
Make your car, name it...whatever, CAR for instance. Then, make a trigger, a/b=0, Repeatedly, type: Switch.

Condition: Player in CAR
on Activation: ActionID=CAR addAction ["Ejector Seat", "ejectseat.sqs"]
on Deactivation: CAR removeAction ActionID

Now, whenever you enter the car, the action will be added TO THE CAR (and thus accessable by you). And, when you leave the car, it's removed (so you can't start whoosing off outside of it....). Easy peasy. Now, this is tested, so it damned well should work! I even made it so that only the player gets ejected (i.e, you can have other passangers but they won't go anywhere). All in all a workable script, I think.

If you still find some bugs I somehow missed, please complain ;)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Nobby

  • Guest
Re:Ejector seats in cars
« Reply #4 on: 23 Oct 2002, 23:51:47 »
Works like a charm mate!

Cheers

Nobby