See update for download link
-----
I recently discovered this pre-made City on BlendSwap (https://www.blendswap.com/blend/23834) and wanted to make a quick track from it. I saw this as an opportunity to test an idea that I have had: a track that randomly changes path each run.
(The textures are broken because the pre-made .blend uses Materials and I haven't learned how to bake materials automatically so it will be a while before this is fixed...)
Here is a video: invidio.us / youtube
This video shows how some of the intersections are scripted to create a semi-random route through the city. This helps make the races more dynamic.
Of course there are major downsides for this much fun:
- AI bots are dumb, so they probably won't be able to finish a dynamic track like this. Maybe I could have the slowest route always open and they use that? Still wouldn't be great.
- speedrunners owned lol I just discovered that custom Add-Ons build, if this map were ever included then the scripting.as file could be modified to use a preset override route.
- probably won't work on online multiplayer for the foreseeable future, unless I use a less random variable such as player count. In version 1.1, Benau has exposed the syncronised random seed to scripting, allowing me to make sure all players have the same random track!
The code is a variation of this:
- {l Code}: {l Select All Code}
/* Generate random numbers to decide which route to enable */
int random = Utils::randomInt(1, 3);
/* Use these to force a route as enabled (true) or disabled (false) */
bool override_enabled = false;
bool override_1 = false;
bool override_2 = false;
/* This SuperTuxKart map makes each route object call one of these
* functions to check whether enable that object or not.
*
* If either 'this route is randomly chosen' or 'we override this route',
* then return 'true', telling SuperTuxKart to enable this route.
*/
bool route_1_active(Track::TrackObject@ obj){
if (override_enabled) {
return override_1;
} else {
return (random == 1);
}
}
bool route_2_active(Track::TrackObject@ obj){
if (override_enabled) {
return override_2;
} else {
return (random == 2);
}
}