SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 29/07/2012, 05:54 PM   #1
Sinner
Gangsta
 
Sinner's Avatar
 
Join Date: Aug 2010
Location: On This Mortal Coil
Posts: 815
Reputation: 292
Default The "Real" vehicle speed thread

There's been a lot of discussion about what the actual max. speed should be when it comes to SA-MP vehicles. This thread discusses this.

I think, though, I have found the most accurate max. speed possible. As we know, the max. speed of any vehicle can be calculated using the following formula (KM/H):

Code:
// vX = X velocity of the vehicle
// vY = Y velocity of the vehicle
// vZ = Z velocity of the vehicle

STEP1 = vX + vY + vZ (Law of Pythagoras)
STEP2 = SQUARE ROOT of STEP 1
STEP3 = STEP2 * magic number

"the magic number" Is the number everyone has been looking for. Some people have proven that around 180.0 should give a fairly accurate result (which makes the max. speed of the Infernus, the fastest vehicle in the game, around 223 KM/H). We will now try to prove this correct.

Fact: Most of the cars in SA-MP are derived from real life vehicles. The Turismo is clearly a Ferrari F40 so we will use this as the base for our calculations.

Ferrari F40:


Turismo:


The max. speed of a Ferrari F40 is equal to 324 KM/H. (Source: http://en.wikipedia.org/wiki/Ferrari_F40)

Running the following code in a very fast loop, we can determine what the highest possible velocity is when a Turismo in SA-MP reaches his max. speed. This was done on a straight road and without nitrous.

Code:
// vid = current vehicle we are in
// Model 451 = Turismo
if(GetVehicleModel(vid) == 451) {
	new 
		Float:speed_x,
		Float:speed_y,
		Float:speed_z
	;
	GetVehicleVelocity(vid,speed_x,speed_y,speed_z);
	printf("[Velocity] X=%f, Y=%f, Z=%f", speed_x, speed_y, speed_z);
}

We get the following result (these will vary ofcourse, but the calculations will always have the same result):

Code:
X = 1.072348
Y = 0.008095
Z = 0.000000

We can than calculate the magic number when the final speed equals 324:

Code:
X = 1.072348 * 1.072348 = 1.149930233104
Y = 0.008095 * 0.008095 = 0.000065529025
Z = 0.000000 * 0.000000 = 0.000000000000

SQUARE ROOT (1.149930233104 + 0.000065529025 + 0.000000000000) = 1.0723785535569983

324 = 1.0723785535569983 * mN

mN = [B]302.13[/B]





So the "magic number" is equal to 302.13 (see test above), this though makes the top speed of the other vehicles out of proportion... A bus suddenly goes over 250KM/H!! I guess this issue is unsolvable and we need to search for an acceptable number somewhere in the middle.
__________________
Please use the search feature before asking a question.
Sinner is offline   Reply With Quote
Old 29/07/2012, 08:13 PM   #2
Arca
Big Clucker
 
Arca's Avatar
 
Join Date: Jul 2012
Location: Plano, Texas, United States
Posts: 173
Reputation: 33
Default Re: The "Real" vehicle speed thread

Well I use 250.666667 for kmph and 199,4166672 for mph as the magic number but there are even more calculation needed to get the most of the accuracy. My formula is the same as yours and for everyone else. From where did you get this number 180.0?
__________________

Code:
Arca is offline   Reply With Quote
Old 30/07/2012, 07:31 AM   #3
Sinner
Gangsta
 
Sinner's Avatar
 
Join Date: Aug 2010
Location: On This Mortal Coil
Posts: 815
Reputation: 292
Default Re: The "Real" vehicle speed thread

Quote:
Originally Posted by Arca View Post
Well I use 250.666667 for kmph and 199,4166672 for mph as the magic number but there are even more calculation needed to get the most of the accuracy. My formula is the same as yours and for everyone else. From where did you get this number 180.0?
Top speeds seemed to make sense somehow when I used 180.0
__________________
Please use the search feature before asking a question.
Sinner is offline   Reply With Quote
Old 30/07/2012, 09:34 AM   #4
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,130
Reputation: 1556
Default Re: The "Real" vehicle speed thread

The unit of the coordinates is known as meters, so for the best matching GTA properties you can just compare the travelled distance to the velocity. Most accurate on a straight and plane are.
Mauzen is offline   Reply With Quote
Old 30/07/2012, 12:06 PM   #5
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,996
Reputation: 2647
Default Re: The "Real" vehicle speed thread

The max speed of every vehicle is listed in the handling.cfg data file. The Infernus is listed as the fastest vehicle with a top speed of 240 Km/h. To achieve this, I multiply with 195.12. It doesn't work for every vehicle though. There must be another factor involved. Some roads seem to affect speed as well. Try getting to top speed on The Strip; it just doesn't work.

Code:
; > UNITS <
; ---------
; vehicle identifier 14 characters max
; dimensions in metres
; mass in Kg
; velocity in Km/h
; acceleration/deceleration in ms-2
; multipliers x1.0 is default
; angles in degrees
; Levels :- (L)ow, (M)edium, (H)igh
; buoyancy = percent submerged (> 100% vehicle sinks)
; engine type :- (P)etrol, (D)iesel, (E)lectric
; engine drive :- (F)ront, (R)ear, (4)-wheel drive
__________________
Vince is offline   Reply With Quote
Old 04/08/2012, 05:46 PM   #6
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,888
Reputation: 1443
Default Re: The "Real" vehicle speed thread

Ooh I was going to open a topic like this!

Just the other day I was testing this, I even scripted a never-ending-road to test it on!

First I found the number to convert it to meters per second, by using the old method (Get the position each second, compare the distance) then got the right "magic number" to get the GetVehicleVelocity numbers to meters per second.


I will try and find my results


Edit:

Code:
speed = floatsqroot( (vx*vx)+(vy*vy)+(vz*vz) ) * MAGIC_NUMBER_FOR_METERS_PER_SECOND;

Meters per second seems to be 57.0, multiply this by 3.6 to get Km/h.

That is game unit correct as far as I know, meters per second is based on the GTA units which are pretty much meters.


It shows the Infernus top speed as 253.3Km/h which seems about right (Ignore the handling.cfg values) however it shows a push-bike going at 100Km/h (which is fine if you're a professional cycle racer, but this is a mountain bike, and the animation looks more like a relaxing Sunday ride!)
__________________
Tools:

Plugins:

Links:


Last edited by [HLF]Southclaw; 04/08/2012 at 06:25 PM.
[HLF]Southclaw is offline   Reply With Quote
Old 05/08/2012, 03:20 AM   #7
Xentiarox
Big Clucker
 
Xentiarox's Avatar
 
Join Date: Jun 2012
Location: Tilburg, NL
Posts: 116
Reputation: 30
Default Re: The "Real" vehicle speed thread

that is why you don't search for 'the magic number' but categorize the vehicles, other magic numbers for each category, for bikes * 20, for cars * 150, for planes * 210 (if using km/h).
__________________
Professional scripting for low price. PM for details.
Pure Nederlandse DM

[img]http://*******/aYXdL[/img]
Xentiarox is offline   Reply With Quote
Old 06/08/2012, 06:23 PM   #8
playbox12
High-roller
 
playbox12's Avatar
 
Join Date: Feb 2010
Location: Netherlands
Posts: 1,669
Reputation: 216
Default Re: The "Real" vehicle speed thread

Bikes are extremely unrealistic in this game. I wouldn't worry about them to much, also most vehicles have unrealistic speeds, this is probably done to keep the game fun. I wouldn't want to drive in a realistic bus, or fly in a fighter jet that reaches mach 2.
playbox12 is offline   Reply With Quote
Old 06/08/2012, 06:56 PM   #9
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,888
Reputation: 1443
Default Re: The "Real" vehicle speed thread

I do wish planes would go a bit faster tbh, but mach 2 would take about 8 seconds to cross the entire map
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is offline   Reply With Quote
Old 06/08/2012, 08:03 PM   #10
Joe Staff
High-roller
 
Joe Staff's Avatar
 
Join Date: Aug 2007
Posts: 2,796
Reputation: 375
Default Re: The "Real" vehicle speed thread

I determined my magic number by simply forcing the velocity of a vehicle to X: 1, Y: 0, Z: 0. Then I measured the speed through distance over time. I don't remember the number I came up with. I think it was on average 192
__________________
Big bottom girls make this rockin' world go 'round.
Joe Staff is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
5 Dialog errors - Input line too long, undefined symbol "t","is" and "only" Deal-or-die Scripting Help 6 01/05/2012 12:08 PM
xMovie Entertainment (3 vids): "Like a boss" "The rapist" "Jizz in my pants" xMovie Screenshots and Videos 11 27/03/2012 12:10 PM
"Slight homing", make a missile "Slightly!" home a vehicle. Donya Help Archive 4 11/06/2011 09:20 PM
Admin script requires "ReturnUser", "strtok" and "IsNumeric" Rubennnnn Help Archive 1 02/12/2009 06:08 PM
"Bots", "AI", "NPCs"... Computer-controlled pedestrians and traffic! ssflsnoob General 2 23/11/2008 06:06 PM


All times are GMT. The time now is 07:55 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.