Skip to content

Instantly share code, notes, and snippets.

@pezcode
Created January 14, 2018 15:25
Show Gist options
  • Save pezcode/b5cf99b6c7f0d146c4846161e0cc64ef to your computer and use it in GitHub Desktop.
Save pezcode/b5cf99b6c7f0d146c4846161e0cc64ef to your computer and use it in GitHub Desktop.
Restores common Dirty Bomb settings after an update or a fresh install.
$backupfolder = 'backup'
$files = 'ShooterGame.ini', 'ShooterInput.ini', 'ShooterUI.ini', 'ShooterEngine.ini'
ForEach($file in $files) {
$backupfile = "$backupfolder\$file"
New-Item $backupfile -Force
Copy-Item $file $backupfile
}
$id = 333930
$execcommands = (
'FogDensity 0'
)
# get Steam install directory (and main library) from the registry
$steam = (Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Valve\Steam -ErrorAction SilentlyContinue).SteamPath -replace '/', '\'
If(!$steam) {
Write-Error "Unable to find Steam folder"
}
# Check if game is installed
If(!(Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Valve\Steam\Apps\$id -ErrorAction SilentlyContinue).Installed) {
Write-Error "Game is not installed"
}
# Find other Steam libraries listed in libraryfolders.vdf
$libraries = @($steam) # create array
$libraries += Get-Content "$steam\steamapps\libraryfolders.vdf" | ForEach-Object {
If($_ -match '^[\s]+"[0-9]+"[\s]+"(?<library>.*)"$') {
$matches.library
}
}
# Find game's appmanifest and read install dir
ForEach($library in $libraries) {
$acfpath = "$library\steamapps\appmanifest_$id.acf"
if(Test-Path $acfpath) {
$gamedir = (Get-Content $acfpath) | ForEach-Object {
If($_ -match '^[\s]+"installdir"[\s]+"(?<dir>.*)"') {
"$library\steamapps\common\" + $matches.dir
}
}
break
}
}
#-exec=exec.txt -nosplash
$execpath = $gamedir + '\Binaries\exec.txt'
$execcommands | Set-Content $execpath
Write-Host @"
Auto exec written to $execpath
Make sure you add the following command to the game's launch options on Steam:
-exec=exec.txt
"@
# YOUR SETTINGS GO HERE
$fov = '73.74' # ToString() uses locale for decimal point, need to use string
$connection_icon = $false # show the network connection quality icon?
$volume = 35 # audio volume in percent
$mouse_sensitivity = '5.006222'
$mouse_smoothing = $false
$console_key = 'Tilde'
$smooth_fps = $false # false defaults to 180fps
$fps_min = 0
$fps_max = 180 #140 # slightly below monitor refresh rate for minimal input lag with G-Sync
$pool_size = 1024 # half your VRAM? default is 160
$longjump_key = 'ThumbMouseButton'
$knife_key = 'Three'
$hud_elements = `
('ChatInputPosition', '(Align=(H=HA_LEFT,V=HA_BOTTOM), Attach=(H=HA_LEFT,V=HA_TOP,VA="Minimap"), PixelOffset=(X=50))'),
('MinimapPosition', '(Align=(H=HA_LEFT,V=HA_TOP), Attach=(H=HA_LEFT,V=HA_BOTTOM,HA="PlayerHealth",VA="PlayerHealth"), PixelOffset=(X=0,Y=-50))'),
('ObituaryMessageLogPosition', '(Align=(H=HA_RIGHT,V=HA_BOTTOM), Attach=(H=HA_RIGHT,V=HA_TOP,VA="Minimap"), PixelOffset=(X=150))'),
('ExpCounterPosition', '(Align=(H=HA_CENTER,V=HA_TOP), Attach=(H=HA_CENTER,V=HA_CENTER), PixelOffset=(Y=75), ShadowOffset=(X=-1, Y=-1))'),
('WeaponAmmoPosition', '(Align=(H=HA_LEFT,V=HA_TOP), Attach=(H=HA_CENTER,V=HA_TOP,VA="PlayerHealth"), PixelOffset=(X=100,Y=0), ShadowOffset=(X=-1,Y=-1))'),
('AbilityCooldownPosition', '(Align=(H=HA_RIGHT,V=HA_TOP), Attach=(H=HA_RIGHT,V=HA_BOTTOM,HA="WeaponAmmo",VA="WeaponAmmo"), PixelOffset=(X=0,Y=-50), ShadowOffset=(X=-1,Y=-1))'),
('PlayerHealthPosition', '(Align=(H=HA_RIGHT,V=HA_BOTTOM), Attach=(H=HA_CENTER,V=HA_BOTTOM), PixelOffset=(X=-100,Y=250), ShadowOffset=(X=-1,Y=-1))'),
('GameWaveTimerPosition', '(Align=(H=HA_LEFT,V=HA_TOP), Attach=(H=HA_CENTER,V=HA_CENTER), PixelOffset=(X=-40,Y=150))'),
('ObjectivePosition', '(Align=(H=HA_LEFT, V=HA_TOP), Attach=(H=HA_LEFT,V=HA_TOP), PixelOffset=(X=50,Y=50))')
# SetBind commands can also be run from autoexec, SetSensitivity needs to be run in a game to have any effect
$commands = `
"SetBind $longjump_key 'Duck | Jump' True",
"SetBind $knife_key 'WeaponSlotOne | StopFire' True",
"SetSensitivity $mouse_sensitivity True"
# need double quotation marks instead of single, but formating strings like above only works with double in PowerShell
$console = $commands -replace "'", '"' -join ' | ' | Out-String
$console | Out-File 'Console.txt'
(Get-Content 'ShooterUI.ini') | ForEach-Object {
ForEach($element in $hud_elements) {
If($_ -match '^' + $element[0] + '=.*') {
$_ = $element[0] + '=' + $element[1]
break
}
}
$_
} | Set-Content 'ShooterUI.ini'
# don't change MasterVolume, otherwise VOIP will be very quiet
(Get-Content 'ShooterGame.ini') `
-replace '(?<=^PlayerDefaultFOV=).*', $fov `
-replace '(?<=^m_bHideConnectionIcon=).*', !$connection_icon `
-replace '(?<=^MusicVolume=).*', $volume `
-replace '(?<=^DialogueVolume=).*', $volume `
-replace '(?<=^SFXVolume=).*', $volume `
| Set-Content 'ShooterGame.ini'
# these don't actually work anymore, need to set in menu/console
(Get-Content 'ShooterInput.ini') `
-replace '(?<=^MouseSensitivity=).*', $mouse_sensitivity `
-replace '(?<=^bEnableMouseSmoothing=).*', $mouse_smoothing `
-replace '(?<=^ConsoleKey=).*', $console_key `
| Set-Content 'ShooterInput.ini'
(Get-Content 'ShooterEngine.ini') `
-replace '(?<=^bSmoothFrameRate=).*', $smooth_fps `
-replace '(?<=^MinSmoothedFrameRate=).*', $fps_min `
-replace '(?<=^MaxSmoothedFrameRate=).*', $fps_max `
-replace '(?<=^PoolSize=).*', $pool_size `
| Set-Content 'ShooterEngine.ini'
$backupfolder = 'backup'
$files = 'ShooterGame.ini', 'ShooterInput.ini', 'ShooterUI.ini', 'ShooterEngine.ini'
ForEach($file in $files) {
$backupfile = "$backupfolder\$file"
If(Test-Path $backupfile) {
Copy-Item $backupfile $file -Force
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment