Praetorians

From LANCommander
Revision as of 01:21, 1 August 2023 by DoctorDalek (talk | contribs) (Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|Pyro Studios}} |Publishers = {{Game.InfoBox.Publisher|Eidos Interactive}} {{Game.InfoBox.Publisher|Kalypso Media}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|February 28, 2003}} |Genres = {{Game.InfoBox.Genre|Real Time Strategy (RTS)}} {{Game.InfoBox.Genre|Strategy}} {{Game.InfoBox.Genre|Indie}} | PCGamingWiki = Praetorians }} {{Game.ActionBox |Actions = {{Game.ActionBox...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Pyro Studios
Publishers
Eidos Interactive Kalypso Media
Release Date
Windows: February 28, 2003
Genres
Real Time Strategy (RTS)

Strategy Indie

View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play Praetorians.exe True

Save Paths

Type Path
File %USERPROFILE%\Documents\Praetorians

Install Script

This script requires admin access to function properly

The game requires some default files to be thrown in the "Documents" folder.

$NewName = $args[0]
$InstallDir = $PSScriptRoot

function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath)
{
    $content = (Get-Content $FilePath) -replace $Regex, $Replacement
    [IO.File]::WriteAllLines($FilePath, $content)
}

$DefaultPlayerName = "68 101 102 97 117 108 116"

Write-ReplaceContentInFile -Regex '*NOMBRE_JUGADOR  11 (.+)' -Replacement "*NOMBRE_JUGADOR  11 $DefaultPlayerName" -FilePath "$InstallDir\Default.usr"
Write-ReplaceContentInFile -Regex 'C:\Games\Praetorians' -Replacement "$InstallDir" -FilePath "$InstallDir\Default.usr"
Write-ReplaceContentInFile -Regex 'C:\Users\Pat' -Replacement "$($env:USERPROFILE)" -FilePath "$InstallDir\Default.usr"

New-Item -ItemType Directory -Force -Path "$($env:USERPROFILE)\Documents\Praetorians\Profiles"

Copy-Item -Path "$InstallDir\Default.usr" -Destination "$($env:USERPROFILE)\Documents\Praetorians\Profiles\Default.usr"

Name Change Script

The player name is stored as an ASCII encoded string in a .usr profile file in the Documents folder. The first number of the ASCII string is the length of the string.

$NewName = $args[0]
$InstallDir = $PSScriptRoot
$Length = $NewName.Length

function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath)
{
    $content = (Get-Content $FilePath) -replace $Regex, $Replacement
    [IO.File]::WriteAllLines($FilePath, $content)
}

function Get-AsciiBytesAsString([string]$InputString, [int]$MaxLength)
{
    $characters = $InputString.ToCharArray()
    $array = @()
    $count = 0

    foreach ($char in $characters)
    {
        if ($count -lt $MaxLength)
        {
            $array += [System.Convert]::ToUInt32($char)
            $count++
        }
    }

    return [System.String]::Join(' ', $array)
}

$NewName = Get-AsciiBytesAsString -InputString $newName -MaxLength 18

Write-ReplaceContentInFile -Regex '\*NOMBRE_JUGADOR  7 (.+)' -Replacement "*NOMBRE_JUGADOR  $Length $NewName" -FilePath "$InstallDir\Default.usr"
Write-ReplaceContentInFile -Regex '\*NOMBRE_SKIRMISH  7 (.+)' -Replacement "*NOMBRE_SKIRMISH  $Length $NewName" -FilePath "$InstallDir\Default.usr"

New-Item -ItemType Directory -Force -Path "$($env:USERPROFILE)\Documents\Praetorians\Profiles"

Copy-Item -Path "$InstallDir\Default.usr" -Destination "$($env:USERPROFILE)\Documents\Praetorians\Profiles\Default.usr"