Skip to content

Instantly share code, notes, and snippets.

@tpill90
Created September 26, 2024 00:06
Show Gist options
  • Save tpill90/ee4c16b548ee3d6a67bf3ad3443d6253 to your computer and use it in GitHub Desktop.
Save tpill90/ee4c16b548ee3d6a67bf3ad3443d6253 to your computer and use it in GitHub Desktop.
Script to apply Frostpunk Balance Mod
# Applies the patches for the Frostpunk Balance Mod found at https://www.nexusmods.com/frostpunk/mods/4
# This script assumes that you've already downloaded and extracted the mod contents
# to your Frostpunk install directory. Once you've done that just run this script and
# the mod should be automatically applied.
cd "C:\Program Files (x86)\Steam\steamapps\common\Frostpunk"
# Checking if we're already patched, so we dont' try to do it again
$alreadyPatched = (Get-FileHash .\common.dat -Algorithm MD5).Hash -eq "722379f95a0e9168130b7607fb06c012" -and `
(Get-FileHash .\common.idx -Algorithm MD5).Hash -eq "b99f3f5b4b4205bb689fe8086bcd1c5f" -and `
(Get-FileHash .\templates.dat -Algorithm MD5).Hash -eq "d4224f7ccd6996a523cd086143bd5c9f" -and `
(Get-FileHash .\templates.idx -Algorithm MD5).Hash -eq "80f5e9873ce8911ff80059fba65ead15"
if($alreadyPatched)
{
Write-Host "Frostpunk balance patch is already applied!"
return
}
Write-Host "Checking original files to make sure we're on the right version"
$hashCheck = (Get-FileHash .\common.dat -Algorithm MD5).Hash -eq "1392fbb363122f09f656ba6020c8119b" -and `
(Get-FileHash .\common.idx -Algorithm MD5).Hash -eq "293e12475f5d7e04898c4ea0f7a72152" -and `
(Get-FileHash .\templates.dat -Algorithm MD5).Hash -eq "1dcf79fbc663909aa28494b9796d9d6c" -and `
(Get-FileHash .\templates.idx -Algorithm MD5).Hash -eq "ae1f9e85b4920c18c443a2adac39c5b7"
if($hashCheck -eq $false)
{
Write-Host "Original files are not the correct version! Cannot continue with patching!" -ForegroundColor Red
return
}
Write-Host "Making a backup of the original game files"
Copy-Item common.idx common.idx.original
Copy-Item common.dat common.dat.original
Copy-Item templates.idx templates.idx.original
Copy-Item templates.dat templates.dat.original
# Getting xdelta if we don't already have it
if(-Not(Test-Path xdelta3.exe))
{
Write-Host "xdelta3 was not found. Downloading it now..."
$xdeltaUrl = "https://github.com/jmacd/xdelta-gpl/releases/download/v3.1.0/xdelta3-3.1.0-x86_64.exe.zip"
Invoke-WebRequest $xdeltaUrl -OutFile "xdelta.zip"
Expand-Archive -Force "xdelta.zip" -DestinationPath .
Copy-Item xdelta3-3.1.0-x86_64.exe xdelta3.exe
}
Write-Host "Patching" -ForegroundColor Yellow
./xdelta3 -f -d -D -s common.idx.original common.idx-balance-mod.vcdiff common.idx
./xdelta3 -f -d -D -s common.dat.original common.dat-balance-mod.vcdiff common.dat
./xdelta3 -f -d -D -s templates.idx.original templates.idx-balance-mod.vcdiff templates.idx
./xdelta3 -f -d -D -s templates.dat.original templates.dat-balance-mod.vcdiff templates.dat
Write-Host "Verifying everything worked"
$patchSuccessful = (Get-FileHash .\common.dat -Algorithm MD5).Hash -eq "722379f95a0e9168130b7607fb06c012" -and `
(Get-FileHash .\common.idx -Algorithm MD5).Hash -eq "b99f3f5b4b4205bb689fe8086bcd1c5f" -and `
(Get-FileHash .\templates.dat -Algorithm MD5).Hash -eq "d4224f7ccd6996a523cd086143bd5c9f" -and `
(Get-FileHash .\templates.idx -Algorithm MD5).Hash -eq "80f5e9873ce8911ff80059fba65ead15"
if($patchSuccessful)
{
Write-Host "Frostpunk balance patch applied successfully!" -ForegroundColor Green
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment