Need for Speed: Underground 2: Difference between revisions

From LANCommander
(Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|EA Black Box}} |Publishers = {{Game.InfoBox.Publisher|Electronic Arts}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|November 9, 2004}} |Genres = {{Game.InfoBox.Genre|Arcade}} {{Game.InfoBox.Genre|Racing}} | PCGamingWiki = Need_for_Speed:_Underground_2 }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play|Path = SPEED2.EXE|Arguments = |WorkingDirectory = |Primary...")
 
No edit summary
 
Line 9: Line 9:
{{Game.InfoBox.ReleaseDate|Windows|November 9, 2004}}
{{Game.InfoBox.ReleaseDate|Windows|November 9, 2004}}
|Genres =
|Genres =
{{Game.InfoBox.Genre|Arcade}}
{{Game.InfoBox.Genre|Racing}}
{{Game.InfoBox.Genre|Racing}}
| PCGamingWiki = Need_for_Speed:_Underground_2
|PCGamingWiki = Need_for_Speed:_Underground_2}}
}}


{{Game.ActionBox
{{Game.ActionBox
|Actions =  
|Actions =  
{{Game.ActionBox.Row|Name = Play|Path = SPEED2.EXE|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Play|Path = {InstallDir}\SPEED2.EXE|Arguments = |WorkingDirectory = |Primary = True}}
}}
 
 
{{Game.Scripts.Install
|Name = Install Script
|Description =
|RequiresAdmin = False
|Contents =
<syntaxhighlight lang="powershell" line>
$Display = Get-PrimaryDisplay
 
Write-ReplaceContentInFile -Pattern '^ResX=(.+)' -Substitution "ResX=$($Display.Bounds.Width)" -FilePath "$InstallDirectory\scripts\NFSUnderground2.WidescreenFix.ini"
Write-ReplaceContentInFile -Pattern '^ResY=(.+)' -Substitution "ResY=$($Display.Bounds.Height)" -FilePath "$InstallDirectory\scripts\NFSUnderground2.WidescreenFix.ini"
</syntaxhighlight>
}}
           
{{Game.Scripts.NameChange
|Name = Name Change Script
|Description =
|RequiresAdmin = False
|Contents =
<syntaxhighlight lang="powershell" line>
$NewPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$OldPlayerAlias = $OldPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
 
if ($NewPlayerAlias.Length -gt 7) {
    $NewPlayerAlias = $NewPlayerAlias.Substring(0, 7);
}
 
if ($OldPlayerAlias.Length -gt 7) {
    $OldPlayerAlias = $OldPlayerAlias.Substring(0, 7);
}
 
if ((![string]::IsNullOrWhitespace($OldPlayerAlias)) -and (Test-Path "$InstallDirectory\Profiles\NFS Underground 2\$OldPlayerAlias")) {
    Rename-Item -Path "$InstallDirectory\Profiles\NFS Underground 2\$OldPlayerAlias\$OldPlayerAlias" -NewName "$NewPlayerAlias"
    Rename-Item -Path "$InstallDirectory\Profiles\NFS Underground 2\$OldPlayerAlias" -NewName "$NewPlayerAlias"
} else {
    Write-Host "Creating profile directory"
    New-Item -ItemType Directory -Force -Path "$InstallDirectory\Profiles\NFS Underground 2"
    Write-Host "Copying template profile"
    Copy-Item -Path "$InstallDirectory\Profiles\Template" -Destination "$InstallDirectory\Profiles\NFS Underground 2\$NewPlayerAlias" -Recurse   
    Write-Host "Renaming template profile folder"
    Rename-Item -Path "$InstallDirectory\Profiles\NFS Underground 2\$NewPlayerAlias\Template" -NewName "$NewPlayerAlias"
}
 
Write-Host "Patching save file"
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 7 -MinLength 7
 
Edit-PatchBinary -FilePath "$InstallDirectory\Profiles\NFS Underground 2\$NewPlayerAlias\$NewPlayerAlias" -Offset 0xD225 -Data $bytes
 
Read-Host
</syntaxhighlight>
}}
}}

Latest revision as of 03:29, 6 January 2024

Developers
EA Black Box
Publishers
Electronic Arts
Release Date
Windows: November 9, 2004
Genres
Racing
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\SPEED2.EXE True

Install Script

$Display = Get-PrimaryDisplay

Write-ReplaceContentInFile -Pattern '^ResX=(.+)' -Substitution "ResX=$($Display.Bounds.Width)" -FilePath "$InstallDirectory\scripts\NFSUnderground2.WidescreenFix.ini"
Write-ReplaceContentInFile -Pattern '^ResY=(.+)' -Substitution "ResY=$($Display.Bounds.Height)" -FilePath "$InstallDirectory\scripts\NFSUnderground2.WidescreenFix.ini"

Name Change Script

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

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

if ($OldPlayerAlias.Length -gt 7) {
    $OldPlayerAlias = $OldPlayerAlias.Substring(0, 7);
}

if ((![string]::IsNullOrWhitespace($OldPlayerAlias)) -and (Test-Path "$InstallDirectory\Profiles\NFS Underground 2\$OldPlayerAlias")) {
    Rename-Item -Path "$InstallDirectory\Profiles\NFS Underground 2\$OldPlayerAlias\$OldPlayerAlias" -NewName "$NewPlayerAlias"
    Rename-Item -Path "$InstallDirectory\Profiles\NFS Underground 2\$OldPlayerAlias" -NewName "$NewPlayerAlias"
} else {
    Write-Host "Creating profile directory"
    New-Item -ItemType Directory -Force -Path "$InstallDirectory\Profiles\NFS Underground 2"
    Write-Host "Copying template profile"
    Copy-Item -Path "$InstallDirectory\Profiles\Template" -Destination "$InstallDirectory\Profiles\NFS Underground 2\$NewPlayerAlias" -Recurse    
    Write-Host "Renaming template profile folder"
    Rename-Item -Path "$InstallDirectory\Profiles\NFS Underground 2\$NewPlayerAlias\Template" -NewName "$NewPlayerAlias"
}

Write-Host "Patching save file"
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 7 -MinLength 7

Edit-PatchBinary -FilePath "$InstallDirectory\Profiles\NFS Underground 2\$NewPlayerAlias\$NewPlayerAlias" -Offset 0xD225 -Data $bytes

Read-Host