OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: OFPfreak on 25 Jun 2005, 06:39:14

Title: setvelocity? anything else?
Post by: OFPfreak on 25 Jun 2005, 06:39:14
Instead of setvelocity, is there any other way of boosting a vehicle? e.g. some addons have NITRO :o!!!!!!
Title: Re:setvelocity? anything else?
Post by: bedges on 25 Jun 2005, 08:06:28
i don't think there are.  addons have the benefit of being able to alter the properties of the vehicle in question, and so a nitro script could be incorporated, which probably uses setvelocity itself.
Title: Re:setvelocity? anything else?
Post by: General Barron on 25 Jun 2005, 08:51:04
There is also the setpos command, although this only changes the position of the vehicle, not it's velocity.

I'm not sure what other ways you would want to 'boost' a vehicle. Perhaps you mean rotation? Not possible unfortunately, but you can 'fake' it with the 'setdir' command (only along 1 axis though).

Perhaps more explaination of what you are trying to do would help?
Title: Re:setvelocity? anything else?
Post by: OFPfreak on 25 Jun 2005, 09:01:34
I have a mustang pack with a boost action and a nitro action.
Both have the same effect. If I keep accelerating, it goes 700kph.
If I brake its goes 100kph.
I want my car to go faster above its top speed. Thats what I mean with boost. But I dont want it to jump from 100kph to 300kph in 1 second.
Title: Re:setvelocity? anything else?
Post by: General Barron on 25 Jun 2005, 09:05:26
Okay, you should use a loop then, which increases the car's velocity by just a little bit each time, so it looks like a smooth acceleration:

Code: [Select]
#accel
_inc = 1
_car setvelocity [(velocity _car select 0) + _inc*cos getdir _car, (velocity _car select 1) + _inc*sin getdir _car, velocity _car select 2]
? speed _car < 300 && alive _car : goto "accel"
Just change _inc to a higher number and the car will accel faster.
Title: Re:setvelocity? anything else?
Post by: Fragorl on 25 Jun 2005, 09:07:18
Just a thought- shouldnt your sin and cosine be the other way around?

EDIT: and the increment needs to be incremented
Title: Re:setvelocity? anything else?
Post by: OFPfreak on 25 Jun 2005, 09:11:55
Cool thanks barron dude! Heres what I got to prevent the nitrous from being for ever:

Code: [Select]
#accel
_inc = 1
_amount = 0
_car setvelocity [(velocity _car select 0) + _inc*cos getdir _car, (velocity _car select 1) + _inc*sin getdir _car, velocity _car select 2]
_amount=_amount+1
_amount>20 : goto "exit"
? speed _car < 300 && alive _car : goto "accel"

#exit
Title: Re:setvelocity? anything else?
Post by: General Barron on 25 Jun 2005, 09:12:33
Why yes, they should be.  :o

You'll have to forgive me, for I just got back from a week-long vacation in sunny Oahu. My brain is a bit scrambled from all the sun and half-naked women.
Title: Re:setvelocity? anything else?
Post by: OFPfreak on 25 Jun 2005, 09:12:43
hm wait thats actually not needed since the script stops after 300kph...
Title: Re:setvelocity? anything else?
Post by: Fragorl on 25 Jun 2005, 09:14:01
I could do with some brain scrambling like that :D

And it looks like OFPFreak has taken care of the increment
Title: Re:setvelocity? anything else?
Post by: OFPfreak on 25 Jun 2005, 09:19:51
nope sorry ;(!
My car is being boosted nort-east into the air already at huge speed.
:P I added a ~0.5 but my car is still traveling north-east :(!
Title: Re:setvelocity? anything else?
Post by: General Barron on 25 Jun 2005, 09:35:28
Yup, I forgot to add a delay in there. I'd suggest a ~0.1 to make it nice and smooth. Be sure to switch the sine and cosine like Fragorl said, or else the boost will go in the wrong direction.

And there should be no need to increment _inc, since it just adds a fixed amount to the cars speed each loop, making a smooth (linear) accelleration. If you want it to accel faster and faster, then increment it.

Ugh... me brain fried. Me sleep now.
Title: Re:setvelocity? anything else?
Post by: OFPfreak on 25 Jun 2005, 09:39:01
aw don't sleep ;D!
Hopefully it works! HOPEFULLY!!!!!
Title: Re:setvelocity? anything else?
Post by: OFPfreak on 25 Jun 2005, 09:42:38
It works! Heres what I got:

Code: [Select]
#accel
_inc = 1
_amountleft = 0
car1 setvelocity [(velocity car1 select 0) + _inc*sin getdir car1, (velocity car1 select 1) + _inc*cos getdir car1, velocity car1 select 2]
~0.25
_amountleft > 40 : goto "exit"
? speed car1 < 300 && alive car1 : goto "accel"

#exit

exit