Skip to content

Clustertruck Documentation

Happyrobot33 edited this page May 9, 2020 · 3 revisions

The way this autosplitter works is by using Livesplit's ASL language. this language uses the games memory to determine when to split and reset. This language has various functions that get called by Livesplit, and each one of these functions does something different inside of them.

Game Variables

ASL uses pointers found inside of the game to find values. this allows for direct access to the games memory. So far we are using these values in the splitter:

  • "Level" with address 0x020B574 with offsets of 0x10, 0x158 and 0x54
  • "inMenuValue" with address 0x01F30AC with offsets of 0x7D4, 0xC, 0x40 and 0x90
  • "levelTime" with address 0x00F6B420 with offsets of 0x20, 0x1C, 0x48, 0x30, 0x14, 0x0 and 0x38
  • "finishedLevelTime" with address 0x020B574 with offsets of 0x10, 0x130, 0x4 and 0x90
  • "inDeathScreen" with address 0x0F4CAB0 with offsets of 0x0, 0x4, 0xAC, 0xB4 and 0x654

The formatting for this looks like this: int level : "mono.dll", 0x020B574, 0x10, 0x158, 0x54;

mono.dll comes from a list of processes running from the game. there are several of these to choose from, each one containing different data about the game.

  • mono.dll
  • Clustertruck.exe

Script Variables

New variables local to the script can also be made. these variables can be anything they want, and do not need to be defined by type when created. The syntax of these variables is var.[NAME] = [NUMBER] There is a multitude of variables used throughout the script, all of which will be listed here:

Booleans

  • "Loading" True if the game is loading.
  • "finishedLevel" True if we finished the current level
  • "deathCounted" Used to determine if we have counted a death yet
  • "isDead" Is true if the player is dead
  • "inMenu" Converts the inMenuValue Game variable to a boolean
  • "newLevelStart" Is true when a new level has been started

Integers

  • "Split" Used for determining what split we are currently on. this is local and does not actually know what split it is on, it just counts every time we call the split function
  • "deaths" used to determine the number of deaths in the current run
  • "worldLevel" determines the current level in the world the player is in. IE if the player is in 5:4, this would be 4
  • "lastLevel" stores the last levels number.

Settings

Settings can be defined for users to change how the script behaves. base settings included in every script are changing if the script auto-resets, splits or starts The script also adds a few settings of its own. these settings have a variable name, a display name and a default value.

  • LevelSplit which goes by the display name "Split by Level" that defaults to true
  • DevMode which goes by the display name of "Dev Mode" that defaults to false

An explanation of what these settings all do can be found in the readme

How the Splitter knows when to split

Start

Start is very short, only needing a few lines to determine when to begin the timer. this is done by checking if the game is currently:

  1. Not in a menu
  2. in the first level of a world
  3. the in game timer has started the way we check for the in game timer is not the way you would first think about doing it. You could just use old.levelTime != current.leveltime but that is very inconsistent due to floating point inaccuracy. instead we use old.levelTime == 0 && current.levelTime > 0 this ensures that we start the tick after the level has begun timing

Reset

Reset is also very short, checking if the current level is lower than the level on the last tick

Split

Split is one of the longer sections of code in this splitter. it has 3 different outcomes depending on what is going on in the game.

Level 90

if the game is currently on level 90, the boss level, it will be checking for if the leaderboard time has changed. Due to how the boss level works, we cant check for the next level loading, since this does not update when you press the button. the only thing that is both a pointer and updates when you press the button is the leaderboard time. using this, we can check when the leaderboard time has changed, thus giving us when the player has pressed the button.

Individual Levels

If the splitter is setup through settings to split at every level, the code will check for when the variable newLevelStart is true. this happens when these conditions are all true:

  1. the last level variable doesn't equal the current level
  2. the previous ticks level time equals 0
  3. the current levels time is > 0

World based splits

If the splitter is setup to only split when a world is completed, then it will only check for if a new level was started and if the worldLevel Variable equals 1

Each one of these returns true inside of them, leading to a split. if none of them are true, nothing happens

Dev Info

ASL allows for printing of info through the use of DebugView. this allows us to print the variables value to somewhere we can monitor it.