forked from p2sr/srconfigs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoexec.cfg
executable file
·370 lines (312 loc) · 17.3 KB
/
autoexec.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// srconfigs 0.9.0 - autoexec
// +============= IMPORTANT NOTICE =============+
// | Unless you know what you're doing, DO NOT |
// | MODIFY THIS FILE! |
// | Chances are, any config changes you're |
// | trying to make should be done in extra.cfg, |
// | *not* here. Otherwise, easily updating |
// | srconfigs without losing your changes will |
// | become near-impossible. Check the README |
// | for more details. |
// +=============================================+
// Load SAR
plugin_load sar
// Update SAR if needed
sar_update pre exit
// sar_update release exit
// Statistics!
sar_import_stats stats
sar_on_exit sar_export_stats stats
sar_function srconfigs_about "echo $'srconfigs are a set of config files for speedrunning Portal 2 and its mods.$'; echo $'More information at: https://github.com/p2sr/srconfigs$'; echo $'Version: 0.9.0$'"
// Handy svar so things can detect srconfigs if they need
svar_set __srconfigs 1
// Disable a weird HUD that can appear in demo playback
sar_disable_coop_score_hud 1
// Blacklist all commands from demo playback; they just cause issues
sar_demo_blacklist_all 1
// Stop the game from going to sleep when it loses focus
sar_disable_no_focus_sleep 1
cond "!game=reloaded" sar_on_config_exec snd_mute_losefocus 0
// Allow OOB vision
cond "!game=mel" r_portal_use_pvs_optimization 0
// Fix portal rendering
r_portal_fastpath 0
r_PortalTestEnts 0
// Fix Mel / Speedrun Mod crashes
save_screenshot 0
// Developer 1 settings; the actual developer mode is set in
// per-category configs
contimes 6
phys_penetration_error_time 0
// Helper alias for saveload binds
sar_function saveload "save $1; load $1"
// Number of quicksaves to keep as backup (quick, quick01, quick02, quick03)
save_history_count 3
// This alias is deprecated, but I'll keep it around for a bit for back
// compat. This is functionally equivalent as 'load' doesn't work in
// coop anyway
sar_alias do_load non_cm_only load
// Reloaded-specific commands
cond "game=reloaded" sar_on_load conds coop "hud_saytext_time 12" "hud_saytext_time 0"
cond "game=reloaded" sar_function +att1 "+attack $1; att1"
cond "game=reloaded" sar_function -att1 "-attack $1"
cond "game=reloaded" sar_function +att2 "+attack2 $1; att2"
cond "game=reloaded" sar_function -att2 "-attack2 $1"
cond "game=reloaded" sar_function +att3 "+attack3 $1"
cond "game=reloaded" sar_function -att3 "-attack3 $1"
cond "game=reloaded" alias att1 "ent_fire @att1 Trigger"
cond "game=reloaded" alias att2 "ent_fire @att2 Trigger"
cond "game=reloaded" alias att3 "+attack3"
cond "game=reloaded" alias using "ent_fire @using Trigger"
cond "game=reloaded" alias holo "cond !coop ent_fire @toggle_ghosting Trigger"
cond "game=reloaded" alias +attack3 "cond !coop ent_fire @caller Trigger; cond !coop ent_fire @att3 Trigger"
cond "game=reloaded" alias -attack3 nop
// Thinking with Time Machine-specific commands (dev way better than reloaded!)
cond "game=twtm" alias "+US" "ent_fire @tm callscriptfunction UseP"
cond "game=twtm" alias "-US" ""
cond "game=twtm" alias "+AT1" "+attack; ent_fire @tm callscriptfunction Fire1"
cond "game=twtm" alias "-AT1" "-attack"
cond "game=twtm" alias "+AT2" "+attack2; ent_fire @tm callscriptfunction Fire2"
cond "game=twtm" alias "-AT2" "-attack2"
cond "game=twtm" alias "+CROUCH" "+duck; ent_fire @tm callscriptfunction CroouchIn"
cond "game=twtm" alias "-CROUCH" "-duck; ent_fire @tm callscriptfunction CroouchOut"
cond "game=twtm" alias "+JP" "+jump; ent_fire @tm callscriptfunction Jump"
cond "game=twtm" alias "-JP" "-jump"
cond "game=twtm" alias "+FW" "ent_fire @tm callscriptfunction StartFW"
cond "game=twtm" alias "-FW" "ent_fire @tm callscriptfunction StopFW"
cond "game=twtm" alias "+BW" "ent_fire @tm callscriptfunction StartBW"
cond "game=twtm" alias "-BW" "ent_fire @tm callscriptfunction StopBW"
cond "game=twtm" alias "+RT" "ent_fire @tm callscriptfunction StartRT"
cond "game=twtm" alias "-RT" "ent_fire @tm callscriptfunction StopRT"
cond "game=twtm" alias "+LT" "ent_fire @tm callscriptfunction StartLT"
cond "game=twtm" alias "-LT" "ent_fire @tm callscriptfunction StopLT"
// persistent svar defaults
svar_set __empty ""
sar_function __set_if_empty cond "?$1=?__empty" svar_set $1 "$2"
sar_function __set_if_empty_persist "__set_if_empty $1 $'$2$'; svar_persist $1"
__set_if_empty_persist sp_use_save 2
__set_if_empty_persist mel_use_save 0
__set_if_empty_persist aptag_use_save 0
__set_if_empty_persist no_dialogue_toasts 0
__set_if_empty_persist no_dialogue_toasts_sp 0
__set_if_empty_persist no_dialogue_toasts_coop 0
__set_if_empty_persist no_taunt_toasts_coop 0
__set_if_empty_persist show_map_name_coop 1
__set_if_empty_persist show_blank_fades 1
__set_if_empty_persist coop_cm_enable_hud 1
__set_if_empty_persist coop_no_stopvideos 0
__set_if_empty_persist coop_no_remoteview 0
__set_if_empty_persist coop_no_remoteview_lobby 0
__set_if_empty_persist solocoop_fullscreen 0
__set_if_empty_persist cm_attempt_counter 1
__set_if_empty_persist cm_ghost_server -1
__set_if_empty_persist cm_keep_pb_only 0
__set_if_empty_persist chapter_il_betsrighter 1
__set_if_empty_persist chapter_il_fly 1
__set_if_empty_persist useswap_invert 0
__set_if_empty_persist useswap_both 0
__set_if_empty_persist supershoot_use_orange 0
__set_if_empty_persist fullbright_amount 0.1
__set_if_empty_persist anypc_transition_time 0
__set_if_empty_persist enable_menu_transitions 0
__set_if_empty_persist viewsnap_dpi_scale 500
__set_if_empty_persist viewsnap_enable_on_load 0
__set_if_empty_persist viewsnap_crazy_box easy
__set_if_empty_persist demo_folder_name "demos"
__set_if_empty_persist fullgame_demo_name "%Y-%m-%d_%H-%M-%S/fullgame"
__set_if_empty_persist anypc_demo_name "%Y-%m-%d_%H-%M-%S/anypc"
__set_if_empty_persist sp_cm_demo_name "chapter$chapter/$map/$map"
__set_if_empty_persist amc_demo_name "$role/%Y-%m-%d_%H-%M-%S/amc"
__set_if_empty_persist ac_demo_name "$role/%Y-%m-%d_%H-%M-%S/ac"
__set_if_empty_persist solocoop_demo_name "%Y-%m-%d_%H-%M-%S/solocoop"
__set_if_empty_persist coop_cm_demo_name "$role/course$course/$map/$map"
__set_if_empty_persist il_demo_name "chapter$chapter/$map/$map"
__set_if_empty_persist chapter_il_demo_name "$role/$chapter_course/%Y-%m-%d_%H-%M-%S/$chapter_course"
__set_if_empty_persist celeste_demo_name "%Y-%m-%d_%H-%M-%S/celeste"
__set_if_empty_persist reverse_demo_name "%Y-%m-%d_%H-%M-%S/reverse"
__set_if_empty_persist workshop_demo_name "%Y-%m-%d_%H-%M-%S/workshop"
// Always keep a backup of the last few demos, just in case you
// accidentally overwrite something
sar_demo_overwrite_bak 3
// Don't show in-game input hints
sar_on_config_exec gameinstructor_enable 0
// Prevent EHM from happening, as it's currently banned in everything
sar_prevent_ehm 1
// SAR HUD
sar_hud_order_bottom text
sar_hud_font_index 68
sar_hud_x 5
sar_hud_y 5
sar_hud_spacing 5
sar_hud_bg 1
sar_hud_velocity 3
sar_hud_position 2
sar_hud_angles 1
cond "!game=mel" sar_hud_demo 2
sar_toast_tag_set_color error FF3333
// We always want to be recording, so set this, even if the category
// uses autorecord
sar_record_at_demo_name ""
// HACKHACK: we don't record demos in Mel
cond "!game=mel" sar_record_at 0
// HACKHACK: really fucking cursed special case to mitigate inexplicable
// game crash
cond "!game=mel" sar_on_load cond "map=mp_coop_wall_5" sar_record_at 120
cond "!game=mel" sar_on_load cond "!map=mp_coop_wall_5" sar_record_at 0
// Deprecated utility function
sar_function __choose conds "$1" "$2" "$3"
// Prevent lag spikes on Lasers and Fling Block
sar_on_load conds "map=mp_coop_laser_2 | map=mp_coop_catapult_wall_intro" "sar_always_transmit_heavy_ents 1" "sar_always_transmit_heavy_ents 0"
// Add all the exposed aliases
exec aliases
// Create extra categories
exec mkcats
// Toast settings
sar_toast_width 500
sar_toast_setpos bottom center
// Perform map detection, setting the appropriate svars
cond "game=portal2 | game=srm" sar_on_load exec map_detect/portal2
cond "game=aptag" sar_on_load exec map_detect/aptag
cond "game=mel" sar_on_load exec map_detect/mel
cond "game=reloaded" sar_on_load exec map_detect/reloaded
cond "game=twtm" sar_on_load exec map_detect/twtm
// Map list
sar_function __printmap "sar_echo_nolf FFFFFF $' $'; conds $'!menu & ?chapter=$1 & ?map=$2$' $'sar_echo 00FF00 $3 - $4$' $'sar_echo FFFFFF $3 - $4$'"
cond "game=portal2 | game=srm" sar_function map_list exec map_list/portal2
cond "game=aptag" sar_function map_list exec map_list/aptag
cond "game=mel" sar_function map_list exec map_list/mel
cond "game=reloaded" sar_function map_list exec map_list/reloaded
cond "game=twtm" sar_function map_list exec map_list/twtm
// Black magic to create categories
sar_function __force_warn "sar_echo FFFF00 Forcing category $1. Run 'auto' to re-enable automatic category selection.; svar_set __force_cat 1"
// Stores the number of categories (increased whenever a category is added)
svar_set __detect_len 0
// Iterate over all categories
// $__loopcmd is executed every iteration and $__cat_i is the current index,
// which increments until it reaches $__detect_len
sar_function __cat_loop "svar_set __loopcmd $'$1$'; svar_set __cat_i 0; __cat_loop_h"
sar_function __cat_loop_h cond "!?__cat_i=?__detect_len" "$__loopcmd; svar_add __cat_i 1; __cat_loop_h"
// Loop through the categories and set $category if the condition is true.
// If the category has changed, stop demo recording
sar_function __detect "svar_set __old_category $category; __cat_loop $'sar_expand sar_expand __detect_$$$$__cat_$$__cat_i$'; cond !?category=?__old_category stop"
// HACKHACK: we don't record demos in Mel
cond "game=mel" sar_alias __record nop
cond "!game=mel" sar_alias __record cond "!?__suppress_record=1" record ""
// The 'cat command' is ran every load while using a category, as well as
// when switching to it.
sar_function add_cat_cmd "sar_alias $1 $'stop; svar_set category $1; __force_warn $1; __run_cat_$1; __record$'; svar_set __cat_$__detect_len $1; sar_alias __run_cat_$1 $'$2$'; sar_alias __detect_$1 nop; svar_add __detect_len 1"
sar_function add_cat add_cat_cmd $1 "exec cats/$1"
sar_function detect_cat sar_alias __detect_$1 cond "$2" svar_set category $1
sar_function default_cat svar_set __detect_default $1
sar_alias list_cats __cat_loop __list_cats
sar_function __list_cats sar_expand "sar_echo_nolf ffffff $$__cat_$__cat_i - ; sar_alias __detect_$$__cat_$__cat_i"
// Category autoselection
sar_alias auto cond "?__force_cat=1" "svar_set __force_cat 0; stop; __detect; sar_expand __run_cat_$category; __record"
cond "game=srm" sar_on_load "svar_capture_quiet __tmp sm_mode; sar_expand __capture_sm_mode $__tmp"
cond "game=srm" sar_function __capture_sm_mode "svar_set __sm_mode $6"
sar_on_load cond "!?__force_cat=1" __detect
// Expect the category exec to specifically suppress recording every
// load if it wants to
sar_on_load svar_set __suppress_record 0
// Run category exec on load
sar_on_load sar_expand __run_cat_$category
// Remove the tile animations, but not in Any%
sar_on_load conds "?category=anypc | ?enable_menu_transitions=1" "ui_transition_effect 1" "ui_transition_effect 0"
conds "?enable_menu_transitions=1" "ui_transition_effect 1" "ui_transition_effect 0"
// If we're suppressing recording, unset sar_record_at
cond "!game=mel" sar_on_load cond "?__suppress_record=1" sar_record_at -1
// Create the built-in categories
add_cat fullgame
cond "game=portal2" add_cat anypc
cond "game=portal2" add_cat sp_cm
cond "game=portal2 | game=reloaded" add_cat amc
cond "game=portal2" add_cat ac
cond "game=portal2" add_cat coop_cm
cond "game=portal2 | game=reloaded" add_cat solocoop
cond "game=srm" add_cat celeste
cond "game=srm" add_cat reverse
cond "game=mel | game=aptag | game=reloaded" add_cat il
cond "game=portal2 | game=srm | game=mel | game=aptag" add_cat chapter_il
add_cat workshop
// Add the auto-selection for all the built-in categories
default_cat fullgame
detect_cat fullgame "!cm & !coop & ?builtin_map=1"
cond "game=portal2" detect_cat sp_cm "cm & !coop & ?builtin_map=1"
cond "game=portal2 | game=reloaded" detect_cat amc "!cm & coop & ?builtin_map=1"
cond "game=portal2" detect_cat coop_cm "cm & coop & ?builtin_map=1"
cond "game=srm" detect_cat celeste "?__sm_mode=2"
cond "game=srm" detect_cat reverse "?__sm_mode=4"
detect_cat workshop workshop
// Coop map name toasts
sar_toast_tag_set_duration map_name forever
sar_on_load sar_toast_tag_dismiss_all map_name
sar_on_load cond "game=portal2 & coop & ?show_map_name_coop=1 & (?category=amc | ?category=ac | ?category=solocoop | ?category=chapter_il)" sar_expand sar_toast_create map_name "$formatted_map"
// Coop taunt toasts
sar_toast_tag_set_duration taunt forever
sar_on_load sar_toast_tag_dismiss_all taunt
sar_on_load cond "game=portal2 & coop & !?no_taunt_toasts_coop=1 & (?category=amc | ?category=ac | ?category=solocoop | ?category=chapter_il)" __taunt_toast
sar_alias __taunt_toast cond "map=mp_coop_lobby_3 & (?__lobby=2 | ?__lobby=3) | map=mp_coop_rat_maze" sar_toast_create taunt "[taunt]"
// Dialogue fade toasts
sar_toast_tag_set_duration fade forever
sar_on_load sar_toast_tag_dismiss_all fade
sar_on_load cond "game=portal2 & coop & !?no_dialogue_toasts=1 & !?no_dialogue_toasts_coop=1 & (?category=amc | ?category=ac | ?category=solocoop | ?category=chapter_il)" exec dialogue_toasts/coop
sar_on_load cond "game=portal2 & !coop & !?no_dialogue_toasts=1 & !?no_dialogue_toasts_sp=1 & (?category=fullgame | ?category=chapter_il)" exec dialogue_toasts/sp
// CM autoreset
sar_on_load sar_speedrun_autoreset_clear
sar_on_load cond "?category=sp_cm | ?category=coop_cm" "__tmp_cvar_save sar_con_filter_default; sar_con_filter_default 0; sar_expand sar_speedrun_autoreset_load autoreset/$map; __tmp_cvar_restore sar_con_filter_default"
// CM attempt counter
sar_on_load svar_set __attempt_counter 0
sar_on_load cond "?cm_attempt_counter=1 & (?category=sp_cm | ?category=coop_cm)" svar_set __attempt_counter 1
sar_on_load cond "!(same_map & ?__attempt_counter=1)" svar_set __attempts 1
sar_on_load cond "same_map & ?__attempt_counter=1" svar_add __attempts 1
sar_on_load cond "!?__attempt_counter=1" sar_hud_set_text 100 ""
sar_on_load cond "?__attempt_counter=1" sar_expand sar_hud_set_text 100 "Attempts: $__attempts"
// CM ghost server
exec cm_ghost
sar_alias chat "conds coop sar_chat ghost_chat; nop"
// Show speedrun result after CM run
sar_on_flags cond "?category=sp_cm | ?category=coop_cm" sar_speedrun_result
// We want to dispatch aliases to handle coop resetting where needed
// This general framework allows a) both players to run a command when
// the reset is run and b) a command to be run after both players finish
// resetting.
sar_function setup_coop_reset "sar_alias do_reset _coop_reset; sar_alias _coop_reset_both $'$1$'; sar_alias _coop_reset_done $'$2$'"
sar_alias _coop_reset "cond coop sar_coop_reset_progress; _coop_reset_both; cond !coop _coop_reset_done"
sar_on_coop_reset_remote _coop_reset_both
sar_on_coop_reset_done _coop_reset_done
// Category cond aliases for rule differences
sar_alias cm_only cond "?category=sp_cm | ?category=coop_cm"
sar_alias non_cm_only cond "!?category=sp_cm & !?category=coop_cm"
sar_function cat_only cond "?category=$1" $+2
sar_function non_cat_only cond "!?category=$1" $+2
// Add the mtrigger categories and the sar_on_load execs
// We do this *after* running the category exec, so that no_mtriggers is set if
// necessary
cond "game=portal2" exec mtriggers/mtriggers
// Same for the chapter categories
cond "!game=reloaded" sar_function run_cur_chapter "svar_set __cur_chapter $'$chapter$'; chapter_il"
cond "!game=reloaded" sar_function run_chapter "svar_set __cur_chapter $'$1$'; chapter_il"
cond "game=portal2 | game=srm" exec chapter_cats/portal2
cond "game=aptag" exec chapter_cats/aptag
cond "game=mel" exec chapter_cats/mel
sar_on_coop_spawn cond "!?coop_no_stopvideos=1 & !map=mp_coop_start" stopvideos
sar_on_coop_spawn cond "!?coop_no_remoteview=1 & !(?coop_no_remoteview_lobby=1 & map=mp_coop_lobby_3)" +remote_view
sar_alias __get_screen_size "__tmp_toast_save; sar_toast_setpos top left; svar_from_cvar height sar_toast_y; svar_from_cvar width sar_toast_x; sar_toast_setpos bottom right; svar_from_cvar __tmp sar_toast_y; svar_add height __tmp; svar_from_cvar __tmp sar_toast_x; svar_add width __tmp; svar_from_cvar __tmp sar_toast_width; svar_add width __tmp; __tmp_toast_restore"
__get_screen_size
sar_alias ss_pip_align sar_pip_align
sar_alias ss_pip_fullscreen "ss_pipscale 1; ss_pip_bottom_offset 0; ss_pip_right_offset 0"
// Viewsnaps!
exec viewsnap
// extra.cfg could change the default category; make sure it's set
// correctly afterwards
// In the interim, use srconfigs' default (fallback edgecase if the
// user does do_reset before config.cfg execs)
sar_expand "svar_set category $__detect_default; __run_cat_$__detect_default"
sar_on_config_exec sar_expand "svar_set category $__detect_default; __run_cat_$__detect_default"
clear
srconfigs_about
sar_about
echo "" // Separate srconfigs output from other stuff
exec con_filter
// Exec personal config
exec extra