Dungeons & Dragons: Dragonshard

From LANCommander
Revision as of 00:42, 22 February 2024 by DoctorDalek (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Liquid Entertainment
Publishers
Atari, Inc.
Release Date
Windows: September 21, 2005
Genres
StrategyRole-playing (RPG)
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\Dragonshard.exe -nointro True

Install Script

# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay

Write-ReplaceContentInFile -Pattern '^video_resolutionX "(.+)"' -Substitution "video_resolutionX ""$($Display.Bounds.Width)""" -FilePath "$InstallDirectory\Dragonshard\Profiles\test.pro"
Write-ReplaceContentInFile -Pattern '^video_resolutionY "(.+)"' -Substitution "video_resolutionY ""$($Display.Bounds.Height)""" -FilePath "$InstallDirectory\Dragonshard\Profiles\test.pro"

Write-ReplaceContentInFile -Pattern '^Width(.+)' -Substitution "Width = $($Display.Bounds.Width)" -FilePath "$InstallDirectory\DND.ini"
Write-ReplaceContentInFile -Pattern '^Height(.+)' -Substitution "Height = $($Display.Bounds.Height)" -FilePath "$InstallDirectory\DND.ini"

$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"

New-Item -Path "$VirtualStore\WOW6432Node\Liquid Entertainment"
New-Item -Path "$VirtualStore\WOW6432Node\Liquid Entertainment\Dragonshard"
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Liquid Entertainment\Dragonshard" -Name "Program" -Value "Dragonshard.exe" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Liquid Entertainment\Dragonshard" -Name "Install Path" -Value "$InstallDirectory" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Liquid Entertainment\Dragonshard" -Name "CD Key" -Value "JDZJ-QD6B-437T-WBDY" -Force

Uninstall Script

$Documents = [Environment]::GetFolderPath("MyDocuments")
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"

Remove-Item -Path "$Documents\My Games\Dragonshard" -Force -Recurse
Remove-Item -Path "$VirtualStore\WOW6432Node\Liquid Entertainment" -Force -Recurse

Name Change Script

$Documents = [Environment]::GetFolderPath("MyDocuments")
$NewPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$OldPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$Display = Get-PrimaryDisplay
$Guid = [Guid]::NewGuid()

# Trim a string down to a specified amount of characters
if ($NewPlayerAlias.Length -gt 20) {
    $NewPlayerAlias = $NewPlayerAlias.Substring(0, 20);
}

if ($OldPlayerAlias.Length -gt 20) {
    $OldPlayerAlias = $OldPlayerAlias.Substring(0, 20);
}

if (Test-Path "$Documents\My Games\Dragonshard\Profiles\$OldPlayerAlias.pro") {
    Move-Item "$Documents\My Games\Dragonshard\Profiles\$OldPlayerAlias.pro" "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
} else {
    New-Item -ItemType Directory -Path "$Documents\My Games"
    New-Item -ItemType Directory -Path "$Documents\My Games\Dragonshard"
    New-Item -ItemType Directory -Path "$Documents\My Games\Dragonshard\Profiles"
    Copy-Item -Path "$InstallDirectory\Dragonshard\Profiles\test.pro" -Destination "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
}

# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^player_name "(.+)"' -Substitution "player_name ""$NewPlayerAlias""" -FilePath "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
Write-ReplaceContentInFile -Pattern '^player_filename "(.+)"' -Substitution "player_filename ""$NewPlayerAlias""" -FilePath "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
Write-ReplaceContentInFile -Pattern '^guid "(.+)"' -Substitution "guid ""{$($Guid.ToString())}""" -FilePath "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"

# The profiles.dat file selects the last used profile. It's a binary file that starts with a 5 byte header with offset 0x01 describing the length of the name based on character count.
# The profile name itself is UTF16 encoded and is suffixed by two bytes of 0x00, probably to denote end-of-file.
$Header = @([byte] 0x00, 0x15, 0x00, 0x00, 0x00)
$NameBytes = ConvertTo-StringBytes -Input "$NewPlayerAlias" -Utf16 1 -MaxLength 21 -MinLength 21
$NameBytes = $Header + $NameBytes

[IO.File]::WriteAllBytes("$Documents\My Games\Dragonshard\Profiles\profiles.dat", $NameBytes)