Welcome, Please Register or Login

Forums \ Street Legal Series \ F.A.Q / Help Section \ Bot Posistion and 1/4 mile Time

12>>>

Author Message
#1\2016-09-14 18:38

Members
2
Offline

Posts: 1933

florida
us United States

http://elboricuadjeddie2013.listen2myradio.com/

ok DanDav did a java for me with racing bot i need to move the bot to the left i also need to figure out the 1/4 mile time .

what line do i need to edit to move the racing bot and for 1/4 mile time
Thanks ?

start position works fin.

JAVA

package java.game;

import java.io.*;
import java.util.*;
import java.util.resource.*;
import java.game.*;
import java.render.*; //Text
import java.render.osd.*; //Text
import java.sound.*;
import java.render.osd.dialog.*; //Dialog Window


public class TestTrack extends Track
{

final static String MapName = "Test Track";
final static String MapDescription = "\n It is default game's Test Track with drag race.";
final static String MapAuthor = "Author: Invictus/DenDav";
final static ResourceRef MapImage = new ResourceRef(MW_Mod:0x0032r);
final static float TS_Version = 1.0;

//ADDED
Bot raceBot1;
Vector3 raceBot1_posStart;
Ypr raceBot1_oriStart;
//ADDED

final static int MPH_60 = 771.604938271604938271604938271605;
final static int MPH_124 = 3086.41975308641975308641975308642;

Vector3 posExit = new Vector3( -456,0.0,-584 );
Ypr oriExit = new Ypr( 3.0, 0.0, 0.0 );

Text messageTextA;
Text messageTextB;
Text messageText0;
Text messageText1;
Text messageText2;

int testStatus = 0;
int triggerIndex = 0;
int acceleration = 0;
int acceleration120 = 0;
float testStartTime = 0.0f;

Round actRound = null;
Round[] round = new Round[2];
int rounds = 2;


public TestTrack()
{
//ADDED
raceBot1_posStart = new Vector3( -3.663, 0.000, -1459.819 ); // First opponent start position
raceBot1_oriStart = new Ypr( 3.103, 0.000, 0.000 ); // First opponent start rotation
//ADDED

map = new GroundRef( maps.test_track:0x00000001r );
nav = new Navigator( -5.317-2.64, -15.996, 2.64, maps.test_track.smallmap:0x00000001r, maps.test_track.smallmap:0x00000002r, maps.test_track.smallmap:0x00000005r, 6, 8, 10 );
}

public void StartMap()
{
GameLogic.changeActiveSection( new TestTrack() );
}

public void enter( GameState prev_state )
{
Frontend.loadingScreen.show();
GfxEngine.flush();

if( prev_state instanceof Garage )
{
posStart=posExit;
oriStart=oriExit;
}

//ADDED
raceBot1 = new Bot( Math.random()*59, 3, 1, 2.0, 2.0, 20.0);

if ( File.exists(GameLogic.carSaveDir + "bot1") )
raceBot1.createCar( map, GameLogic.carSaveDir + "bot1" );
else
raceBot1.createCar( map, new Vehicle( map, cars.racers.Enula:0x0006r, 1.0, 1.0, 1.0, 1.0, 1.0 ) );

RenderRef policeman = new RenderRef( map, humans:0x0018r, "driver" );
raceBot1.car.command( "corpse 0 " + policeman.id() );

raceBot1.brain.queueEvent( null, EVENT_COMMAND, "AI_params 10.0 200.0" );
raceBot1.car.queueEvent( null, EVENT_COMMAND, "reset" );
raceBot1.car.queueEvent( null, EVENT_COMMAND, "reload" );
raceBot1.car.setMatrix( raceBot1_posStart, raceBot1_oriStart );
raceBot1.car.setParent( map );
raceBot1.car.wakeUp();
raceBot1.car.queueEvent( null, EVENT_COMMAND, "idle" );
//ADDED


// 1/4 miles
round[0] = new Round( this, "Go straight ahead", "to time the accelearation of your car!" );
round[0].startdir( 3.14 );
round[0].point( 0.000, 0.000, -1461.785, 1, 10 );
round[0].point( 0.000, 0.000, -1059.785, 1, 20 ); //quartermile
round[0].point( 0.000, 0.000, 148.215, 1, 20 ); //mile

round[1] = new Round( this, "Test lap time!", "GO!" );
round[1].startdir( 3.14 );
round[1].point( -450.598, 0.000, -524.816, 1 );
round[1].point( -450.598, 0.000, -223.142, 1 );
round[1].point( -444.736, 1.011, 72.270, 1 );
round[1].point( -27.535, 1.425, 450.475, 1 );
round[1].point( 444.689, 1.011, 72.560, 1 );
round[1].point( 450.598, 0.000, -223.142, 1 );
round[1].point( 450.598, 0.000, -544.816, 1 );
round[1].point( 450.598, 0.000, -893.995, 1 );
round[1].point( 446.293, 0.965, -1124.731, 1 );
round[1].point( -40.000, 1.425, -1513.328, 1 );
round[1].point( -446.000, 1.425, -1124.000, 1 );
round[1].point( -450.598, 0.000, -893.996, 1 );
round[1].loop();

actRound = null;

super.enter( prev_state );

messageTextA = osd.createText( "", Frontend.largeFont, Text.ALIGN_CENTER, 0.0, -0.8 );
messageTextB = osd.createText( "", Frontend.largeFont, Text.ALIGN_CENTER, 0.0, -0.7 );
messageText0 = osd.createText( "", Frontend.largeFont, Text.ALIGN_RIGHT, 0.0, -0.7 );
messageText1 = osd.createText( "", Frontend.largeFont, Text.ALIGN_LEFT, 0.0, -0.7 );
messageText2 = osd.createText( "", Frontend.largeFont, Text.ALIGN_CENTER, 0.0, -0.6 );
}

public void exit( GameState next_state )
{
if( !(next_state instanceof RaceSetup) )
removeAllTimers();

if( round[0] )
{
round[0].destroy();
round[0] = null;
}
if( round[1] )
{
round[1].destroy();
round[1] = null;
}

super.exit( next_state );
}

public void event_handlerTrigger( GameRef obj_ref, int event, String param )
{
int id = param.token(0).intValue();
if (id == player.car.id())
{
if( event == EVENT_TRIGGER_ON )
{
if( !activeTrigger )
{
activeTrigger=obj_ref.id();
}
}
else
{
activeTrigger=0;
}
}
}

public void handleEvent( GameRef obj_ref, int event, int param )
{
super.handleEvent( obj_ref, event, param );

if( event == EVENT_TIME )
{
if( param == 2 ) //one sec tick
{
if( activeTrigger )
{
if( player.car.getSpeedSquare() < 0.25 ) //slow speed?
{
for( int i = 0; i < rounds; i++ )
{
if( round )
{
if( activeTrigger == round.trigger.elementAt(0).trigger.id() )
{
Ypr ypr = player.car.getOri();

float diff = ypr.y-round.startOri.y;
if( diff >= 3.14 )
diff = 6.28 - diff;
if( diff <= -3.14 )
diff = -6.28 - diff;

if( diff < 0.5f && diff > -0.5f)
{
actRound = round;
testStatus = 0;
triggerIndex = 1;
if( actRound.type == 0 )
{
acceleration = 1;
acceleration120 = 1;
}
else
{
acceleration = 0;
acceleration120 = 0;
}
}
}
}
}
}
}
else
{
}
}
}
}

public void animate()
{
super.animate();

if( actRound )
{
float speedSquare = player.car.getSpeedSquare();

if( player.car.maxTestTrackSpeedSq < speedSquare )
player.car.maxTestTrackSpeedSq = speedSquare;


if( testStatus == 0 )
{
messageTextA.changeText( actRound.messageA );
messageTextB.changeText( actRound.messageB );
messageText0.changeText( "" );
messageText1.changeText( "" );
messageText2.changeText( "" );
testStatus = 1;
raceBot1.brain.command( "AI_BeginRace 0.9" );
}
if( testStatus == 1 )
{
if( speedSquare > 0.25 )
{
messageTextA.changeText( "" );
messageTextB.changeText( "" );
messageText0.changeText( "Time: " );
testStartTime = System.simTime();
testStatus = 2;
raceBot1.driveStraightTo( new Vector3(-6.229, -0.013, 403.379) );
Sound.changeMusicSet( Sound.MUSIC_SET_RACE );
}
}
if( testStatus == 2 )
{
float time = System.simTime() - testStartTime;
messageText1.changeText( String.timeToString( time, String.TCF_NOHOURS ) + " s" );
if( acceleration )
{
if( speedSquare >= MPH_60 )
{
messageText2.changeText( "Acceleration 0-100 KPH (0-62.1 MPH): " + String.timeToString( time, String.TCF_NOHOURS ) + " s" );
acceleration = 0;
if( player.car.bestTestTrackAcc > time || player.car.bestTestTrackAcc < 0.10 )
player.car.bestTestTrackAcc = time;
}
}
if( acceleration120 )
{
if( speedSquare >= MPH_124 )
{
messageText2.changeText( "Acceleration 0-200 KPH (0-124.2 MPH): " + String.timeToString( time, String.TCF_NOHOURS ) + " s" );
acceleration120 = 0;
if( player.car.bestTestTrackAcc120 > time || player.car.bestTestTrackAcc120 < 0.10 )
player.car.bestTestTrackAcc120 = time;
}
}
if( activeTrigger )
{
Trigger tr = actRound.trigger.elementAt( triggerIndex );
if( activeTrigger == tr.trigger.id() )
{
if( triggerIndex == 1 ) // 402 m //
{
if( actRound.type == 0 )
{
messageText2.changeText( "1/4 mile time: " + String.timeToString( time, String.TCF_NOHOURS ) + " s" );
if( player.car.bestTestTrackTime2 > time || player.car.bestTestTrackTime2 < 0.10 )
{
player.car.bestTestTrackTime2_speedSq = speedSquare;
player.car.bestTestTrackTime2 = time;
}
}
}
triggerIndex++;
if( triggerIndex == actRound.trigger.size() )
{
if( actRound.type == 0 )
{
messageText2.changeText( "1 mile time: " + String.timeToString( time, String.TCF_NOHOURS ) + " s" );
if( player.car.bestTestTrackTime0 > time || player.car.bestTestTrackTime0 < 0.10 )
{
player.car.bestTestTrackTime0_speedSq = speedSquare;
player.car.bestTestTrackTime0 = time;
}
}
else
{
if( player.car.bestTestTrackTime1 > time || player.car.bestTestTrackTime1 < 0.10 )
player.car.bestTestTrackTime1 = time;
}
actRound = null;
Sound.changeMusicSet( Sound.MUSIC_SET_DRIVING );
}
}
}
}
}
}

}




My Face Book Link
You Can See Me Play other Games and SLRR 230LE
MWM221 LE2MWM SLRRMWM2011-Stage1
Street-Legal-Racing-Redline-Mod-Videos

Intel Core i5-4590S Haswell Quad-Core 3.0 GHz-G.Skill 8GB Ram-24"Acer-4 Sata WD 500GB Caviar Blue-Amd Radion HD 6700-ASUS B85M Motherboard
#2\2016-09-18 16:52

GOM Team
3
Offline

Posts: 94

Saint-Petersburg
ru Russian Federation

Hi man. Thx for waiting. FL Studio took me away from slrr modding.
I've edited this line to move the bot to the left side:
raceBot1_posStart = new Vector3( 6.398, 0.000, -1456.559 ); // First opponent start position
Btw. My 1/4 time are displaying pretty well.

Best regards.
P.S. I'll be happy if someone can explain me how to move the bot back to the starting position after finish.
This post was edited by DenDav (2016-09-18 17:10, 6 months ago)
End of the line.
#3\2016-09-18 17:32

GOM Team
3
Offline

Posts: 868


pt Portugal

DenDav you need to create a restarter when you finish the race.
When finish the race you need to do a yes no dialog where you ask if player want to restart. Then in the next you will need to do 2 new changeActiveSection one for garage and other for test track and it will work perfectly. If you say yes it will restart the race if you say no the bot will will stay in the finish ;)

Added 2 minutes later:

if you didn't understand tomorrow I will show you what I mean because today I'm not anymore in my Pc I'm at my mobile phone.
#4\2016-09-19 11:37

Members
2
Offline

Posts: 1933

florida
us United States

http://elboricuadjeddie2013.listen2myradio.com/

hi gorgoil can you outline what line i have to edit for opponent 1/4 mile time Thanks for helping DanDav hes alright man .

ok im trying to do the same in Topeka Park V.08 that has a working race bot
but the 1/4 mile time is not working right i have the java for it ?


JAVA V.08

package java.game;

import java.io.*;
import java.util.*;
import java.util.resource.*;
import java.game.*;
import java.render.*; //Text
import java.render.osd.*; //Text
import java.sound.*;
import java.render.osd.dialog.*; //Dialog Window

import java.game.parts.*;
import java.game.parts.enginepart.*;

public class Topeka_Park extends Track
{
final static String MapName = "Topeka Heartland Park Circuit";
final static String MapDescription = "The Topeka Heartland Park Circuit is a motorsport race track located in Topeka, Kansas. Opened in 1989 it was the first new racing structure built in the USA in 20 years. Featuring 4 circuit layouts and a 1/4 mile drag strip.";
final static String MapAuthor = "from rFactor, Conv. by D1Racer java by Nightrider";
final static ResourceRef MapImage = new ResourceRef(Maps.Addon_Maps.Topeka_Park:0x0DC2r); // Image for track selector
final static float TS_Version = 1.0; // Dont change it!

final static int RaceOption = 0;

//bot stuff
int defaultCar = cars.racers.Duhen:0x0006r; // Default car for opponents if no custom cars found

Bot raceBot1,raceBot;
Vector3 raceBot1_posStart;
Ypr raceBot1_oriStart;

Bot raceBot2;
Vector3 raceBot2_posStart;
Ypr raceBot2_oriStart;

Bot raceBot3;
Vector3 raceBot3_posStart;
Ypr raceBot3_oriStart;

Bot raceBot4; //DragCar
Vector3 raceBot4_posStart;
Ypr raceBot4_oriStart;

Marker mRaceBot;

//Timer stuff
Text current_time_text, laps_text, last_time_text, best_time_text, check_text;
Round LoopRound;
int Checked, Laps;
int TestStatus;// -1 Ready, 0 Off, 1 Loop
float StartTime, LastCheckTime, BestTime = 9999;

//Countdown stuff
int raceCountDown;
int checkStart;

//Drag stuff
Trigger FinishTrigger;

float botTime;
float playerTime;
float startTime;

Round round;

Text messageTextA;
Text messageTextB;
Text messageText0;
Text messageText1;
Text messageText2;
Text messageText3;

int testStatus = 0;
int triggerIndex = 0;
int activator = 0;
float testStartTime = 0.0f;
int raced = 0;
int finished = 0;

Round actRound = null;

public Topeka_Park()
{
//posStart = new Vector3( 204.000, 4.000, -71.500 ); - Start at 4th grid
//posStart = new Vector3( 204.000, 3.770, -59.800 ); - Start at 5th grid
//posStart = new Vector3( 166.380, 8.700, -273.150 );
//oriStart = new Ypr(-1.571, 0.0, 0.0 );
//posStart = new Vector3( 204.000, 3.770, -59.800 );

if ( RaceOption == 3 ) // Circuit Mode - Player and Opponents position
{
posStart = new Vector3( 0.296, -4.082, -139.945 );
oriStart = new Ypr(-2.987, 0.0, 0.0 );

raceBot1_posStart = new Vector3( 3.335, -4.035, -140.812 ); // First opponent start position
raceBot1_oriStart = new Ypr( -2.987, 0.000, 0.000 ); // First opponent start rotation

raceBot2_posStart = new Vector3( 8.038, -4.036, -140.812 ); // Second opponent start position
raceBot2_oriStart = new Ypr( -2.987, 0.000, 0.000 ); // Second opponent start rotation

raceBot3_posStart = new Vector3( 5.490, -4.079, -156.740 ); // Third opponent start position
raceBot3_oriStart = new Ypr( -2.987, 0.000, 0.000 ); // Third opponent start rotation
}
else //Player position for other gamemodes
{
posStart = new Vector3( 288.350, -0.049, -577.703 );
oriStart = new Ypr(1.429, 0.0018, 0.002 );
}

if ( RaceOption == 0 ) // Drag Mode Map
{
map = new GroundRef( Maps.Addon_Maps.Topeka_Park:0x0001r );

FinishTrigger = new Trigger( map, null, new Vector3( -50.906, -5.500, -234.000 ), 15, 10, 0.001, "finish" );
addNotification( FinishTrigger.trigger, EVENT_TRIGGER_ON, EVENT_SAME, null, "event_handlerFinish" );

raceBot4_posStart = new Vector3( -105.268, -5.500, -677.093 ); // Drag opponent start position
raceBot4_oriStart = new Ypr( -2.987, 0.000, 0.000 ); // Drag opponent start rotation
}
else //Other modes map
{
map = new GroundRef( Maps.Addon_Maps.Topeka_Park:0x0001r );
}
//GPS for all modes
nav = new Navigator( -5.317-2.64, -15.996, 2.64, maps.test_track.smallmap:0x00000001r, maps.test_track.smallmap:0x00000002r, maps.test_track.smallmap:0x00000005r, 6, 8, 10 ); // GPS map
}

public void enter( GameState prev_state )
{
Frontend.loadingScreen.show();
GfxEngine.flush();

if ( RaceOption == 0 ) // Drag Mode
{
round = new Round( this, null, null );
round.startdir( 0.0 );
round.point( -116.290, -5.500, -674.827, 0.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) );
round.point( -50.906, -5.500, -234.000, 1, 20 ); //quartermile
raceCountDown=3;
// Create bot and his car

//----Drag Opponent
raceBot4 = new Bot( Math.random()*59, 3, 1, 2.0, 2.0, 20.0);

if ( File.exists(GameLogic.carSaveDir + "DragCar") )
raceBot4.createCar( map, GameLogic.carSaveDir + "DragCar" );
else
raceBot4.createCar( map, new Vehicle( map, defaultCar, 1.0, 1.0, 1.0, 1.0, 1.0 ) );

raceBot4.brain.queueEvent( null, EVENT_COMMAND, "AI_params 200.0 200.0" );
raceBot4.car.queueEvent( null, EVENT_COMMAND, "reset" );
raceBot4.car.queueEvent( null, EVENT_COMMAND, "reload" );
raceBot4.car.setMatrix( raceBot4_posStart, raceBot4_oriStart );
raceBot4.car.setParent( map );
raceBot4.car.wakeUp();
raceBot4.car.queueEvent( null, EVENT_COMMAND, "idle" );
raceBot4.car.queueEvent( null, EVENT_COMMAND, "stop" );
if(nav) mRaceBot = nav.addMarker( Marker.RR_CAR1, raceBot4.car );
}
if ( RaceOption == 2 ) // Time Attack Mode - Lap sectors
{
LoopRound = new Round( this, null, null );
LoopRound.startdir( -0.00 );
LoopRound.point( 8.395, -4.034, -140.188, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) ); // Start/Finish
LoopRound.point( 5.254, -15.860, 640.426, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) );
LoopRound.point( 489.214, -5.723, 613.180, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) );
LoopRound.point( 385.454, 0.608, -554.760, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) );
}

if ( RaceOption == 3 ) // Circuit Mode - Lap sectors and countdown
{
//track stuff
LoopRound = new Round( this, null, null );
LoopRound.startdir( -0.00 );
LoopRound.point( 6.212, -4.034, -139.331, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) ); // Start/Finish
LoopRound.point( 5.254, -15.860, 640.426, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) );
LoopRound.point( 489.214, -5.723, 613.180, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) );
LoopRound.point( 385.454, 0.608, -554.760, 12.0, frontend:0x0060r, frontend:0x0070r, new Pori(new Vector3(0.0, 2.0, 0.0), new Ypr(0.0, 0.0, 0.0)) );
raceCountDown=3;

// Create bots and their cars

//----Opponent 1
raceBot1 = new Bot( Math.random()*59, 3, 1, 2.0, 2.0, 20.0);

if ( File.exists(GameLogic.carSaveDir + "RaceCar1") )
raceBot1.createCar( map, GameLogic.carSaveDir + "RaceCar1" );
else
raceBot1.createCar( map, new Vehicle( map, defaultCar, 1.0, 1.0, 1.0, 1.0, 1.0 ) );

raceBot1.brain.queueEvent( null, EVENT_COMMAND, "AI_params 10.0 200.0" );
raceBot1.car.queueEvent( null, EVENT_COMMAND, "reset" );
raceBot1.car.queueEvent( null, EVENT_COMMAND, "reload" );
raceBot1.car.setMatrix( raceBot1_posStart, raceBot1_oriStart );
raceBot1.car.setParent( map );
raceBot1.car.wakeUp();
raceBot1.car.queueEvent( null, EVENT_COMMAND, "idle" );
raceBot1.car.queueEvent( null, EVENT_COMMAND, "stop" );
if(nav) mRaceBot = nav.addMarker( Marker.RR_CAR1, raceBot1.car );

//----Opponent 2
raceBot2 = new Bot( Math.random()*59, 3, 1, 2.0, 2.0, 20.0);

if ( File.exists(GameLogic.carSaveDir + "RaceCar2") )
raceBot2.createCar( map, GameLogic.carSaveDir + "RaceCar2" );
else
raceBot2.createCar( map, new Vehicle( map, defaultCar, 1.0, 1.0, 1.0, 1.0, 1.0 ) );

raceBot2.brain.queueEvent( null, EVENT_COMMAND, "AI_params 11.0 200.0" );
raceBot2.car.queueEvent( null, EVENT_COMMAND, "reset" );
raceBot2.car.queueEvent( null, EVENT_COMMAND, "reload" );
raceBot2.car.setMatrix( raceBot2_posStart, raceBot2_oriStart );
raceBot2.car.setParent( map );
raceBot2.car.wakeUp();
raceBot2.car.queueEvent( null, EVENT_COMMAND, "idle" );
raceBot2.car.queueEvent( null, EVENT_COMMAND, "stop" );
if(nav) mRaceBot = nav.addMarker( Marker.RR_CAR1, raceBot2.car );

//----Opponent 3
raceBot3 = new Bot( Math.random()*59, 3, 1, 2.0, 2.0, 20.0);

if ( File.exists(GameLogic.carSaveDir + "RaceCar3") )
raceBot3.createCar( map, GameLogic.carSaveDir + "RaceCar3" );
else
raceBot3.createCar( map, new Vehicle( map, defaultCar, 1.0, 1.0, 1.0, 1.0, 1.0 ) );

raceBot3.brain.queueEvent( null, EVENT_COMMAND, "AI_params 9.0 200.0" );
raceBot3.car.queueEvent( null, EVENT_COMMAND, "reset" );
raceBot3.car.queueEvent( null, EVENT_COMMAND, "reload" );
raceBot3.car.setMatrix( raceBot3_posStart, raceBot3_oriStart );
raceBot3.car.setParent( map );
raceBot3.car.wakeUp();
raceBot3.car.queueEvent( null, EVENT_COMMAND, "idle" );
raceBot3.car.queueEvent( null, EVENT_COMMAND, "stop" );
if(nav) mRaceBot = nav.addMarker( Marker.RR_CAR1, raceBot3.car );
//Bot end
}
super.enter( prev_state );


best_time_text = osd.createText( "" , Frontend.largeFont, Text.ALIGN_LEFT, -0.9, -0.9 );
last_time_text = osd.createText( "" , Frontend.largeFont, Text.ALIGN_LEFT, -0.9, -0.82 );
current_time_text = osd.createText( "", Frontend.largeFont, Text.ALIGN_LEFT, -0.9, -0.74 );

check_text = osd.createText( "", Frontend.largeFont, Text.ALIGN_RIGHT, 0.9, -0.9 );
laps_text = osd.createText( "" , Frontend.largeFont, Text.ALIGN_RIGHT, 0.9, -0.82 );

messageTextA = osd.createText( "", Frontend.largeFont, Text.ALIGN_CENTER, 0.0, -0.8 );
messageTextB = osd.createText( "", Frontend.largeFont, Text.ALIGN_CENTER, 0.0, -0.7 );
messageText0 = osd.createText( "", Frontend.largeFont, Text.ALIGN_RIGHT, 0.0, -0.7 );
messageText1 = osd.createText( "", Frontend.largeFont, Text.ALIGN_LEFT, 0.0, -0.7 );
messageText2 = osd.createText( "", Frontend.largeFont, Text.ALIGN_CENTER, 0.0, -0.6 );
messageText3 = osd.createText( "", Frontend.largeFont, Text.ALIGN_CENTER, 0.0, -0.3 );

player.car.wakeUp();
player.car.command( "idle" );// Run car engine

}

public void exit( GameState next_state )
{
if ( RaceOption == 2 )
{
if( !(next_state instanceof RaceSetup) )
removeAllTimers();

LoopRound.destroy();
LoopRound = null;

if( nav && mRaceBot )
{
nav.remMarker( mRaceBot );
mRaceBot=null;
}
}
if ( RaceOption == 3 )
{
if( !(next_state instanceof RaceSetup) )
removeAllTimers();

LoopRound.destroy();
LoopRound = null;

if( nav && mRaceBot )
{
nav.remMarker( mRaceBot );
mRaceBot=null;
}
}
if ( RaceOption == 0 )
{
if( !(next_state instanceof RaceSetup) )
removeAllTimers();

round.destroy();
round = null;

if( nav && mRaceBot )
{
nav.remMarker( mRaceBot );
mRaceBot=null;
}
}
super.exit( next_state );
}

public void LoopTest_Start()
{
StartTime = System.simTime();

Checked = 0;
TestStatus = 1;

if(BestTime == 9999) best_time_text.changeText( "Best Time: N/A" );
else best_time_text.changeText( "Best Time: " + String.timeToString( BestTime, String.TCF_NOHOURS ) );

//check_text.changeText( "Sectors: 0/"+LoopRound.positions.size() );
if ( RaceOption == 3 )
{
laps_text.changeText("Laps: " + Laps +"/3");
}
else
{
laps_text.changeText("Laps: " + Laps);
}
}

public void event_handlerTrigger( GameRef obj_ref, int event, String param )
{
int id = param.token(0).intValue();

if ( RaceOption == 0 )
{
if (id == player.car.id())
{
if( event == EVENT_TRIGGER_ON )
{
if( !activeTrigger )
{
activeTrigger=obj_ref.id();
activator = id;
}
}
else
{
activeTrigger=0;
}
}
}
else
if( id == player.car.id() )
{
if( event == EVENT_TRIGGER_ON )
{
int trgId = obj_ref.id();
activeTrigger = trgId;
LastCheckTime = System.simTime();

if( id == player.car.id() )
{
if( LoopRound.trigger.elementAt( 0 ).trigger.id() == trgId )
{// Start/Finish
if( TestStatus == 1 )// Loop
{
if( Checked == LoopRound.positions.size()-1 )// Finished
{
last_time_text.changeText( "Last Time: " + String.timeToString( System.simTime()-StartTime, String.TCF_NOHOURS ) );

Laps += 1;
laps_text.changeText("Laps: " + Laps);

if(System.simTime()-StartTime < BestTime)
{
BestTime = System.simTime()-StartTime;
best_time_text.changeText( "Best Time: " + String.timeToString( BestTime, String.TCF_NOHOURS ) );
setMessage( "New Record: " + String.timeToString( BestTime, String.TCF_NOHOURS ) );
}
else
setMessage( "Lap Time: " + String.timeToString((System.simTime()-StartTime), String.TCF_NOHOURS ));
}
else
setMessage( "Sector missed! Try again" );

LoopTest_Start();
}
}
else
{// everyone checkpoint

if( TestStatus == 1 && LoopRound.trigger.elementAt( Checked+1 ).trigger.id() == trgId )// Circuit
{
Checked++;
//setMessage( "Sector "+Checked+" of "+LoopRound.positions.size()+" passed!" );
setMessage( "Sector "+Checked+" Time: " + String.timeToString((System.simTime()-StartTime), String.TCF_NOHOURS ));
//check_text.changeText( "Sectors: "+Checked+"/"+LoopRound.positions.size() );
}
}
}
}
else
{
activeTrigger = 0;
}
}
}

public void handleEvent( GameRef obj_ref, int event, int param )
{
super.handleEvent( obj_ref, event, param );

if ( RaceOption == 3 ) // Circuit Mode timer trigger
{
if( activeTrigger && activeTrigger == LoopRound.trigger.elementAt(0).trigger.id() )// Loop start/finish trigger
{
if( TestStatus == 0 && player.car.getSpeedSquare() > 0.1 )
{
TestStatus = -1;
}
if( TestStatus == -1 )// start timers
{
checkStart = -1;//erase GO! message
last_time_text.changeText( "Last Time: N/A" );
LastCheckTime = System.simTime();
LoopTest_Start();
}
}
checkStart = 1;// start counter
if( param == 2 ) //one sec tick
{
if( checkStart == 1 && TestStatus == 0 )
{
if( raceCountDown ) //3..2..1..
{
if( raceCountDown == 3 )
{
setMessage( "3" );
player.car.queueEvent( null, GameType.EVENT_COMMAND, "stop" );
raceBot1.brain.command( "AI_BeginRace 0.5" );
raceBot2.brain.command( "AI_BeginRace 0.5" );
raceBot3.brain.command( "AI_BeginRace 0.5" );
}
else
if( raceCountDown == 2 )
{
setMessage( "2" );
}
else
if( raceCountDown == 1 )
{
setMessage( "1" );
raceBot1.brain.command( "AI_BeginRace 1.0" );
raceBot2.brain.command( "AI_BeginRace 1.0" );
raceBot3.brain.command( "AI_BeginRace 1.0" );
}
setMessage( raceCountDown-- );
}
else
{
setMessage( "GO!" );

player.car.queueEvent( null, GameType.EVENT_COMMAND, "start" );

//----Wake up A.I-bots
if (raceBot1)
if (raceBot1.car)
raceBot1.car.queueEvent( null, GameType.EVENT_COMMAND, "start" );
if( raceBot1 )
raceBot1.followSplineTrack( 0.01, "maps\\Addon_Maps\\Topeka_Park\\Topeka_Park1.spl", player.car.id() ); // Opponent 1 starts racing using the .spl

if (raceBot2)
if (raceBot2.car)
raceBot2.car.queueEvent( null, GameType.EVENT_COMMAND, "start" );
if( raceBot2 )
raceBot2.followSplineTrack( 0.01, "maps\\Addon_Maps\\Topeka_Park\\Topeka_Park2.spl", player.car.id() ); // Opponent 2 starts racing using the .spl

if (raceBot3)
if (raceBot3.car)
raceBot3.car.queueEvent( null, GameType.EVENT_COMMAND, "start" );
if( raceBot3 )
raceBot3.followSplineTrack( 0.01, "maps\\Addon_Maps\\Topeka_Park\\Topeka_Park1.spl", player.car.id() ); // Opponent 3 starts racing using the .spl
}
}
}
}
if ( RaceOption == 0 ) //Drag mode time trigger
{
if( actRound )
{
if( testStatus == 0 && raced == 0)
{
messageTextA.changeText( actRound.messageA );
messageTextB.changeText( actRound.messageB );
messageText0.changeText( "" );
messageText1.changeText( "" );
messageText2.changeText( "" );
messageText3.changeText( "" );
testStatus = 1;
}
if( testStatus == 1 )
{
messageTextA.changeText( "" );
messageTextB.changeText( "" );
messageText0.changeText( "Time: " );
testStartTime = System.simTime();
}
if( testStatus == 2 )
{
float time = System.simTime() - testStartTime;
messageText1.changeText( String.timeToString( time, String.TCF_NOHOURS ) + " s" );
}
}
if( event == EVENT_TIME )
{
if( activeTrigger )
{
if( player.car.getSpeedSquare() < 0.01 ) //slow speed?
{
checkStart = 1;
if( round )
{
if( activeTrigger == round.trigger.elementAt(0).trigger.id() )
{
Ypr ypr = player.car.getOri();
float diff = ypr.y-round.startOri.y;
if( diff >= 3.14 )
diff = 6.28 - diff;
if( diff <= -3.14 )
diff = -6.28 - diff;

if( diff < 0.5f && diff > -0.5f)
{
actRound = round;
testStatus = 0;
triggerIndex = 1;
}
if( param == 2 ) //one sec tick
{
if( checkStart == 1 )
{
if( raceCountDown ) //3..2..1..
{
if( raceCountDown == 3 )
{
setMessage( "3" );
player.car.queueEvent( null, GameType.EVENT_COMMAND, "stop" );
raceBot4.brain.command( "AI_BeginRace 0.5" );
}
else
if( raceCountDown == 2 )
{
setMessage( "2" );
}
else
if( raceCountDown == 1 )
{
setMessage( "1" );
raceBot4.brain.command( "AI_BeginRace 1.0" );
}
setMessage( raceCountDown-- );
}
else
{
setMessage( "GO!" );
testStatus = 2;
raced = 1;

player.car.queueEvent( null, GameType.EVENT_COMMAND, "start" );

//----Wake up A.I-bot
if (raceBot4)
if (raceBot4.car)
raceBot4.car.queueEvent( null, GameType.EVENT_COMMAND, "start" );
raceBot4.driveStraightTo( new Vector3(-39.581, -5.497, -229.994) );
}
}
}
}
}
}
}
}
}
}
public void event_handlerFinish( GameRef obj_ref, int event, String param )
{
int id = param.token(0).intValue();
float time = System.simTime() - testStartTime;
if (id == player.car.id() && finished == 0)
{
actRound = null;
messageText1.changeText( String.timeToString( time, String.TCF_NOHOURS ) + " s" );
if( player.car.bestTestTrackTime2 > time || player.car.bestTestTrackTime2 < 0.10 )
{
player.car.bestTestTrackTime2_speedSq = player.car.getSpeedSquare();
player.car.bestTestTrackTime2 = time;
finished = 1;
}
}

if (id == raceBot4.car.id())
{
messageText2.changeText( "Opponent time: " + String.timeToString( time, String.TCF_NOHOURS ) + " s" );
if (raceBot4.car)
raceBot4.driveStraightTo( new Vector3(-39.581, -5.497, -229.994) );
raceBot4.car.queueEvent( null, GameType.EVENT_COMMAND, "brake" );
}
}
/*public void handleEvent( GameRef obj_ref, int event, String param )
{
if( event == EVENT_COLLISION )// if any player car collision
{
if( raceBot.car && raceBot.car.id() == param.token(0).intValue())// if player's car hit raceBot.car
{
raceBot.stopCar( player.car );
if(nav) mRaceBot = nav.addMarker( Marker.RR_POLICE, raceBot.car );
}
if( raceBot2.car && raceBot2.car.id() == param.token(0).intValue())// if player's car hit raceBot2.car
{
raceBot2.stopCar( player.car );
if(nav) mRaceBot = nav.addMarker( Marker.RR_CAR2, raceBot2.car );
}
if( raceBot3.car && raceBot3.car.id() == param.token(0).intValue())// if player's car hit raceBot3.car
{
raceBot3.stopCar( player.car );
if(nav) mRaceBot = nav.addMarker( Marker.RR_CAR3, raceBot3.car );
}
}
}*/

public void animate()
{
super.animate();

if( TestStatus > 0 )
{
float time = System.simTime() - StartTime;
current_time_text.changeText( "Current Time: " + String.timeToString( time, String.TCF_NOHOURS ) );

if( LastCheckTime+600 < System.simTime() )// 600 sec wait - 10 minutes
{// turn off and erase timer osd
TestStatus = 0;
current_time_text.changeText(null);
best_time_text.changeText(null);
last_time_text.changeText(null);
//check_text.changeText(null);
laps_text.changeText(null);
}
else
if ( RaceOption == 3 ) //Circuit lap limiter
{
if( Laps == 4 )
{
setMessage( "Well Done!" );
checkStart = -1;//erase GO! message
TestStatus = -2;
current_time_text.changeText(null);
//check_text.changeText(null);
laps_text.changeText(null);
}
}
}

/*best_time_text.changeText( activeTrigger );// deboging
if(player.car) // Position debuging text
{
best_time_text.changeText( "Pos: x" + player.car.getPos().x + ", y" + player.car.getPos().y + ", z" + player.car.getPos().z);
}*/

if ( RaceOption == 2 ) //Time Attack timer trigger
{
if( activeTrigger && activeTrigger == LoopRound.trigger.elementAt(0).trigger.id() )// Loop start/finish trigger
{
if( TestStatus == 0 && player.car.getSpeedSquare() > 0.1 )// crossed start lane
{
TestStatus = -1;// Started
}
if( TestStatus == -1 )// started
{
setMessage( "Lap Start" );
last_time_text.changeText( "Last Time: N/A" );
LastCheckTime = System.simTime();
LoopTest_Start(); //Start timer
}
}
}
}

public void StartMap()
{
RaceOption = 0;
new Topeka_Park_Options().display();
}
}
public class Topeka_Park_Options extends Dialog
{
final static int CMD_BACK = 15;
final static int CMD_OK = 16;
final static int CMD_GAMEMODE = 20;

Menu m;
Style Menu_Center, Menu_Left;

int CurrentMode;

Button opt1;
Button opt2;


public Topeka_Park_Options()
{
super( GameLogic.player.controller, DF_MODAL|DF_DEFAULTBG|DF_HIGHPRI|DF_DARKEN, "TRACK OPTIONS", "" );

Menu_Center = new Style( 0.50, 0.13, Frontend.mediumFont, Text.ALIGN_CENTER, Osd.RRT_TEST );

m = osd.createMenu( Menu_Center, 0.0, -0.6, 0, Osd.MD_VERTICAL );
opt1 = m.addItem( "Practice", CMD_GAMEMODE, "Choose gamemode." );

CurrentMode = 1;
Topeka_Park.RaceOption = 1;

m = osd.createMenu( Menu_Center, -0.4, 0.9, 0, Osd.MD_HORIZONTAL );
m.addItem( "OK", CMD_OK );

m = osd.createMenu( Menu_Center, 0.4, 0.9, 0, Osd.MD_HORIZONTAL );
m.addItem( "BACK", CMD_BACK );

super.show();
}

public void osdCommand( int cmd )
{
if( cmd == CMD_GAMEMODE )
{
if( CurrentMode == 0 )
{
Topeka_Park.RaceOption = 1;
opt1.changeLabelText( "Practice" );
CurrentMode = 1;
}
else
if( CurrentMode == 1 )
{
Topeka_Park.RaceOption = 2;
opt1.changeLabelText( "Time Trial" );
CurrentMode = 2;
}
else
if( CurrentMode == 2 )
{
Topeka_Park.RaceOption = 3;
opt1.changeLabelText( "Circuit Race" );
CurrentMode = 3;
}
else
if( CurrentMode == 3 )
{
Topeka_Park.RaceOption = 0;
opt1.changeLabelText( "Drag Race" );
CurrentMode = 0;
}
}
else
if( cmd == CMD_BACK )
{
osd.hide();
super.hide();
}
else
if( cmd == CMD_OK )
{
osd.hide();
super.hide();
GameLogic.changeActiveSection( new Topeka_Park() );
}
}
}





Added 1 hours later:

ok this is what im talking about 1/4 mile time ?
its not displaying right
Topeka park


drag track MwM

This post was edited by Locomanusa (2016-09-19 13:04, 6 months ago)


My Face Book Link
You Can See Me Play other Games and SLRR 230LE
MWM221 LE2MWM SLRRMWM2011-Stage1
Street-Legal-Racing-Redline-Mod-Videos

Intel Core i5-4590S Haswell Quad-Core 3.0 GHz-G.Skill 8GB Ram-24"Acer-4 Sata WD 500GB Caviar Blue-Amd Radion HD 6700-ASUS B85M Motherboard
#5\2016-09-19 13:40

GOM Team
3
Offline

Posts: 868


pt Portugal

Use the update by Oxman99.
Drag track isn't good because it's only 290m not 402 like test track, drag strip and Topeka
#6\2016-09-19 13:52

Members
2
Offline

Posts: 1933

florida
us United States

http://elboricuadjeddie2013.listen2myradio.com/

i have it but it docent have a racing bot that's why im trying to edit end trigger to move it at 402 and fix the 1/4 mile on V.08 if you can highlight what i have to edit to do what i need ill appreciated a lot Thank you.

i think its this one not sure?

FinishTrigger = new Trigger( map, null, new Vector3( -50.000, -5.000, -234.000 ), 15, 10, 0.001, "finish" );


My Face Book Link
You Can See Me Play other Games and SLRR 230LE
MWM221 LE2MWM SLRRMWM2011-Stage1
Street-Legal-Racing-Redline-Mod-Videos

Intel Core i5-4590S Haswell Quad-Core 3.0 GHz-G.Skill 8GB Ram-24"Acer-4 Sata WD 500GB Caviar Blue-Amd Radion HD 6700-ASUS B85M Motherboard
#7\2016-09-19 13:56

GOM Team
3
Offline

Posts: 868


pt Portugal

No it isn't. that's the finish point I've done a fix to it some years ago but I don't know if I still have it.
#8\2016-09-19 15:35

Members
2
Offline

Posts: 1933

florida
us United States

http://elboricuadjeddie2013.listen2myradio.com/

gorgoil im not a wizard like you or dav in java.
all im asking is to highlight what i need to edit in the order that it goes
in the java so i can try and fix it if anyone can help ill appreciated a million.

Topeka Park V.1 dos not have a racing bot

gorgoil btw i tested your Drag tires the java works perfect .
ill be uploading the video on my Facebook soon Awesome.

This post was edited by Locomanusa (2016-09-19 15:51, 6 months ago)


My Face Book Link
You Can See Me Play other Games and SLRR 230LE
MWM221 LE2MWM SLRRMWM2011-Stage1
Street-Legal-Racing-Redline-Mod-Videos

Intel Core i5-4590S Haswell Quad-Core 3.0 GHz-G.Skill 8GB Ram-24"Acer-4 Sata WD 500GB Caviar Blue-Amd Radion HD 6700-ASUS B85M Motherboard
#9\2016-09-19 15:45

GOM Team
3
Offline

Posts: 868


pt Portugal

I know but I can't tell you correctly what you should look because I can't remember well and I'm a bit busy sorry.
#10\2016-09-19 16:03

Members
2
Offline

Posts: 1933

florida
us United States

http://elboricuadjeddie2013.listen2myradio.com/

that's ok thank you when you have some time ill appropriated the help man.

what im trying to do is take all the Drag Track and have racing bots for a little more competition on Facebook its where i have more fans so they can challenge me to see who can make a better time in the tracks just for fun.


My Face Book Link
You Can See Me Play other Games and SLRR 230LE
MWM221 LE2MWM SLRRMWM2011-Stage1
Street-Legal-Racing-Redline-Mod-Videos

Intel Core i5-4590S Haswell Quad-Core 3.0 GHz-G.Skill 8GB Ram-24"Acer-4 Sata WD 500GB Caviar Blue-Amd Radion HD 6700-ASUS B85M Motherboard

12>>>