Live for Speed - LFS Main Site
- LFS World
- LFS News
- LFS Manual
- LFS Merchandise
  http://www.bean0.com/

Go Back   Live for Speed > Main > LFS Programmer Forum > LFSLapper Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th March 2010, 23:02   #1  -   
MrSir
No longer welcome
 
Join Date: Mar 2010
Posts: 3
LFSLapper Drift System Upgrade W.I.P.

Hello everybody, ive been playing LFS for quite some time now and in the past 6 months have involved myself in learning how the Lapper really works and looking at its source code. Over that period of time i came to two conclusions that probably many of you have:
1. The lapper doesnt provide real angle of the car as a variable, but rather AngleVelocity
2. The drift point calculation is based entirely on speed and angle.
3. There was no event that could give the user real-time data.

So after about a week of setting up my programming environment and looking through the source code of LFSLapper 6.0 curtecy of Gai-Luron, I have come up with this:


Othern than the obvious visual menus and Drift Meter i have changed a couple of things on the back end.
1. I made the absolute angle be an available variable for use in the .lpr files
2. Modified the drift calculation allowing the player for possible chaning of drifts and raising their multiplier. (I will give more details further down on how it works)
3. I have added a "OnDrive" event which is being called withing the UpdateState method of the infoPlayer.cs file (meaning it gets called 10 times a second)
4. Added a best drift feature which tracks down the single best drift done by any driver and displays it for all players on their personal drift meters

Drift System Details:
Ok so wat ive done with the drift calculation is this. The basic formula for calculating the drift points in a drifttick is still the same:
points = anglee * speed *speed/10000

However i have added an additional variable which begins to increment if the players angle goes out of the drift range(sort of like a timer). I use it to create a time gap in which a new drift can be started and added to the previous one creating a chained drift. Furthermore by chaining drifts for each additional one the multiplier goes up by 0.1. If no new drift is started in the time gap, then the total sum of all the drifts in the current combo is multiplied by the current multiplier and added to the total score. Some limitations i have implemented so far to avoid cheating and absurd scores in the 500k range, are the following. The multiplier has a max value of 2.0 otherwise clever players would continue chaining drifts for a whole lap getting a x50 multiplier and blowing up their score like crazy. Also the time gap between drifts is 1.2seconds long however in the first 0.2seconds you can not start a new drift, giving the player a 1 second gap after the initial 0.2seconds to start a new drift. This is done to eliminated the case of people doing quick slides from side to side getting their multiplier very high and basically cheating the system.

There are still some imperfections with the system i am working on fixing up, as well as making it a bit more compatible with the Racing components of the Lapper, since its not very friendly with the pitboard and the OnDrive event isnt called all the time but only when drifting. Let me know wat you think and if you have any additions you might want to see made.

Last edited by MrSir; 4th March 2010 at 23:12.
Reply With Quote
Old 4th March 2010, 23:36   #2  -   
Fire_optikz001
S2 licensed
 
Fire_optikz001's Avatar
 
Join Date: Apr 2004
Posts: 1,001
Fire_optikz001's online stats
Quote:
Originally Posted by MrSir View Post
Hello everybody, ive been playing LFS for quite some time now and in the past 6 months have involved myself in learning how the Lapper really works and looking at its source code. Over that period of time i came to two conclusions that probably many of you have:
1. The lapper doesnt provide real angle of the car as a variable, but rather AngleVelocity
2. The drift point calculation is based entirely on speed and angle.
3. There was no event that could give the user real-time data.

So after about a week of setting up my programming environment and looking through the source code of LFSLapper 6.0 curtecy of Gai-Luron, I have come up with this:


Othern than the obvious visual menus and Drift Meter i have changed a couple of things on the back end.
1. I made the absolute angle be an available variable for use in the .lpr files
2. Modified the drift calculation allowing the player for possible chaning of drifts and raising their multiplier. (I will give more details further down on how it works)
3. I have added a "OnDrive" event which is being called withing the UpdateState method of the infoPlayer.cs file (meaning it gets called 10 times a second)
4. Added a best drift feature which tracks down the single best drift done by any driver and displays it for all players on their personal drift meters

Drift System Details:
Ok so wat ive done with the drift calculation is this. The basic formula for calculating the drift points in a drifttick is still the same:
points = anglee * speed *speed/10000

However i have added an additional variable which begins to increment if the players angle goes out of the drift range(sort of like a timer). I use it to create a time gap in which a new drift can be started and added to the previous one creating a chained drift. Furthermore by chaining drifts for each additional one the multiplier goes up by 0.1. If no new drift is started in the time gap, then the total sum of all the drifts in the current combo is multiplied by the current multiplier and added to the total score. Some limitations i have implemented so far to avoid cheating and absurd scores in the 500k range, are the following. The multiplier has a max value of 2.0 otherwise clever players would continue chaining drifts for a whole lap getting a x50 multiplier and blowing up their score like crazy. Also the time gap between drifts is 1.2seconds long however in the first 0.2seconds you can not start a new drift, giving the player a 1 second gap after the initial 0.2seconds to start a new drift. This is done to eliminated the case of people doing quick slides from side to side getting their multiplier very high and basically cheating the system.

There are still some imperfections with the system i am working on fixing up, as well as making it a bit more compatible with the Racing components of the Lapper, since its not very friendly with the pitboard and the OnDrive event isnt called all the time but only when drifting. Let me know wat you think and if you have any additions you might want to see made.
sounds cool ... i dont really like the layout of your drift meter so was wondering i would still be able to use my own layout right
Reply With Quote
Old 4th March 2010, 23:49   #3  -   
MrSir
No longer welcome
 
Join Date: Mar 2010
Posts: 3
Ye adjusting the visual components is all up to you, what ive done is just one way to arrange it. You dont even need half the stuff u can still have the old style drift meter with the points only, however the multiplier and drift algorithm will still do its thing in the back like it or not.
Reply With Quote
Old 5th March 2010, 01:50   #4  -   
Krayy
S2 licensed
 
Krayy's Avatar
 
Join Date: Nov 2007
Location: Auckland, NZ
Posts: 459
Krayy's online stats
From what you're saying, I'm assuming that you have modified the source code to allow for the custom variables. What I would suggest is to post the modifications that you have made to the code into the "Requests" thread so that Gai can integrate the modifications into future releases.

I would also suggest that you have a look at the Cruise.lpr addon, which has added the $Mode global variable to Lapper, and maybe integrate the drift system so that the drift score info only occurs when you are in Drift mode (Probably by typing "!mode drift")

NB: Acutaly we should move the !mode command inot Utils.lpr so that it becomes a standard part of Lapper. Then people can code addons to use Drift, Cruise or Race modes
__________________
Live For Speed New Zealand
Reply With Quote
Old 5th March 2010, 01:53   #5  -   
Fire_optikz001
S2 licensed
 
Fire_optikz001's Avatar
 
Join Date: Apr 2004
Posts: 1,001
Fire_optikz001's online stats
Quote:
Originally Posted by Krayy View Post
From what you're saying, I'm assuming that you have modified the source code to allow for the custom variables. What I would suggest is to post the modifications that you have made to the code into the "Requests" thread so that Gai can integrate the modifications into future releases.

I would also suggest that you have a look at the Cruise.lpr addon, which has added the $Mode global variable to Lapper, and maybe integrate the drift system so that the drift score info only occurs when you are in Drift mode (Probably by typing "!mode drift")

NB: Acutaly we should move the !mode command inot Utils.lpr so that it becomes a standard part of Lapper. Then people can code addons to use Drift, Cruise or Race modes
and the $mode is also in the updated !gui (not released yet)
Reply With Quote
Old 5th March 2010, 02:02   #6  -   
Krayy
S2 licensed
 
Krayy's Avatar
 
Join Date: Nov 2007
Location: Auckland, NZ
Posts: 459
Krayy's online stats
Quote:
Originally Posted by Fire_optikz001 View Post
and the $mode is also in the updated !gui (not released yet)
All the more reason to put it into Utils.lpr to make it a standard part of Lapper, so that there is one interface for turning the different modes on or off
__________________
Live For Speed New Zealand
Reply With Quote
Old 5th March 2010, 02:05   #7  -   
MrSir
No longer welcome
 
Join Date: Mar 2010
Posts: 3
in the screenshot that menu that is in the center of the screen is the first thing that pops up, and the first thing Show drift meter, is basically my trigger for displaying the drift meter and doing the drift notifications. Ive coded it in the .lpr file such that it doesnt display any of the info to you if you have turned it off. The only thing you will see is the Best Drift Record msg in the chat when some player makes a new record. As well as other players drift score on finishing the lap, since that is a global msg aswell. As for teh Cruise.lpr i'll take a look at it and see if it has any conflicts with my mod. The only conflict my mod has is the OnLapperStart event with the pitboard, since the pitboard menu pops up, and i simply dont want it to i have just disabled it and made my thing pop up, but thats a minor change and could be disabled. I have the text commands set up to make it pop up on demand anyway.
Reply With Quote
Old 5th March 2010, 03:35   #8  -   
Fire_optikz001
S2 licensed
 
Fire_optikz001's Avatar
 
Join Date: Apr 2004
Posts: 1,001
Fire_optikz001's online stats
Quote:
Originally Posted by MrSir View Post
in the screenshot that menu that is in the center of the screen is the first thing that pops up, and the first thing Show drift meter, is basically my trigger for displaying the drift meter and doing the drift notifications. Ive coded it in the .lpr file such that it doesnt display any of the info to you if you have turned it off. The only thing you will see is the Best Drift Record msg in the chat when some player makes a new record. As well as other players drift score on finishing the lap, since that is a global msg aswell. As for teh Cruise.lpr i'll take a look at it and see if it has any conflicts with my mod. The only conflict my mod has is the OnLapperStart event with the pitboard, since the pitboard menu pops up, and i simply dont want it to i have just disabled it and made my thing pop up, but thats a minor change and could be disabled. I have the text commands set up to make it pop up on demand anyway.
you could have your menu pop up when u join race
Reply With Quote
Old 5th March 2010, 08:54   #9  -   
Gai-Luron
S2 licensed
 
Gai-Luron's Avatar
 
Racername: FRH Gai-Luron
Join Date: Feb 2005
Location: France - Paris
Posts: 986
Gai-Luron's online stats
Hello

Sound Good.

Anyway i'am little affraid about OnDrive event called 10 time/second. It's for each player or for all?
Because that's can charge CPU. Don't forgot that GLScript is tokenized interpreted language. If you have done test and this don't change usage CPU, forgot that i say previously .

For your's modification in Lapper can you send me a svn patch?

Good job


for mode, maybe a modes.lpr displaying all mode avaiable mode registered on catchEvent OnLapperStart with function
registerMode( $idMode, "Libel mode",$state_mode, backcallOnChange );

retreived or setted by
$myMode = getMode( $idMode );
setMode( $idMode, $state );

$idMode and unique id of registered Mode
$state = "Yes" or "Complete" etc...

$state_mode are all mode selectable in gui select screen mode
example:
"Yes|No"
"Complete|Partial|None"


I hope you understand my very good english

I dont know if backcallOnChange is very usefull, in this case i have to dev a new GLScript function CallSub("nameOfSub"[,arg1,arg2,...,argn] ) to have this to work in script language



Gai-Luron
__________________
FRH Team
All my progs LFSLapper LFSRelax LFSStat

Last edited by Gai-Luron; 5th March 2010 at 09:14.
Reply With Quote
Old 5th March 2010, 12:05   #10  -   
sinanju
S2 licensed
 
sinanju's Avatar
 
Racername: [><]Sinanju
Join Date: May 2006
Location: Livingston
Posts: 1,120
sinanju's online stats
Looks very good.

I've been giving some thought to the multiplier idea recently, but I was going to do on a sustained angle with a specific ideal angle (say 45 deg - any less could be a slide, and any more could be a spin), but your system looks workable.

Be interesting to see it in action - is it on a public server?
Reply With Quote
Old 5th March 2010, 13:08   #11  -   
morpha
S2 licensed
 
morpha's Avatar
 
Racername: 42D×morpha
Join Date: Jan 2008
Location: Austria
Posts: 2,172
morpha's online stats
9 replies and not a single burning banana for a demo user on Kyoto? Seriously?
Well alright:

That aside, it'll be interesting to see if this can match DriftWars's DriftWarrior, which I presume was the inspiration.
__________________
Minecraft: das_morpha
Reply With Quote
Old 5th March 2010, 13:24   #12  -   
SamH
Moderator
 
SamH's Avatar
 
Racername: UKCT..SamH
Join Date: Jul 2005
Location: Yorkshire
Posts: 10,268
SamH's online stats
MrSir, please use your S2 account to post S2 content.
__________________
Thou shalt not watch Hollyoaks.
Reply With Quote
Old 9th March 2010, 22:57   #13  -   
Fire_optikz001
S2 licensed
 
Fire_optikz001's Avatar
 
Join Date: Apr 2004
Posts: 1,001
Fire_optikz001's online stats
Quote:
Originally Posted by MrSir View Post
Hello everybody, ive been playing LFS for quite some time now and in the past 6 months have involved myself in learning how the Lapper really works and looking at its source code. Over that period of time i came to two conclusions that probably many of you have:
1. The lapper doesnt provide real angle of the car as a variable, but rather AngleVelocity
2. The drift point calculation is based entirely on speed and angle.
3. There was no event that could give the user real-time data.

So after about a week of setting up my programming environment and looking through the source code of LFSLapper 6.0 curtecy of Gai-Luron, I have come up with this:


Othern than the obvious visual menus and Drift Meter i have changed a couple of things on the back end.
1. I made the absolute angle be an available variable for use in the .lpr files
2. Modified the drift calculation allowing the player for possible chaning of drifts and raising their multiplier. (I will give more details further down on how it works)
3. I have added a "OnDrive" event which is being called withing the UpdateState method of the infoPlayer.cs file (meaning it gets called 10 times a second)
4. Added a best drift feature which tracks down the single best drift done by any driver and displays it for all players on their personal drift meters

Drift System Details:
Ok so wat ive done with the drift calculation is this. The basic formula for calculating the drift points in a drifttick is still the same:
points = anglee * speed *speed/10000

However i have added an additional variable which begins to increment if the players angle goes out of the drift range(sort of like a timer). I use it to create a time gap in which a new drift can be started and added to the previous one creating a chained drift. Furthermore by chaining drifts for each additional one the multiplier goes up by 0.1. If no new drift is started in the time gap, then the total sum of all the drifts in the current combo is multiplied by the current multiplier and added to the total score. Some limitations i have implemented so far to avoid cheating and absurd scores in the 500k range, are the following. The multiplier has a max value of 2.0 otherwise clever players would continue chaining drifts for a whole lap getting a x50 multiplier and blowing up their score like crazy. Also the time gap between drifts is 1.2seconds long however in the first 0.2seconds you can not start a new drift, giving the player a 1 second gap after the initial 0.2seconds to start a new drift. This is done to eliminated the case of people doing quick slides from side to side getting their multiplier very high and basically cheating the system.

There are still some imperfections with the system i am working on fixing up, as well as making it a bit more compatible with the Racing components of the Lapper, since its not very friendly with the pitboard and the OnDrive event isnt called all the time but only when drifting. Let me know wat you think and if you have any additions you might want to see made.
is this ever gonna be released?
Reply With Quote
Old 10th March 2010, 06:31   #14  -   
Krayy
S2 licensed
 
Krayy's Avatar
 
Join Date: Nov 2007
Location: Auckland, NZ
Posts: 459
Krayy's online stats
Quote:
Originally Posted by Gai-Luron View Post
Hello

Sound Good.

Anyway i'am little affraid about OnDrive event called 10 time/second. It's for each player or for all?
Because that's can charge CPU. Don't forgot that GLScript is tokenized interpreted language. If you have done test and this don't change usage CPU, forgot that i say previously .

For your's modification in Lapper can you send me a svn patch?

Good job


for mode, maybe a modes.lpr displaying all mode avaiable mode registered on catchEvent OnLapperStart with function
registerMode( $idMode, "Libel mode",$state_mode, backcallOnChange );

retreived or setted by
$myMode = getMode( $idMode );
setMode( $idMode, $state );

$idMode and unique id of registered Mode
$state = "Yes" or "Complete" etc...

$state_mode are all mode selectable in gui select screen mode
example:
"Yes|No"
"Complete|Partial|None"


I hope you understand my very good english

I dont know if backcallOnChange is very usefull, in this case i have to dev a new GLScript function CallSub("nameOfSub"[,arg1,arg2,...,argn] ) to have this to work in script language



Gai-Luron
I think the idea of specific functions to register and retrieve Modes are a little too overly complex. Setting a Global using a Const as the value is a heck of a lot less fiddly, and it's only GL scripts that would use it, so a Callback would hav no purpose. i.e. the Lapper instance wouldn't care about the mode, unless you want to rewrite all of the internal functions that check if LFS is in a race, practice, qualify or other.
__________________
Live For Speed New Zealand
Reply With Quote
Old 14th September 2010, 20:02   #15  -   
tam3535
Demo Racer
 
Join Date: Aug 2010
Posts: 13
tam3535's online stats
Guys

Hey man What the lapper Version ?
Reply With Quote
Old 16th September 2010, 11:23   #16  -   
sinanju
S2 licensed
 
sinanju's Avatar
 
Racername: [><]Sinanju
Join Date: May 2006
Location: Livingston
Posts: 1,120
sinanju's online stats
If you look at his signature, you'll see that MrSir is no longer welcome - unlikely you'll get reply.
Reply With Quote
Reply

  Live for Speed > Main > LFS Programmer Forum > LFSLapper Development

Tags
drift, lapper

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump


All times are GMT. The time now is 04:21.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Live for Speed © 2002-2014 - Scawen Roberts, Eric Bailey, Victor van Vlaardingen