OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: eegore on 07 Sep 2009, 09:14:41

Title: Blown out of a vehicle script.
Post by: eegore on 07 Sep 2009, 09:14:41

  I've been looking for but can't find a thread that had a script where an explosion blacks out the screen and ejects the player from the vehicle. 

  I've tried making my own but I have terrible scripting skills, I can barely make the camera focus on where the player is teleported to a game logic.  Does anyone know of a script similar to this? 

  All I need is the screen to go blank, and the player ends up outside, but near a ural. 

  Thanks
Title: Re: Blown out of a vehicle script.
Post by: bedges on 07 Sep 2009, 14:28:40
The first thing to decide is how to detect damage done to the vehicle. If it's destroyed, chances are the player is too. If it's hit by small-arms fire, chances are the player won't need to bail. Thus a hit event handler might involve too much detection of the type of 'hit' to be practical.

The next option is a slowly looping script which detects whether the vehicle canMove. If it can't, the damage is sufficient to force the player to abandon the vehicle even if it's not destroyed.

So. Call using vehicle_name exec "check_vehicle.sqs"

Code: (check_vehicle.sqs) [Select]
; variable passed to script
   _vehicle = _this

; slow loop
   #loop
   ~5
   ? (canMove _vehicle) : goto "loop"

; vehicle is sufficiently damaged

; black out
   cuttext[" ", "black out", 2]
   ~3

; all black, stop the vehicle momentum (to prevent player dying on eject)
   _vehicle setvelocity [0,0,0]

; get the player out
   unassignvehicle player
   player action["eject", _vehicle]

; black in again
   cuttext[" ", "black in", 3]

; all done
   exit


Naturally the script is only of any use when the player is actually in the vehicle calling the script. That should be enough to get you on the right track though.
Title: Re: Blown out of a vehicle script.
Post by: eegore on 07 Sep 2009, 16:37:39

  Thanks for that info.  I'll play with it. 

  I guess the script will be set off by a location trigger.  The plan is that 3 urals are driving on a road with the player in the last.  When the lead vehicle gets hit (dofire trigger) the script goes off making the screen go blank, and the player appears outside the vehicle at a Game Logic just off the road. 

  Now is there a way to make the player lay down?  Then regain control so they can stand up and get a weapon?
Title: Re: Blown out of a vehicle script.
Post by: bedges on 07 Sep 2009, 19:59:28
See attached.
Title: Re: Blown out of a vehicle script.
Post by: eegore on 08 Sep 2009, 15:24:13

  Thanks for the sample mission.  With just a few tweaks on the script I got exactly what I wanted. 

  I've never used getposmarker before.  Much easier than the GL teleportation.

  Nothing beats a good sample mission, I'll have to stop talking bad about you when you aren't around Bedges. 
Title: Re: Blown out of a vehicle script.
Post by: savedbygrace on 20 Sep 2009, 06:29:40
Don't do that. He wouldn 't feel loved if we didn't talk about him.