Star Wars: Jedi Knight - Dark Forces II

From LANCommander
Revision as of 21:57, 8 January 2024 by DoctorDalek (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
LucasArts
Publishers
LucasArts
Release Date
Windows: September 30, 1997
Genres
Shooter
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\openjkdf2-64.exe True

Name Change Script

$NewPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$OldPlayerAlias = $OldPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'

# Trim a string down to a specified amount of characters
if ($OldPlayerAlias.Length -gt 15) {
    $OldPlayerAlias = $OldPlayerAlias.Substring(0, 15);
}

if ($NewPlayerAlias.Length -gt 15) {
    $NewPlayerAlias = $NewPlayerAlias.Substring(0, 15);
}

# Scaffold an "old" profile using the included template
if (!$OldPlayerAlias) {
    $OldPlayerAlias = "ProfileTemplate";
    Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$InstallDirectory\player\$OldPlayerAlias" -Recurse
}

Copy-Item -Path "$InstallDirectory\player\$OldPlayerAlias" -Destination "$InstallDirectory\player\$NewPlayerAlias" -Recurse
Remove-Item "$InstallDirectory\player\$OldPlayerAlias" -Recurse -ErrorAction Ignore

Rename-Item "$InstallDirectory\player\$NewPlayerAlias\$OldPlayerAlias.plr" "$InstallDirectory\player\$NewPlayerAlias\$NewPlayerAlias.plr"
Rename-Item "$InstallDirectory\player\$NewPlayerAlias\$OldPlayerAlias.mpc" "$InstallDirectory\player\$NewPlayerAlias\$NewPlayerAlias.mpc"

# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '"gameName": "(.+)",' -Substitution """gameName"": ""$NewPlayerAlias's Game""," -FilePath "$InstallDirectory\registry.json"
Write-ReplaceContentInFile -Pattern '"playerShortname": "(.+)",' -Substitution """playerShortname"": ""$NewPlayerAlias""," -FilePath "$InstallDirectory\registry.json"