Stronghold Crusader: Difference between revisions

From LANCommander
(Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|Firefly Studios}} |Publishers = {{Game.InfoBox.Publisher|Take-Two Interactive}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|July 31, 2002}} |Genres = {{Game.InfoBox.Genre|Simulator}} {{Game.InfoBox.Genre|Real Time Strategy (RTS)}} {{Game.InfoBox.Genre|Strategy}} | PCGamingWiki = Stronghold_Crusader }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play Stronghold...")
 
No edit summary
 
Line 9: Line 9:
{{Game.InfoBox.ReleaseDate|Windows|July 31, 2002}}
{{Game.InfoBox.ReleaseDate|Windows|July 31, 2002}}
|Genres =
|Genres =
{{Game.InfoBox.Genre|Simulator}}
{{Game.InfoBox.Genre|Simulator}}{{Game.InfoBox.Genre|Real Time Strategy (RTS)}}{{Game.InfoBox.Genre|Strategy}}
{{Game.InfoBox.Genre|Real Time Strategy (RTS)}}
|PCGamingWiki = Stronghold_Crusader}}
{{Game.InfoBox.Genre|Strategy}}
| PCGamingWiki = Stronghold_Crusader
}}


{{Game.ActionBox
{{Game.ActionBox
|Actions =  
|Actions =  
{{Game.ActionBox.Row|Name = Play Stronghold: Crusader Extreme|Path = Stronghold_Crusader_Extreme.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Play Stronghold: Crusader Extreme|Path = {InstallDir}\Stronghold_Crusader_Extreme.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Play Stronghold: Crusader|Path = Stronghold Crusader.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Play Stronghold: Crusader|Path = {InstallDir}\Stronghold Crusader.exe|Arguments = |WorkingDirectory = |Primary = True}}
}}
}}


{{Game.Scripts.NameChange
 
|Name = Name Change Script
{{Game.Scripts.Install
|Name = Install Script
|Description =  
|Description =  
|RequiresAdmin = False
|RequiresAdmin = False
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
$NewName = $args[0]
<syntaxhighlight lang="powershell" line>
$InstallDir = $PSScriptRoot
$Documents = [Environment]::GetFolderPath("MyDocuments")
 
$Display = Get-PrimaryDisplay
function Get-AsciiBytes([string]$InputString, [int]$MaxLength)
{
    if ($InputString.Length -gt $MaxLength)
    {
        $InputString = $InputString.Substring(0, $MaxLength)
    }
 
    $bytes = [System.Text.Encoding]::ASCII.GetBytes($InputString)
    $array = @()
    $count = 0


    $extraPadding = $MaxLength - $bytes.Length
$Resolution = Switch ("$($Display.Bounds.Width)x$($Display.Bounds.Height)") {
 
     "800x600" { 0x01; Break }
    foreach ($byte in $bytes)
    "1024x768" { 0x02; Break }
     {
    "1280x720" { 0x03; Break }
        if ($count -lt $MaxLength)
    "1280x1024" { 0x04; Break }
        {
    "1366x768" { 0x05; Break }
            $array += $byte
    "1440x900" { 0x06; Break }
            $count++
     "1600x900" { 0x07; Break }
        }
    # "FAIL" { 0x08; Break }
     }
     "1680x1050" { 0x09; Break }
 
     "1920x1080" { 0x0A; Break }
     for ($i = $count; $i -lt $MaxLength; $i++)
     "1920x1200" { 0x0B; Break }
     {
     "2560x1440" { 0x0C; Break }
        $array += 0x00
     }
 
     return $array
}
}


function Patch-Binary([byte[]]$Data, [int]$Offset, [string]$FilePath)
New-Item -ItemType Directory -Force -Path "$Documents\Stronghold Crusader"
{
    $bytes = [System.IO.File]::ReadAllBytes($FilePath)


    for ($i = 0; $i -lt $Data.Length; $i++)
Copy-Item -Path "$InstallDirectory\Default.cfg" -Destination "$Documents\Stronghold Crusader\crusader.cfg"
    {
Copy-Item -Path "$InstallDirectory\Default.cfg" -Destination "$Documents\Stronghold Crusader\crusaderExtreme.cfg"
        $bytes[$Offset + $i] = $Data[$i]
    }


    [System.IO.File]::WriteAllBytes($FilePath, $bytes)
Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusader.cfg" -Offset 0x3B9 -Data ([byte[]]@( $Resolution )
}
Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusaderExtreme.cfg" -Offset 0x3B9 -Data ([byte[]]@( $Resolution )
</syntaxhighlight>
}}
           
{{Game.Scripts.Uninstall
|Name = Uninstall Script
|Description =
|RequiresAdmin = False
|Contents =
<syntaxhighlight lang="powershell" line>
$Documents = [Environment]::GetFolderPath("MyDocuments")


$rawBytes = Get-AsciiBytes -InputString $newName -MaxLength 16
Remove-Item "$Documents\Stronghold Crusader" -Recurse -ErrorAction Ignore
 
</syntaxhighlight>
New-Item -ItemType Directory -Force -Path "$($env:USERPROFILE)\Documents\Stronghold Crusader"
}}
           
{{Game.Scripts.NameChange
|Name = Name Change Script
|Description =
|RequiresAdmin = False
|Contents =
<syntaxhighlight lang="powershell" line>
$Documents = [Environment]::GetFolderPath("MyDocuments")


Copy-Item -Path "$InstallDir\Default.cfg" -Destination "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusader.cfg"
# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases.
Copy-Item -Path "$InstallDir\Default.cfg" -Destination "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusaderExtreme.cfg"
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 16 -MinLength 16


Patch-Binary -FilePath "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusader.cfg" -Offset 0x23 -Data $rawBytes
Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusader.cfg" -Offset 0x23 -Data $bytes
Patch-Binary -FilePath "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusaderExtreme.cfg" -Offset 0x23 -Data $rawBytes
Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusaderExtreme.cfg" -Offset 0x23 -Data $bytes
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Latest revision as of 21:57, 8 January 2024

Developers
Firefly Studios
Publishers
Take-Two Interactive
Release Date
Windows: July 31, 2002
Genres
SimulatorReal Time Strategy (RTS)Strategy
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play Stronghold: Crusader Extreme {InstallDir}\Stronghold_Crusader_Extreme.exe True
Play Stronghold: Crusader {InstallDir}\Stronghold Crusader.exe True

Install Script

$Documents = [Environment]::GetFolderPath("MyDocuments")
$Display = Get-PrimaryDisplay

$Resolution = Switch ("$($Display.Bounds.Width)x$($Display.Bounds.Height)") {
    "800x600" { 0x01; Break }
    "1024x768" { 0x02; Break }
    "1280x720" { 0x03; Break }
    "1280x1024" { 0x04; Break }
    "1366x768" { 0x05; Break }
    "1440x900" { 0x06; Break }
    "1600x900" { 0x07; Break }
    # "FAIL" { 0x08; Break }
    "1680x1050" { 0x09; Break }
    "1920x1080" { 0x0A; Break }
    "1920x1200" { 0x0B; Break }
    "2560x1440" { 0x0C; Break }
}

New-Item -ItemType Directory -Force -Path "$Documents\Stronghold Crusader"

Copy-Item -Path "$InstallDirectory\Default.cfg" -Destination "$Documents\Stronghold Crusader\crusader.cfg"
Copy-Item -Path "$InstallDirectory\Default.cfg" -Destination "$Documents\Stronghold Crusader\crusaderExtreme.cfg"

Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusader.cfg" -Offset 0x3B9 -Data ([byte[]]@( $Resolution )
Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusaderExtreme.cfg" -Offset 0x3B9 -Data ([byte[]]@( $Resolution )

Uninstall Script

$Documents = [Environment]::GetFolderPath("MyDocuments")

Remove-Item "$Documents\Stronghold Crusader" -Recurse -ErrorAction Ignore

Name Change Script

$Documents = [Environment]::GetFolderPath("MyDocuments")

# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases.
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 16 -MinLength 16

Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusader.cfg" -Offset 0x23 -Data $bytes
Edit-PatchBinary -FilePath "$Documents\Stronghold Crusader\crusaderExtreme.cfg" -Offset 0x23 -Data $bytes