Difference between revisions of "SAR"

From P2SR Wiki

m
(Rewrote SAR page to give more broad explanations and include several SAR 1.12 features)
Line 68: Line 68:
 
</gallery>
 
</gallery>
  
==Commands==
+
== Speedrun Timer ==
  
====Shorter Load Times====
+
One of SAR's main uses is for timing runs. SAR will interface with
The following commands in [https://github.com/Blenderiste09/SourceAutoRecord/releases Blenderiste's version of SAR] are used to stop the game from loading visuals that acompany the load screens. These visuals actively stop the game from loading while they're being displayed, so disabling them helps load times.
+
LiveSplit (or other speedrun timing programs that support it), and
 +
automatically start/split/stop runs. This is done through the
 +
<code>sar_speedrun</code> category of commands. Most these commands are
 +
fairly self explanatory; the most important ones are below.
  
<code>ui_loadingscreen_fadein_time 0</code>
+
* <code>sar_speedrun_category [name]</code>: sets the category being run (affects how the run timing starts and stops).
  
<code>ui_loadingscreen_mintransition_time 0</code>
+
* <code>sar_speedrun_offset [ticks]</code>: offsets the timer by a certain amount at the start of the run. Used, for instance, with the Container Ride save.
  
<code>ui_loadingscreen_transition_time 0</code>
+
* <code>sar_speedrun_time_pauses [0/1]</code>: affects whether pauses are timed. You are allowed to omit pauses if you do not use them to gain an advantage.
  
===Disabling the Challenge Mode Leaderboard Popup===
+
* <code>sar_speedrun_smartsplit [0/1]</code>: enabled by default. Will prevent SAR from splitting on maps which you have previously entered in this run. Should be disabled in coop runs!
This command automatically closes the leaderboard popup at the start of map in challenge mode. It is now allowed in all single player challenge mode levels.
 
  
'''Note: Not recommended for use in coop, as it can cause issues with the start of the level, and potentially make your run invalid.'''
+
* <code>sar_speedrun_reset</code>: resets a run in preparation for another.
 +
 
 +
In fullgame runs, the timer offset used for the Container Ride save is '''16868''', so <code>sar_speedrun_offset 16868</code>.
 +
 
 +
=== Custom Categories ===
 +
 
 +
SAR 1.12 allows the creation of custom categories for sar_speedrun based
 +
on entity inputs.
 +
 
 +
<code>sar_speedrun_category_create [name] [map] [entity] [input] [map] [entity] [input]</code>
 +
<code>sar_speedrun_category_remove [name]</code>
 +
 
 +
To create a category, you give:
 +
* The map in which the speedrun starts
 +
 
 +
* The entity and input which trigger the start of the run
 +
 
 +
* The map in which the speedrun ends
 +
 
 +
* The entity and input which trigger the end of the run
 +
 
 +
Entity names are targetnames by default, but a leading ! will cause it
 +
to be treated as a classname instead. For instance, this is a small
 +
custom category that times within Wakeup; from the start of the map to
 +
placing Wheatley in his receptacle.
 +
 
 +
<code>sar_speedrun_category_create Wakeup sp_a1_wakeup !portal_stats_controller OnLevelStart sp_a1_wakeup socket_powered_rl Trigger</code>
 +
 
 +
This is a custom category named "Wakeup" which:
 +
 
 +
* Starts in Wakeup
 +
 
 +
* Looks at the entity with classname <code>portal_stats_controller</code>
 +
 
 +
* Watches for its <code>OnLevelStart</code> input to start the timer
 +
 
 +
* Ends in Wakeup
 +
 
 +
* Looks at the entity with targetname <code>socket_powered_rl</code>
 +
 
 +
* Watches for its <code>Trigger</code> input to end the timer
 +
 
 +
== Demo Recording ==
 +
 
 +
If you are recording demos (for run verification or analysis), the command <code>sar_autorecord 1</code> will automatically begin recording a new demo every level load or restart. Make sure to start recording demos at the start of your run with <code>record demoname</code>, and stop recording after the timer stops with <code>stop</code>.
 +
 
 +
== Loading Fixes ==
 +
 
 +
SAR contains several commands to improve loading times:
 +
 
 +
* <code>ui_loadingscreen_transition_time</code>
 +
 
 +
* <code>ui_loadingscreen_fadein_time</code>
 +
 
 +
* <code>ui_loadingscreen_mintransition_time</code>
 +
 
 +
* <code>sar_disable_mat_snapshot_recompute</code>
 +
 
 +
* <code>sar_prevent_peti_materials_loading</code>
 +
 
 +
* <code>sar_disable_progress_bar_update</code>
 +
 
 +
* <code>sar_shane_loads</code>
 +
 
 +
* <code>sar_shane_norendering</code>
 +
 
 +
To make using these easier, there is one unified command to set all of them to preset values.
 +
 
 +
<code>sar_fast_load_preset [preset]</code>
 +
 
 +
The following presets exist:
 +
* <code>none</code> - disables all loading fixes
 +
 
 +
* <code>normal</code> - enables most loading fixes, but retains loading screen and progress bar rendering
 +
 
 +
* <code>sla</code> - enables all loading fixes which do not affect SLA
 +
 
 +
* <code>full</code> - enables all loading fixes
 +
 
 +
The <code>full</code> preset is generally recommended for most runners.
 +
 
 +
== CM Leaderboard ==
 +
 
 +
SAR can disable the leaderboard popup at the start of the map in challenge mode. It is allowed in all single player CM levels.
 +
 
 +
'''Note: Not recommended for use in coop, as it can cause issues with the start of the level, and potentially invalidate your run.'''
  
 
<code>sar_disable_challenge_stats_hud 1</code>
 
<code>sar_disable_challenge_stats_hud 1</code>
  
 +
== HUDs ==
 +
 +
SAR adds many optional HUDs on top of the base game, including the "SAR HUD", input HUD (ihud), portal HUD (lphud), vphysics HUD (vphys_hud), and more.
 +
 +
=== SAR HUD ===
 +
 +
SAR's main HUD is effectively a more extensible version of <code>cl_showpos</code>, displaying useful information in a simple text form somewhere on your scren. It allows for displaying arbitrary text; higher precision on position and angle values; demo and session times; customizable fonts and position; and more. Elements of this HUD are enabled and tweaked through the <code>sar_hud_xxxx</code> commands. For instance, <code>sar_hud_position</code> and <code>sar_hud_angles</code> will display your position and angle like <code>cl_showpos</code> does. To replicate the behaviour of <code>cl_showpos 1</code>, run the following commands:
 +
 +
* <code>sar_hud_velocity 1</code>
 +
 +
* <code>sar_hud_position 2</code>
 +
 +
* <code>sar_hud_angles 2</code>
 +
 +
* <code>sar_hud_precision 2</code>
 +
 +
You can customize the color, font, and spacing of the SAR HUD using these commands:
 +
 +
* <code>sar_hud_default_font_index</code>
 +
 +
* <code>sar_hud_default_font_color</code>
 +
 +
* <code>sar_hud_default_spacing</code>
 +
 +
* <code>sar_hud_default_padding_x</code>
 +
 +
* <code>sar_hud_default_padding_y</code>
 +
 +
You can reorder HUD elements using <code>sar_hud_default_order_top</code> and <code>sar_hud_default_order_bottom</code>.
 +
 +
The SAR HUD also allows you to write arbitrary text on the screen. A line of text is added with <code>sar_hud_set_text [id] [text]</code>; for example, <code>sar_hud_set_text 0 "flyin into portals"</code> will set the piece of text with ID 0 to "flyin into portals". Pieces of text can then be shown or hidden from the HUD using <code>sar_hud_show_text [id]</code> and <code>sar_hud_hide_text [id]</code>. For instance, this config provides a portal funneling toggle alias named "funneling_change" which displays this text when funneling is enabled:
 +
 +
<code>
 +
sar_hud_set_text 0 "flyin into portals"
 +
 +
alias "funneling_off" "sv_player_funnel_into_portals 0; sar_hud_hide_text 0; alias funneling_change funneling_on"
 +
 +
alias "funneling_on" "sv_player_funnel_into_portals 1; sar_hud_show_text 0; alias funneling_change funneling_off"
 +
 +
funneling_on
 +
</code>
 +
 +
=== Input HUD ===
 +
 +
Another commonly used HUD is the input HUD (ihud). This is a HUD element which displays a subset of your inputs to the game on a keyboard overlay. It is enabled using the <code>sar_ihud</code> variable, which can be given one of several values:
 +
 +
* <code>sar_ihud 0</code> - disable the HUD entirely
 +
 +
* <code>sar_ihud 1</code> - show WASD movement
 +
 +
* <code>sar_ihud 2</code> - show all of the above, as well as duck, jump, and use
 +
 +
* <code>sar_ihud 3</code> - show all of the above, as well as attack and attack2 (portal shots)
 +
 +
* <code>sar_ihud 4</code> - show all of the above, as well as speed and reload (not generally used in Portal 2)
 +
 +
This HUD can be used to see inputs in demos, which can be useful when, for instance, learning movement.
 +
 +
=== Portal HUD ===
 +
 +
The Least Portals HUD (lphud) shows how many portals you've shot in total across a play session. It is enabled through <code>sar_lphud</code>, and its portal count can be reset using <code>sar_lphud_set 0</code>. The LP HUD accurately accounts for save loads and other level changes, so is useful in category extensions like 100 Portals.
 +
 +
=== Vphys HUD ===
 +
 +
'''Note: This HUD exists for routing purposes. It is not allowed in runs, and is therefore cheat protected.'''
 +
 +
The vphys HUD displays some physics information on-screen. It is useful for routers and those trying to understand various glitches in the game; it shows the states of your physics hitboxes, your current funnel handle and count, etc. It can be enabled using <code>sar_vphys_hud 1</code>.
 +
 +
== Ghosts ==
 +
 +
== Config+ ==
 +
 +
Config+ is the name for two SAR commands allowing more complex configurations. The first is the <code>seq</code> command. This command takes an arbitrary number of commands as arguments, and runs them all one tick after another. For instance:
 +
 +
<code>seq "say 1" "say 2" "say 3"</code>
 +
 +
This will output 1 to the chat, then one tick later 2, then one tick later 3.
 +
 +
The second command is <code>sar_exec_condition</code>. This command allows you to register a command to be run on map load '''in certain conditions'''.
 +
 +
<code>sar_exec_condition [condition] [command]</code>
 +
 +
This can be used, for instance, to automatically apply execs for different categories or levels; as an example, the condition "map=mp_coop_start & !orange" will make a command run when you load into Calibration as blue. Conditions work as follows:
 +
 +
* <code>map=map_name</code> checks whether you are in a certain map
 +
 +
* <code>prev_map=map_name</code> checks the last map you were in
 +
 +
* <code>same_map</code> checks whether the current map is the same as the previous map
  
===Full Game Commands===
+
* <code>coop</code> checks whether you are in coop
  
====Timer Offsets (Container Ride Save)====
+
* <code>orange</code> checks whether you are playing as orange (P-Body)
For Container Ride Save, the command <code>sar_speedrun_offset</code> is used to offset the timer to account for the skipped cutscene. The full value used is 16868, so <code>sar_speedrun_offset 16868</code>
 
  
====Replacement Larger cl_showpos====
+
* <code>!</code> is logical NOT; if put before a condition, it inverts it (e.g. the condition <code>!orange</code> will run '''unless''' you are playing as orange)
The <code>cl_showpos 1</code> values are very small. Using <code>sar_hud</code> allows you to change to a larger font type. The three commmands that replace <code>cl_showpos 1</code> are:
 
  
*<code>sar_hud_velocity 1</code>
+
* <code>&</code> is logical AND; it chains conditions, requiring both to be true (e.g. <code>coop & !orange</code> will only run if you are playing as blue in coop)
  
*<code>sar_hud_position 2</code>
+
* <code>|</code> is logical OR; it chains conditions, requiring at least one to be true (e.g. <code>map=sp_a1_intro1 | map=sp_a1_intro2</code> will run in both Container Ride and Portal Carousel)
  
*<code>sar_hud_angles 2</code>
+
* Parentheses can be used to group expressions
  
The <code>sar_hud_precision</code> command is coming to SAR 1.12 soon, and will allow you to round to better emulate <code>cl_showpos 1</code>
+
For example, the following condition would run a coop_orange exec when you loaded into a coop map as orange:
  
====Demo Recording====
+
<code>sar_exec_condition "coop & orange" "exec coop_orange"</code>
If you are using [[demo]] recording for your verification on speedrun.com, using the command <code>sar_autorecord 1</code> will automatically start recording a new demo every new level and restart. Make sure to start a demo recording at the start of your run with <code>record demoname</code>, and to use the command <code>stop</code> after the timer stops, after moonshot at the end of your run.
 
  
====Reseting a Run====
+
== ZachStats ==
To reset a speedrun simply input <code>sar_speedrun_reset</code>
 
  
====Timing / Not Timing Pauses====
+
== Freecam ==
If you wish for SAR to not continue timing the run when paused, use <code>sar_speedrun_time_pauses 0</code> as it is set to <code>1</code> by default (Note: Pausing to gain any sort of advantage will disqualify your run. ie checking coordinates for coordinate specific lineups)
 
  
 
[[Category:Plugin]]
 
[[Category:Plugin]]

Revision as of 07:33, 15 February 2021

NeKz.jpg

Source Auto Record (SAR)


Source Auto Record is a Portal 2 Plugin developed by NeKz. The plugin is widely used by most if not all Portal 2 speedrunners across all different categories. It adds a wide variety of useful commands, and quality of life improvements that make running the game easier, and at times, more accurate.

How to install

SAR is very easy to install and use. To install, start by downloading your desired version from github (Linked in the info box at the top).

Windows Firewall Issues

It's important to note that Windows often doesn't trust .dll files from github. There is a chance that downloads of this plugin will result in windows defender or other anti-virus programs automatically deleting the file. You will need to go and manually add exceptions for the file in any directory you keep it in (more than likely the downloads folder, and your portal2 folder).

Loading SAR in Portal 2

Portal 2 can load .dll plugins through the console command plugin_load pluginname. This command will search the default directory of \steamapps\common\Portal 2 and \steamapps\common\Portal 2\portal2, so your \Portal 2 folder, or \portal2 folder is where you will want to place SAR.

Notes

  • Ensure that SAR is installed in your actual install location. Be sure to check this by browsing local files through the steam properties of the game.
  • All plugins are unloaded after the game is closed. Every time you reopen Portal 2, the plugin will be unloaded, it is recommended you add the plugin_load sar line to your autoexec so that you will not need to reload the plugin every time you launch the game.
  • Portal 2 Speedrun Mod (p2sm) uses SAR for timing as well. But the mod reads from your base game install, so you do not need any special installation for SAR with p2sm. Just install SAR normally for portal 2.

Configuring with Livesplit

.asl files are used to interface with livesplit, so using sar with livesplit is fairly simple following these steps.

1. Create a new file called sar.asl (the folder does not matter as long as you can find it), or alternatively, download the already made file from the Resources page on Speedrun.com

2. Copy and Paste the information from this link into the file, and save it.

3. Open Livesplit with Portal 2 splits (splits can be found at here).

4. Right-click and select Edit Layout

5. Select the large + icon at the top left.

6. Go to Control

7. Select Scriptable Auto Splitter and enter the file directory (Ex: C:\Livesplit\Components\sar.asl)

8. Right click on Livesplit, and hover "Compare Against", and select "Game Time"


Trouble Shooting

  • Livesplit sometimes needs to be ran as an admin on your machine to work. If Livesplit isn't updating, run Livesplit as an admin.
  • Attempting to run Livesplit while Livesplit is still located in it's original ZIP file will cause issues, be sure to extract.
  • Be sure to disable the Autosplitter built into to Livesplit through the Edit Splits... tab. This will interfere with SAR's autosplitter
  • Ensure you haven't accidentally unchecked any of the options boxes in the settings for the Scriptable Autosplitter. (Start, Split & Reset)
  • Make sure your livesplit SAR.asl file is an .asl file, and not a text file, and try remaking the file to ensure there are no issues.
  • On fresh windows installs, there can often be dependencies that aren't installed. If all steps have been followed, and SAR is still not loading, check your device drivers, and install other applications that are common on Windows machines (can include other games). Try installing these dependencies:

Speedrun Timer

One of SAR's main uses is for timing runs. SAR will interface with LiveSplit (or other speedrun timing programs that support it), and automatically start/split/stop runs. This is done through the sar_speedrun category of commands. Most these commands are fairly self explanatory; the most important ones are below.

  • sar_speedrun_category [name]: sets the category being run (affects how the run timing starts and stops).
  • sar_speedrun_offset [ticks]: offsets the timer by a certain amount at the start of the run. Used, for instance, with the Container Ride save.
  • sar_speedrun_time_pauses [0/1]: affects whether pauses are timed. You are allowed to omit pauses if you do not use them to gain an advantage.
  • sar_speedrun_smartsplit [0/1]: enabled by default. Will prevent SAR from splitting on maps which you have previously entered in this run. Should be disabled in coop runs!
  • sar_speedrun_reset: resets a run in preparation for another.

In fullgame runs, the timer offset used for the Container Ride save is 16868, so sar_speedrun_offset 16868.

Custom Categories

SAR 1.12 allows the creation of custom categories for sar_speedrun based on entity inputs.

sar_speedrun_category_create [name] [map] [entity] [input] [map] [entity] [input] sar_speedrun_category_remove [name]

To create a category, you give:

  • The map in which the speedrun starts
  • The entity and input which trigger the start of the run
  • The map in which the speedrun ends
  • The entity and input which trigger the end of the run

Entity names are targetnames by default, but a leading ! will cause it to be treated as a classname instead. For instance, this is a small custom category that times within Wakeup; from the start of the map to placing Wheatley in his receptacle.

sar_speedrun_category_create Wakeup sp_a1_wakeup !portal_stats_controller OnLevelStart sp_a1_wakeup socket_powered_rl Trigger

This is a custom category named "Wakeup" which:

  • Starts in Wakeup
  • Looks at the entity with classname portal_stats_controller
  • Watches for its OnLevelStart input to start the timer
  • Ends in Wakeup
  • Looks at the entity with targetname socket_powered_rl
  • Watches for its Trigger input to end the timer

Demo Recording

If you are recording demos (for run verification or analysis), the command sar_autorecord 1 will automatically begin recording a new demo every level load or restart. Make sure to start recording demos at the start of your run with record demoname, and stop recording after the timer stops with stop.

Loading Fixes

SAR contains several commands to improve loading times:

  • ui_loadingscreen_transition_time
  • ui_loadingscreen_fadein_time
  • ui_loadingscreen_mintransition_time
  • sar_disable_mat_snapshot_recompute
  • sar_prevent_peti_materials_loading
  • sar_disable_progress_bar_update
  • sar_shane_loads
  • sar_shane_norendering

To make using these easier, there is one unified command to set all of them to preset values.

sar_fast_load_preset [preset]

The following presets exist:

  • none - disables all loading fixes
  • normal - enables most loading fixes, but retains loading screen and progress bar rendering
  • sla - enables all loading fixes which do not affect SLA
  • full - enables all loading fixes

The full preset is generally recommended for most runners.

CM Leaderboard

SAR can disable the leaderboard popup at the start of the map in challenge mode. It is allowed in all single player CM levels.

Note: Not recommended for use in coop, as it can cause issues with the start of the level, and potentially invalidate your run.

sar_disable_challenge_stats_hud 1

HUDs

SAR adds many optional HUDs on top of the base game, including the "SAR HUD", input HUD (ihud), portal HUD (lphud), vphysics HUD (vphys_hud), and more.

SAR HUD

SAR's main HUD is effectively a more extensible version of cl_showpos, displaying useful information in a simple text form somewhere on your scren. It allows for displaying arbitrary text; higher precision on position and angle values; demo and session times; customizable fonts and position; and more. Elements of this HUD are enabled and tweaked through the sar_hud_xxxx commands. For instance, sar_hud_position and sar_hud_angles will display your position and angle like cl_showpos does. To replicate the behaviour of cl_showpos 1, run the following commands:

  • sar_hud_velocity 1
  • sar_hud_position 2
  • sar_hud_angles 2
  • sar_hud_precision 2

You can customize the color, font, and spacing of the SAR HUD using these commands:

  • sar_hud_default_font_index
  • sar_hud_default_font_color
  • sar_hud_default_spacing
  • sar_hud_default_padding_x
  • sar_hud_default_padding_y

You can reorder HUD elements using sar_hud_default_order_top and sar_hud_default_order_bottom.

The SAR HUD also allows you to write arbitrary text on the screen. A line of text is added with sar_hud_set_text [id] [text]; for example, sar_hud_set_text 0 "flyin into portals" will set the piece of text with ID 0 to "flyin into portals". Pieces of text can then be shown or hidden from the HUD using sar_hud_show_text [id] and sar_hud_hide_text [id]. For instance, this config provides a portal funneling toggle alias named "funneling_change" which displays this text when funneling is enabled:

sar_hud_set_text 0 "flyin into portals"

alias "funneling_off" "sv_player_funnel_into_portals 0; sar_hud_hide_text 0; alias funneling_change funneling_on"

alias "funneling_on" "sv_player_funnel_into_portals 1; sar_hud_show_text 0; alias funneling_change funneling_off"

funneling_on

Input HUD

Another commonly used HUD is the input HUD (ihud). This is a HUD element which displays a subset of your inputs to the game on a keyboard overlay. It is enabled using the sar_ihud variable, which can be given one of several values:

  • sar_ihud 0 - disable the HUD entirely
  • sar_ihud 1 - show WASD movement
  • sar_ihud 2 - show all of the above, as well as duck, jump, and use
  • sar_ihud 3 - show all of the above, as well as attack and attack2 (portal shots)
  • sar_ihud 4 - show all of the above, as well as speed and reload (not generally used in Portal 2)

This HUD can be used to see inputs in demos, which can be useful when, for instance, learning movement.

Portal HUD

The Least Portals HUD (lphud) shows how many portals you've shot in total across a play session. It is enabled through sar_lphud, and its portal count can be reset using sar_lphud_set 0. The LP HUD accurately accounts for save loads and other level changes, so is useful in category extensions like 100 Portals.

Vphys HUD

Note: This HUD exists for routing purposes. It is not allowed in runs, and is therefore cheat protected.

The vphys HUD displays some physics information on-screen. It is useful for routers and those trying to understand various glitches in the game; it shows the states of your physics hitboxes, your current funnel handle and count, etc. It can be enabled using sar_vphys_hud 1.

Ghosts

Config+

Config+ is the name for two SAR commands allowing more complex configurations. The first is the seq command. This command takes an arbitrary number of commands as arguments, and runs them all one tick after another. For instance:

seq "say 1" "say 2" "say 3"

This will output 1 to the chat, then one tick later 2, then one tick later 3.

The second command is sar_exec_condition. This command allows you to register a command to be run on map load in certain conditions.

sar_exec_condition [condition] [command]

This can be used, for instance, to automatically apply execs for different categories or levels; as an example, the condition "map=mp_coop_start & !orange" will make a command run when you load into Calibration as blue. Conditions work as follows:

  • map=map_name checks whether you are in a certain map
  • prev_map=map_name checks the last map you were in
  • same_map checks whether the current map is the same as the previous map
  • coop checks whether you are in coop
  • orange checks whether you are playing as orange (P-Body)
  • ! is logical NOT; if put before a condition, it inverts it (e.g. the condition !orange will run unless you are playing as orange)
  • & is logical AND; it chains conditions, requiring both to be true (e.g. coop & !orange will only run if you are playing as blue in coop)
  • | is logical OR; it chains conditions, requiring at least one to be true (e.g. map=sp_a1_intro1 | map=sp_a1_intro2 will run in both Container Ride and Portal Carousel)
  • Parentheses can be used to group expressions

For example, the following condition would run a coop_orange exec when you loaded into a coop map as orange:

sar_exec_condition "coop & orange" "exec coop_orange"

ZachStats

Freecam