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: 771
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):

pawn 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.

pawn 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):

pawn Code:
X = 1.072348
Y = 0.008095
Z = 0.000000

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

pawn 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: 171
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: 771
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
Banned
 
Join Date: Jun 2007
Location: Western Germany
Posts: 4,897
Reputation: 1597
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,092
Reputation: 2655
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 06/08/2012, 06:23 PM   #6
playbox12
High-roller
 
playbox12's Avatar
 
Join Date: Feb 2010
Location: Netherlands
Posts: 1,319
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, 08:03 PM   #7
Joe Staff
High-roller
 
Joe Staff's Avatar
 
Join Date: Aug 2007
Posts: 2,567
Reputation: 377
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
Old 06/08/2012, 09:14 PM   #8
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,092
Reputation: 2655
Default Re: The "Real" vehicle speed thread

Which is pretty much consistent with the 195.12 I came up with.
__________________
Vince is offline   Reply With Quote
Old 12/08/2012, 09:07 AM   #9
zugg48
Little Clucker
 
Join Date: Feb 2011
Posts: 22
Reputation: 3
Default Respuesta: The "Real" vehicle speed thread

Everybody see this info:

http://projectcerbera.com/gta/sa/tutorials/acceleration

http://projectcerbera.com/gta/sa/tutorials/handling
zugg48 is offline   Reply With Quote
Old 14/08/2012, 11:56 PM   #10
Mauzen
Banned
 
Join Date: Jun 2007
Location: Western Germany
Posts: 4,897
Reputation: 1597
Default Re: Respuesta: The "Real" vehicle speed thread

I like the acceleration part, i was trying to measure it itself, but this is more precise. This might become handy for RNPC vehicles.
Mauzen 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
"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 12:16 PM.


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