Battlefield Vietnam: Difference between revisions
DoctorDalek (talk | contribs) (Created new page for Battlefield Vietnam) |
DoctorDalek (talk | contribs) No edit summary |
||
Line 5: | Line 5: | ||
{{Game.InfoBox.Developer|Digital Illusions CE: Canada}} | {{Game.InfoBox.Developer|Digital Illusions CE: Canada}} | ||
|Publishers = | |Publishers = | ||
{{Game.InfoBox. | {{Game.InfoBox.Publisher|Electronic Arts}} | ||
|Release Date = | |Release Date = | ||
{{Game.InfoBox.ReleaseDate|Windows|March 14, 2004}} | {{Game.InfoBox.ReleaseDate|Windows|March 14, 2004}} | ||
Line 14: | Line 14: | ||
{{Game.ActionBox | {{Game.ActionBox | ||
|Actions = | |Actions = | ||
{{Game.ActionBox.Row|Name = Play|Path = {InstallDir}\BfVietnam.exe|Arguments = |WorkingDirectory = |Primary = True}} | {{Game.ActionBox.Row|Name = Play Battlefield Vietnam|Path = {InstallDir}\BfVietnam.exe|Arguments = |WorkingDirectory = |Primary = True}} | ||
}} | }} | ||
Line 136: | Line 136: | ||
Write-ReplaceContentInFile -Pattern 'game.setPlayerName "(.+)"' -Substitution "game.setPlayerName ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$NewPlayerAlias\GeneralOptions.con" | Write-ReplaceContentInFile -Pattern 'game.setPlayerName "(.+)"' -Substitution "game.setPlayerName ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$NewPlayerAlias\GeneralOptions.con" | ||
</syntaxhighlight> | |||
}} | |||
{{Game.Scripts.KeyChange | |||
|Name = Key Change Script | |||
|Description = | |||
|RequiresAdmin = False | |||
|Contents = | |||
<syntaxhighlight lang="powershell" line> | |||
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE" | |||
$AllocatedKey = $AllocatedKey.Replace("-", "") | |||
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts" | |||
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games" | |||
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Battlefield Vietnam" | |||
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Battlefield Vietnam\ergc" | |||
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Battlefield Vietnam\ergc" -Value "$AllocatedKey" -Force | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} |
Latest revision as of 00:38, 22 February 2024
Developers | |
---|---|
Digital Illusions CE: Canada | |
Publishers | |
Electronic Arts | |
Release Date | |
Windows: March 14, 2004 | |
Genres | |
Shooter | |
View at PCGamingWiki |
Actions
Name | Path | Arguments | Working Directory | Primary |
---|---|---|---|---|
Play Battlefield Vietnam | {InstallDir}\BfVietnam.exe | True |
Install Script
Automatically sets the 4:3 resolution for the current display in video settings. Make sure to copy the ProfileTemplate as described in the name change script.
# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
#$Display = Get-PrimaryDisplay
# Bounds accessible via $Resolution.Height, $Resolution.Width
#$Resolution = Convert-AspectRatio -Width $Display.Bounds.Width -Height $Display.Bounds.Height -AspectRatio (4 / 3)
#Copy-Item -Path "$InstallDirectory\ProfileTemplate\Video.con" -Destination "$InstallDirectory\Mods\BfVietnam\settings\Video.con" -Force
# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
#Write-ReplaceContentInFile -Pattern '^game.setGameDisplayMode (.+)' -Substitution "game.setGameDisplayMode $($Resolution.Width) $($Resolution.Height) 32 0" -FilePath "$InstallDirectory\Mods\BfVietname\settings\Video.con"
#######################################################################
#Updates Screen Resolution to match desktop resolution
#######################################################################
$Config1 = "$InstallDirectory\ProfileTemplate\Video.con"
$Config2 = "$InstallDirectory\ProfileTemplate\VideoCustom.con"
$Config3 = "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\Custom\Video.con"
$Config4 = "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\Custom\VideoCustom.con"
# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay
# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^game.setGameDisplayMode (.+)' -Substitution "game.setGameDisplayMode $($Display.Bounds.Width) $($Display.Bounds.Height) 32 60" -FilePath "$Config1"
Write-ReplaceContentInFile -Pattern '^game.setGameDisplayMode (.+)' -Substitution "game.setGameDisplayMode $($Display.Bounds.Width) $($Display.Bounds.Height) 32 60" -FilePath "$Config2"
Write-ReplaceContentInFile -Pattern '^game.setGameDisplayMode (.+)' -Substitution "game.setGameDisplayMode $($Display.Bounds.Width) $($Display.Bounds.Height) 32 0" -FilePath "$Config3"
Write-ReplaceContentInFile -Pattern '^game.setGameDisplayMode (.+)' -Substitution "game.setGameDisplayMode $($Display.Bounds.Width) $($Display.Bounds.Height) 32 0" -FilePath "$Config4"
#######################################################################
#Patch exe for desktop resolution for menus
# Default was 800x600
#######################################################################
[uint32]$Width = $Display.Bounds.Width
[uint32]$Height = $Display.Bounds.Height
# Note: Codepage 28591 returns a 1-to-1 char to byte mapping
$Encoding = [Text.Encoding]::GetEncoding(28591)
function fileToString($path) {
$Stream = New-Object IO.FileStream -ArgumentList (Resolve-Path $path), 'Open', 'Read'
$StreamReader = New-Object IO.StreamReader -ArgumentList $Stream, $Encoding
$BinaryText = $StreamReader.ReadToEnd()
$StreamReader.Close()
$Stream.Close()
return $BinaryText
}
function asBytesLE($lengthDecimal) {
$lengthAsBytes = [BitConverter]::getBytes($lengthDecimal)
# Convert to little-endian (switch order of bytes) if system is big-endian
if (![BitConverter]::IsLittleEndian) {
$lengthAsBytes = [Array]::reverse($lengthAsBytes)
}
return $lengthAsBytes;
}
function bytesAsString($bytes) {
return $Encoding.GetString($bytes)
}
$WidthString = bytesAsString(asBytesLE($Width))
$HeightString = bytesAsString(asBytesLE($Height))
$BinaryString = fileToString("$InstallDirectory\BfVietnam.exe")
# \xnn Matches an ASCII character, where nn is a two-digit hexadecimal character code.
$HotpatchableRegex = [Regex] '(\x20\x03\x00\x00)(?<keep>\xC7.{2,3})(\x58\x02\x00\x00)'
$matches = $HotpatchableRegex.Matches($BinaryString)
# First group (old width) is replaced with new width; second is kept the same; third group (old height) is replaced with new height
# Had to escape dollar with backticks, as it's regex matcher group, not powershell variable
# Had to use named group, otherwise heightString value as bytes might interfere (depending on what it is)
$Replacement = "${WidthString}`${keep}${HeightString}"
$Result = $HotpatchableRegex.Replace($BinaryString, $Replacement)
$ResultBytes = $Encoding.GetBytes($Result)
[System.IO.File]::WriteAllBytes("$InstallDirectory\BfVietnam.exe", $ResultBytes); -froce
Name Change Script
This script will automatically rename the old name's profile or it will scaffold a new one from a template profile located in the install directory with the name ProfileTemplate. To create this, create a profile in the game called "ProfileTemplate". Exit the game and copy the Mods/BfVietnam/settings/Profiles/ProfileTemplate directory to the root of the install.
# Clear out any existing profile with the same name
Remove-Item "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$NewPlayerAlias" -Recurse -ErrorAction Ignore
if ($OldPlayerAlias -ne "") {
if (Test-Path -Path "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$OldPlayerAlias") {
# Profile exists with old name
Move-Item -Path "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$OldPlayerAlias" -Destination "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$NewPlayerAlias" -Force
} else {
# Old profile doesn't exist, scaffold a new one
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$NewPlayerAlias" -Recurse
}
} else {
# New install, scaffold new profile
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$NewPlayerAlias" -Recurse
}
Write-ReplaceContentInFile -Pattern 'rem \*\* (.+) \*\*' -Substitution "rem ** $NewPlayerAlias **" -FilePath "$InstallDirectory\Mods\BfVietnam\Settings\Profile.con"
Write-ReplaceContentInFile -Pattern 'game.setProfile "(.+)"' -Substitution "game.setProfile ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Mods\BfVietnam\Settings\Profile.con"
Write-ReplaceContentInFile -Pattern 'game.setPlayerName "(.+)"' -Substitution "game.setPlayerName ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Mods\BfVietnam\Settings\Profiles\$NewPlayerAlias\GeneralOptions.con"
Key Change Script
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
$AllocatedKey = $AllocatedKey.Replace("-", "")
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts"
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games"
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Battlefield Vietnam"
New-Item -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Battlefield Vietnam\ergc"
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Battlefield Vietnam\ergc" -Value "$AllocatedKey" -Force