Track scripting examples?

I'm wondering if anyone has any track script examples floating around?

I've been playing with trigger lines a bit and doing things like reverb for tunnels and near trees etc which is really cool. It's amazing how much depth can be added with some well placed ambient samples and reverbs running etc.

However certain things I'd like to be set from the start, like a default reverb set so you don't have to hit a trigger line to set it going.

I've no idea how to either get a triggerline to run a script (qscript, onyx or whatever), or how to have one run at track load somehow... or if it's even possible to have a script run once at track load up.

I've also tried to call a script via a triggerline but it seems to have issues finding the file, so I was wondering if people had had any luck getting track scripts to work via a triggerline, and how they set them all up?!


Cheers

Dave
 
Code:
// script to warp the current player car to traffic waypoints

// use ctrl+up/down to switch waypoints
// use ctrl+enter to go to the selected one

// save this in <track>/scripts/paint/warpscript.rsx

rcar $localcar = get local car

int $toggleup = 0
int $toggledown = 0
int $toggleenter = 0
int $nwaypoints = waypointcount
int $curpoint = 0

int $displayuntil = 0
int $ctime = 0
// time to pop up help in ms
int $displaytime = 1000


while 1
{
    $ctime = simtime
    // Ctrl key 17
    if is key 17 pressed
    {
      // up key 38 
      if is key 38 pressed 
      {
        if $toggleup == 0
        {
          $toggleup = 1
          $curpoint = $curpoint + 1
          $displayuntil = $ctime + $displaytime
        }
      }
      else
      {
        $toggleup = 0
      }
      // down key 40
      if is key 40 pressed
      {
        if $toggledown == 0
        {
          $toggledown = 1
          $curpoint = $curpoint - 1
          $displayuntil = $ctime + $displaytime
        }
      }
      else
      {
        $toggledown = 0
      }
      // make sure curpoint is inside 0,max-1
      if $curpoint < 0
      {
        $curpoint = $nwaypoints - 1
      }
      if $curpoint >= $nwaypoints
      {
        $curpoint = 0
      }
      
      // enter key 13
      if is key 13 pressed
      {
        if $toggleenter == 0
        {
          $toggleenter = 1
          // warp to the current point
          warp $localcar to waypoint $curpoint
        }
      }
      else
      {
        $toggleenter = 0
      }
    }
    // display if necessary
    if $ctime < $displayuntil
    {
      string $paint = "Current waypoint selected: " + $curpoint
      paint $paint at float[2]{30,10}
    }
    interrupt
}

This requires a track with splines as well as traffic waypoints, uses ctrl+up/down to select waypoints and ctrl+enter to warp your car to them. It's certainly useful for testing out the track in-game since you can just put a waypoint near the object you're having problems with.
 
Hi Stereo,

So I take it that while 1 loops all the time the track is loaded, but only on paint frames (probably ample for our needs vs physics steps)?

I'll give it a shot later.

I want to try get this Leeds Loops track using some more features of Racer to make it more exciting for players, and also useful for other people to see and take ideas from for more rich content.
Racer is pretty nice but I still think too many tracks feel dead, like something from The Langoliers...





Currently toying with the idea of triggering more random events, or changing them.

I was thinking a nice bodge to get an interesting effect might be to use the night variable to instead fudge rain into shaders, so if it starts to rain (randomly driven with a ramp rate over time) then the night value gets pushed up and adjusts special shaders reflectivity amounts...

OK not perfect but these are things Ruud can see the potential of and then implement for us in future versions. Ie, a wet variable exposed to the shaders and powered by 'rain', and then fix that reflection shader for roads etc, and we'd have super nice wet roads and reflections :D

I'm assuming that reflection shader does indeed work because he put it in there specifically for the power boat sims and using it on the sea surface... hmmm.


Thanks

Dave
 
Yeah, it runs top of the script once, then 'while 1 {' to 'interrupt }' gets run once per paint step (as I understand it, it continues from the interrupt but just loops)
 
Yeah I got it working nicely here, thanks for that.

A super quick test and I got a nice ramping rain curve, and used rain * time to get a wetness value...

So I'll try fire 'wetness' (aka night) via shaders and get a nice road that goes all wet and then dries out after the rain.

Mmmmmm... rainy wetness on roads!


It'd be nice to have a few shader exposures for things like a global wetness and also a wind variable.

That way we could have trees wave around more in the wind, and rain start to blow around a bit more too.

OK maybe not super important, but for the sake of shader exposure of a few more variables it's not exactly a big issues I can't imagine... but would make for some really nice weather possibilities!

Dave
 
Last edited:
OK maybe not super important, but for the sake of shader exposure of a few more variables it's not exactly a big issues I can't imagine... but would make for some really nice weather possibilities!
Yeah, I think the big limits are on per-pixel/per-vertex data (which goes in a2v, v2p, seems to be limited to about 64 bytes), putting in a few more scene variables that scripts can modify would be nice.
 
I don't think we're terribly far off what you'd generally want to expose.

Rain would be useful for things like windshield effects for rain.
Wet could be used for env shaders, as things don't get instantly wet, but more importantly tracks stay wet a good while after rain stops.
Wind would allow you to tie all these things in together more, such as blowy rain, tree wafting, grass wafting, flags wafting etc.

And we already have night, and all the other env variables like clouds, sunny etc.


I'm struggling to think of much else you'd really need for something real-time. OK there are probably many other more subtle effects but not that'd be instantly noticeable for a car sim/game.


Maybe late next week I'll post a video up with things working to show off the effects :D

Cheers

Dave
 

Latest News

Shifting method

  • I use whatever the car has in real life*

  • I always use paddleshift

  • I always use sequential

  • I always use H-shifter

  • Something else, please explain


Results are only viewable after voting.
Back
Top