Home   Help Search Login Register  

Author Topic: [SOLVED]Vehicle, slow to stop?  (Read 1473 times)

0 Members and 1 Guest are viewing this topic.

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
[SOLVED]Vehicle, slow to stop?
« on: 15 Feb 2012, 21:42:10 »
Is there a way to get a car to slowly come to a stop, say over 10 seconds, through a script? (How long it takes doesn't matter).

THANKS!

- Mad Pup
« Last Edit: 11 Mar 2012, 04:35:17 by Mad Pup »
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: Vehicle, slow to stop?
« Reply #1 on: 24 Feb 2012, 00:26:45 »
You could do it with a script using the setVelocity command. I made a function called "setSpeed.sqf" that simplifies the scripting for manipulating vehicle speeds. I will make a demo for you once I have access to my computer (later this evening). I do need to know, do you want the parameters to be based on the deceleration rate, the distance traveled or a position? For example, do you want the vehicle to come to a stop just as it reaches another object or unit, or do you just want it to slow at a given rate or do you want it to cover a certain distance before it stops?
« Last Edit: 24 Feb 2012, 02:36:23 by Raptorsaurus »

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Re: Vehicle, slow to stop?
« Reply #2 on: 25 Feb 2012, 16:00:06 »
Basically, you're chasing the car. And if you come within say 10 feets of the back of the car, it will cause the car to slow down, slowly to  a stop.... I'm currently using

Code: [Select]
car1 setfuel 0.0
car2 setfuel 0.0

car1 being the car you're chasing.
car2 being you're car.

but that's kind of unrealistic. Just stoping....

Again, thanks for all the responses!

-Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

STiT/LK

  • Guest
Re: Vehicle, slow to stop?
« Reply #3 on: 25 Feb 2012, 21:10:35 »
Try with this script. When you're within a given distance (5 meters, but you can modifiy according to your needs) the vehicle will slow down and then completely stop.  :)

To execute it, put this in some init field: [car1,car2] exec "slowDown.sqs" and play as car2.

slowDown.sqs
Code: [Select]
_veh = _this select 0
_cha = _this select 1

_veh setSpeedMode "FULL"
_veh setBehaviour "DANGER"
_veh lock true

#chase
@(_cha distance _veh) < 5
goto "stop"

#stop
_veh setSpeedMode "LIMITED"
~1.5+random(0.5)
_veh action ["ENGINE OFF"]
~1.5+random(0.2)
?isEngineOn _veh : _veh action ["ENGINE OFF"]
_veh stop true
exit

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: Vehicle, slow to stop?
« Reply #4 on: 29 Feb 2012, 19:40:27 »
You could try this:

Script named "stopCar.sqs"

Code: [Select]
_car1 = _this select 0
_car2 = _this select 1
_dis = _this select 2

@ _car1 distance _car2 < _dis || {canMove _x} count [_car1, _car2] < 2 || ! isEngineOn _car1
;the script waits until one of the above conditions is true

? {canMove _x} count [_car1, _car2] < 2 || ! isEngineOn _car1 : exit
;if _car1 turns off his engine (like being out of fuel or engine is damaged) or either car is damaged to the point of not being able to move there is no point in the script continuing

_car1 lockWP true
;this locks the current waypoint of the car being chased (he will not resume following waypoints until the command "_car1 lockWP false" is used.

_car1 move getPos _car1
;this makes the car stop because he is already at his present location

@ speed _car1 < .1
;script waits until _car1 slows to almost a complete stop

_car1 setFuel 0
;sets the fuel of _car1 to zero so he cannot drive away

exit

Call this script using something like:
Code: [Select]
[badcar, policeCar, 10] exec "stopCar.sqs"
You would be the in the policeCar and the other car would be the one you are chasing (the badcar), but use whatever names you want for the two cars. The distance for the car to stop is 10, but you can change this also.
« Last Edit: 29 Feb 2012, 19:42:48 by Raptorsaurus »

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Re: Vehicle, slow to stop?
« Reply #5 on: 01 Mar 2012, 01:07:31 »
Looks good Raptorsaurus. I'll test both the scripts out tonight!!! I'll let you both know how it goes! I might even let you guys beta test the mission!  :blink:
 ;)

-Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad