Skip to content

Features

YaLTeR edited this page Oct 28, 2022 · 32 revisions

bxt-rs Modules

Each module represents a feature or a set of features of bxt-rs. Console commands and variables starting with an underscore (_) are not meant for normal use.

This wiki page is generated automatically with src/bin/gen-wiki.rs. Do not edit it by hand.

bxt_disable_loading_text

Disabling the LOADING text.

Console Variables

  • bxt_disable_loading_text (default: "0")

    Set to 1 to disable the LOADING text.

bxt_fade_remove

Removing the screen blackout effect.

Console Variables

  • bxt_fade_remove (default: "0")

    Set to 1 to disable the screen blackout effect.

bxt_force_fov

Overriding the field-of-view.

Console Variables

  • bxt_force_fov (default: "0")

    Field-of-view to set.

    This variable will work even when default_fov doesn't work or when default_fov is set by the demo. Set to 0 to disable the override.

bxt_hud_scale

Changing the scale of the HUD elements like health and ammo count.

Console Variables

  • bxt_hud_scale (default: "0")

    Sets the scale of the HUD elements. For example, 2 makes them 2 times bigger.

    Setting to 0 disables the bxt-rs scaling code, making it a safer default than 1.

bxt_novis

Rendering entities behind walls.

Console Variables

  • bxt_novis (default: "0")

    Set to 1 to render entities behind walls.

bxt_shake_remove

Removing the screen shake effect.

Console Variables

  • bxt_shake_remove (default: "0")

    Set to 1 to disable the screen shake effect.

bxt_skybox_remove

Disabling the skybox drawing.

Console Variables

  • bxt_skybox_remove (default: "0")

    Set to 1 to remove the skybox.

bxt_tas_log

Logging the player state during TAS playback.

This is a useful subset of bxt_tas_log, including RNG state dumping, when you can't use the one from the original Bunnymod XT.

Console Commands

  • bxt_tas_log <0|1>

    Enables (1) or disables (0) TAS logging into the file at bxt_tas_log_filename.

Console Variables

  • bxt_tas_log_filename (default: "taslogger.log")

    Filename of the log file to write.

  • _bxt_tas_log_write_full_rng_state (default: "0")

    Set to 1 to write the full engine RNG state every frame.

    This massively increases the log file size while being seldom needed, so it's not enabled by default.

bxt_viewmodel_remove

Removing the viewmodel.

Console Variables

  • bxt_viewmodel_remove (default: "0")

    Set to 1 to disable rendering viewmodel.

bxt_wallhack

Seeing through walls.

Console Variables

  • bxt_wallhack (default: "0")

    Set to 1 to enable the wallhack.

  • bxt_wallhack_additive (default: "0")

    Set to 1 to make the wallhack additive, which sometimes makes objects easier to see.

Comment command buffer overflow fix

Bunnymod XT spams demos with data stored in console command comments. They overflow the command buffer upon playback leading to console spam and commands being skipped. In particular, the command to play the next demo in bxt_play_run can get skipped, which means the demo playback interrupts mid-way.

This module strips prefix comments from console commands as they are added to the command buffer, preventing the overflow.

Console commands

Makes bxt-rs able to add console commands.

Console variables

Makes bxt-rs able to register console variables.

Help

Printing the list of modules, their console commands and variables and documentation.

Console Commands

  • bxt_help [module|command|variable]

    Without arguments, shows the list of modules and their status.

    With an argument, shows help for that module, command or variable.

Multiple demo playback

Playing multiple demos at once.

Console Commands

  • bxt_play_run <name>

    Plays back all name_N.dem demos in order.

Player-movement tracing

Makes bxt-rs able to use the game's player movement collision detection.

TAS optimizer

Brute-force optimization for TASes.

Console Commands

  • bxt_tas_optim_disable

    Stops and disables the optimizer.

  • bxt_tas_optim_minimize

    Minimizes the optimized script. This removes things like enabled autojump that does nothing because during this frame bulk the player never lands on the ground. It also joins together equivalent frame bulks.

  • bxt_tas_optim_reset

    Resets the optimizer path back to the non-optimized starting state.

    Use bxt_tas_optim_stop;bxt_tas_optim_reset after changing the optimization goal, or after toggling bxt_tas_optim_multiple_games, to start from scratch without having to replay the whole TAS.

  • bxt_tas_optim_save

    Saves the optimized script.

  • bxt_tas_optim_start

    Starts the optimization.

  • bxt_tas_optim_stop

    Stops the optimization.

  • _bxt_tas_optim_init <script.hltas> <frame number>

    Initializes the optimization with the given script, starting from the given frame.

    You're not meant to use this command directly. Instead, use bxt_tas_optim_init (without arguments) provided in Bunnymod XT, which sets the script name and frame number automatically.

  • _bxt_tas_optim_simulation_done

    Sends simulated frames to the remote server.

    You're not meant to use this command. It's run automatically by bxt-rs in simulator clients.

  • _bxt_tas_optim_simulation_start_recording_frames

    Starts recording frames to send to the remote server.

    You're not meant to use this command. It's run automatically by bxt-rs in simulator clients.

Console Variables

  • bxt_tas_optim_change_single_frames (default: "0")

    Set to 0 to make the optimizer mutate entire frame bulks at once. Set to 1 to make the optimizer mutate individual frames.

    Generally 0 gives better results and produces a script ready to be copy-pasted. 1 can be useful for fine-tuning, e.g. if you're very close but barely not making the jump.

  • bxt_tas_optim_constraint_type (default: ">")

    Type of the constraint. Can be < or > for less-than and greater-than constraint, respectively.

  • bxt_tas_optim_constraint_value (default: "0")

    Value to constraint against.

  • bxt_tas_optim_constraint_variable (default: "")

    Set to a variable to constrain it. Possible values are the same as bxt_tas_optim_variable.

    A constraint is set by bxt_tas_optim_constraint_variable, bxt_tas_optim_constraint_type and bxt_tas_optim_constraint_value. It forces the variable to be less-than or greater-than the value. For example, you can set pos.x < 300 or speed > 500. Then those brute-force attempts that do not satisfy this constraint get discarded.

  • bxt_tas_optim_direction (default: "maximize")

    Direction to optimize bxt_tas_optim_variable towards. Can be minimize or maximize.

  • bxt_tas_optim_frames (default: "0")

    How much of the script, in number of frames, can be mutated in the single-frame mode.

    Use when you want the tail of the script to remain unchanged, but still included in the optimization objective.

  • bxt_tas_optim_multiple_games (default: "0")

    Set to 1 to use multi-game optimization.

    When set to 1, instead of prediction, the optimizer will use game instances launched in parallel to run the script. This results in 100% accurate simulation including entity interaction, but is much slower compared even to accurate prediction.

    You need to start one or more game instances in addition to the one running the optimizer.

  • bxt_tas_optim_random_frames_to_change (default: "6")

    Number of individual frames to mutate on every iteration in single-frame mode.

  • bxt_tas_optim_rhai_file (default: "")

    Set to filename.rhai to use a Rhai script as the optimization objective.

    The optimization objective can be set either with console variables (bxt_tas_optim_variable, bxt_tas_optim_direction and constraints), or as a Rhai script. The script should define three functions:

    • is_valid(curr) that returns whether the brute-force attempt is valid (analogue of constraint),
    • is_better(curr, best) that returns whether the brute-force attempt is better than the best one,
    • to_string(curr) that returns a string representation of the optimization objective.

    Here's an example script:

    fn is_valid(curr) {
        // X pos < -3500
        curr.pos[0] < -3500
    }
    
    fn is_better(curr, best) {
        // New Y pos > best Y pos
        curr.pos[1] > best.pos[1]
    }
    
    fn to_string(curr) {
        // Need to convert to string manually at the moment
        curr.pos[0].to_string()
    }
    

    The script can also define a should_pass_all_frames variable set to true to receive an array of all simulated frames of the brute-force attempt, rather than just the last one. Note that this makes it considerably slower. Here's an example:

    // Set this to true to get all frames rather than just one
    let should_pass_all_frames = true;
    
    fn is_valid(curr) {
        // You can use -1 to grab the last array element like in Python
        curr[-1].pos[0] < -3500
    }
    
    fn is_better(curr, best) {
        // Loop through all frames to find the highest Z we ever reached
        let best_z = best[0].pos[2];
        for player in best {
            if player.pos[2] > best_z {
                best_z = player.pos[2];
            }
        }
    
        let curr_z = curr[0].pos[2];
        for player in curr {
            if player.pos[2] > curr_z {
                curr_z = player.pos[2];
            }
        }
    
        curr_z > best_z
    }
    
    fn to_string(curr) {
        // You can reference variables that you set in is_better() here
        curr_z.to_string()
    }
    

    The Rhai language has an online playground with examples, a VSCode extension and a reference which you can find on its website: https://rhai.rs/.

  • bxt_tas_optim_simulation_accuracy (default: "0")

    Set to 1 to enable whole-map player movement tracing.

    This makes the optimization considerably slower, so only use it when 0 makes the optimizer path go through entities.

  • bxt_tas_optim_variable (default: "pos.x")

    Variable to optimize. Can be pos.x, pos.y, pos.z, vel.x, vel.y, vel.z or speed, which represents the horizontal speed.

TAS recording

Recording of real-time gameplay into a HLTAS script.

This is not perfect and needs a Bunnymod XT patch to set host_frametime directly instead of going through the host_framerate console variable (thus missing precision due to the f64->f32->f64 roundtrip) for better sync. Nevertheless, it was very useful for diagnosing and fixing a number of TAS determinism issues.

Console Commands

  • bxt_tas_recording_start <filename.hltas>

    Starts recording gameplay into a HLTAS script.

  • bxt_tas_recording_stop

    Stops gameplay recording.

TAS server time fix

Fixes server-side movement non-determinism when the player is stuck.

Triangle drawing

Makes bxt-rs able to draw shapes in the 3D space.

Video capture

Recording videos from demos and TAS playback.

Console Commands

  • bxt_cap_start [filename.mp4]

    Starts capturing video. The default filename is output.mp4.

    If the filename ends with .wav, captures only the sound.

  • bxt_cap_stop

    Stops capturing video.

Console Variables

  • bxt_cap_fps (default: "60")

    Frames-per-second of the recorded video.

  • bxt_cap_sampling_exposure (default: "0")

    How much of the sampled frame contributes to it. E.g. 1 means that the whole frame duration is averaged, 0.5 means that half of the frame is averaged, 0.25 means that a quarter of the frame is averaged, and so on. The averaging always happens towards the end of the frame: that is, an exposure of 0.5 means that every frame is an average of the second half of that frame's duration.

    0 disables sampling.

  • bxt_cap_slowdown (default: "1")

    Slowdown factor for the recording.

    For example, 2 means that the video will be two times slower than the realtime playback. Especially useful for TASes.

  • bxt_cap_sound_extra (default: "0")

    How many extra seconds of audio to mix and capture past the end of the recording.

  • bxt_cap_volume (default: "0.4")

    Volume of the recording.

    This is the same as the volume console variable, but for the recorded video. The volume variable itself does not affect the recorded video.

  • _bxt_cap_force_fallback (default: "0")

    Set to 1 to force the use of simple OpenGL capturing instead of the fast GPU-accelerated Vulkan capturing. Try this if you get artifacts on the recorded video.

  • _bxt_cap_override_ffmpeg_args (default: "")

    Extra arguments to pass to FFmpeg.

    When using this variable, you might want to also add some of the following arguments, that bxt-rs adds automatically when this variable is unset: -c:v libx264 -crf 15 -preset ultrafast -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -chroma_sample_location center.

  • _bxt_cap_sampling_min_fps (default: "7200")

    Minimum recording FPS for frames that make up a sampled frame.

_bxt_rng_set

Setting the engine RNG state.

Console Commands

  • _bxt_rng_set "<idum> <iy> <iv[0]> <iv[1]> ... <iv[31]>"

    Sets the non-shared RNG state. The parameter is 34 numbers.

Clone this wiki locally