-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGGSTModPorter.ps1
48 lines (48 loc) · 2.54 KB
/
GGSTModPorter.ps1
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
#Requires -PSEdition Core
<## "seriously though, someone should like
make a program or something to expedite slot porting
particle headers and folder names and all that" ##>
if (!$args) {
exit
}
$InputPath = Get-Item $args[0]
$ModName = $InputPath.BaseName
<## "I'm sure it'd be really simple if you knew how to use the tools, it's just
edit a couple files with an incremental adjustment
drop them into another program
grab the result file, rename it, put it in folder
repeat" ##>
$ResponseFile = New-Item -Name 'filelist.txt' -Value @"
"$InputPath\*.*" "..\..\..\*.*"
"@ -Force
$OutputDir = New-Item -ItemType Directory -Path "$ModName Paks" -Force
$Range = 11..1
# Iterate through numbers 1 to 11 and pak the mod for that slot
foreach($i in $Range) {
$Num = '{0:D2}' -f $i
$Colour = "Color$Num"
## "considering the standardised format (color01/02/03 etc), I don't think it should take too much manual direction"
Rename-Item -Path "$ModName\RED\Content\Chara\*\Costume01\Material\Color*" -NewName $Colour
# Stuff for editing uasset headers in hex
$CBytes = [System.Text.Encoding]::UTF8.GetBytes('Color')
$CHex = [Convert]::ToHexString($CBytes)
$Target = $CHex + "(3[0-9]){2}" # Regex to match "Color" followed by two digits (in hex)
$ColourBytes = [System.Text.Encoding]::UTF8.GetBytes($Colour)
$ColourHex = [Convert]::ToHexString($ColourBytes) # Target colour/number (in hex)
## "just tell it to look in the area, grab any uasset file and change any instance of that by +1"
$UAssets = Get-ChildItem "$ModName\RED\Content\Chara\*\Costume01\Material\$Colour" -Filter *.uasset
foreach($UAsset in $UAssets) { # Iterate through all the uasset files and change the Color headers
# Read uasset binary and convert it to hex
$ByteStream = Get-Content -Path $UAsset.FullName -AsByteStream -ReadCount 0
$UAssetHex = [Convert]::ToHexString($ByteStream)
# Run regex on the data and convert it back to binary
$NewAssetHex = $UAssetHex -replace $Target, $ColourHex
$NewStream = [Convert]::FromHexString($NewAssetHex)
# Write the updated binary back to the file
Set-Content -Path $UAsset.FullName -Value $NewStream -AsByteStream
}
.\UnrealPak.exe "$InputPath.pak" "-create=$ResponseFile" -compress
Move-Item -Path "$InputPath.pak" -Destination "$OutputDir\$ModName $Num.pak" -Force
}
Remove-Item -Path $ResponseFile
## "[...] you will eventually figure it out yourself and achieve enlightenment" -CatScrem