Home   Help Search Login Register  

Author Topic: Force eject from damaged plane  (Read 841 times)

0 Members and 2 Guests are viewing this topic.

Skaircro

  • Guest
Force eject from damaged plane
« on: 03 Feb 2003, 16:39:11 »
I'm working on a script to force eject a pilot and gunner from a plane when it is too damaged.
This is basically what I have so far.


_plane = _this select 0
_player = player

#EjectLoop
?(_player in _plane and damage _plane >=0.9): goto "Eject"
goto "EjectLoop"

#Eject
_plane setdamage 0.8
driver _plane setcaptive true
gunner _plane setcaptive true
~0.5

driver _plane action ["eject", vehicle driver _plane]
gunner _plane action ["eject", vehicle gunner _plane]
? setcaptive false
? setcaptive false

exit


It all works ok, but I need to know what to call the pilot and gunner after they have ejected, as they are no longer considered "driver _plane" or "gunner _plane".
(I'm using the setcaptive to stop AI (shilkas etc) from firing at it before there is a chance to eject.)

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Force eject from damaged plane
« Reply #1 on: 03 Feb 2003, 17:46:00 »
You can name the pilot and gunner with either global or local variables.  If you want to use global variables, then in the aircraft's initialization field, put the following code:

pilot1 = driver MyPlane; gunner1 = gunner MyPlane

Replace MyPlane with the name you assigned to the aircraft.

If you'd rather use a local variable, then in your script, put the following code anywhere *before* you force the units to eject:

_pilot1 = driver _plane
_gunner1 = gunner _plane


Easy, huh?  :D

As a note, I have not been successfully able to force a client-player to eject in a multiplayer mission by using a script.  So, if your mission will be multiplayer-capable, your script might not work properly.
« Last Edit: 03 Feb 2003, 17:50:44 by Ranger »
Ranger

Skaircro

  • Guest
Re:Force eject from damaged plane
« Reply #2 on: 04 Feb 2003, 18:04:36 »
Hey thanks for that, I was hoping to avoid having to name the plane or use init fields so I tried your local variable option and it seems to work fine.

The script isnt actually for a mission, its for a plane addon I'm making.
I thought I would incorporate an eject script for a bit of fun.  ;D
Since a human player is always considered dead when the plane gets to a certain amount of damage, but the ai survives and is able to eject, I didnt think this was very fair.

Hopefully it will be a bit of fun for single and multiplayer levels. (If it does work multiplayer).
I tested with 2 planes, me + ai gunner in one & ai pilot + ai gunner in another and it worked fine, so hopefully it will work multiplayer.

Thanks again!  ;)