Skip to content

Instantly share code, notes, and snippets.

@LucasOe
Last active November 30, 2023 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucasOe/ed5b507c08af2914df2126d5a3580924 to your computer and use it in GitHub Desktop.
Save LucasOe/ed5b507c08af2914df2126d5a3580924 to your computer and use it in GitHub Desktop.
Powershell module for detecting conflicts between Witcher 3 mods
# Usage
# 1. Download quickbms.exe and witcher3.bms (The ScriptMerger files are outdated):
# http://aluigi.altervista.org/papers/quickbms.zip
# http://aluigi.altervista.org/bms/witcher3.bms
# 2. Place this file into a directory next to quickbms.exe and witcher3.bms
# 3. Load this module in your PowerShell profile
$quickbmsPath = "$PSScriptRoot\quickbms.exe"
$witcherbmsPath = "$PSScriptRoot\witcher3.bms"
# To show conflicts between two (or more) mods, run `Find-WitcherConflicts <mod1> <mod2> <...>` inside the Powershell console.
# For example: `Find-WitcherConflicts modHDReworkedProject modBrothersInArms`
# To list every conflicting mod file, run this script with only one mod as an argument.
# For example: `Find-WitcherConflicts modBrothersInArms`
function Find-WitcherConflicts {
$outputs = New-Object System.Collections.Generic.List[System.Object]
$modCount = $args.Count
$args | ForEach-Object {
$arg = $_
$output = Show-WitcherBundles $arg
$outputs += $output
# if only one argument is provided, comapare agains every other mods
if ($modCount -eq 1) {
Write-Host "Looking for conflicts. This may take a while!`n"
Get-ChildItem -Directory -Filter "mod*" | Select-Object -ExpandProperty Name | ForEach-Object {
$mod = $_
if ($mod -ne $arg) {
$modOutput = Show-WitcherBundles $mod
if ($modOutput.Length -gt 0) {
$conflicts = Compare-Object -ReferenceObject $output -DifferenceObject $modOutput -PassThru -ExcludeDifferent | Out-String
if ($conflicts.Length -gt 0) { Write-Host "$mod`n$conflicts"}
}
}
}
}
}
if ($modCount -gt 1) { Compare-Object @outputs -PassThru -ExcludeDifferent }
}
# List every bundled file in the mods provided
function Show-WitcherBundles {
$args | ForEach-Object {
$arg = $_
if (Test-Path -Path $arg) {
$modOutput = (. $quickbmsPath -l -F "$arg/content/blob0.bundle" $witcherbmsPath "./" 2>$null)
$files = $modOutput.ForEach({ ($_ -split '\s+')[3] })
return $files
} else {
Write-Error "$arg doesn't exist in the current directory" -ErrorAction Stop
}
}
}
Export-ModuleMember -Function Find-WitcherConflicts
Export-ModuleMember -Function Show-WitcherBundles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment