Impossible Creatures

From LANCommander
Revision as of 00:36, 1 August 2023 by DoctorDalek (talk | contribs) (Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|Relic Entertainment}} |Publishers = {{Game.InfoBox.Publisher|Nordic Games Publishing}} {{Game.InfoBox.Publisher|Microsoft Game Studios}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|December 29, 2002}} |Genres = {{Game.InfoBox.Genre|Simulator}} {{Game.InfoBox.Genre|Real Time Strategy (RTS)}} {{Game.InfoBox.Genre|Strategy}} | PCGamingWiki = Impossible_Creatures }} {{Game.Act...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Relic Entertainment
Publishers
Nordic Games Publishing Microsoft Game Studios
Release Date
Windows: December 29, 2002
Genres
Simulator

Real Time Strategy (RTS) Strategy

View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Setup ICConfig.exe False
Mission Editor MissionEditor.exe False
Play IC.exe True

Install Script

$InstallDir = $PSScriptRoot
# Accessible via $Display.ScreenWidth and $Display.ScreenHeight
Add-Type -AssemblyName System.Windows.Forms
$Display = [System.Windows.Forms.Screen]::AllScreens | Where-Object Primary | Select Bounds

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

# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Regex '^screenwidth=(.+)' -Replacement "screenwidth=$($Display.Width)" -FilePath "$InstallDir\local.ini"
Write-ReplaceContentInFile -Regex '^screenheight=(.+)' -Replacement "screenheight=$($Display.Height)" -FilePath "$InstallDir\local.ini"

Name Change Script

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

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

    foreach ($byte in $bytes)
    {
        if ($count -lt $MaxLength)
        {
            $array += $byte
            $count++
        }
    }

    # Pad the end with 0x00 to meet our max length
    for ($i = $count; $i -lt $MaxLength; $i++)
    {
        $array += 0x00
    }

    return $array
}

function Patch-Binary([byte[]]$Data, [int]$Offset, [string]$FilePath)
{
    $bytes = [System.IO.File]::ReadAllBytes($FilePath)

    for ($i = 0; $i -lt $Data.Length; $i++)
    {
        $bytes[$Offset + $i] = $Data[$i]
    }

    [System.IO.File]::WriteAllBytes($FilePath, $bytes)
}

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

function Separate-AsciiBytes([byte[]]$Data)
{
    $array = @()

    foreach ($byte in $Data)
    {
        $array += $byte
        $array += 0x00
    }

    return $array
}

# Convert an input string to ASCII-encoded byte[]. Shorter strings will pad out to 12 bytes, longer strings will be trimmed.
$bytes = Get-AsciiBytes -InputString $NewName -MaxLength 10
$bytes = Separate-AsciiBytes -Data $bytes

# Writes byte[] to a file at an offset
Patch-Binary -FilePath "$InstallDir\Profiles\Profile2\name.dat" -Offset 0x02 -Data $bytes