Call of Duty: Difference between revisions

From LANCommander
No edit summary
(Fixes to deprecated PowerShell scripts)
Line 2: Line 2:
{{Game.InfoBox
{{Game.InfoBox
|Cover = cover.jpg
|Cover = cover.jpg
|Developers =
{{Game.InfoBox.Developer|Infinity Ward}}
|Publishers =
{{Game.InfoBox.Developer|Activision}}
|Release Date =
|Release Date =
{{Game.InfoBox.ReleaseDate|Windows|October 29, 2003}}
{{Game.InfoBox.ReleaseDate|Windows|October 29, 2003}}
| PCGamingWiki = Call_of_Duty
|Genres =
}}
{{Game.InfoBox.Genre|Shooter}}
|PCGamingWiki = Call_of_Duty}}


{{Game.ActionBox
{{Game.ActionBox
|Actions =  
|Actions =  
{{Game.ActionBox.Row|Name = Call of Duty: United Offensive (Multiplayer)|Path = CoDUOMP.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Call of Duty: United Offensive (Multiplayer)|Path = {InstallDir}\CoDUOMP.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Call of Duty (Multiplayer)|Path = CoDMP.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Call of Duty (Multiplayer)|Path = {InstallDir}\CoDMP.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Call of Duty (Singleplayer)|Path = CoDSP.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Call of Duty (Singleplayer)|Path = {InstallDir}\CoDSP.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Call of Duty: United Offensive (Singleplayer)|Path = CoDUOSP.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Call of Duty: United Offensive (Singleplayer)|Path = {InstallDir}\CoDUOSP.exe|Arguments = |WorkingDirectory = |Primary = True}}
}}
}}


{{Game.SaveBox
 
|Paths =  
{{Game.Scripts.Install
{{Game.SaveBox.Row|Type = Registry|Path = HKLM:\SOFTWARE\WOW6432Node\Activision\Call of Duty United Offensive}}
|Name = Install Script
{{Game.SaveBox.Row|Type = Registry|Path = HKLM:\SOFTWARE\WOW6432Node\Activision\Call of Duty}}
|Description =  
{{Game.SaveBox.Row|Type = File|Path = {InstallDir}/Main/config_mp.cfg}}
|RequiresAdmin = False
{{Game.SaveBox.Row|Type = File|Path = {InstallDir}/uo/uoconfig_mp.cfg}}
|Contents =
<syntaxhighlight lang="powershell" line>
# 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 '^seta r_mode(.+)' -Substitution "seta r_mode ""-1""" -FilePath "$InstallDirectory\startup\user.cfg"
Write-ReplaceContentInFile -Pattern '^seta r_customheight(.+)' -Substitution "seta r_customheight ""$($Display.Bounds.Height)""" -FilePath "$InstallDirectory\main\config_mp.cfg"
Write-ReplaceContentInFile -Pattern '^seta r_customwidth(.+)' -Substitution "seta r_customwidth ""$($Display.Bounds.Width)""" -FilePath "$InstallDirectory\main\config_mp.cfg"
Write-ReplaceContentInFile -Pattern '^seta r_customaspect(.+)' -Substitution "seta r_customaspect ""1.7""" -FilePath "$InstallDirectory\main\config_mp.cfg"
</syntaxhighlight>
}}
}}
 
           
{{Game.Scripts.NameChange
{{Game.Scripts.NameChange
|Name = Name Change Script
|Name = Name Change Script
|Description =  
|Description =  
|RequiresAdmin = False
|RequiresAdmin = False
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
$NewName = $args[0]
<syntaxhighlight lang="powershell" line>
$InstallDir = $PSScriptRoot
Write-ReplaceContentInFile -Pattern '^seta name (.+)' -Substitution "seta name ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Main\config_mp.cfg"
 
Write-ReplaceContentInFile -Pattern '^seta name (.+)' -Substitution "seta name ""$NewPlayerAlias""" -FilePath "$InstallDirectory\uo\uoconfig_mp.cfg"
function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath)
{
    $content = (Get-Content $FilePath) -replace $Regex, $Replacement
    [IO.File]::WriteAllLines($FilePath, $content)
}
 
Write-ReplaceContentInFile -Regex '^seta name (.+)' -Replacement "seta name ""$NewName""" -FilePath "$InstallDir\Main\config_mp.cfg"
Write-ReplaceContentInFile -Regex '^seta name (.+)' -Replacement "seta name ""$NewName""" -FilePath "$InstallDir\uo\uoconfig_mp.cfg"
</syntaxhighlight>
</syntaxhighlight>
}}
}}
 
           
{{Game.Scripts.KeyChange
{{Game.Scripts.KeyChange
|Name = Key Change Script
|Name = Key Change Script
|Description =  
|Description =  
|RequiresAdmin = True
|RequiresAdmin = True
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
<syntaxhighlight lang="powershell" line>
# Requires Admin
# Requires Admin
 
$Key = $AllocatedKey
$Key = $args[0]


$Key = $Key.Replace("-", "")
$Key = $Key.Replace("-", "")

Revision as of 02:05, 6 January 2024

Developers
Infinity Ward
Publishers
Activision
Release Date
Windows: October 29, 2003
Genres
Shooter
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Call of Duty: United Offensive (Multiplayer) {InstallDir}\CoDUOMP.exe True
Call of Duty (Multiplayer) {InstallDir}\CoDMP.exe True
Call of Duty (Singleplayer) {InstallDir}\CoDSP.exe True
Call of Duty: United Offensive (Singleplayer) {InstallDir}\CoDUOSP.exe True

Install Script

# 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 '^seta r_mode(.+)' -Substitution "seta r_mode ""-1""" -FilePath "$InstallDirectory\startup\user.cfg"
Write-ReplaceContentInFile -Pattern '^seta r_customheight(.+)' -Substitution "seta r_customheight ""$($Display.Bounds.Height)""" -FilePath "$InstallDirectory\main\config_mp.cfg"
Write-ReplaceContentInFile -Pattern '^seta r_customwidth(.+)' -Substitution "seta r_customwidth ""$($Display.Bounds.Width)""" -FilePath "$InstallDirectory\main\config_mp.cfg"
Write-ReplaceContentInFile -Pattern '^seta r_customaspect(.+)' -Substitution "seta r_customaspect ""1.7""" -FilePath "$InstallDirectory\main\config_mp.cfg"

Name Change Script

Write-ReplaceContentInFile -Pattern '^seta name (.+)' -Substitution "seta name ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Main\config_mp.cfg"
Write-ReplaceContentInFile -Pattern '^seta name (.+)' -Substitution "seta name ""$NewPlayerAlias""" -FilePath "$InstallDirectory\uo\uoconfig_mp.cfg"

Key Change Script

This script requires admin access to function properly

# Requires Admin
$Key = $AllocatedKey

$Key = $Key.Replace("-", "")

$codkey, $coduokey = $Key -Split ',',2

# Non-destructively creates path in registry
New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Activision"
New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Activision\Call of Duty"
New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Activision\Call of Duty United Offensive"

# Creates or updates a key in the registry
New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Activision\Call of Duty" -Name "codkey" -Value $codkey -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Activision\Call of Duty United Offensive" -Name "key" -Value $coduokey -Force