Advertisement
t3h_m00kz

POWERSHELL - Halo 3 - UT2k4 Mod Pipeline

Jan 6th, 2023 (edited)
1,109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <# PARAMETERS #>
  2. param(
  3.    [parameter(helpMessage     ="Convert - DDS to TIF")]
  4.       [bool]$loopScript       =0,  
  5.    [parameter(helpMessage     ="Convert - DDS to TIF")]
  6.       [bool]$DDStoTIF         =0,
  7.    [parameter(helpMessage     ="Import - Bitmaps")]
  8.       [bool]$Bitmaps          =0,
  9.    [parameter(helpMessage     ="Import - Models")]
  10.       [bool]$Models           =1,
  11.    [parameter(helpMessage     ="Import - Models(First Person)")]
  12.       [bool]$ModelsFP         =1,
  13.    [parameter(helpMessage     ="Import - Models(Projectiles)")]
  14.       [bool]$ModelsProjectiles=0,
  15.    [parameter(helpMessage     ="Import - Animations(First Person)")]
  16.       [bool]$FPModelAnimations=0,
  17.    [parameter(helpMessage     ="Import - Sounds")]
  18.       [bool]$Sounds           =0,
  19.    [parameter(helpMessage     ="Extract - Tags to Data")]
  20.       [bool]$StealTags        =0,
  21.    [parameter(helpMessage     ="Extract - Tags to Data")]
  22.       [bool]$stealBitmaps     =0
  23.    )
  24.  
  25. <# INCLUDES #>
  26. . "P:\Program Files\Steam\steamapps\common\H3EK\init.ps1" -windowName "UT2k4" -outputFile "ut2k4_output"
  27.  
  28. <# WEAPON ARRAY #>
  29. $weaponList=[System.Collections.ArrayList]::new()
  30. $weaponList.Add("Assault_Rifle")
  31. $weaponList.Add("Assault_Rifle_2k3")
  32. #$weaponList.Add("AVRiL")
  33. #$weaponList.Add("Ball_Launcher")
  34. #$weaponList.Add("Bio_Rifle")
  35. #$weaponList.Add("Flak_Cannon")
  36. #$weaponList.Add("Grenade_Launcher")
  37. #$weaponList.Add("Ion_Painter")
  38. #$weaponList.Add("Lightning_Gun")
  39. #$weaponList.Add("Link_Gun")
  40. #$weaponList.Add("Link_Gun_2k3")
  41. #$weaponList.Add("Mine_Layer")
  42. #$weaponList.Add("Minigun")
  43. #$weaponList.Add("Redeemer")
  44. #$weaponList.Add("Rocket_Launcher")
  45. #$weaponList.Add("Shield_Gun")
  46. #$weaponList.Add("Shock_Rifle")
  47. #$weaponList.Add("Shock_Rifle_2k3")
  48. #$weaponList.Add("Sniper_Rifle")
  49. #$weaponList.Add("Target_Painter")
  50. #$weaponList.Add("Translocator")
  51. #$weaponList.Add("Translocator2k3")
  52.  
  53. <# VARIABLES #>
  54. [string]$dirRoot          =("P:\Program Files\Steam\steamapps\common\H3EK")
  55. [string]$dirFMod          =("$dirRoot"+"\fmod\PC")
  56. [string]$dirProject       =("m00kz\Objects\Weapons\ut2k4")
  57. [string]$dirTags          =("$dirRoot"+"\tags\"+"$dirProject")
  58. [string]$dirData          =("$dirRoot"+"\data\"+"$dirProject")
  59. [string]$dirTagsSound     =("$dirTags"+"\SOUND")
  60. [string]$dirDataSound     =("$dirData"+"\SOUND")
  61. [string]$dirDataSoundRaw  =("$dirData"+"\SOUND_RAW")
  62. [string]$dirDataSoundFixed=("$dirData"+"\SOUND_FIXES")
  63.  
  64. <# FUNCTIONS #>
  65. function convertDDStoTIF{#Convert Unreal-extracted *.DDS files to Halo-compatible *.TIFF
  66.    printActionName -actionName "BITMAPS - DDS TO TIF"
  67.    $ddsFiles=Get-ChildItem $dirData -File -recurse -include *.dds
  68.    forEach($ddsFile in $ddsFiles){
  69.       Push-Location $ddsFile.PSParentPath
  70.       & "$dirData\texconv.exe" $ddsFile.fullname -y -ft tif -f R8G8B8A8_UNORM
  71.       Pop-Location
  72.       }
  73.    return
  74.    }
  75.  
  76. function importBitmaps{#Import *.TIFF files to .bitmap tags
  77.    printActionName -actionName "BITMAPS - TIF TO TAGS"
  78.    foreach($w in $weaponList){
  79.       .\tool.exe bitmaps $dirProject\$w\bitmaps
  80.       }
  81.    return
  82.    }
  83.  
  84. function importModels{#Import third person *.JMS models to *.model tags
  85.    printActionName -actionName "MODELS - JMS TO TAGS"
  86.    foreach($w in $weaponList){
  87.       .\tool.exe bulk-import-model-folder $dirProject\$w\models final
  88.       }
  89.    return
  90.    }
  91.  
  92. function importModelsFP{#Import first person *.JMS models to *.model tags
  93.    printActionName -actionName "MODELS(FP)- JMS TO TAGS"
  94.    foreach($w in $weaponList){
  95.       .\tool.exe bulk-import-model-folder $dirProject\$w\fp\models final
  96.       }
  97.    return
  98.    }
  99.  
  100.    function importModelsProjectiles{#Import projectile *.JMS models to *.model tags
  101.       printActionName -actionName "MODELS - JMS TO TAGS"
  102.       foreach($w in $weaponList){
  103.          $projectileFolders=get-childitem -Force -Recurse("$dirData\$w\projectiles")
  104.          foreach ($projectileFolder in ($projectileFolders).Name){
  105.             .\tool.exe bulk-import-model-folder $dirProject\$w\projectiles\$projectileFolder\models final
  106.             }
  107.          }
  108.       return
  109.       }
  110.  
  111. function importFPModelAnimations{#Import *.JMA / *.JMM / etc animation files to *.model_animation_graph tags
  112.    printActionName -actionName "ANIMATIONS(FP)- JMA TO TAGS"
  113.    foreach($w in $weaponList){
  114.       write-host (".\tool.exe fp-model-animations-uncompressed $dirProject\$w\fp objects\characters\masterchief\fp $dirProject\$w\fp\models")
  115.       .\tool.exe fp-model-animations "$dirProject\$w\fp" "objects\characters\masterchief\fp" "$dirProject\$w\fp\models"}
  116.    return
  117.    }
  118. function runSounds{#Audio pipeline
  119.    restoreSoundDefaults
  120.    convertWAVtoH3
  121.    importSound
  122.    return
  123.    }
  124.  
  125. function restoreSoundDefaults{#Restore our audio setup to default so we're not risking breaking references
  126.    remove-item   -Force -Recurse("$dirDataSound"+"\")
  127.    remove-item   -Force -Recurse("$dirTagsSound"+"\")
  128.    Copy-Item     -Force         ("$dirFMod"+"\BACKUP\sfx.fsb.info") -Destination("$dirFMod"+"\sfx.fsb.info")
  129.    Copy-Item     -Force         ("$dirFMod"+"\BACKUP\sfx.fsb")      -Destination("$dirFMod"+"\sfx.fsb")
  130.    Copy-Item     -Force -Recurse("$dirDataSoundRaw"+"\")            -Destination("$dirDataSound"+"\")
  131.    get-childitem -Force -Recurse("$dirDataSound"+"\")               -include *.wav
  132.    | foreach-object{remove-item -Force -path $_.fullname}
  133.    return
  134.    }
  135.  
  136. function convertWAVtoH3{#Convert unreal-exported .WAV files to 16-bit PCM format
  137.    $wavFiles=Get-ChildItem "$dirDataSoundRaw" -File -recurse -include *.wav
  138.    forEach($wav in $wavFiles){
  139.       $wavStructure=$wav -replace ".*RAW"
  140.       $wavSource   =("$dirDataSoundRaw"+"$wavStructure")
  141.       $wavDest     =("$dirDataSound"   +"$wavStructure")
  142.       & "$dirData\ffmpeg.exe" -y -acodec pcm_s16le -i $wavSource $wavDest
  143.       }
  144.    foreach($item in Get-ChildItem $dirDataSoundFixed){
  145.       Copy-Item -Force -Recurse $item -Destination $dirDataSound
  146.       }#Manually-converted *.wav files in case ffmpeg breaks any of them
  147.    return
  148.    }
  149.  
  150. function importSound{#Import 16-bit PCM .wavs(Stored in sfx.fsb, indexed in sfx.fsb.info, refrenced by *.sound tags)
  151.    foreach($subFolder in Get-ChildItem $dirDataSound){
  152.       foreach($soundFolder in Get-ChildItem $subFolder){
  153.          $parsedFolder=$soundFolder -replace ".*data\\"
  154.          .\tool.exe sounds-single-layer $parsedFolder test sfx
  155.          }
  156.       }
  157.    return
  158.    }
  159.  
  160. function stealTags{# LITERALLY STEAL BUNGIE'S TAGS
  161.    $RIPDIR = "fx\"
  162.    $RIPFROM = ("$dirRoot"+"\tags\"+"$RIPDIR")
  163.    foreach($tag in Get-ChildItem($RIPFROM) *.* -recurse
  164.    | Where-Object{! $_.PSIsContainer}){
  165.       $parsedTag=($tag).fullname -replace ".*h3ek\\"
  166.       .\tool.exe extract-import-info $parsedTag
  167.       }
  168.    return
  169.    }
  170.  
  171. <# MAIN ROUTINE #>
  172. function mainRoutine(){
  173.    setWindow
  174.    Push-Location $dirRoot
  175.    if($DDStoTIF)         {convertDDStoTIF}
  176.    if($Bitmaps)          {importBitmaps}
  177.    if($Models)           {importModels}
  178.    if($ModelsFP)         {importModelsFP}
  179.    if($ModelsProjectiles){importModelsProjectiles}
  180.    if($FPModelAnimations){importFPModelAnimations}
  181.    if($Sounds)           {runSounds}
  182.    if($StealTags)        {stealTags}
  183. }
  184.  
  185. while ($loopScript){
  186.    mainRoutine
  187.    promptForRestart
  188.    }
  189.  
  190. if (!$loopScript){
  191.    mainRoutine
  192.    endScript
  193.    exit
  194.    }
  195.  
  196. <# you're gay #>
  197.  
  198.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement