Jump to content
Sign in to follow this  
2ndBattalionBard

Car crashing into bus

Recommended Posts

Rounding the corner at 80 miles per hour, the sports car barrels down the city street narrowly missing bystandards and traffic. Suddenly, a loaded bus pulls out in front of him and WHAM! Smoke and debris flying in every direction, the car flipping end over end, the bus rolls over....

This is the kind of scene I was hoping to make, and its what I get when I'm the driver. However, when I leave it up to a computer driver in order to operate a camera (I just set a waypoint through the bus and set speed for full, which I know isn't enough) he successfully bypasses the bus, or at least slows down enough to keep anything from happening outside of a few blown tires. How can I make the driver take his own personal safety out of the equation so he'll fly into the bus and make the awsome crash sequence I'm looking for?

Share this post


Link to post
Share on other sites

Didnt test it but it should work, execute it when you are sure the car is, at least, heading to the bus, even being far away.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;crash.sqs

_car = _this select 0

_bus = _this select 1

_speedms = (speed _car) / 3.6

#check

_posc = getPos _car

_posb = getPos _bus

_dir = ((_posb select 0)-(_posc select 0)) atan2 ((_posb select 1)-(_posc select 1))

_car setDir _dir

_car setVelocity [sin(_dir)*_speedms,cos(_dir)*_speedms, -1]

~0.005

?(_car distance _bus > 1): goto "check"

Share this post


Link to post
Share on other sites
Didnt test it but it should work, execute it when you are sure the car is, at least, heading to the bus, even being far away.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;crash.sqs

_car = _this select 0

_bus = _this select 1

_speedms = (speed _car) / 3.6

#check

_posc = getPos _car

_posb = getPos _bus

_dir = ((_posb select 0)-(_posc select 0)) atan2 ((_posb select 1)-(_posc select 1))

_car setDir _dir

_car setVelocity [sin(_dir)*_speedms,cos(_dir)*_speedms, -1]

~0.005

?(_car distance _bus > 1): goto "check"

Sooo... is this a trigger or.... what should I put this into?

Share this post


Link to post
Share on other sites

A scrip, an sqs file. You may execute it from a trigger if you wish: [carname, busname]exec"crash.sqs"

Share this post


Link to post
Share on other sites

Is there any way to pimort that script without having to remember the whole thing? I'm still pretty new to this, and I tried writing it all down, but it still didn't work. The other trigger script didn't work either.

I need HELP!!

Share this post


Link to post
Share on other sites

smile_o.gif Why are you writing it down?

Just copy and paste from this page

into a new text document.Calling it

"crash.sqs".Then stuff it in yer mission

folder.

Just so you know,you can copy and

paste in the mission editor too.

Just highlight what you want,hit CTRL+C,

then paste it where you need it using CTRL+V.

Saves you a lot of typing in triggers and init fields.

Share this post


Link to post
Share on other sites
smile_o.gif Why are you writing it down?

Just copy and paste from this page

into a new text document.Calling it

"crash.sqs".Then stuff it in yer mission

folder.

Just so you know,you can copy and

paste in the mission editor too.

Just highlight what you want,hit CTRL+C,

then paste it where you need it using CTRL+V.

Saves you a lot of typing in triggers and init fields.

Thank you verrrry much, I'm so used to the two-click copy and paste...

EDIT: Ok, I put the whole thing in, but when I finish it says "Unknown Operator"... what am I doing wrong now?

Share this post


Link to post
Share on other sites

Ok, now I'm confused again... do I put both the script and the [car, bus]exec "crash.sqs" thing into the initialization bar of the car, the bus, or in a trigger?

Share this post


Link to post
Share on other sites

Once you save your mission , go into your user mission folder located in your OFP install

Here :

...\Codemasters\Operation Flashpoint\Users\YourOwnUserName\missions\

Find your mission name folder, and enter into it (as an example, if you named a mission " testmission" and it was on desert island, the folder name you seek would be testmission.intro ).

There once you are inside your "MissionName" folder, you can see the mission.sqm file.

Next to your mission.sqm, create a new text file (right click -> new -> text document) , open it with notepad/wordpad and copy paste :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;crash.sqs

_car = _this select 0

_bus = _this select 1

_speedms = (speed _car) / 3.6

#check

_posc = getPos _car

_posb = getPos _bus

_dir = ((_posb select 0)-(_posc select 0)) atan2 ((_posb select 1)-(_posc select 1))

_car setDir _dir

_car setVelocity [sin(_dir)*_speedms,cos(_dir)*_speedms, -1]

~0.005

?(_car distance _bus > 1): goto "check"

Close the text file and save the changes.

Now rename your text file from WhateverNameItis.txt to crash.sqs

Ingame, put in the initialisation line of a trigger or an unit, it depends on your mission

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[yourcarname, yourbusname] exec "crash.sqs"

With yourbusname being the name you gave to the bus, and yourcarname being the name of the car.

Share this post


Link to post
Share on other sites

Ok, apparently the script is at lest having some effect, because now the car is getting its wheels stuck in the ground...

Share this post


Link to post
Share on other sites

You should execute the script once the car is already running fast, as the script will keep its speed constant. If you execute the script with the car stopped, it will remain stopped.

To test it, put your bus in a rect long segment of a road moving in one direction, put your car in the same segment moving to the opposite direction and with a collision course. Now execute the script from a trigger and write: (carname distance busname) < 50 in your condition field. You may adjust that distance to tune up the results.

Share this post


Link to post
Share on other sites

The trigger is now working, but there seems to be something wrong with the trigger. Though the car is hitting the bus without stopping, it still sinks into the ground when the trigger activates, so it just sort of slides under the bus and explodes, which isn't the effect I want. I find it odd that something so simple is so difficult to do...

Share this post


Link to post
Share on other sites

You could also try something simple... like setvelocity. But I don't know if it fits in to your mission.

(your bus or car name) setvelocity [x,y,z]

Example:

BUS1 setvelocity [120,0,0]

Place a fewe triggers with the above in the INIT... So that the car keeps it speed and doesnt slow down...

This also works for empty cars.

Hope this helps smile_o.gif

Share this post


Link to post
Share on other sites

Ok, well if this helps, the scene goes like this:

The car is going down the street very fast and hits a bus that pulls out in front of it (this part is done from the driver's prespective, so I control this crash). The the camera goes to the other side of the bus (the left side, the car hits the right side) and shows the resulting destruction from that angle while the pursuing cars swerve around the wreck.

Share this post


Link to post
Share on other sites

If you want to get the car up off the ground make a trigger or change the script to do it close to where the impact occurs

such as;

in trigger;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

Condition: _car distance _bus < 1

Activation: _car setpos [(getpos this select 1),(getpos this select 2),1]

1 will set the car to approx 1m off ground

or maybe try this in the script(at the end)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;crash.sqs

_car = _this select 0

_bus = _this select 1

_speedms = (speed _car) / 3.6

#check

_posc = getPos _car

_posb = getPos _bus

_dir = ((_posb select 0)-(_posc select 0)) atan2 ((_posb select 1)-(_posc select 1))

_car setDir _dir

_car setVelocity [sin(_dir)*_speedms,cos(_dir)*_speedms, -1]

~0.005

?(_car distance _bus > 1): goto "check"

Exit

This should cause the script to stop if the car is close to the bus (less than 1m), and i doubt that the car will have time to stop or swerve. You can adjust the distances to make sure your crash works.

BTW gravity as we know it doesn't seem to apply in OFP

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;crash.sqs

_car = _this select 0

_bus = _this select 1

_speedms = (speed _car) / 3.6

#check

_posc = getPos _car

_posb = getPos _bus

_dir = ((_posb select 0)-(_posc select 0)) atan2 ((_posb select 1)-(_posc select 1))

_car setDir _dir

_car setVelocity [sin(_dir)*_speedms,cos(_dir)*_speedms, -1]

~0.005

?(_car distance _bus > 1): goto "check"

Exit

Should I just copy and paste that into teh same mission folder?

Share this post


Link to post
Share on other sites

yes replace the crash.sqs file in your mission folder with the new version

From the problem you were expressing it seemed that the script file never ended(hence the Exit command I added) also the script sets the cars height to -1, I suppose that is what was making it "sink" when it crashes and also increasing its speed by "sticking" to the ground.

There are many ways to make the car flip up or raise up upon impact.A lot of this depends on what you want to do with camera.

Creating an artificial explosion on impact could add to the drama of the scene.

Share this post


Link to post
Share on other sites

*EDIT

looks like Fellini just beat me to it. biggrin_o.gif

No point in me reposting the same info.

I'll have to pay more attention.

Macser smile_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×