Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Uncomment to make a seperate exe for the patched version. (Comment out the other option)
- $source = 'game.exe'
- $output = 'game_patched.exe'
- #Uncomment to make a backup of the original exe and output to the original name
- #Make sure to delete 'game_original.exe' if they ever put out an update or it'll use the old version!
- #$source = 'game_original.exe'
- #$output = 'game.exe'
- Function SwapCostumes{
- #Costume names
- $script:costumes =@{
- 'Daily'='H050'
- 'Swim'='H052'
- 'Yukata'='H053'
- 'Towel'='H054'
- #Note: Sophie only supports Daily
- }
- #if you want to use the original costume just comment out the line
- $JokerCostumeChanges=1 #use 2 for 'hotfix', 1 for latest.
- $SophieCostumeChanges=2 #seems to require 2 replacements for both versions
- for ($num = 1 ; $num -le $JokerCostumeChanges ; $num++)
- {
- SetCostume 'Joker' 'Daily'
- }
- SetCostume 'Skull' 'Daily'
- SetCostume 'Panther' 'Daily'
- SetCostume 'Fox' 'Daily'
- SetCostume 'Queen' 'Swim'
- SetCostume 'Noir' 'Swim'
- SetCostume 'Navi' 'Swim'
- for ($num = 1 ; $num -le $SophieCostumeChanges ; $num++){
- SetCostume 'Sophie' 'Daily' #for some reason requires two changes
- }
- }
- #Remaining of file is just logic
- Function LoadFile{
- #If the source file does not exist, but the destination does, make a backup of the destination and use that.
- if (-not(Test-Path -Path $source -PathType Leaf) -and(Test-Path -Path $output -PathType Leaf)) {
- try {
- Copy-Item $output -Destination $source
- }
- catch {
- throw $_.Exception.Message
- }
- }
- Write-Host "Reading file"
- $script:content = Get-Content -path $source -Raw
- Write-Host "Finished Reading file"
- }
- Function Unicode {
- Begin {
- $output=[System.Text.StringBuilder]::new()
- }
- Process {
- $output.Append($(
- if ($_ -is [int]) { [char]::ConvertFromUtf32($_) }
- else { [string]$_ }
- )) | Out-Null
- }
- End { $output.ToString() }
- }
- function Pad{
- param (
- [string]$shortName
- )
- $longname='CE1MotorCharacterSetting', 0xEF, 0xBC, 0xBB, $shortName, 0xEF, 0xBC, 0xBD |Unicode
- $length=$longname.Length
- [int]$paddedLength=[Math]::floor($longname.length/8)
- $paddedLength*=8
- #if($longname.length%8 -ne 0)
- #{
- $paddedLength+=8
- #}
- $longname=$longname.PadRight($paddedLength,"`0")
- return $longname
- }
- function InnerSwap{
- param (
- [string]$original_short,
- [string]$costume_short
- )
- $original=Pad $original_short
- $costume=Pad $costume_short
- $index=$script:content.IndexOf($original)
- $extratext = 'CE1MotorCharacterSetting'
- if($index -ne -1){
- if($original.Length -ne $costume.Length){
- if($original.Length -le $costume.Length){
- $extraCount=$costume.Length-$original.Length
- $original+=$extratext.Substring(0,$extraCount)
- }
- if($original.Length -gt $costume.Length){
- $costume=$costume.PadRight($original.Length,"`0")
- }
- }
- Write-Host "Swapping" $original_short "for" $costume_short
- [regex]$pattern = $original
- $script:content=$pattern.replace($script:content, $costume, 1)
- }else {
- Write-Host "Couldn't find " $original_short
- }
- }
- function SetCostume {
- param (
- [string]$original,
- [string]$costume
- )
- $names = @{
- 'Joker' = 'Hero', '0'
- 'Skull' = 'Ryuji', '1'
- 'Panther' = 'Ann', '3'
- 'Fox' = 'Yusuke', '4'
- 'Queen' = 'Makoto', '5'
- 'Noir' = 'Haru', '6'
- 'Navi' = 'Futaba', '7'
- 'Sophie' = 'Sophia', '8'
- }
- $info=$names[$original]
- $name=$info[0]
- $num=$info[1]
- $costumenum=$script:costumes[$costume]
- $originalfile='H000'+$num+'_'+$original
- $replacement=$costumenum+$num+'_'+$name+'_'+$costume
- InnerSwap $originalfile $replacement
- }
- Function SaveFile{
- Write-Host "Writing file"
- Set-Content -Path $output -Value $script:content
- Write-Host "Finished"
- }
- LoadFile
- SwapCostumes
- SaveFile
Advertisement